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

Home -> Community -> Usenet -> c.d.o.server -> Re: How to Determine Whether to Insert or Update

Re: How to Determine Whether to Insert or Update

From: Ben Hills <bhills_at_lycos.co.uk>
Date: 14 Mar 2005 02:25:00 -0800
Message-ID: <8cf2fc34.0503140225.730bb676@posting.google.com>


Hi,

You could always use the implicit cursor sql to determine how many rows were updated and if none were, insert one :

update CHILD set -- whatever
 where PARENT_ID = P_ID and ORDERING = P_ORDERING;

if sql%rowcount = 0 then

    insert into CHILD (PARENT_ID, ORDERING)     values (P_ID, ORDERING);
end if;

Ben. Received on Mon Mar 14 2005 - 04:25:00 CST

Original text of this message

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