我想打印一个特定变量的值在一个匿名块内。我使用Oracle sql Developer。我尝试使用dbms_output.put_line。但它不工作。我使用的代码如下所示。
原文链接:https://www.f2er.com/oracle/208320.htmlSET SERVEROUTPUT ON DECLARE CTABLE USER_OBJECTS.OBJECT_NAME%TYPE; CCOLUMN ALL_TAB_COLS.COLUMN_NAME%TYPE; V_ALL_COLS VARCHAR2(500); CURSOR CURSOR_TABLE IS SELECT OBJECT_NAME FROM USER_OBJECTS WHERE OBJECT_TYPE='TABLE' AND OBJECT_NAME LIKE 'tb_prm_%'; CURSOR CURSOR_COLUMNS (V_TABLE_NAME IN VARCHAR2) IS SELECT COLUMN_NAME FROM ALL_TAB_COLS WHERE TABLE_NAME = V_TABLE_NAME; BEGIN OPEN CURSOR_TABLE; LOOP FETCH CURSOR_TABLE INTO CTABLE; EXIT WHEN CURSOR_TABLE%NOTFOUND; OPEN CURSOR_COLUMNS (CTABLE); V_ALL_COLS := NULL; LOOP FETCH CURSOR_COLUMNS INTO CCOLUMN; V_ALL_COLS := V_ALL_COLS || CCOLUMN; IF CURSOR_COLUMNS%FOUND THEN V_ALL_COLS := V_ALL_COLS || ','; ELSE EXIT; END IF; END LOOP; DBMS_OUTPUT.PUT_LINE(V_ALL_COLS); END LOOP; CLOSE CURSOR_TABLE; END;
我得到的输出只作为匿名块完成。