Home » RDBMS Server » Server Administration » Record block
Record block [message #371605] Mon, 13 November 2000 21:53 Go to next message
Kiki
Messages: 13
Registered: November 2000
Junior Member
Hi there,

I have a situation that I have a function which returns ref cursor. and that ref cursor will return several records from different fields. In addition to that, I also want to implement those records from many different fields.

My questions:
1. Can I select the column name by using the parameter. for example
cursor c_test(column_name varchar2)
select column_name
from table_name
I have tested, even though it has no syntax error but the result is not what I am expecting.
2. how do you declare the variable contains multi records under RECORD? since I am using ref cursor, I want to place those ref cursor record under one variable. the record will be from select * from table_name.

Thanks for your time!
Re: Record block:(Return Multiple Records) [message #371796 is a reply to message #371605] Thu, 07 December 2000 04:37 Go to previous message
vasanth Kumar
Messages: 3
Registered: December 2000
Junior Member
/* First create a package decleration for variables */
CREATE PACKAGE emp_data AS
TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
TYPE EmpCurTyp IS REF CURSOR RETURN EmpRecTyp;
ENd emp_data;

-- Then create procedure as

CREATE PROCEDURE get_mystaff (
emp_cv IN OUT emp_data.TYPE EmpCurTyp) IS
BEGIN
OPEN emp_cv FOR
Select * from emp;
END;

----- Then from SQL*PLUS you can execute this
----- procedure as below

SET AUTOPRINT ON
VARIABLE cv3 REFCURSOR
EXECUTE get_mystaff(:cv3);

----- Instead of SQl*PLUS you may want to call
----- this in any other client environment
Previous Topic: Multiple Records from Stored Procedures
Next Topic: printing on same line
Goto Forum:
  


Current Time: Sun Dec 22 19:52:24 CST 2024