pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
how to call a function with row-type arg
3+ messages / 3 participants
[nested] [flat]

* how to call a function with row-type arg
@ 2003-09-12 05:31 sad <sad@bankir.ru>
  2003-09-12 13:35 ` Re: how to call a function with row-type arg Richard Hall <rhall@micropat.com>
  2003-09-12 13:57 ` Re: how to call a function with row-type arg Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 3+ messages in thread

From: sad @ 2003-09-12 05:31 UTC (permalink / raw)
  To: pgsql-sql

hi
 how to call a function with a row_type arg ??
 that is the question

CREATE FUNCTION foo(tablename) returns int .....

SELECT foo ( ??????? );





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

* Re: how to call a function with row-type arg
  2003-09-12 05:31 how to call a function with row-type arg sad <sad@bankir.ru>
@ 2003-09-12 13:35 ` Richard Hall <rhall@micropat.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Richard Hall @ 2003-09-12 13:35 UTC (permalink / raw)
  To: ; +Cc: pgsql-sql

DECLARE
    I INTEGER;
BEGIN
    SELECT *
      INTO I
      FROM foo( <tablename> )

That part is easy, but I don't understand what you are using as a function
parameter.

Rick

sad wrote:

> hi
>  how to call a function with a row_type arg ??
>  that is the question
>
> CREATE FUNCTION foo(tablename) returns int .....
>
> SELECT foo ( ??????? );
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings

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

* Re: how to call a function with row-type arg
  2003-09-12 05:31 how to call a function with row-type arg sad <sad@bankir.ru>
@ 2003-09-12 13:57 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2003-09-12 13:57 UTC (permalink / raw)
  To: sad <sad@bankir.ru>; +Cc: pgsql-sql

sad <sad@bankir.ru> writes:
>  how to call a function with a row_type arg ??

> CREATE FUNCTION foo(tablename) returns int .....

	SELECT foo(tablename) FROM tablename;
or
	SELECT foo(tablename.*) FROM tablename;

The first is traditional Postgres usage, but I think the second makes it
more clear what's going on.

BTW, if you use a table alias then the alias is the name to refer to.

	SELECT foo(x.*) FROM tablename as x;

			regards, tom lane



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


end of thread, other threads:[~2003-09-12 13:57 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-09-12 05:31 how to call a function with row-type arg sad <sad@bankir.ru>
2003-09-12 13:35 ` Richard Hall <rhall@micropat.com>
2003-09-12 13:57 ` 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