Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 使用类似'的单引号时出现问题;字符串标记';在executeimmediate语句中_Database_Oracle_Plsql - Fatal编程技术网

Database 使用类似'的单引号时出现问题;字符串标记';在executeimmediate语句中

Database 使用类似'的单引号时出现问题;字符串标记';在executeimmediate语句中,database,oracle,plsql,Database,Oracle,Plsql,这是代码的一部分,我使用“blah”来转义单引号,但我猜它不起作用: declare my_func varchar2(20) :='test_func'; begin execute immediate 'insert into TABLE_TEST (OUTPUT) select ' || my_func || ' from dual where TABLE_TEST.FUNCTION_NAME like ' 'VALIDATION1_%' ' '; end; 我得到以下错误: PL

这是代码的一部分,我使用“blah”来转义单引号,但我猜它不起作用:

declare
my_func varchar2(20) :='test_func';

begin 
execute immediate 'insert into TABLE_TEST (OUTPUT) select ' || my_func || ' from dual where TABLE_TEST.FUNCTION_NAME like ' 'VALIDATION1_%' '  ';
end;
我得到以下错误:

PLS-00103: Encountered the symbol "VALIDATION1_%" when expecting one of the following:

   & = - + ; < / > at in is mod remainder not rem return
   returning <an exponent (**)> <> or != or ~= >= <= <> and or
   like like2 like4 likec between into using || bulk member
   submultiset
The symbol "* was inserted before "VALIDATION1_%" to continue.
PLS-00103:在预期以下情况之一时遇到符号“VALIDATION1%”:
& = - + ; < / > at in是mod余数而非rem返回

返回或返回!=或者~=>=看起来您正试图使用另一个单引号(这很好),但是在这两个引号之间有一个额外的空间。这是必须的

改变

' from dual where TABLE_TEST.FUNCTION_NAME like ' 'VALIDATION1_%' '  '


看起来您正试图使用另一个报价(这很好),但在这两个报价之间有一个额外的空间。这是必须的

改变

' from dual where TABLE_TEST.FUNCTION_NAME like ' 'VALIDATION1_%' '  '


在这种情况下,对文字字符串使用新的
q
语法要简单得多,例如:

execute immediate 'insert into TABLE_TEST (OUTPUT) select ' || my_func ||
  q[' from dual where TABLE_TEST.FUNCTION_NAME like 'VALIDATION1_%' ]';

在这种情况下,对文字字符串使用新的
q
语法要简单得多,例如:

execute immediate 'insert into TABLE_TEST (OUTPUT) select ' || my_func ||
  q[' from dual where TABLE_TEST.FUNCTION_NAME like 'VALIDATION1_%' ]';

这样做会给我一个ORA-00904表\u TEST.FUNCTION\u NAME的无效标识符错误。好吧,表\u TEST有列函数\u NAME吗?是的,它有列函数\u NAME。我想我已经解决了,与解决我原来问题的解决方案无关。我需要在dual旁边添加table_test,这样它应该读“from dual,table_test where…”这样做会给我一个ORA-00904 table_test.FUNCTION_NAME的无效标识符错误。table_test有列函数_NAME吗?是的,它有列函数_NAME我想我已经找到了,与你的解决方案无关,你的解决方案确实解决了我原来的问题。我需要在dual旁边添加table_test,所以它应该读为“from dual,table_test where…”