pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Randall Lucas <rlucas@tercent.net>
To: Mario Alberto Soto Cordones <mario_soto@compuall.cl>
Cc: pgsql-sql@postgresql.org
Subject: Re: PROBLEM WITH FUNCTIONS
Date: Mon, 21 Apr 2003 17:46:36 -0400
Message-ID: <B9FA6AB3-7442-11D7-9BCD-000A957653D6@tercent.net> (raw)
In-Reply-To: <1848.192.168.1.100.1050961085.squirrel@www.compuall.cl>

Mario,

If your function returns a record, you have to treat it like it's a 
relation (table).  So you don't select it, you select from it.

Try:

select * from get_unidades(10, 1, 15, 17);

Also you may have to give it an explicit variable list such as:

select * from get_unidades(10,1,15,17) as (codigo numeric(3,0), 
descripcion text);

Best,

Randall

On Monday, April 21, 2003, at 05:38 PM, Mario Alberto Soto Cordones 
wrote:

> Hi.
>
> i have a problem with a function.
>
> i create a type unidades
>    CREATE TYPE unidades AS (codigo numeric(3,0),
>                             descripcion text);
>
> and i create a function get_unidades
>     CREATE FUNCTION get_unidades(int4, int4, int4, int4) RETURNS  
> typeof
> unidades AS '
> SELECT cucoduni, cudesuni
> FROM cumauni
> WHERE cuempuni = $1 and
>       cuseduni = $2 and
>       cucaruni = $3 and
>       cuasiuni= $4
> ; '  LANGUAGE 'sql';
>
> and at this moment´s it´s all ok BUT when execute this function
>      select get_unidades(10,1,15,17)
>
> say
>      "cannot display a value of type RECORD"
>
> any idea, PLEASE HELP MY
>
> saludos
>
>
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>




view thread (6+ messages)  latest in thread

Message-ID: <B9FA6AB3-7442-11D7-9BCD-000A957653D6@tercent.net>
Permalink:  ../B9FA6AB3-7442-11D7-9BCD-000A957653D6@tercent.net/
Also on:    postgresql.org/message-id/B9FA6AB3-7442-11D7-9BCD-000A957653D6@tercent.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: rlucas@tercent.net, mario_soto@compuall.cl
  Subject: Re: PROBLEM WITH FUNCTIONS
  In-Reply-To: <B9FA6AB3-7442-11D7-9BCD-000A957653D6@tercent.net>
  References: <1848.192.168.1.100.1050961085.squirrel@www.compuall.cl> <B9FA6AB3-7442-11D7-9BCD-000A957653D6@tercent.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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