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!

Populate a REF CURSOR from regular cursor...

alinkJan 11 2007 — edited Jan 12 2007
Hi all,

I apologize if the answer to this is somewhere...I've been looking on the web for sometime and can't find an answer to the following problem. I have a Significant Events database that contains network based issues and problems. As problems are detected on the network an SE is issued and published. As the SE records are updated, NEW records are entered into the table and "linked" back to the original. Each update results in a new row. Thus, an SE with two updates would have a total of 3 lines. When the SE gets closed (set the column CLOSED to SYSDATE), only the "original" SE is closed, any updates are left open...aka, the CLOSED column is left null.

That said, I need a way to get the original and/or latest updated SE rows from the table. Thus, I am trying to use a PL/SQL package. The PL/SQL "must" return a REF CURSOR as the results are being passed to a client process.

My initial approach was within a PL/SQL procedure, I have an SQL statement that returns the SE originals. Once in that cursor I need to do the following:

- Attempt to fetch any linked SE rows.
- if no rows then
- add the original to the REF CURSOR.
- else
- find latest SE update
- add latest SE update to REF CURSOR.
- end if

My Question is : How do I manually "add" a row to a REF CURSOR?

If this is not possible, is there a way to populate a REF CURSOR from maybe another construct like:

TYPE ian_se_record is RECORD (
se_id number
,linked_se_id number
,submitted date
,updated date
,closed date
,segroup varchar2(150)
,incident_start_time varchar2(150)
,business_units_affected varchar2(150)
,officenum varchar2(1500)
,sedetails varchar2(4000)
);

TYPE ian_se_table is table of ian_se_record index by binary_integer;

With the above construct I could:
- Fill ian_se_table with the process described above.
- And finally select off ian_se_table into the REF CURSOR?

Any help would be greatly appreciated,

adym
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 9 2007
Added on Jan 11 2007
7 comments
834 views