Subject | Re: [firebird-support] How to drop a user only if it does exist. |
---|---|
Author | Mark Rotteveel |
Post date | 2011-12-16T12:38:49Z |
On Fri, 16 Dec 2011 19:28:41 +0700, Ichiro Kobayashi
<nouva.lyon@...>
wrote:
that.
eg
EXECUTE STATEMENT 'DROP USER '|| OLD.username;
WHEN ANY DO
BEGIN
-- ignore
END;
You may want to use an additional check on the specific SQLCODE, GDSCODE
or SQLSTATE instead of doing a blanket catch all like this.
Mark
<nouva.lyon@...>
wrote:
> I've tried it, Thomas.You should be able to handle the error in your trigger when you execute
> Such as :
>
> DROP USER FONDA
>
> But it does give a message like this :
>
> "Cannot commit transaction:
> Unsuccessful execution caused by system error that does not preclude
> successful execution of subsequent statements.
> record not found for user: FONDA."
>
> FYI, i need to use it at my trigger.
>
> May use something like this :
>
> **
> if (exists(select distinct rdb$user
> from rdb$user_privileges
> where rdb$user=OLD.username)) then
> EXECUTE STATEMENT 'DROP USER '|| OLD.username;
> **
> ??
>
> However, Thank You in Advance Thomas, for a very quick response !
that.
eg
EXECUTE STATEMENT 'DROP USER '|| OLD.username;
WHEN ANY DO
BEGIN
-- ignore
END;
You may want to use an additional check on the specific SQLCODE, GDSCODE
or SQLSTATE instead of doing a blanket catch all like this.
Mark