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

From Richard Huxton
Subject Re: 2 questions about types
Date
Msg-id 4238516F.8080008@archonet.com
Whole thread Raw
In response to Re: 2 questions about types  (Jason Tesser <jtesser@nbbc.edu>)
Responses Re: 2 questions about types
List pgsql-general
Jason Tesser wrote:
> OK here is an example of a function where I had to create a type called
> login.
> How could I have written this function without having to create a type.
>
> CREATE OR REPLACE FUNCTION "public"."loginbyindidget" (integer) RETURNS
> SETOF "public"."login" AS'
[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.
--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: generating statistics
Next
From: Tom Lane
Date:
Subject: Re: plPerl subroutine