Subject Re: [firebird-support] Default value for RDB$GET_CONTEXT
Author Paul Vinkenoog
Hi Belal,

> Where is the default value in RDB$GET_CONTEXT ?
> I think the definition of it should be like this
> RDB$GET_CONTEXT ('<namespace>', '<varname>', '<default> = null');
> or is there another way ?

Looks like this question wasn't answered.

RDB$GET_CONTEXT does not support a third argument.

If you poll a non-existing variable in the SYSTEM namespace, an error is raised. This is not as bad as it seems, because this read-only namespace only contains a handful of variables, and you can't add anything to it (obviously).

If you poll a non-existing variable in one of the user namespaces, NULL is returned. If you want another default value, you can wrap the call in a COALESCE, e.g.:

select coalesce(RDB$GET_CONTEXT('USER_SESSION', 'MyUncertainVar'), -1) from rdb$database


Hope this helps,
Paul Vinkenoog