On Thu, 6 Aug 2009 16:58:02 -0400
Michael Glaesemann wrote:
> That's not a SELECT query per se: AIUI it's how the evaluation of
> the NEW != OLD expression is evaluated within the PL/pgSQL function
> as part of the IF statement (note the "line 2 at IF" context line).
> It's just saying the <> ope
On Thu, Aug 6, 2009 at 3:31 PM, Josh Trutwin wrote:
> On Thu, 6 Aug 2009 13:15:57 -0400
> Merlin Moncure wrote:
>
>> CREATE OR REPLACE FUNCTION set_last_modified ()
>> RETURNS TRIGGER
>> AS $$
>> BEGIN
>> IF NEW != OLD THEN -- 8.4 syntax
>> NEW.last_modified = NOW();
>> END IF;
>>
>> RE
On Aug 6, 2009, at 15:31 , Josh Trutwin wrote:
Interestingly, this syntax is accepted in 8.3.7, but SELECT queries
fail:
CREATE TRIGGER trigger_test_upd_set_last_mod
BEFORE UPDATE ON test_upd
FOR EACH ROW EXECUTE PROCEDURE set_last_modified();
Then:
UPDATE test_upd SET foo = 'foo' WHERE id =
On Thu, 6 Aug 2009 13:15:57 -0400
Merlin Moncure wrote:
> CREATE OR REPLACE FUNCTION set_last_modified ()
> RETURNS TRIGGER
> AS $$
> BEGIN
> IF NEW != OLD THEN -- 8.4 syntax
> NEW.last_modified = NOW();
> END IF;
>
> RETURN NEW;
> END;
> $$ LANGUAGE PLPGSQL;
Interestingly, this synt
On Thu, 6 Aug 2009 13:15:57 -0400
Merlin Moncure wrote:
> CREATE OR REPLACE FUNCTION set_last_modified ()
> RETURNS TRIGGER
> AS $$
> BEGIN
> IF NEW != OLD THEN -- 8.4 syntax
> NEW.last_modified = NOW();
> END IF;
>
> RETURN NEW;
> END;
> $$ LANGUAGE PLPGSQL;
Thanks - I'll try this.
On Thu, Aug 6, 2009 at 1:38 PM, Jeff Davis wrote:
> On Thu, 2009-08-06 at 13:15 -0400, Merlin Moncure wrote:
>> in 8.4 you can (and should) do:
>> WHERE old = new
>
> I couldn't get that to work in a rule.
it should, maybe try old::foo = new::foo
>> IF NEW != OLD THEN -- 8.4 syntax
>
> Does th
2009/8/6 Jeff Davis :
> On Thu, 2009-08-06 at 13:15 -0400, Merlin Moncure wrote:
>> in 8.4 you can (and should) do:
>> WHERE old = new
>
> I couldn't get that to work in a rule.
>
>> IF NEW != OLD THEN -- 8.4 syntax
>
> Does this work correctly in the case of NULLs? It looks like it does,
> but
On Thu, 2009-08-06 at 13:15 -0400, Merlin Moncure wrote:
> in 8.4 you can (and should) do:
> WHERE old = new
I couldn't get that to work in a rule.
> IF NEW != OLD THEN -- 8.4 syntax
Does this work correctly in the case of NULLs? It looks like it does,
but that seems strange, because ROW(1, N
On Thu, 2009-08-06 at 11:53 -0500, Josh Trutwin wrote:
> The set_last_modified() trigger is run even though the data didn't
> actually change. Perhaps due to an application program which doesn't
> know the contents before running the UPDATE.
The following doc explains the standard way to accompli
On Thu, Aug 6, 2009 at 12:53 PM, Josh Trutwin wrote:
> Hello,
>
> I have a simple table that has a trigger to set a last_modified column
> using the following:
>
> CREATE OR REPLACE FUNCTION set_last_modified ()
> RETURNS TRIGGER
> AS $$
> BEGIN
> NEW.last_modified = NOW();
> RETURN NEW
Hello,
I have a simple table that has a trigger to set a last_modified column
using the following:
CREATE OR REPLACE FUNCTION set_last_modified ()
RETURNS TRIGGER
AS $$
BEGIN
NEW.last_modified = NOW();
RETURN NEW;
END;
$$ LANGUAGE PLPGSQL;
CREATE TRIGGER trigger_test_upd_set_la
11 matches
Mail list logo