我試圖將DBMS_METADATA.GET_DDL
的輸出設置爲SQLPlus中的我的RET_VAR
綁定變量。SP2-1504:無法打印未初始化的LOB變量
我嘗試以下script.sql
:
set pagesize 0
SET LONG 9999999
VARIABLE ret_val CLOB
VARIABLE lengthRet NUMBER
select DBMS_METADATA.GET_DDL('TABLE', 'MY_TABLE') into :ret_val from dual;
spool testClean.sql
print :ret_val;
spool off
/-- I had to add this line because the script would never run otherwise
,但我得到:
SP2-1504: Cannot print uninitialized LOB variable "RET_VAL"
我也試過圍繞RET_VAL
分配與BEGIN
/END
塊:
set pagesize 0
SET LONG 9999999
VARIABLE ret_val CLOB
VARIABLE lengthRet NUMBER
BEGIN
select DBMS_METADATA.GET_DDL('TABLE', 'MY_TABLE') into :ret_val from dual;
END;
spool testClean.sql
print :ret_val;
spool off
/
但是,當時我試圖在sqlplus運行它,我得到這個錯誤:
ERROR at line 5: ORA-06550: line 5, column 1: PLS-00103: Encountered the symbol "SPOOL"
我如何分配的DBMS_METADATA.GET_DDL
輸出到我的RET_VAR
?
我首先看到的 - 在BEGIN ... END之後需要'/'塊 –