Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

I need Help to use Declare in qlikview

Good morning Guys,

I need some help to fetch data from Oracle database and put that information on the Qlikview. But to get this information I need to use the information it has on the script below. Could you help me how can I put it in QlikView? Grateful
******************************************************************************************

declare





















cursor ordens_producao

is

select

a.ordem_producao op, a.ultimo_estagio ue, c.codigo_estagio estagio,



sum

(c.qtde_pecas_prod + c.qtde_conserto + c.qtde_pecas_2a + c.qtde_perdas) qtde_corte_op



from

pcpc_020 a, basi_030 b, pcpc_040 c



where

a.referencia_peca = b.referencia



and

a.ordem_producao = c.ordem_producao



and

a.referencia_peca = c.proconf_grupo



and

c.proconf_nivel99 = b.nivel_estrutura



and

c.codigo_estagio = b.estagio_altera_programado



and b.nivel_estrutura =

'1'

and a.cod_cancelamento =

0

and a.ordem_producao = 251740



and c.qtde_pecas_prod + c.qtde_conserto + c.qtde_pecas_2a + c.qtde_perdas <> 0

group by

a.ordem_producao, a.ultimo_estagio, c.codigo_estagio



union

select

a.ordem_producao op, a.ultimo_estagio ue, c.codigo_estagio estagio,



sum

(c.qtde_pecas_prod + c.qtde_conserto + c.qtde_pecas_2a + c.qtde_perdas) qtde_corte_op



from

pcpc_020 a, basi_030 b, pcpc_040 c



where

a.referencia_peca = b.referencia



and

a.ordem_producao = c.ordem_producao



and

a.referencia_peca = c.proconf_grupo



and

c.proconf_nivel99 = b.nivel_estrutura



and c.codigo_estagio = 21

and

c.codigo_estagio < b.estagio_altera_programado



and b.nivel_estrutura =

'1'

and a.cod_cancelamento =

0

and a.ordem_producao = 251740



and c.qtde_pecas_prod + c.qtde_conserto + c.qtde_pecas_2a + c.qtde_perdas <>

0

and not exists (select

1

from

pcpc_040 d



where

d.periodo_producao = c.periodo_producao



and

d.ordem_confeccao = c.ordem_confeccao



and

d.ordem_producao = c.ordem_producao



and

d.codigo_estagio = b.estagio_altera_programado



and d.qtde_pecas_prod + d.qtde_conserto + d.qtde_pecas_2a + d.qtde_perdas <> 0

)

group by

a.ordem_producao, a.ultimo_estagio, c.codigo_estagio;

saldo_op



number

;

qtde_ultimo_estagio_op



number

;

qtde_tecido_pendente



number

;

v_registro



varchar(1500

);

qtde_total_pcs



number

;

custo_medio



number

;

deposito_tecido



number

;

mes



number

;

ano



number

;

qtde_em_dep



number

;

begin

qtde_total_pcs:=

0

;



for ops in ordens_producao

loop

select sum

(d.qtde_pecas_prod + d.qtde_conserto + d.qtde_pecas_2a + d.qtde_perdas)



into

qtde_ultimo_estagio_op



from

pcpc_040 d



where

d.ordem_producao = ops.op



and

d.codigo_estagio = ops.ue;



select count(*) into

qtde_em_dep



from

pcpc_330 f



where

f.ordem_producao = ops.op



and f.estoque_tag =

1

and f.deposito in (400, 420, 430, 488, 489, 500, 501, 502, 505

)



and f.data_inclusao >= '01-jan-2007'

;



saldo_op:= ops.qtde_corte_op - qtde_ultimo_estagio_op + qtde_em_dep;

if saldo_op >

0



then



declare

cursor tecidos is



select

e.pano_fin_nivel99 n, e.pano_fin_grupo tec, e.pano_fin_subgrupo proc, e.pano_fin_item cor,



sum

(e.qtde_kg_final) qtde_alocada



from

pcpt_025 e



where

e.ordem_producao = ops.op



and e.codigo_rolo >

0

group by

e.pano_fin_nivel99, e.pano_fin_grupo, e.pano_fin_subgrupo, e.pano_fin_item



order by

e.pano_fin_nivel99, e.pano_fin_grupo, e.pano_fin_subgrupo, e.pano_fin_item;



begin

for tec in tecidos

loop

mes:= to_char(

sysdate,'MM'

);

ano:= to_char(



sysdate,'YYYY'

);

custo_medio:=



0

;

qtde_tecido_pendente :=



0

;

qtde_tecido_pendente := (tec.qtde_alocada / ops.qtde_corte_op) * saldo_op;



if tec.n is null then tec.n:= '0'

;



end if

;



if tec.tec is null then tec.tec:= '00000'

;



end if

;



if tec.proc is null then tec.proc:= '000'

;



end if

;



if tec.cor is null then tec.cor:= '000000'

;



end if

;



v_registro:= to_char(ops.op) ||

' - '

||

to_char(tec.n) ||



'.'

||

to_char(tec.tec) ||



'.'

||

to_char(tec.proc) ||



'.'

||

to_char(tec.cor) ||



' - '

||

to_char(ops.qtde_corte_op,



'999,999,999') ||' - '

||

to_char(qtde_ultimo_estagio_op,



'999,999,999') ||' - '

||

to_char(tec.qtde_alocada,



'999,999,990.000') ||' - '

||

to_char(qtde_tecido_pendente,



'999,999,990.000')||' - '

||

to_char(qtde_em_dep,



'999,999,990.000') ||' - '

||

to_char(custo_medio,



'990.00000') ||' - '

||

to_char(mes,



'00') ||' - '

||

to_char(ano,



'0000'

);

dbms_output.put_line(v_registro);



commit

;



end loop

;



end

;



end if

;



if saldo_op > 0 then

qtde_total_pcs:= qtde_total_pcs + saldo_op;



end if

;

dbms_output.put_line(



''

);

v_registro:= to_char(



'Saldo da op: '||to_char(ops.op,'999999999')||' '

||

to_char(saldo_op,



'999,999,999,990'

));

dbms_output.put_line(v_registro);

dbms_output.put_line(



''

);



end loop

;

dbms_output.put_line(



''

);

v_registro:= to_char(



'Total geral saldo ops: ' ||''

||

to_char(qtde_total_pcs,



'999,999,999,990'

));

dbms_output.put_line(v_registro);



end



;



3 Replies
Not applicable
Author

There is "end loop" and "commit" . This is a stored procedure, not a select statement. Make a stored procedure in Oracle, call it from QlikvIew, than do a simple select from QlikView .

I think only MS SQL server stored procedures can return rows as if they were a select .

-Alex

Not applicable
Author

Hello my friend,

I need a result of this script in qlikview.

Not applicable
Author

I am afraid you will have to pay a visit to the DBA first : create the stored procedure for you, and write it's result into a table.

See here how to call Oracle stored procedures: http://community.qlik.com/forums/p/35080/137075.aspx

Than do a select from the table into QlikView

-Alex