Link to home
Start Free TrialLog in
Avatar of AbhiJeet
AbhiJeet

asked on

Bad bind variable oracle

In an after update trigger I am getting bad bind variable error.
I am using two bind variable in the select statement as
Select field1, field2 from table1 t1 where t1.id = :new.id and t1.code = :new.code which is causing the error
Is there any alternate way to write this select in the trigger
Avatar of Helena Marková
Helena Marková
Flag of Slovakia image

This is from documentation (http://docs.oracle.com/database/122/LNPLS/CREATE-TRIGGER-statement.htm#LNPLS01374):
•In an AFTER statement trigger, the trigger body cannot read :NEW or :OLD. (In an AFTER row trigger, the trigger body can read but not write the :OLD and :NEW fields.)

So from your code it seems that you want to use AFTER row trigger but you have created only AFTER trigger.

I hope this can help you.
Avatar of AbhiJeet
AbhiJeet

ASKER

It is row trigger when there is one bind variable in the select there is no issue.

Issue comes when I take two bind variables
ASKER CERTIFIED SOLUTION
Avatar of Helena Marková
Helena Marková
Flag of Slovakia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If your table t1 is the table that has the "after update for each row" trigger, you don't need to use (and you shouldn't use) a query to fetch values from the row being changed.  You can simply use the PL\SQL assignment syntax like Helena suggested.