我对Oracle还不陌生,但是我受命编写这条声明。
BEGIN
FOR partition IN 1..32 LOOP
lQuery := 'UPDATE CORE.tbl PARTITION(tbl' || LPAD(partition, 2, '0') || ') SET p = NULL '
|| 'WHERE p IS NOT NULL';
EXECUTE IMMEDIATE lQuery;
END LOOP;
END;
但是,出现以下错误
Error starting at line 1 in command:
BEGIN
FOR partition IN 1..32 LOOP
lQuery := 'UPDATE CORE.user_login PARTITION(user_login' || LPAD(partition, 2, '0') || ') SET password_md5 = NULL '
|| 'WHERE password_md5 IS NOT NULL';
EXECUTE IMMEDIATE lQuery;
END LOOP;
END;
Error report:
ORA-06550: line 3, column 5:
PLS-00201: identifier 'LQUERY' must be declared
ORA-06550: line 3, column 5:
PL/SQL: Statement ignored
ORA-06550: line 6, column 23:
PLS-00201: identifier 'LQUERY' must be declared
ORA-06550: line 6, column 5:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
当我尝试运行它时。我知道这可能是因为没有声明lQuery
而是在线搜索了一些示例,这些示例声明了某种类型的变量,例如(整数,varchar等。),但是没有一个实例表明如何声明此语句所期望的查询。
您的语句可以简单地声明为varchar2。例如:
declare
vsql varchar2(1000);
n integer;
begin
vsql := 'select 1 from dual';
execute immediate vsql into n;
dbms_output.put_line(n);
end;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句