Re: Parser does not like %ROWTYPE in the RETURNS clause

From: Ron St-Pierre <rstpierre(at)syscor(dot)com>
To: ezra epstein <ee_newsgroup_post(at)prajnait(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Parser does not like %ROWTYPE in the RETURNS clause
Date: 2003-12-24 17:41:34
Message-ID: 3FE9CFCE.3080908@syscor.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

ezra epstein wrote:

>Aother head banger for me.
>
>Below is a complete example of the code
>
>Using Postgres 7.4,
> the function "test" gets this: psql:temp3.sql:10: ERROR: syntax error
>at or near "%" at character 135
> the function "test2" gets this: psql:temp3.sql:10: ERROR: syntax error
>at or near "ROWTYPE" at character 141
>
>Very odd. The first doesn't even like the '%' character -- perhaps because
>doof is a table type rather than a column (domain) type???
>
>And when we schema qualify the name of the table then the % is ok, but
>ROWTYPE is not.
>
>Is this a well-known limitation or a new (7.4) bug? I tried combing the
>docs to no avail.
>
>Thanks,
>
> Ezra E.
>
><code>
>/*
> CREATE TABLE doof ( "pk_id" serial )
> WITHOUT OIDS;
>*/
>
>CREATE OR REPLACE FUNCTION test(INTEGER)
> RETURNS doof%ROWTYPE AS '
>SELECT * FROM doof WHERE pk_id=$1;
> ' LANGUAGE SQL STABLE RETURNS NULL ON NULL INPUT;
>
>CREATE OR REPLACE FUNCTION test2(INTEGER)
> RETURNS public.doof%ROWTYPE AS '
>SELECT * FROM doof WHERE pk_id=$1;
> ' LANGUAGE SQL STABLE RETURNS NULL ON NULL INPUT;
> </code>
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>
>
>
>
Try replacing the rowtype with SETOF doof:

CREATE OR REPLACE FUNCTION test(INTEGER)
RETURNS SETOF doof AS '
SELECT * FROM doof WHERE pk_id=$1;
' LANGUAGE SQL STABLE RETURNS NULL ON NULL INPUT;

Hope that helps.
Ron

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sai Hertz And Control Systems 2003-12-24 17:53:00 Re: Parser does not like %ROWTYPE in the RETURNS clause of a
Previous Message Christian Kienle 2003-12-24 10:06:21 Re: PostgreeSQL C header files