Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

cursor with parameter

Tricampeon_1981Mar 15 2018 — edited Mar 15 2018

friends because this cursor with an in when passing the variable does not return data, consider that the data is well past

PROCEDURE SP_CONSUL_LIQUIDACION ( P_Rut         IN   NUMBER,P_Periodo    IN    varchar2,

                                                            vjsonres    OUT VARCHAR2,MsgError  OUT VARCHAR2)  IS

                                                           

/****************************************************************************

Nombre    : SP_CONSUL_LIQUIDACION

Objetivo   : Sp encargado Enviar datos  de liquidacion como salida

  Fecha       : 2018-03-14

 

  entarda       : Rut Funcionario, Fecha-Liquidacion

  Salida         : Json con los datos del funcionario y su liquidacion

   ejemplo  salida : '{"nombre":"Juan Perez","periodo":"201705","cargo":"ejecutivo Financiero","fecha_ingreso":"12032015","prevision":"AFP PROVIDA", "salud":"FONASA", "centro_costo":"3011400 - LINARES SUBGERENCIA RELACIONES", "area":"053 LINARES", "haberes":[{"item1":[{"descripcion":"Sueldo Base $266.640,00","valor":"266.640"}],"item2":[{"descripcion":"Bono de Productividad","valor":"61.000"}],"item3":[{"descripcion":"Comision Avances RF(XL)","valor":"10.200"}],    "item4":[{"descripcion":"Total Haberes","valor":"337.840"}]    }], "otros_haberes":[{"item1":[{"descripcion":"Movilizacion Cont. Colectivo Fed. Sind. Trab. Unidos","valor":"32.200"}],"item2":[{"descripcion":"Total Asignaciones","valor":"32.200"}] }],     "descuentos_legales":[{"item1":[{"descripcion":"11.45% Cotiz. AFP PROVIDA sobre: 765.454","valor":"87.644"}],     "item2":[{"descripcion":"7% FONASA","valor":"53.582"}],    "item3":[{"descripcion":"Total Descuentos Legales","valor":"141.226"}] }], "otros_descuentos":[{"item1":[{"descripcion":"Anticipo de sueldo","valor":"50.000"}],"item2":[{"descripcion":"Anticipo Prestamo sindical Cuota 11 de 24","valor":"10.417"}],    "item3":[{"descripcion":"Seguro Ptmo. Los andes","valor":"52.859"}],"item4":[{"descripcion":"Total Otros Descuentos","valor":"113.276"}] }], "totales":[{"totalfinal":[{"totala":"337.840","totald":"113.246"}],"item2":[{"descripcion":"Alcanse liquido a pagar","valor":"10.417"}],"item3":[{"descripcion":"Descuentos (-)","valor":"52.859"}],"item4":[{"descripcion":"TOTAL A PAGAR","valor":"113.276"}] }] },  { "nombre":"Juan Perez", "periodo":"201706", "cargo":"ejecutivo Financiero", "fecha_ingreso":"12032015", "prevision":"AFP PROVIDA", "salud":"FONASA",  "centro_costo":"3011400 - LINARES SUBGERENCIA RELACIONES", "area":"053 LINARES",  "haberes":[{"item1":[{"descripcion":"Sueldo Base $266.640,00","valor":"266.640"}],    "item2":[{"descripcion":"Bono de Productividad","valor":"61.000"}],    "item3":[{"descripcion":"Comision Avances RF(XL)","valor":"10.200"}],"item4":[{"descripcion":"Total Haberes","valor":"337.840"}] }], "otros_haberes":[{ "item1":[{"descripcion":"Movilizacion Cont. Colectivo Fed. Sind. Trab. Unidos","valor":"32.200"}], "item2":[{"descripcion":"Total Asignaciones","valor":"32.200"}]  }],  "descuentos_legales":[{ "item1":[{"descripcion":"11.45% Cotiz. AFP PROVIDA sobre: 765.454","valor":"87.644"}],    "item2":[{"descripcion":"7% FONASA","valor":"53.582"}],    "item3":[{"descripcion":"Total Descuentos Legales","valor":"141.226"}] }], "otros_descuentos":[{"item1":[{"descripcion":"Anticipo de sueldo","valor":"50.000"}],"item2":[{"descripcion":"Anticipo Prestamo sindical Cuota 11 de 24","valor":"10.417"}],    "item3":[{"descripcion":"Seguro Ptmo. Los andes","valor":"52.859"}],"item4":[{"descripcion":"Total Otros Descuentos","valor":"113.276"}] }], "totales":[{"totalfinal":[{"totala":"337.840","totald":"113.246"}],"item2":[{"descripcion":"Alcanse liquido a pagar","valor":"10.417"}],"item3":[{"descripcion":"Descuentos (-)","valor":"52.859"}],"item4":[{"descripcion":"TOTAL A PAGAR","valor":"113.276"}] }] }';

--MsgError:='Sin errores';

*****************************************************************************/                                                           

--declaro cursor

--cursor   FunLiq (pRut IN NUMBER , P_Periodo IN VARCHAR2) IS

cursor   FunLiq ( P_Mes IN varchar2) IS

--cursor   FunLiq (pRut IN NUMBER ) IS

        SELECT MES_LIQ ,

                    NOMBRE       

        FROM fun_liquidacion2

             WHERE    MES_LIQ  in (P_Mes);

      

       

--Declaro Variables--

   FunLiq_rec FunLiq%ROWTYPE;

  

vnPeriodo   VARCHAR2(100);

--variable json salida --

vsNombre2       VARCHAR2(1000);

vSlista2            VARCHAR2(1000);

vnTipoTransa2  NUMBER;

vnBoton2          NUMBER;

vBandera2        NUMBER;

vBander2        NUMBER;

vRetorno2        NUMBER;

BEGIN

         --LIMPIO VARABLE PAA CONSULTA

        SELECT REPLACE(P_Periodo,'"','''')

                 INTO vnPeriodo

         FROM DUAL;

      

      

        Dbms_Output.put_line('Variable Periodos: '||vnPeriodo);

           

       

        --RECORRO CURSOR CON DATOS DE LIQUIDACION 

       

           --OPEN  FunLiq (P_Rut,P_Periodo);

           OPEN  FunLiq (P_Periodo);

                 --LOOP

                  FETCH  FunLiq  INTO FunLiq_rec;

                      while FunLiq%found

                      loop

                              IF vBandera2 = 0 T

HEN

                                       vjsonres:='{ "nombre": ' || '"' || FunLiq_rec.nombre ||'","funcionario":"' || '1'   || '","boton":"'|| '1'||'","lista_meses":['            ;         

                                       

                                        vBandera2 := 1; 

                                        vBander2 := 1;

                              ELSE

                                       vSlista2  :=   vSlista2 || '","'||  FunLiq_rec.MES_LIQ ;

                              END IF;

                               

                      

                      --EXIT WHEN Fun%NOTFOUND; -- Último registro.

                      FETCH  FunLiq  INTO FunLiq_rec;

                 END LOOP;

                   CLOSE FunLiq;

           

  

END SP_CONSUL_LIQUIDACION;

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 12 2018
Added on Mar 15 2018
7 comments
758 views