从字符串中获取特定单词,ORACLE

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10069733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 00:42:49  来源:igfitidea点击:

get specific words from string , ORACLE

oracleplsql

提问by Ahmed Dimah

Kindly are there any one knows how to get a specific string from a huge string using pl/sql, I'm some kind beginner in creating querys,so any help will be useful. BTW i don't want to use the function : select substr( *, * ,* ) from * cuz the input is variable, so can any one help me on this problem, and do you advice me to use block instate of that.

请问有没有人知道如何使用pl/sql从一个巨大的字符串中获取一个特定的字符串,我是创建查询的初学者,所以任何帮助都会有用。顺便说一句,我不想​​使用这个函数: select substr( *, * ,* ) from * 因为输入是可变的,所以任何人都可以帮助我解决这个问题,你是否建议我使用块状态。

Thanks & regards,

感谢和问候,

回答by Dan A.

It sounds like you're looking for a specific string inside of a bigger string. If so, the function you're probably looking for is INSTR:

听起来您正在寻找更大字符串中的特定字符串。如果是这样,您可能正在寻找的函数是 INSTR:

http://docs.oracle.com/cd/B28359_01/olap.111/b28126/dml_functions_1103.htm

http://docs.oracle.com/cd/B28359_01/olap.111/b28126/dml_functions_1103.htm

回答by Gaurav Soni

As far my understanding to your question you want to checkwhether a specific wordis present in a string or not,if this is the question you can find the solution below .

就我对您的问题的理解而言,您想check知道 a 中specific word是否存在 a string or not,如果这是问题,您可以在下面找到解决方案。

DECLARE
v_string VARCHAR2(200):='MY NAME IS GAURAV SONI';
v_check PLS_INTEGER;
BEGIN

v_check:=INSTR(v_string,'GAURAV'); --this is case sensitive 

IF v_check >0 THEN 
dbms_output.put_line('Word exists');
END IF;

END;

In the above block we are searching Word GAURAVin the String MY NAME IS GAURAV SONIand this word exist in 12place .

在上面的块中,我们GAURAV在 String中搜索 WordMY NAME IS GAURAV SONI并且这个词12就地存在。

Please note this is Case sensitiveand if you put word gaurav,value of v_checkwill be zero.

请注意这是Case sensitive,如果您输入单词gaurav,则值v_check将是zero

If you are are looking for Case insensitivethen go for REGULAR EXPRESSIONS in oracle REGEXP_INSTRin place of INSTR.Read the oracle document before using this function REGEXP_INSTR

如果你正在寻找Case insensitive然后去 oracleREGEXP_INSTR中的REGULAR EXPRESSIONS代替INSTR。 在使用这个函数REGEXP_INSTR之前阅读 oracle 文档

Worked out example in SQL Fiddle

在 SQL Fiddle 中制定出示例