eJEMPLO DE PASAR FILAS A COLUMNAS
Publicado por MICHAEL (1 intervención) el 16/10/2007 18:04:12
HOLA ALGUIEN TIENE UN EJEMPLO DE PASAR FILAS A COLUMNAS
YO ESTOY HACIENDO ESTO PERO NO LOGRO CONSEGUIR ESTO SOY NUEVO EN INFORMIX
create procedure sp_crosstab(as_perfil char(3) )
returning char(80), char(80), char(80),
char(80);
define ll_filas integer;
define ll_fila integer;
define ls_codser char(80);
define ls_codper char(80);
define ls_nrover char(80);
define ls_codcau char(80);
define ls_codcla char(80);
define ls_velcla char(80);
define ls_porpagar char(80);
define ls_velvideo char(80);
define ls_porvideo char(80);
select count(*) into ll_filas from simpercau Where pccodper =001; --12 no se ejecuta
if ll_filas >0 then
foreach Select pcnrover,
pccodcau,
pccodcla,
pcvelcla,
pcporgar
into ls_nrover,
ls_codcau,
ls_codcla,
ls_velcla,
ls_porpagar
From simpercau
Where pccodper =as_perfil
-- caudal voz
if ls_codcau ='001' then
Insert Into pivot
(dpcodper,dpvelvoz ,dpporvoz)
values
(ll_filas ,ls_velcla,ls_porpagar);
end if ;
-- caudal video
if ls_codcau ='002' then
- Insert Into pivot
-- (dpcodper, dpvelvid,dpporvid )
-- values
-- (ll_filas ,ls_velcla,ls_porpagar);
end if;
-- caudal datos
-- if ls_codcau ='003' then
-- Insert Into pivot
-- (dpcodper,dpveldat,dppordat )
-- values
-- (ll_filas ,ls_velcla,ls_porpagar);
-- end if;
-- Clase Platino
--if ls_codcla ='003' then
--- Insert Into pivot
-- (dpcodper,dppltvel,dppltpor )
-- values
-- (ll_filas ,ls_velcla,ls_porpagar);
--end if;
-- Clase Oro
--if ls_codcla ='004' then
-- Insert Into pivot
-- (dpcodper,dporovel,dporopor )
-- values
--(ll_filas ,ls_velcla,ls_porpagar);
-- end if;
-- Clase Platino
--if ls_codcla ='004' then
-- Insert Into pivot
-- (dpcodper,dporovel,dporopor )
--values
-- (ll_filas ,ls_velcla,ls_porpagar);
--end if;
-- Clase Platino
--if ls_codcla ='006' then
-- Insert Into pivot
-- (dpcodper,dpbrovel,dpbropor )
-- values
--(ll_filas ,ls_velcla,ls_porpagar);
--end if;
end foreach;
end if;
End procedure;
YO ESTOY HACIENDO ESTO PERO NO LOGRO CONSEGUIR ESTO SOY NUEVO EN INFORMIX
create procedure sp_crosstab(as_perfil char(3) )
returning char(80), char(80), char(80),
char(80);
define ll_filas integer;
define ll_fila integer;
define ls_codser char(80);
define ls_codper char(80);
define ls_nrover char(80);
define ls_codcau char(80);
define ls_codcla char(80);
define ls_velcla char(80);
define ls_porpagar char(80);
define ls_velvideo char(80);
define ls_porvideo char(80);
select count(*) into ll_filas from simpercau Where pccodper =001; --12 no se ejecuta
if ll_filas >0 then
foreach Select pcnrover,
pccodcau,
pccodcla,
pcvelcla,
pcporgar
into ls_nrover,
ls_codcau,
ls_codcla,
ls_velcla,
ls_porpagar
From simpercau
Where pccodper =as_perfil
-- caudal voz
if ls_codcau ='001' then
Insert Into pivot
(dpcodper,dpvelvoz ,dpporvoz)
values
(ll_filas ,ls_velcla,ls_porpagar);
end if ;
-- caudal video
if ls_codcau ='002' then
- Insert Into pivot
-- (dpcodper, dpvelvid,dpporvid )
-- values
-- (ll_filas ,ls_velcla,ls_porpagar);
end if;
-- caudal datos
-- if ls_codcau ='003' then
-- Insert Into pivot
-- (dpcodper,dpveldat,dppordat )
-- values
-- (ll_filas ,ls_velcla,ls_porpagar);
-- end if;
-- Clase Platino
--if ls_codcla ='003' then
--- Insert Into pivot
-- (dpcodper,dppltvel,dppltpor )
-- values
-- (ll_filas ,ls_velcla,ls_porpagar);
--end if;
-- Clase Oro
--if ls_codcla ='004' then
-- Insert Into pivot
-- (dpcodper,dporovel,dporopor )
-- values
--(ll_filas ,ls_velcla,ls_porpagar);
-- end if;
-- Clase Platino
--if ls_codcla ='004' then
-- Insert Into pivot
-- (dpcodper,dporovel,dporopor )
--values
-- (ll_filas ,ls_velcla,ls_porpagar);
--end if;
-- Clase Platino
--if ls_codcla ='006' then
-- Insert Into pivot
-- (dpcodper,dpbrovel,dpbropor )
-- values
--(ll_filas ,ls_velcla,ls_porpagar);
--end if;
end foreach;
end if;
End procedure;
Valora esta pregunta
0