Print text in Oracle SQL Developer SQL Worksheet window

前端 未结 8 471
醉梦人生
醉梦人生 2021-01-30 01:47

I am using Oracle SQL (in SQLDeveloper, using the SQL Worksheet). I would like to print a statement before my select, such as

PRINT \'Querying Table1\';
SELECT          


        
8条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 02:31

    enter image description here

    for simple comments:

    set serveroutput on format wrapped;
    begin
        DBMS_OUTPUT.put_line('simple comment');
    end;
    /
    
    -- do something
    
    begin
        DBMS_OUTPUT.put_line('second simple comment');
    end;
    /
    

    you should get:

    anonymous block completed
    simple comment
    
    anonymous block completed
    second simple comment
    

    if you want to print out the results of variables, here's another example:

    set serveroutput on format wrapped;
    declare
    a_comment VARCHAR2(200) :='first comment';
    begin
        DBMS_OUTPUT.put_line(a_comment);
    end;
    
    /
    
    -- do something
    
    
    declare
    a_comment VARCHAR2(200) :='comment';
    begin
        DBMS_OUTPUT.put_line(a_comment || 2);
    end;
    

    your output should be:

    anonymous block completed
    first comment
    
    anonymous block completed
    comment2
    

提交回复
热议问题