Discussion:
PROBLEM WITH FUNCTION
(too old to reply)
Mario Alberto Soto Cordones
2004-05-02 19:01:15 UTC
Permalink
HI list,
i have a next function

CREATE OR REPLACE FUNCTION "public"."contador_distrito_activos" (numeric,
numeric, numeric) RETURNS SETOF "public"."ty_activo" AS'
declare
con bigint;
act bigint;
emp alias for $1;
sed alias for $2;
zon alias for $3;
begin
con := contador_distrito(1,2,5);
if (con > 0) then
act := ( select count(*) from activos where
activos.co_empresa = 1 and
activos.co_filial = 2 and
activos.co_zona = 5);
if act isnull then
act := 0;
end if;
else
con :=0;
act :=0;
end if;
return con , act;

end;
'LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

But this function only return the value of con ;

any idea

Thank



---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ***@postgresql.org)
Tom Lane
2004-05-03 03:18:13 UTC
Permalink
Post by Mario Alberto Soto Cordones
CREATE OR REPLACE FUNCTION "public"."contador_distrito_activos" (numeric,
numeric, numeric) RETURNS SETOF "public"."ty_activo" AS'
declare
con bigint;
act bigint;
...
return con , act;
plpgsql has no shorthand for constructing a rowtype result, as you seem
to be expecting here. Declare a variable of type ty_activo, fill it in,
and return it.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ***@postgresql.org
Loading...