Re: Setting expire date on insert/modify - Mailing list pgsql-general

From Tom Lane
Subject Re: Setting expire date on insert/modify
Date
Msg-id 25891.1138160849@sss.pgh.pa.us
Whole thread Raw
In response to Re: Setting expire date on insert/modify  ("Foster, Stephen" <stephenlfoster@comcast.net>)
List pgsql-general
"Foster, Stephen" <stephenlfoster@comcast.net> writes:
> Michael, I tried that line in the trigger procedure with double quotes,
> single quotes and without.  The only way it would save was with single
> quotes and that is why you saw it that way.

Just for reference, the thing that was tripping you up (or one thing
that was tripping you up at least) was trying to extrapolate the syntax

    typename 'literal value'

to situations where you didn't mean an actual literal constant.  This
syntax is something that's forced on us by the SQL standard, but we do
not support it for anything but literal constants (which is all that the
standard defines it for, either).  In the examples you gave, you wanted
to coerce the value of a variable of one type to some other type, and so
you should have written either

    CAST( variablename AS typename )
or
    variablename :: typename

the former being the SQL-spec syntax for a runtime type conversion
and the latter being a traditional Postgres abbreviation.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: pgxml
Next
From: Bruce Momjian
Date:
Subject: Re: hardware checks (was Re: invalid memory alloc request