替换功能内的符号错误(PL/SQL,ORACLE) [英] Wrong symbol inside replace function (PL/SQL, ORACLE)

查看:140
本文介绍了替换功能内的符号错误(PL/SQL,ORACLE)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在包装内有以下步骤:

I have below procedure inside package:

PROCEDURE test1
IS
     InsertST varchar2(32000) : = 'INSERT INTO tableA (col1, col2) 
                                   (select cola, 
                                   INITCAP(REPLACE(colX, '_', ''))
                                   from tableB))';
Begin
    execute immediate InsertST;
END

在编译过程中出现错误:

during compilation I got error:

错误(1177,45):PLS-00103:在预期以下情况之一时遇到了符号"_":*& =-+; < />处为mod余数,而不是rem<>或!=或〜=> =< =<>和||之间的like2 like4 likec成员子多重集

Error(1177,45): PLS-00103: Encountered the symbol "_" when expecting one of the following: * & = - + ; < / > at in is mod remainder not rem <> or != or ~= >= <= <> and or like like2 like4 likec between || member submultiset

内部函数INITCAP(REPLACE(colX, '_', ''))

如何解决?也许是其他方式吗?

How to fix it? Maybe is other way?

推荐答案

'INSERT开头的带引号的字符串以colX, '结尾.要引用报价,您需要将报价加倍:

The quoted string starting 'INSERT ends at colX, '. To quote a quote you need to either double up the quotes:

'INSERT INTO tableA (col1, col2) 
 (select cola, 
 INITCAP(REPLACE(colX, ''_'', ''''))
 from tableB))'

否则使用q引号语法:

q'[INSERT INTO tableA (col1, col2) 
 (select cola, 
 INITCAP(REPLACE(colX, '_', ''))
 from tableB))]';

此外,赋值运算符是:=而不是: =.

Also, the assignment operator is := not : =.

您似乎想生成这样的语句:

It looks like you want to generate a statement like this:

insert into tablea ( col1, col2 )
select cola, initcap(replace(colx, '_', ''))
from   tableb

少了几个括号.

它看起来根本不需要动态,但是我假设这是一个简化的版本.

It doesn't look like it needs to be dynamic at all, but I'm assuming this is a simplified version of something that does.

这篇关于替换功能内的符号错误(PL/SQL,ORACLE)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆