Subject Re: [firebird-support] Check if an alias is defined
Author Helen Borrie
At 08:07 AM 21/08/2007, you wrote:
>I use FireBird 2.0, Delphi 5 and IBX.
>Suppose the file aliases.conf in the server has the following lines:
>MyDB1 = C:\MyDataBases\Data1.FDB
>MyDB2 = C:\MyDataBases\Data2.FDB
>If my application is running in a client PC... is there a way to know
>if some alias is defined?

Since aliasing is primarily a security measure, it would hardly make
sense for client applications to be able to query the contents of the
configuration file!

>What I need is a function that has a
>parameter for an alias name and returns true or false. If this
>function exists (suppose its name is CheckIfAliasExists) it should be
>used like the following:
> AliasExists: Boolean;
> AliasExists:=CheckIfAliasExists('MyDB1') { This should return
>True }
> AliasExists:=CheckIfAliasExists('MyDB2') { This should return
>True }
> AliasExists:=CheckIfAliasExists('MyDB3') { This should return
>False }
>Does anybody know if there is a function like CheckIfAliasExists

There isn't. The existence of an alias is server business, not
client business.

> or how can I do it?

Write a function that attempts to connect using the alias and returns
true if it succeeds, false if it returns an exception.