1

myscript.sql:

set serveroutput on
set feedback off
set heading off
set echo off


DECLARE
    CURSOR c1 IS
        select 2 from dual
BEGIN
    FOR i IN c1
    LOOP
        DBMS_OUTPUT.put_line (i.object_text );
    END LOOP;
END;
/
exit;

I call my script with that:

sqlplus  user/pass@database  @Dpath\myscript.sql  -S | Out-String | echo
  1. SQL*Plus Version..........is always printed in the beginning. I don't want it.
  2. the lines of my query are printed. that is OK.
  3. Disconnected .... from Oracle Database is always printeed in the end. I don't want it

This code is just a reproductible example.I know that for the particular case, there is other way to do that. But what I want is to print just the dbms_out

2
  • 1
    The -s (or -silent) flag will suppress the banner, but also the statement being executed; are you sure you want to see that? But that flag has to be before the @script part (and the credentials), otherwise it's just seen as another positional parameter. Commented Jun 8, 2022 at 7:32
  • Ok it's working now. the banner isn't printed. But the output from prompt or dbms_output is printed. Thanks Commented Jun 8, 2022 at 7:59

2 Answers 2

1

You can just use SPOOL to create a separate file, where you will have full control of what is printed. You can also use a combination of the options SET FEEDBACK OFF, SET HEAD OFF and SET VERIFY OFF to remove the number of rows received, column names etc. so that your file looks more like an actual report instead of redirected output.

Sign up to request clarification or add additional context in comments.

Comments

0
    set serveroutput on
    set feedback off
    set heading off
    set echo off

    DECLARE
        CURSOR c1 IS
            select 2 as object_text  from dual;
    BEGIN
        FOR i IN c1
        LOOP
            DBMS_OUTPUT.put_line (i.object_text );
        END LOOP;
    END;
    /
    EXIT;


    PS C:\otr> sqlplus -s user/password@dev19  @c:\otr\file1.sql  -S | Out-String | echo
    2

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.