Re: SQL%notfound

From: Marcus Collins <eccmr_at_abhp2.aberdeen.chevron.com>
Date: 18 Jun 93 14:35:11 GMT
Message-ID: <1993Jun18.153511_at_abhp2.aberdeen.chevron.com>


In article <1993Jun14.203828.20224_at_news.unomaha.edu>, moswald_at_cwis.unomaha.edu (Mike Oswald) writes:
|> I thought by writing the following it would prevent the user from deleting
|> records if the record exists in a related table but it doesn't work. The
|> coded segment can be found in SQL*Forms v3, KEY-DELREC trigger.
|>
|> declare
|> cursor CNV_CUR is
|> SELECT *
|> FROM <table_1> a
|> WHERE a.field = :<block>.<field> ;
|> begin
|> if SQL%notfound then
|> delete_record ;
|> else
|> <blah>
|> end if ;
|> end ;

The SQL%... commands are set when explicit cursors are used, delete, insert single row select - Not implicit cursors. Do you really need a cursor, multiple record, when you are only deleting a single record. I see two solutions - put the <blah> processing in the exception 'no_data_found' clause, or use a cursor and open/fetch the first row. You can use the %FOUND or %NOTFOUND after the fetch.

--
 Marcus Collins                     Internet: eccmr_at_aberdeen.chevron.com
 MFI Project.                       Profs: CCMR
 Chevron (UK) Ltd.                  Phone: +44 224 242690. CTN 677-2690.
 Ninian House, Crawpeel Road, Altens, Aberdeen AB1 4LG.
Received on Fri Jun 18 1993 - 16:35:11 CEST

Original text of this message