[ask] Return Query - Mailing list pgsql-general

From ataherster
Subject [ask] Return Query
Date
Msg-id 49BC9D5D.2060401@yahoo.co.id
Whole thread Raw
In response to Re: ODBC limitation??  (Martin Gainty <mgainty@hotmail.com>)
Responses Re: [ask] Return Query  (Justin <justin@emproshunts.com>)
Re: [ask] Return Query  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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



pgsql-general by date:

Previous
From: Martin Gainty
Date:
Subject: Re: ODBC limitation??
Next
From: Pedro Doria Meunier
Date:
Subject: to_hex leading zeroes