[ask] Return Query

From: ataherster <ataherster(at)yahoo(dot)co(dot)id>
To: pgsql-general(at)postgresql(dot)org
Subject: [ask] Return Query
Date: 2009-03-15 06:17:01
Message-ID: 49BC9D5D.2060401@yahoo.co.id
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

hai all, i'm trying create function like this

CREATE OR REPLACE FUNCTION penjualan(idcb integer)
RETURNS SETOF penjualan AS
$BODY$
BEGIN

IF ($1 IS NULL) THEN
return query SELECT * FROM PENJUALAN;
ELSE
return query SELECT * FROM PENJUALAN WHERE IDCABANG=$1;
END IF;

END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100
ROWS 1000;

but this function is not work with this error :
ERROR: structure of query does not match function result type
CONTEXT: PL/pgSQL function "penjualan" line 6 at RETURN QUERY

on the time i try with other table and working well

thanks for your help

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pedro Doria Meunier 2009-03-15 12:47:00 to_hex leading zeroes
Previous Message Martin Gainty 2009-03-15 03:08:17 Re: ODBC limitation??