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: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
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 Feb 12 17:23:09 CST 2025