Posts

Showing posts with the label oracle

Dynamic table in SQL query using union

Dynamic table in SQL query using union I have below query and it is not working with mag_re as( select a as "A", b as "B" from table1 where 'condition' union all select a as "A", b as "B" from table2 where 'condition' ) select t.a as "A", t.b as "B", M.b as "BB" from table3 t, mag_re M where t.a = M.A union all select t.a as "A", t.b as "B", M.b as "BB" from table4 t, mag_re M where t.a = M.A It is not working, I have the query same as above. I just want to run some query and store into that dynamic table. By using that dynamic table I want to get some data. Original data: with market_reg as ( select acc.account_name, rc1.code_label from customer_node_history cnh,account acc,schedule sc,customer_node_type cnt,reference_Code rc1 where acc.customer_node_id = cnh.customer_node_id and cnh.customer_node_status_code = 3 and account_t...

I have an error with trigger using if conditional and update

I have an error with trigger using if conditional and update Executing this trigger in ORACLE I got the following error: Table, View Or Sequence reference 'OCEX_COMI.FECHA_ASIG_GT' not allowed in this context. This is my trigger: create or replace trigger ocex_comi_total before insert or update of id_gt,fecha_asig_gt on ocex_comi for each row begin if ((ocex_comi.fecha_asig_gt > to_date('2018-12-15','yyyy-mm-dd')) and (ocex_comi.fecha_asig_gt < to_date('2019-01-01','yyyy-mm-dd'))) then update ocex_comi cm set cm.PAGO_COM = (select uea.total_bono_especial from OCEX_UEA uea join OCEX_GUIA_TRANSITO gt on uea.id_uea = gt.dest_id where gt.cod_gt=cm.id_gt) where cm.id_gt = (select gt.cod_gt from ocex_guia_transito gt JOIN ocex_uea uea on uea.id_uea=gt.dest_id where gt.cod_gt=cm.id_gt); else update ocex_comi cm set cm.PAGO_COM = (select uea.total_x_pnp fr...