Subject | Re: [firebird-support] Check update succeeded |
---|---|
Author | Ivan Prenosil |
Post date | 2005-02-10T10:23:44Z |
> - How can i check if an update is succeeded? I have to update aTest the ROW_COUNT variable:
> single row, if the row doesn't exist i have to raise an exception. I
> tried checking SQLCCODE after the updates 'WHEN SQLCODE 100' but that
> didn't workout. Or do i have to do 'IF (EXISTS (SELECT 1 FROM ...
> WHERE ...) prior to doing the update?
IF (ROW_COUNT = 0) THEN ...
> - How can i get hold of the changed exception messagetext in a 'WHENWhat about this:
> EXCEPTION' block for logging purposes.
>
> BEGIN
> ...
> ...
> if ... then
> EXCEPTION BAD_ENTRY 'Not good'; <-------
> ...
> ...
> if ... then
> EXCEPTION BAD_ENTRY 'Better but still not right'; <-------
> ...
> ...
> END
> WHEN EXCEPTION BAD_ENTRY DO
> BEGIN
> /* 'Not good' or 'Better but still not right' */
> INSERT LOG (...,MessageText,...)
> VALUES (...,???,...) <-------
> END
DECLARE VARIABLE msg VARCHAR(80);
BEGIN
msg = 'Not good';
IF (...) THEN EXCEPTION BAD_ENTRY :msg;
msg = ''Better but still not right';
IF (...) THEN EXCEPTION BAD_ENTRY :msg;
WHEN EXCEPTION BAD_ENTRY DO
INSERT LOG (...,MessageText,...) VALUES (..., :msg,...);
END
Ivan
http://www.volny.cz/iprenosil/interbase/