Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> PL/SQL REF CURSOR Question
I am a newbie to ref cursors in PL/SQL so bear with me. I found the usual
trivial examples on how to use ref cursors in Oracle and they all looked
like Ex1 below. You declared a cursor, then opened it and selected data
into it and then copied it to the output variable.
I took a shortcut and just selected the data directly into the output variable ala Ex2. It seemed to work fine for me (my Cold Fusion page was able to read all the data from the output cursor with no problem), but the DBA I was working with flipped out.
Fine, I don't really care which style I use, but I am curious as to why Ex1 is so much better than Ex2. Any answers will be appreciated.
Jimbo
jimbo_at_poehler.com
Ex1
>OPEN t_cursor FOR
> SELECT event_loc_id, event_loc_name
> FROM vt.t_tmp_legs
> WHERE package_data_id = pi_PACKAGE_DATA_ID
> ORDER BY event_dt DESC;
>po_LEG_STATUS := t_cursor;
Ex2
>OPEN po_LEG_STATUS FOR
> SELECT event_loc_id, event_loc_name
> FROM vt.t_tmp_legs
> WHERE package_data_id = pi_PACKAGE_DATA_ID
> ORDER BY event_dt DESC;
Received on Mon Jul 01 2002 - 20:20:09 CDT
![]() |
![]() |