programing tip

Oracle SQL Developer SQL 워크 시트 창에서 텍스트 인쇄

itbloger 2020. 9. 18. 07:51
반응형

Oracle SQL Developer SQL 워크 시트 창에서 텍스트 인쇄


Oracle SQL을 사용하고 있습니다 (SQLDeveloper에서 SQL 워크 시트 사용). 선택하기 전에 다음과 같은 명세서를 인쇄하고 싶습니다.

PRINT 'Querying Table1';
SELECT * from Table1;

텍스트 출력을 인쇄 / 표시하려면 무엇을 사용합니까? 그것은 나에게 오류를 제공하기 때문에 인쇄 Table1가 아닙니다 : Bind Variable is NOT DECLARED. DBMS_OUTPUT.PUT_LINE은 알 수없는 명령입니다. (분명히 저는 경험이없는 SQLDeveloper 및 Oracle 사용자입니다. Print와 동의어가있을 것 같지만 그것이 무엇인지 모르고 도움말을 찾는 데 어려움을 겪고 있습니다.)


여기에 이미지 설명 입력

간단한 설명 :

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

-- do something

begin
    DBMS_OUTPUT.put_line('second simple comment');
end;
/

당신은 얻어야한다 :

anonymous block completed
simple comment

anonymous block completed
second simple comment

변수의 결과를 출력하려면 여기에 또 다른 예가 있습니다.

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;

출력은 다음과 같아야합니다.

anonymous block completed
first comment

anonymous block completed
comment2

PROMPT text to print

참고 : Run 문 (Ctl + Enter)이 아닌 Run as Script (F5)를 사용해야합니다 .


당신은 수있는 에코 설정 에에 :

set echo on
REM Querying table
select * from dual;

In SQLDeveloper, hit F5 to run as a script.


You could put your text in a select statement such as...

SELECT 'Querying Table1' FROM dual;

For me, I could only get it to work with

set serveroutput on format word_wrapped;

The wraped and WRAPPED just threw errors: SQLPLUS command failed - not enough arguments


The main answer left out a step for new installs where one has to open up the dbms output window.

여기에 이미지 설명 입력

Then the script I used:

dbms_output.put_line('Start');

Another script:

set serveroutput on format wrapped;
begin
    DBMS_OUTPUT.put_line('jabberwocky');
end;

If you don't want all of your SQL statements to be echoed, but you only want to see the easily identifiable results of your script, do it this way:

set echo on

REM MyFirstTable

set echo off

delete from MyFirstTable;

set echo on

REM MySecondTable

set echo off

delete from MySecondTable;

The output from the above example will look something like this:

-REM MyFirstTable

13 rows deleted.

-REM MySecondTable

27 rows deleted.

참고 URL : https://stackoverflow.com/questions/193107/print-text-in-oracle-sql-developer-sql-worksheet-window

반응형