Subject Re: Server and application names
Author Adam
--- In firebird-support@yahoogroups.com, "Roberto Freitas"
<solanofreitas@...> wrote:
>
> --- In firebird-support@yahoogroups.com, "Ann W. Harrison"
> <aharrison@> wrote:
> >
> > Roberto Freitas wrote:
> > >
> > > In this situation, it has been necessary the application to pass
> > > a kind of "inoffensive" string to the database server, so we can
> > > decide some actions in a trigger depending on that string value,
> > > as I've been doing with SQL Server, through string connection
> > > parameters. I haven't yet gived up to do it with FireBird ...
> >
> > Would it be possible to do something like that at the application
> > level? Once you've connected to the database, store a record (or
> > in V2 set a variable) that identifies your application and make
> > tests based on that?
> > Regards,
> > Ann
>
> I've developed a kind of Distributed Database; in this structure I
> need to known (inside triggers) some parameters values coming from
> client (the client who is making the update). After implementing this
> structure, I've got a great performance improvement in some
> applications. It's working very well with SQL Server. In SQL Server
> there is a function APP_NAME() that returns a string I
> can "inoffensively" set from client, rided on Connection String.
> I'm not sure I've correctly understood what you mean, Ann, are you
> asking something?

Ann is suggesting the same approach, your application inserts
something into the database which your triggers can then query. The
stored procedure approach does exactly this. There is no requirement
to use a stored procedure, I just find it helps because then you don't
have to worry about a backup-restore resetting the connection number
and your triggers then thinks a connection is a particular application
but it is not.

> If you are, Adam has proposed a solution on message #74061 that seems
> to be a good one: to store these values in an auxiliary table
> controlled by CURRENT_CONNECTION number.
> I haven't yet implemented it, but it seems to me that it's a good
> idea.
> With FB2, he has proposed to use the two system functions
> RDB$GET_CONTEXT and RDB$SET_CONTEXT to set and get values as I need,
> but I don't know if these variables are linked to each client
> connection, as necessary. Are they?

Not sure whether it is to the connection or the user. Check the FB 2
release notes for the functions details, or there may even be a readme
for them in the docs folder of FB2.

Adam