An execute query Procedure
687481Feb 25 2009 — edited Mar 19 2009Hi 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