Plsql
OR-01422 ORA-06512
有人可以幫助解決這個錯誤嗎?我無法編寫此 .thanks 的 pl/sql 查詢。
spool 150OMGIddl.sql declare c clob; begin SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name,'150OMGI') into c from dba_tables u where owner='150OMGI'; dbms_output.put_line(c); dbms_output.put(';'); end; / spool off
錯誤:
ERROR at line 1: ORA-01422: exact fetch returns more than requested number of rows ORA-06512: at line 3
當我跑步時,
SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name,'150OMGI') from dba_tables u where owner='150OMGI';
我得到了 26 行。
該腳本只需要 1 行。不是你得到的26。您必須使用游標並遍歷獲得的行:
set serveroutput on DECLARE CURSOR CRS IS SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name,'150OMGI') FROM dba_tables u WHERE owner='150OMGI'; C CLOB; BEGIN OPEN CRS; LOOP FETCH CRS INTO C; EXIT WHEN CRS%NOTFOUND; dbms_output.put_line(c); dbms_output.put(';'); END LOOP; CLOSE CRS; END; /