
Query has no destination for result data
Publicado por antonio (1 intervención) el 12/04/2022 01:55:10
tengo el codigo de la siguiente funcion en posgres
y al hacer un select a la funcion me sale el sigueinte error: Query has no destination for result data
quicierqa saber si me podriar ayudar.
de ante mano muchas gracias.
soy nuevo en esto
-- FUNCTION: public.sp_carga_menu(integer, integer, integer)
-- DROP FUNCTION IF EXISTS public.sp_carga_menu(integer, integer, integer);
CREATE OR REPLACE FUNCTION public.sp_carga_menu(
cve_cte_fun integer,
semana_fun integer,
consec_evento_fun integer)
RETURNS void
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
AS $BODY$
declare consec_menu integer;
declare consec_menu_ant integer;
declare descripcion varchar(100);
declare descripcion_1 varchar(100);
declare descripcion_2 varchar(100);
declare consecutivo integer;
declare renglon integer;
declare encabezado integer;
begin
create temporary table t_menus(
descripcion_1 char(100) null,
descripcion_2 char(100) null,
consecutivo integer null,
encabezado integer null,
encabezado_2 integer null
)on commit delete rows;
begin declare cur_menus scroll cursor for select clientes_menus.consec_menu,clientes_menus.descripcion,platillos.desc_platillo,platillos.cve_encabezado from clientes_menus,clientes_menus_detalle,platillos where(clientes_menus.cve_cte = clientes_menus_detalle.cve_cte) and(clientes_menus_detalle.cve_platillo = platillos.cve_platillo) and(clientes_menus.semana = clientes_menus_detalle.semana) and(clientes_menus.consecutivo = clientes_menus_detalle.consecutivo) and(clientes_menus.consec_menu = clientes_menus_detalle.consec_menu) and((clientes_menus.cve_cte = cve_cte_fun) and(clientes_menus.semana = semana_fun) and(clientes_menus.consecutivo = consec_evento_fun)) order by clientes_menus.consec_menu asc,clientes_menus_detalle.renglon asc;
begin open cur_menus;
fetch next from cur_menus into consec_menu,descripcion_1,descripcion_2,encabezado;
select consecutivo = 0,consec_menu_ant = 0,renglon = 0;
if encabezado is null then
select encabezado = 0;
end if;
while sqlstatus <> 2 loop
if consec_menu_ant <> consec_menu then
select consec_menu_ant = consec_menu,descripcion = to_char(consec_menu)+' '+descripcion_1,consecutivo =consecutivo+1;
if consecutivo < 32 then
insert into t_menus( consecutivo,descripcion_1,encabezado ) values( consecutivo,descripcion,encabezado );
else
select renglon = renglon+1;
update t_menus set descripcion_2 = descripcion,encabezado_2 = encabezado where consecutivo = renglon;
end if;
end if;
if consec_menu_ant = consec_menu then
select descripcion =descripcion_2,consecutivo = consecutivo+1;
if consecutivo < 32 then
insert into t_menus( consecutivo,descripcion_1,encabezado ) values( consecutivo,descripcion_2,encabezado );
else
select renglon = renglon+1;
update t_menus set descripcion_2 = descripcion,encabezado_2 = encabezado where consecutivo = renglon;
end if;
end if;
begin fetch next from cur_menus into consec_menu,descripcion_1,descripcion_2,encabezado;
if encabezado is null then
select encabezado =0;
end if;
end;
end loop;
close cur_menus;
end;
end;
deallocate cur_menus;
select * from t_menus;
end;
$BODY$;
ALTER FUNCTION public.sp_carga_menu(integer, integer, integer)
OWNER TO postgres;
y al hacer un select a la funcion me sale el sigueinte error: Query has no destination for result data
quicierqa saber si me podriar ayudar.
de ante mano muchas gracias.
soy nuevo en esto
-- FUNCTION: public.sp_carga_menu(integer, integer, integer)
-- DROP FUNCTION IF EXISTS public.sp_carga_menu(integer, integer, integer);
CREATE OR REPLACE FUNCTION public.sp_carga_menu(
cve_cte_fun integer,
semana_fun integer,
consec_evento_fun integer)
RETURNS void
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
AS $BODY$
declare consec_menu integer;
declare consec_menu_ant integer;
declare descripcion varchar(100);
declare descripcion_1 varchar(100);
declare descripcion_2 varchar(100);
declare consecutivo integer;
declare renglon integer;
declare encabezado integer;
begin
create temporary table t_menus(
descripcion_1 char(100) null,
descripcion_2 char(100) null,
consecutivo integer null,
encabezado integer null,
encabezado_2 integer null
)on commit delete rows;
begin declare cur_menus scroll cursor for select clientes_menus.consec_menu,clientes_menus.descripcion,platillos.desc_platillo,platillos.cve_encabezado from clientes_menus,clientes_menus_detalle,platillos where(clientes_menus.cve_cte = clientes_menus_detalle.cve_cte) and(clientes_menus_detalle.cve_platillo = platillos.cve_platillo) and(clientes_menus.semana = clientes_menus_detalle.semana) and(clientes_menus.consecutivo = clientes_menus_detalle.consecutivo) and(clientes_menus.consec_menu = clientes_menus_detalle.consec_menu) and((clientes_menus.cve_cte = cve_cte_fun) and(clientes_menus.semana = semana_fun) and(clientes_menus.consecutivo = consec_evento_fun)) order by clientes_menus.consec_menu asc,clientes_menus_detalle.renglon asc;
begin open cur_menus;
fetch next from cur_menus into consec_menu,descripcion_1,descripcion_2,encabezado;
select consecutivo = 0,consec_menu_ant = 0,renglon = 0;
if encabezado is null then
select encabezado = 0;
end if;
while sqlstatus <> 2 loop
if consec_menu_ant <> consec_menu then
select consec_menu_ant = consec_menu,descripcion = to_char(consec_menu)+' '+descripcion_1,consecutivo =consecutivo+1;
if consecutivo < 32 then
insert into t_menus( consecutivo,descripcion_1,encabezado ) values( consecutivo,descripcion,encabezado );
else
select renglon = renglon+1;
update t_menus set descripcion_2 = descripcion,encabezado_2 = encabezado where consecutivo = renglon;
end if;
end if;
if consec_menu_ant = consec_menu then
select descripcion =descripcion_2,consecutivo = consecutivo+1;
if consecutivo < 32 then
insert into t_menus( consecutivo,descripcion_1,encabezado ) values( consecutivo,descripcion_2,encabezado );
else
select renglon = renglon+1;
update t_menus set descripcion_2 = descripcion,encabezado_2 = encabezado where consecutivo = renglon;
end if;
end if;
begin fetch next from cur_menus into consec_menu,descripcion_1,descripcion_2,encabezado;
if encabezado is null then
select encabezado =0;
end if;
end;
end loop;
close cur_menus;
end;
end;
deallocate cur_menus;
select * from t_menus;
end;
$BODY$;
ALTER FUNCTION public.sp_carga_menu(integer, integer, integer)
OWNER TO postgres;
Valora esta pregunta


0