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: PLSQL Newbie Qn

Re: PLSQL Newbie Qn

From: Gerard H. Pille <ghp_at_skynet.be>
Date: Fri, 10 Jun 2005 21:11:52 +0200
Message-ID: <42a9e458$0$344$ba620e4c@news.skynet.be>


simon wrote:
> "Gerard H. Pille" <ghp_at_skynet.be> ¦b¶l¥ó
>

>>Not if id can be 0 or 99, else it is OK.  It is abnormal to select nothing

>
> or
>
>>multiple values in to a single, simple variable.

>
> Ok, assuming id cannot be 0 or 99, or I can just use another variable as the
> flag.
>
> What i am trying clarify is that if this way of using exception for testing
> row count returned by SELECT INTO a good practice? Because I am thinking
> exception should be used to handle abnormal cases, not an IF test of
> expected possibilities. However, given the fact that SELECT INTO will raise
> exception, it seems this technique have to be used.
>
>

I wouldn't do it that way, but I don't think your way is worse.

declare

     v_number number;
     cursor c_test (p_param varchar2) is
         select id from table where varchar_col = p_param;
begin
     v_number := 0;
     for r_test in c_test( something_else)  loop
         v_number := v_number + 1;
         if v_number > 1 then
             v_number := 99;
             exit;
         end if;
     end loop;

end;
/ Received on Fri Jun 10 2005 - 14:11:52 CDT

Original text of this message

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