pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
plpgsql notify trigger
2+ messages / 2 participants
[nested] [flat]

* plpgsql notify trigger
@ 2001-02-28 19:30 George Young <gry@ll.mit.edu>
  2001-03-01 04:26 ` Re: plpgsql notify trigger Yury Don <yura@vpcit.ru>
  0 siblings, 1 reply; 2+ messages in thread

From: George Young @ 2001-02-28 19:30 UTC (permalink / raw)
  To: pgsql-sql

[postgres 7.0.2, x86 linux]

I am trying to use a trigger to perform an sql 'notify' command.
I do something like:

CREATE FUNCTION run_changed() RETURNS opaque AS '
   declare
      nm text;
   begin
       nm := NEW.run_name;
       notify nm
       return null;
   end;        
' LANGUAGE 'plpgsql';

create trigger run_changed_tr after update on runs for each row
       execute procedure run_changed();


BUT, when I update the table, I get:
   ERROR:  parser: parse error at or near "$1"     

It looks like the *name* (or it's alias here: $1.run_name), not the *value* of the variable nm,
is passwd to the notify command.  Since notify only takes a name, not a string,
I don't see how to proceed.  

Is there some way in plsql to construct a string and have it executed in sql?

disappointed in plsql,
	George

--
George Young,  Rm. L-204		gry@ll.mit.edu
MIT Lincoln Laboratory
244 Wood St.
Lexington, Massachusetts  02420-9108	(781) 981-2756



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: plpgsql notify trigger
  2001-02-28 19:30 plpgsql notify trigger George Young <gry@ll.mit.edu>
@ 2001-03-01 04:26 ` Yury Don <yura@vpcit.ru>
  0 siblings, 0 replies; 2+ messages in thread

From: Yury Don @ 2001-03-01 04:26 UTC (permalink / raw)
  To: pgsql-sql

Hello George,

Once, Thursday, March 01, 2001, 12:30:07 AM, you wrote:

GY> [postgres 7.0.2, x86 linux]

GY> I am trying to use a trigger to perform an sql 'notify' command.
GY> I do something like:

GY> CREATE FUNCTION run_changed() RETURNS opaque AS '
GY>    declare
GY>       nm text;
GY>    begin
GY>        nm := NEW.run_name;
GY>        notify nm
GY>        return null;
GY>    end;        
GY> ' LANGUAGE 'plpgsql';

GY> create trigger run_changed_tr after update on runs for each row
GY>        execute procedure run_changed();


GY> BUT, when I update the table, I get:
GY>    ERROR:  parser: parse error at or near "$1"     

GY> It looks like the *name* (or it's alias here: $1.run_name), not the *value* of the variable nm,
GY> is passwd to the notify command.  Since notify only takes a name, not a string,
GY> I don't see how to proceed.  

GY> Is there some way in plsql to construct a string and have it executed in sql?

GY> disappointed in plsql,
GY>         George

Trigger function must return record, try "return NEW" instead of
"return null"

-- 
Best regards,
 Yury





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-03-01 04:26 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-02-28 19:30 plpgsql notify trigger George Young <gry@ll.mit.edu>
2001-03-01 04:26 ` Yury Don <yura@vpcit.ru>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox