Gracias
Fernando
CREATE OR REPLACE FUNCTION proc_transactionlog_report2(pstartdate date, penddate date, porderby integer)
RETURNS SETOF character varying AS
$BODY$
/*
Author: Fernando Vasquez Gonzalez
Description: Rpt Transactions
Creation Date: 07/12/07
Modified:
*/
DECLARE
psql CHARACTER VARYING;
BEGIN
psql:= 'select a.customerid as "Customer",
a.classid as "Application",
b.carrierid as "Carrier",
a.technologyid as "Technology",
date(a.startdatetime) as "TransactionDate",
count(0) as "Cantidad_TX"
from tb_transactionlog a, tb_phonesubscriber b
where date(a.startdatetime)>='||$1||'
and date(a.startdatetime)<='||$2||'
and a.phonesubscriberid=b.phonesubscriberid
group by a.customerid,date(a.startdatetime),a.classid,b.carrierid,a.technologyid ';
IF $3=1
THEN
psql := psql || 'order by a.customerid';
End If;
IF $3=2
THEN
psql := psql || 'order by a.classid';
End If;
IF $3=3
THEN
psql := psql || 'order by b.carrierid';
End If;
IF $3=4
THEN
psql := psql || 'order by a.technologyid';
End If;
--psql := psql || ' order by a.customerid';
RAISE NOTICE '%',psql;
[b]EXECUTE psql; --- esta es la parte que no me funciona me sale error
End;$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION proc_transactionlog_report2(pstartdate date, penddate date, porderby integer) OWNER TO db_billing;
El error es
ERROR: set-valued function called in context that cannot accept a set
SQL state: 0A000





