我在Teradata中使用execute immediate时遇到了问题。
SET str_sql = 'UPDATE TABLE
SET COLA = 0';
EXECUTE IMMEDIATE str_sql;
上面的代码工作正常。
SET str_sql = 'UPDATE TABLE
SET COLA = 0,
COLB = ''test''';
EXECUTE IMMEDIATE str_sql;
上面带有字符串的代码返回错误。
以下是错误消息:
Executed as Single statement. Failed [3706 : 42000] Table:Syntax error: expected something between a string or a Unicode character literal and the word 'test'.
Elapsed time = 00:00:00.212
STATEMENT 1: CALL failed.
任何人都知道如何在sql中使用String调用execute immediate? 谢谢!
Frank Liu答案 0 :(得分:0)
问题可能出在报价上。而不是这个
SET str_sql = 'UPDATE TABLE
SET COLA = 0,
COLB = ''test''';
EXECUTE IMMEDIATE str_sql;
使用双引号。
SET str_sql = 'UPDATE TABLE
SET COLA = 0,
COLB = 'test'';
EXECUTE IMMEDIATE str_sql;