Re: PL/SQL cursor

From: Paul Koppens <pkoppens_at_sqlsystems.nl>
Date: 1998/04/01
Message-ID: <01bd5da8$f832a740$073ff161_at_pko.ntdom1>#1/1


Hi,

I suppose you want to be able to use your cursor to retrieve myparent when myparent_id is null. In that case, try (for example):

cursor c(cur_id in varchar2) is select myparent from myfamily where NVL(myparent_id,'12345') = NVL(cur_id,'12345');

which works fine as long as '12345' is not a normal value of the column myparent_id. The easiest way to avoid that is to exceed the length of the column in your NVL alternative, so the above example would suit a column myparent_id which is VARCHAR2(4).

Good luck,

Paul.

Phong Paul Tran <ptran_at_houston.geoquest.slb.com> wrote in article <35228F1C.6F17CE29_at_houston.geoquest.slb.com>...
> I have a cursor defined below:
>
> cursor c(cur_id in varchar2) is select myparent from myfamily where
> myparent_id = cur_id;
>
> My problem is the select statement for this cursor only works on
> non-null cur_id values. _id;
>
>
> How do I create a cursor that will work on both null and not null
> cur_id?
>
> Thank you much for your help.
>
>
> Paul Tran
> pptran_at_slb.com
>
>
>
>
>
Received on Wed Apr 01 1998 - 00:00:00 CEST

Original text of this message