Re: EXIST, NOT EXIST problem

From: crappy <nospam_at_newsranger.com>
Date: Wed, 20 Jun 2001 15:32:29 GMT
Message-ID: <hm3Y6.2654$yp1.74576_at_www.newsranger.com>


or maybe try select count(*) into var1, if possible .. depending on the actual query.

In article <9gq228$78u8_at_kcweb01.netnews.att.com>, JJ says...
>
>
>"Enrico Brighi" <ebrighi_at_cineca.it> wrote in message
>news:9gphk3$2o5$1_at_newsfeed.cineca.it...
>> Hi,
>> how can i translate this pseudocode in PL/SQL?
>>
>> if EXISTS(select ......) then
>>
>> elsif NOT EXISTS(select....) then
>>
>> end if;
>>
>> I think one way is the sequent:
>>
>> Condition 1
>>
>> select ... into var1 where ....
>>
>> Condition 2
>>
>> select ... into var2 where.....
>>
>> and so the code is:
>>
>> if (var1 <> 0 ) then
>>
>> elsif (var2 = 0) the
>>
>> end if;
>>
>> ...but it's a problem, because the select fails if no return a value INTO
>> the variable!!
>>
>> How can i do??
>>
>> Thank
>> enrico brighi
>>
>If i understood your question correctly....
>
>Use the exception "when no_data_found"
>
>Sample code:
>begin
>declare var1 varchar(2);
>begin
>select 'b' into var1
>from dual
>where exists (select dummy from dual where 1 =2);
>exception
>when no_data_found then
>if var1 is null then
>dbms_output.put_line('var1 is null');
>end if;
>end;
>end;
>
>HTH
>JJ
>
>
Received on Wed Jun 20 2001 - 17:32:29 CEST

Original text of this message