Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bind variables in trigger

51 views
Skip to first unread message

Fernando Navarro Pulido

unread,
Jun 24, 1999, 3:00:00 AM6/24/99
to
Hola,

Tengo un problema con una sentencia dinámica en un trigger.
Necesito usar los registros :new y :old en una sentencia dinámica y Oracle
los trata como si fueran bind variables. Se utiliza esta sentencia en una
auditoría
parametrizable de columnas de tablas.

--------------------------------------------------------

Hi,

I have a problem with a dynamic sentence in a trigger.

I need to use the :new and :old pseudo-records in a dynamic sentence but
Oracle
manages this ones like bind variables.
This process is used for audit changes in table columns pre-defined by user
in
configuration options.

Help me, please.

--------------------------------------------------
CREATE OR REPLACE TRIGGER trigger_name
AFTER UPDATE ON table_name
REFERENCING OLD as old_reg
NEW as new_reg
FOR EACH ROW
.
.
.
/* Column in process: */
ls_CurrCol := ...; -- retrieved from a Cursor of current table updateable
columns
.
.
.
ls_SQL := 'INSERT INTO A_AUDITS
(col1, col2, col_auditing, old_value, new_value) VALUES (' ;
ls_SQL := ls_SQL || ':data1, ''YYY'', ''' || ls_CurrCol ;
ls_SQL := ls_SQL || ''', :old_reg.' || ls_CurrCol || ', :new_reg.' ||
ls_CurrCol || ')' ;
.
.
.
open_cursor ...
parse ...
bind_variable (ln_Cursor, ':data1', ls_XXX) ;
execute ...
.
.
.
----------------------------------------------------------------------
Cuando se actualiza la columna en la tabla que se quiere auditar y se
ejecuta el
trigger, este lanza la sentencia que se ha formado en la sentencia dinámica
y se
produce el error "ORA-01008: No todas las variables han sido transferidas"
pero
creo que :old y :new no son bind variables. ¿Que puedo hacer?
----------------------------------------------------------------------
When i update a column in the table and jump the trigger, it fails because
"ORA-01008: not all variables bound",
but ":old_reg.XX"/"new_reg.XX" aren't bind variables!! (only ":data1" is)

Helpppppppppppppppp

Sunder

unread,
Jun 24, 1999, 3:00:00 AM6/24/99
to
You will have to use the dbms_sql package to accomplish this.

sunder

0 new messages