pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
new and old as parameter in a function
2+ messages / 2 participants
[nested] [flat]

* new and old as parameter in a function
@ 2004-05-06 12:24 Riccardo G. Facchini <abief_ag_-postgresql@yahoo.com>
  2004-05-06 12:51 ` Re: new and old as parameter in a function Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Riccardo G. Facchini @ 2004-05-06 12:24 UTC (permalink / raw)
  To: pgsql-sql

Hi.

I'm having some trouble, and I would like to receive some input by the
pg community...

I would like to write a failry complex PLPGSQL trigger that calls a
secondary function. The trigger calls the function with the NEW record
that returns a variable of type RECORD whith the NEW variable modified
accordingly to a series of actions.

By Reading the documentation, I understand that I can write a PLPGSQL
function that receives a parameter of type RECORD, and returns a
parameter of type RECORD, and that this function is callable from a
Trigger.

But:

I haven't been able to write what's expressed above...

is there somebody that can provide some help and/or some examples?

thanks in advance,



=====
Riccardo G. Facchini



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

* Re: new and old as parameter in a function
  2004-05-06 12:24 new and old as parameter in a function Riccardo G. Facchini <abief_ag_-postgresql@yahoo.com>
@ 2004-05-06 12:51 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2004-05-06 12:51 UTC (permalink / raw)
  To: Riccardo G. Facchini <abief_ag_-postgresql@yahoo.com>; +Cc: pgsql-sql

"Riccardo G. Facchini" <abief_ag_-postgresql@yahoo.com> writes:
> By Reading the documentation, I understand that I can write a PLPGSQL
> function that receives a parameter of type RECORD,

You misread it --- that's not presently supported.

regression=# create function foo(record) returns int as '
regression'# begin
regression'#   return $1.f1;
regression'# end' language plpgsql;
ERROR:  plpgsql functions cannot take type record

However you can make a plpgsql function that accepts a parameter of a
specific (named) rowtype:

regression=# create table fooey(f1 int, f2 text);
CREATE TABLE
regression=# create function foo(fooey) returns int as '
regression'# begin
regression'#   return $1.f1;
regression'# end' language plpgsql;
CREATE FUNCTION

			regards, tom lane



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


end of thread, other threads:[~2004-05-06 12:51 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-05-06 12:24 new and old as parameter in a function Riccardo G. Facchini <abief_ag_-postgresql@yahoo.com>
2004-05-06 12:51 ` Tom Lane <tgl@sss.pgh.pa.us>

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