我创建了下面的DB2 plsql脚本,并尝试通过putty运行.sql文件。但我得到以下错误;
BEGIN
DECLARE abc VARCHAR2(15)
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "END-OF-STATEMENT" was found following "abc
VARCHAR2(15)". Expected tokens may include: "<psm_semicolon>". LINE
NUMBER=2. SQLSTATE=42601
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "IN" was found following "FOR abc ".
Expected tokens may include: "JOIN". SQLSTATE=42601
下面是我写的示例plsql语句。
BEGIN
DECLARE abc VARCHAR2(15);
FOR abc IN (SELECT empid FROM employee where mark=2 order by 1) LOOP
Insert into salary
(id,
name,mark)
SELECT id,
name,
3
FROM salary A
WHERE id=abc.empid and mark=2;
END LOOP;
COMMIT;
END;
/
1条答案
按热度按时间wmtdaxz31#
只要将
DECLARE
关键字放在BEGIN
之前,或者将BEGIN
放在DECLARE
之后,如果这是您想要做的。由于声明节后缺少BEGIN
关键字而发生错误。你的代码可能看起来像这样: