0 Replies Latest reply: Sep 7, 2016 11:06 AM by Pablo Mora Ramírez RSS

    Dynamic Stored Procedure

    Pablo Mora Ramírez

      Hello all,


      Im trying t créate a scrip with a stored procedure that calls the data I need to show but I need it to be dynamic. I mean, when I change the Project, the store procedure must rerun and show me the new data.


      My problem is that whren creating the variables can't manage to make the stored procedure work... Here is the scrip if you could please help me with it. Ihave been usign Qlikview for little time so I don't really know how to fix this.





      Set vPeriodoselect2 = Año & Mes;
      Set vProyectoselect2 = Projectcode;

      LET vPeriodoselect = if($(vPeriodoselect2)<> Null(), $(vPeriodoselect2),Year(today())&06);
      LET vProyectoselect = if($(vProyectoselect2)<> Null(),$(vProyectoselect2),'CT0009');

      OLEDB CONNECT32 TO [Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sharperlight;Initial Catalog=MPCAPP;Data Source=cunco;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=NOTE-PMORA-W10;Use Encryption for Data=False;Tag with column collation when possible=False](mode is write);

      Load Proyecto as Projectcode,
      Descr as [Nombre Proyecto];

      SQL SELECT Descr,
      FROM MPCAPP.dbo.PJvProj;

      Load FISCALNO,
      left(FISCALNO,4) as Año,
      Right(FISCALNO,2) as Mes;
      FROM MPCAPP.dbo.PJvTran;

      Load Acct as [Categoria Cta],
      if(left(Acct,2)=07,'Ingresos' , 'Egresos' ) as TipoCuenta,
      cur as Moneda,
      eac as EAT,
      grupo as [Grupo Cuenta],

      SQL exec xMPC_Resumen_Economico_Base $(vProyectoselect), $(vPeriodoselect);