Re: Umm, almost embarrassed to ask this, but....
Posted in 1998
Paul Roberts wrote:
>
> In article <34DB8723.410D@netcomuk.co.uk>,
> Neil Truby <ntruby@netcomuk.co.uk> wrote:
> >What's the best way to retrieve the value of a system variable, say
> >TODAY? Obviously, I can do:
> >
> >SELECT TODAY from table1
> >where key='aaa'> >
> >but I have to know that this will return a single row. How about a
> >general select statement that doesn't require detailed knowledge of a
> >table's data?
>
> The standard way to do this seems to be:-
>
> select today
> from systables
> where tabid = 1>
> If I were given to making universal assertions I would probably claim
> that all Informix databases have a table called "systables" and it
> always has exactly one row whose tabid is 1; so instead I will merely
> say that this has been the case with all Informix databases that it
> has been my pleasure to meet.
Then I guess you've not met MODE ANSI databases... :-(
I agree with the general technique (it's what I use), but if the
code has to work in both MODE ANSI and non-ANSI databases, then you
need to quote the table owner:
SELECT TODAY
FROM 'informix'.SysTables
WHERE TabID = 1;
To be horrendously nit-picking, table owners became part of the Informix
product set somewhere around the 4.00 release, so this would fail on the
older versions of the product. I trust that no-one reading this has to
actually be concerned with pre-4 databases (in fact, I'd like to think
that most people don't have to fuss with pre-5 databases, but that's a
bit optimistic, to judge from the questions I see).
Yours pedantically,
Jonathan Leffler (jleffler@earthlink.net or jleffler@visa.com)