Subject Re: [firebird-support] How to drop a user only if it does exist.
Author Thomas Steinmaurer
> I've tried it, Thomas.
> 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;
> **
> ??

The following PSQL works fine here:

set term !! ;
execute block
as
begin
execute statement 'drop user testxyz';
end
!!

set term ; !!


But I'm not sure why you want to drop a user in the security database if
the user isn't found in the privileges table, because user are
server-wide and not per database. So, someone else could be in need for
a particular user stored in the server-wide security database.


--
With regards,
Thomas Steinmaurer

* Upscene Productions - Database Tools for Developers
http://www.upscene.com/

* My Blog
http://blog.upscene.com/thomas/index.php

* Firebird Foundation Committee Member
http://www.firebirdsql.org/en/firebird-foundation/


> However, Thank You in Advance Thomas, for a very quick response !
>
> Regards,
> Ichiro Kobayashi
>
> On 12/16/11, Thomas Steinmaurer<ts@...> wrote:
>>> I'd like to ask :
>>> How to drop a user only if it does exist ?
>>
>> Use the new syntax:
>>
>> DROP USER<your_user>
>>
>>
>> Doesn't give an error when the user doesn't exist.
>>
>>
>> --
>> With regards,
>> Thomas Steinmaurer
>>
>> * Upscene Productions - Database Tools for Developers
>> http://www.upscene.com/
>>
>> * My Blog
>> http://blog.upscene.com/thomas/index.php
>>
>> * Firebird Foundation Committee Member
>> http://www.firebirdsql.org/en/firebird-foundation/
>>
>
>
> ------------------------------------
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Yahoo! Groups Links
>
>
>