X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2A0ED475D3B for ; Mon, 21 Apr 2003 17:46:34 -0400 (EDT) Received: from randalls-laptop.kicks-ass.net (h00062577286a.ne.client2.attbi.com [24.61.43.102]) by postgresql.org (Postfix) with ESMTP id C63C7475A8D for ; Mon, 21 Apr 2003 17:46:24 -0400 (EDT) Received: from tercent.net (localhost [127.0.0.1]) by randalls-laptop.kicks-ass.net (8.12.7/8.12.6) with ESMTP id h3LLkbVg003240; Mon, 21 Apr 2003 17:46:41 -0400 (EDT) Date: Mon, 21 Apr 2003 17:46:36 -0400 Subject: Re: PROBLEM WITH FUNCTIONS Content-Type: text/plain; charset=ISO-8859-1; format=flowed Mime-Version: 1.0 (Apple Message framework v551) Cc: To: "Mario Alberto Soto Cordones" From: Randall Lucas In-Reply-To: <1848.192.168.1.100.1050961085.squirrel@www.compuall.cl> Message-Id: Content-Transfer-Encoding: quoted-printable X-Mailer: Apple Mail (2.551) X-Spam-Status: No, hits=-28.3 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES,USER_AGENT_APPLEMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/310 X-Sequence-Number: 13011 Mario, If your function returns a record, you have to treat it like it's a=20 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),=20 descripcion text); Best, Randall On Monday, April 21, 2003, at 05:38 PM, Mario Alberto Soto Cordones=20 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=20=20 > typeof > unidades AS ' > SELECT cucoduni, cudesuni > FROM cumauni > WHERE cuempuni =3D $1 and > cuseduni =3D $2 and > cucaruni =3D $3 and > cuasiuni=3D $4 > ; ' LANGUAGE 'sql'; > > and at this moment=B4s it=B4s 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=20 > broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster >