Re: 2 questions about types - Mailing list pgsql-general

From Richard Huxton
Subject Re: 2 questions about types
Date
Msg-id 4238607E.8010704@archonet.com
Whole thread Raw
In response to Re: 2 questions about types  (Jason Tesser <jtesser@nbbc.edu>)
List pgsql-general
Jason Tesser wrote:
> <snip>
>
>>There's an example in the manuals - chapter "7.2.1.4. Table Functions"
>>
>>SELECT *
>>     FROM dblink('dbname=mydb', 'select proname, prosrc from pg_proc')
>>       AS t1(proname name, prosrc text)
>>     WHERE proname LIKE 'bytea%';
>>
>>So basically, you need to supply the type definitions in your SELECT if
>>you aren't going to supply it in the function definition.
>
>
> ok I tried to rewrite as follows but I get an error that says "a column
> definition list is required fro functions returning record

Because you didn't supply the type definitions in your SELECT...

> here is my function and call for it now
> CREATE OR REPLACE FUNCTION "public"."loginbyindidgettest" (integer)
> RETURNS SETOF "pg_catalog"."record" AS'
...
> select * from loginbyindidgettest(43650);

This needs to be something like:
   SELECT * FROM loginbyindidgettest(43650) AS myres(a int, b text, c
date, ...)

Obviously, the types need to match the results of your function.
--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Jason Tesser
Date:
Subject: Re: 2 questions about types
Next
From: Marco Colombo
Date:
Subject: Re: New user: Windows, Postgresql, Python