Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a complex sql statement, I want to print the output of this statement to the sqlplus command line. I tried the following but no output or errors were displayed. I want to display the output of this select statement. Thanks.

SQL
CREATE OR REPLACE PROCEDURE test1 AS
BEGIN
SELECT sname from student
END;
Posted

for executing procedure u should write
exec test1
 
Share this answer
 
You say complex sql statement but above shared SQL looks straight forward.

About above query execution, you are creating a SP that holds a SELECT query. If you want to run that select query and get data, either execute SP or run the SQL directly.

i.e.:
SQL
SELECT sname from student

OR
SQL
exec test1;
 
Share this answer
 
Thanks for your replies. I did not post the actual SQL query because my problem is not the complexity of the query, it is about how to display output. I also know how to exec a sql proc.

It turned out that I needed to select INTO some variable and the use DBMS_OUTPUT.PUTLINE, the most important part was "set serveroutput on"

Thanks any way
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900