Home » SQL & PL/SQL » SQL & PL/SQL » Execute any sql statement in package and return cursor (win server 2003, 10g)
Execute any sql statement in package and return cursor [message #323876] Thu, 29 May 2008 22:25 Go to next message
jimsang
Messages: 13
Registered: May 2008
Junior Member
--head
CREATE OR REPLACE package pkg_test_sql as 
type myrctype is ref cursor; 
function get_record(sql_str varchar2) return myrctype; 
end pkg_test_sql; 

--body
CREATE OR REPLACE package body pkg_test_sql as 
function get_record(sql_str varchar2) return myrctype is
rc myrctype;
begin 
if sql_str<>'' then 
  open rc for sql_str; --maybe error
end if; 

return rc; 
end get_record; 
end pkg_test_sql; 



i want to call it, then get the recordset:
pkg_test_sql.get_record('select * from Any_Table_Name')
Re: Execute any sql statement in package and return cursor [message #323877 is a reply to message #323876] Thu, 29 May 2008 22:28 Go to previous messageGo to next message
jimsang
Messages: 13
Registered: May 2008
Junior Member
pkg_test_sql.get_record('select * from Any_Table_Name ... and many other where sentences')
Re: Execute any sql statement in package and return cursor [message #323910 is a reply to message #323876] Fri, 30 May 2008 00:40 Go to previous message
Michel Cadot
Messages: 64132
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
What is the need of a package for this?
Just use "open mycursor for mystring" in the calling program.

Regards
Michel
Previous Topic: partitioning
Next Topic: Date difference with in rows on the same column using group by
Goto Forum:
  


Current Time: Wed Dec 07 20:20:50 CST 2016

Total time taken to generate the page: 0.09033 seconds