insert / update branching decision

From: Chris Eastwood <c.eastwood_at_gu.edu.au>
Date: Tue, 05 May 1998 08:07:53 GMT
Message-ID: <6imh1d$rvg$1_at_nkraken.itc.gu.edu.au>



HiYa

I am inserting or updating records in a database, based on wether they exist or not. If the record exists I just update it, if it doesn't then I insert it. Insert is not so simple as update, it involves a couple of tables to instanciate the record. So .... I am wondering if it is better to have

2 seperate cursors:

*one for those that I know are going to exist
*another for those that I know won't exist

OR

one cursor for all of the data with an exception handler that inserts in the case of failing to insert.

I can see merit in both methods, and drawback in both too. Eg

If I have 2 seperate cursors there is the possibility of them not getting the total set of data when summed (particularly later in the maintainence phase of the code)

If I use an exception handler for no_data_found then this might be for different reasons (like database hassles). Also with an exception handler I am doing some quite complex steps to add a record (its not just a simple insert) so I was going to use a function to do the insert operation, which poses the question of:

Am I using the exception handler for somethig that it wasn't intended for?

I have thought of having the exception handler raise something that is trapped that allows me to perform the insert if the update fails for the "right" reason.

However will this upset the iteration cycle of the loop?

Thanks

See Ya
(when bandwidth gets better ;-)

Chris Eastwood

Photographer, Programmer               email    ua.ude.ug.cti_at_doowtsae.c
Motorcyclist and dingbat               WWW   http://chrise.itc.gu.edu.au

************************************************************************
Ohhh ... you work all day, slave over a hot stove all night  yet you *still* have time for sadomasochism ... how do you do it?

A little man hurts me.

<ding>

    Oh Mister Mean ... Oh Mister Mean
    15 Minutes with him and you'll be blue and green     Studded belts and leather whips
    Bondage trousers on his hips
    Wack and punish as you dust with Mister Mean   Ohhhh he whips me around the house in minutes ... lets get cracking ... Received on Tue May 05 1998 - 10:07:53 CEST

Original text of this message