Posts

Showing posts with the label plsql

Need help on PL/SQL database trigger

Need help on PL/SQL database trigger I have a DB trigger before insert on emp table. I would like to add sal, comm from emp_test table and want to use those value as a default in the emp table, by trigger. Any idea how to do it? before insert on emp sal, comm from emp_test emp How do those tables look like (we need their description). What is stored in EMP_TEST? A single row? Many rows (perhaps one per employee)? How are they distinguished? Why don't you create a DEFAULT value for those EMP columns? – Littlefoot Jul 1 at 9:42 1 Answer 1 Until you provide answers to questions I posted in a comment, here's how you might do it. See if you can adjust it. EMP_TEST table contains only one row (which is kind of stupid ; you'd rather use DEFAULT v...

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...