Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

An execute query Procedure

687481Feb 25 2009 — edited Mar 19 2009
Hi guys, I'm starting to work in PL/SQL. I've got some experience in ms
sql server with T-SQL and I'm trying to understand some PL basis.

What
I want to do, is a stored procedure that returns the result of a given
query. Thats a simple thing to do in T-SQL. The code would be:

bq. create procedure runQuery(@someQuery varchar(200)) \\ * as* \\ * exec(@someQuery)* \\ * return*
and the use of it would be:

bq. runQuery 'select 123' \\ * -----------* \\ * 123*
bq. *(1 row(s) affected)*

Now, I'm trying to do the same thing in PL/SQL. What i've written by now is:

bq. CREATE OR REPLACE PROCEDURE RunQuery(someQuery IN VARCHAR2) \\ IS \\ BEGIN \\ EXECUTE IMMEDIATE someQuery ; \\ END; \\ */*
I got a messaje saying "procedure created", but when i try to use the procedure, it doesn't shows any results:

bq. begin \\ RunQuery('select from myTable');* \\ end; \\ */*
I just get a "Statement processed." message with out results.

Any idea of what I'm doing wrong?

thanks in advance
D

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 25 2009
Added on Feb 25 2009
8 comments
1,336 views