Subject Re: [firebird-support] Can you identify user/attachment in trigger
Author Thomas Steinmaurer
> I am currently running a v2.1 database with 50+ users each of whome open a number of programs.
>
> I have a problem in that a block of records on one table are being incorrectly deleted, but cannot similate or otherwise identify it. The records are automatically recreated by a program every few hours, but every time within a few hours the block is deleted again.
>
> I have created an ondelete trigger on the database that identifies the records being deleted and that records the record id and time in a #monitor' table.
>
> Is there a function/udf that I can use in the ondelete event that will give me information to track the user/program/computer/sql responsible?

Check out the in 2.0 introduced RDB$GET_CONTEXT function with the SYSTEM
namespace. There you can retrieve e.g. the client IP address.

For example as a pure SELECT statement:

select rdb$get_context('SYSTEM', 'CLIENT_ADDRESS') from rdb$database;

or in PSQL (triggers, stored procedures) with variable assignment:

begin
myvar = rdb$get_context('SYSTEM', 'CLIENT_ADDRESS');
end


With the monitoring tables introduced in 2.1, you can even join more
client information by using CURRENT_CONNECTION and the MON$... tables.

HTH.



--
Best Regards,
Thomas Steinmaurer
LogManager Series - Logging/Auditing Suites supporting
InterBase, Firebird, Advantage Database, MS SQL Server and
NexusDB V2
Upscene Productions
http://www.upscene.com

> Thanks in advance
>
>
>
> ------------------------------------
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> 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
>
>
>
>
>