Subject Re: [firebird-support] Re: Making evaluation of UDFs constant across a query
Author Mike Pomraning
On Sat, Mar 19, 2011 at 12:47 PM, homerjones1941 <homer@...>wrote:

>
> > Is there a technique to make the return value of a UDF constant across
> > the execution of a single query?
> >
> > For example, I'd like getExactTimestamp() -- or, rather, a UDF very
> > much like it -- to return the same result every time it is evaluated...
>
> Can you declare a variable, and then just assign the value once?
>

In a stored procedure, yes. IMHO this is suitable for regular, production
environments, when you already know all the queries you want to run.
However, I find it too restrictive for general or "on the fly" querying.

Another possibility is using a table or GTT or RDB$SET_CONTEXT() to store
the precomputed value. In this case you'd have to explicitly compute the
value before every SELECT, which is still cumbersome but more flexible IMHO
than using a stored procedure.

But, I'm wondering if there is an easier technique than any of the above.

-Mike


[Non-text portions of this message have been removed]