Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tricky sqlplus

Status
Not open for further replies.

hok1man

Technical User
Feb 16, 2008
102
Hi guys,

I would like to print out the sql query before execute it
here's part of my code :
Code:
sqlplus -s $userID/$PASS@$oracle_sid << SQL 

[red]echo "SELECT Count(*),in_process FROM TABLE;" [/red]

SELECT Count(*),in_process FROM TABLE; 
exit 
SQL

the code above doesn't work, but if I changed the red line with this :
Code:
SET SERVEROUTPUT ON
DBMS_OUTPUT.PUT_LINE('SELECT Count(*),in_process FROM TABLE;')

it works..
because I print output from oracle command,
is there anyway put some unix command in the middle of sqlplus buffer?

Thanks guys,
 
Perhaps:

Code:
QUERY='SELECT Count(*),in_process FROM TABLE;'

echo "$QUERY"

sqlplus -s $userID/$PASS@$oracle_sid << SQL
$QUERY
exit
SQL

Annihilannic.
 
Thanks Anni,

but unfortunately my queries is going to be many.
I can't login to sqlplus everytime I ran the query,
so it should be inside the sql buffer.

Thanks,
 
If you ask the same question in an Oracle forum, you will get the advice to have a look at the host command in your sqlplus manual.
[smile]
 
Remove the -s option.
You can play with the SET ECHO {ON|OFF} in you sql script.

Jean-Pierre.

Jean-Pierre.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top