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: If EXISTS before insert clause

Re: If EXISTS before insert clause

From: Stan Milam <stmilam_at_swbell.net>
Date: Tue, 15 Feb 2005 04:26:56 GMT
Message-ID: <kSeQd.30601$wi2.4124@newssvr11.news.prodigy.com>


JPike wrote:

> I suppose that will work but it is a pretty big script file and adding
> that to every insert would be a pain. Also there are some table
> creations, alters, update and stuff falling under the contraints of the
> if, so wrapping the whole block in a big IF would be easiest if it's
> somehow possible.
>
> Somehow though I am think easy and Oracle don't belong in the same
> sentence.
>
> Jim
>

Please forgive because my PL/SQL is a little rusty.

Perhaps something like:

declare

     l_prd_uid number default null;
     l_test is cursor for
         select prd_uid
         from   wst_prd
         where  prd_uid = 502;

begin
     open cursor l_test;
     fetch l_test into l_prd_uid;
     close cursor l_test;

     if l_prd_uid is not null
     then
         insert into WST_PFD(
              pfg_uid,
              obj_uid
         )
         values (
             '14014',
             'GRP_VIEW_RSK'
         );

         /***********************************************************/
         /* Do other stuff here.  Make sure you handle execeptions. */
         /***********************************************************/

     end if;

end; Received on Mon Feb 14 2005 - 22:26:56 CST

Original text of this message

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