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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: PL/SQL Question

Re: PL/SQL Question

From: Andreas Haunschmidt <saerdnah_at_yahoo.de>
Date: Wed, 13 Sep 2000 11:52:18 +0200
Message-Id: <10620.117095@fatcity.com>


Hello Helmut!

Try this:


	BEGIN
		INSERT INTO mytable ... ;
	        ...
	EXCEPTION
		WHEN DUP_VAL_ON_INDEX THEN
			UPDATE mytable ... ;
		WHEN OTHERS THEN
			... ;
	END;

----------------------------------------------------
I don't know if this is the fastest way to to this, but it works for me.

Hope this helps

Andreas

Helmut Daiminger schrieb:
>
> Hi!
>
> I do have a weird problem to solve. I wanna check if a specific record
> already exists in a table (select * from table where PrimaryKey = 1234). If
> it does, I wanna do an update on that record and if it doesn't, I wanna
> insert a record.
>
> What would be the best (and least expensive) way to achieve this in a
> procedure?
>
> Thanks,
> Helmut
>
> --
> Author: Helmut Daiminger
> INET: hdaiminger_at_vivonet.com
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).



Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com Received on Wed Sep 13 2000 - 04:52:18 CDT

Original text of this message

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