Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL in Pl/SQL

Re: SQL in Pl/SQL

From: Lynn Ranen <ranen_at_ix.netcom.com>
Date: Thu, 30 Apr 1998 21:46:31 +0100
Message-ID: <3548E327.E4C8FF92@ix.netcom.com>


Try the following =>

PROCEDURE foo
IS

   CURSOR some_curname(v_city IN varchar2, v_state IN varchar2)    IS
     SELECT ADID
    FROM OP_ADDRESS
    WHERE STATE IN (V_STATE, NULL);
    AND CITY IN (V_CITY, NULL);
BEGIN
   FOR thisrec IN some_curname(city,state)    LOOP

>
>
> In article <3547872F.3C3E590F_at_rspa.dot.gov>, Mark Aengenheyster <"'no spam
> loser' aengenhm"@rspa.dot.gov> wrote:
> >hello everybody!
> >
> >I am having a serious lapse of intelligence here.
> >
> >here is my SQL which is inside my PL/SQL function:
> > SELECT ADID INTO V_ADID FROM OP_ADDRESS
> > WHERE CITY = V_CITY
> > AND STATE = V_STATE;
> >
> >The problem is, city or state could be NULL but not necessarily.
> >How do I right the SQL so that it will return a row if the value is NULL
> >and if it is not NULL ( = 'something')?
> >
> >If it is null then I want to write:
> > SELECT ADID INTO V_ADID FROM OP_ADDRESS
> > WHERE CITY IS NULL
> > AND STATE IS NULL;
> >
> >DECODE won't work and NVL doesn't help. I don't want to get into using
> >dynamic SQL.
> >What do I do?
> >
> >Thanks in advance
> >
>
> Nicolas
>
> Nissakid_at_planete.net
> Microsoft Certified Product Specialist
> AUI Member
>
> The above represents my own opinion not my employer's and does not
> necessarily constitute the official policy of my employer. Any opinion
> developed through this account represent a private conversation.
Received on Thu Apr 30 1998 - 15:46:31 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US