Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL Oracle database
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.
 
CREATE OR REPLACE PROCEDURE test1 AS
BEGIN
SELECT sname from student
END;
Posted 29-Sep-12 10:53am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

for executing procedure u should write
exec test1
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.:
SELECT sname from student
OR
exec test1;
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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
  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 30 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100