Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
cristian_av
Creator III
Creator III

Trouble while copying SQL into QlikView

Hi

I've copied an SQL code that I've previously tried in SQL Server manager and that was working there.

In QlikView I get "ErrorSource: (null), ErrorMsg: (null)"

What could be the mistake? I'm using multiple Inserto into because I use temporary tables in SQL Server.

Thanks!!

LOAD *;

SQL INSERT INTO #Clasif1

     SELECT de.pate_tempor, de.prod_codigo, de.liqu_numero,

               concepto = Convert(char(50),'FOB Fruta Exportacion'),

               kilos = Convert(decimal(14,2),SUM(de.dece_kilrea)),

               total_plata = Convert(decimal(14,2),sum((de.dece_kilrea/de.enva_pesone)*de.dece_fobuni))

          FROM dba.detacajemb de

         WHERE de.pate_tempor = 2015

           and de.pool_tipool = 1

      GROUP BY de.pate_tempor, de.prod_codigo, de.liqu_numero

          

     INSERT INTO #Clasif1

        SELECT de.pate_tempor, de.prod_codigo, de.liqu_numero,

               concepto = Convert(char(50),'Servicio de Exportación'),

               kilos = SUM(de.dece_kilrea), total_plata = sum(de.dece_valcom)*-1              

          FROM dba.detacajemb de

         WHERE de.pate_tempor = 2015

           AND de.pool_tipool = 1

        GROUP BY de.pate_tempor, de.prod_codigo, de.liqu_numero

        INSERT INTO #Clasif1

        SELECT de.pate_tempor, de.prod_codigo, de.liqu_numero,

               concepto = Convert(char(50),'Materiales & Otros Servicios'),

               kilos = SUM(de.dece_kilrea), total_plata = sum(de.dece_totcos - de.dece_valcom)*-1               

          FROM dba.detacajemb de

         WHERE de.pate_tempor = 2015

           AND de.pool_tipool = 1

        GROUP BY de.pate_tempor, de.prod_codigo, de.liqu_numero

        INSERT INTO #Clasif1

        SELECT de.pate_tempor, de.prod_codigo, de.liqu_numero,

               concepto = Convert(char(50),'Bonificación Servicio'),

               kilos = SUM(de.dece_kilrea), total_plata = sum(isnull(de.dece_bonser,0))              

          FROM dba.detacajemb de

         WHERE de.pate_tempor = 2015

           AND de.pool_tipool = 1

           AND isnull(de.dece_bonser,0) <> 0

        GROUP BY de.pate_tempor, de.prod_codigo, de.liqu_numero

        Having sum(isnull(de.dece_bonser,0)) <> 0

        SELECT cla.pate_tempor, cla.prod_codigo, cla.concepto, cla.kilos, cla.total_plata, cla.liqu_numero

        FROM #Clasif1 cla;

1 Solution

Accepted Solutions
cristian_av
Creator III
Creator III
Author

You cannot perform an INSERT command from QV. You can create a stored procedure that runs your code above and call that.

SQL exec stored_procedure <parameters>

mickeger

View solution in original post

3 Replies
cristian_av
Creator III
Creator III
Author

You cannot perform an INSERT command from QV. You can create a stored procedure that runs your code above and call that.

SQL exec stored_procedure <parameters>

mickeger

View solution in original post

tunoi
Creator
Creator

Why dont you use:

LOAD *;

SQL

     SELECT de.pate_tempor, de.prod_codigo, de.liqu_numero,

               concepto = Convert(char(50),'FOB Fruta Exportacion'),

               kilos = Convert(decimal(14,2),SUM(de.dece_kilrea)),

               total_plata = Convert(decimal(14,2),sum((de.dece_kilrea/de.enva_pesone)*de.dece_fobuni))

          FROM dba.detacajemb de

         WHERE de.pate_tempor = 2015

           and de.pool_tipool = 1

      GROUP BY de.pate_tempor, de.prod_codigo, de.liqu_numero

         

     union all

        SELECT de.pate_tempor, de.prod_codigo, de.liqu_numero,

               concepto = Convert(char(50),'Servicio de Exportación'),

               kilos = SUM(de.dece_kilrea), total_plata = sum(de.dece_valcom)*-1             

          FROM dba.detacajemb de

         WHERE de.pate_tempor = 2015

           AND de.pool_tipool = 1

        GROUP BY de.pate_tempor, de.prod_codigo, de.liqu_numero

     union all

        SELECT de.pate_tempor, de.prod_codigo, de.liqu_numero,

               concepto = Convert(char(50),'Materiales & Otros Servicios'),

               kilos = SUM(de.dece_kilrea), total_plata = sum(de.dece_totcos - de.dece_valcom)*-1              

          FROM dba.detacajemb de

         WHERE de.pate_tempor = 2015

           AND de.pool_tipool = 1

        GROUP BY de.pate_tempor, de.prod_codigo, de.liqu_numero

        union all

        SELECT de.pate_tempor, de.prod_codigo, de.liqu_numero,

               concepto = Convert(char(50),'Bonificación Servicio'),

               kilos = SUM(de.dece_kilrea), total_plata = sum(isnull(de.dece_bonser,0))             

          FROM dba.detacajemb de

         WHERE de.pate_tempor = 2015

           AND de.pool_tipool = 1

           AND isnull(de.dece_bonser,0) <> 0

        GROUP BY de.pate_tempor, de.prod_codigo, de.liqu_numero

        Having sum(isnull(de.dece_bonser,0)) <> 0

cristian_av
Creator III
Creator III
Author

Thanks! That works too!!