469,323 Members | 1,583 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

bad bind variable trigger

Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE OR REPLACE TRIGGER "NEO".TEMP_TR BEFORE
  3. INSERT ON TEMP FOR EACH ROW
  4. declare
  5. c_id number:=0;
  6. BEGIN
  7. select :new_ID into c_id from dual ;
  8. dbms_output.put_line(c_id);
  9.  
  10.  
  11. End;
  12.  
i am getting the error

4/8 PLS-00049: bad bind variable 'NEW_ID'

basically i want to store :new_ID value into a variable for further processing
Dec 13 '07 #1
7 23053
amitpatel66
2,367 Expert 2GB
Hi,

Please make use of CODE tags every time you post the source code in this forum

Thanks
MODERATOR
Dec 13 '07 #2
amitpatel66
2,367 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE OR REPLACE TRIGGER "NEO".TEMP_TR BEFORE
  3. INSERT ON TEMP FOR EACH ROW
  4. declare
  5. c_id number:=0;
  6. BEGIN
  7. select :new_ID into c_id from dual ;
  8. dbms_output.put_line(c_id);
  9.  
  10.  
  11. End;
  12.  
i am getting the error

4/8 PLS-00049: bad bind variable 'NEW_ID'

basically i want to store :new_ID value into a variable for further processing
What is the value of :new_id?

Its not allowed in trigger because trigger uses two standard bind variables :new and :old.
Why dont you store the value of :new_id in to simple variable within a trigger and do what ever you want to??
Dec 13 '07 #3
debasisdas
8,127 Expert 4TB
What exactly you are trying to do in trigger ?

What is that :new_ID ???
Dec 13 '07 #4
gnanda
2
Dear Friend,

Syntax for old and new keywords in Triggers were :Old.<Column_name> referes the existing value of the column in a record. :New.<Column_Name> referes the new value for the column in a record.

In your Triggers what is New_id? is a column in Temp table.

If New_id is a column in Temp table then use :New.New_id or only ID is a column in the Temp table then use :New.Id.

And u can directly assign the value to the variable c_id like c_id=:new.id(I am considering ID is the column name)

go though this

Expand|Select|Wrap|Line Numbers
  1.  
  2. SQL> create table temp (id varchar2(15));
  3.  
  4. Table created.
  5.  
  6. SQL> ed
  7. Wrote file afiedt.buf
  8.  
  9. line 9 truncated.
  10.   1  CREATE OR REPLACE TRIGGER TEMP_TR BEFORE
  11.   2  INSERT ON TEMP FOR EACH ROW
  12.   3  DECLARE
  13.   4    c_id varchar2(15);
  14.   5  BEGIN
  15.   6    c_id :=:new.id;
  16.   7    dbms_output.put_line('Output from the Trigger c_id : '||c_id);
  17.   8* END;
  18.   9  /
  19.  
  20. Trigger created.
  21.  
  22. SQL> set serveroutput on;
  23. SQL> insert into temp values('Gnk');
  24. Output from the Trigger c_id : Gnk
  25.  
  26. 1 row created.
  27.  
  28. SQL> 
  29.  
  30.  


Regards
GNK
Dec 18 '07 #5
amitpatel66
2,367 Expert 2GB
Hi Gnanda ,

please make use of [code] tags when ever you post any code in this forum.

MODERATOR
Dec 18 '07 #6
@amitpatel66
Hi the main problem with new.id you just change the id value
it will be work for example my table variable is name then give new.name it will be workkkk...
Aug 14 '13 #7
Exequiel
288 256MB
I didn't mean to reply to this post, I just accidentally send the message here a while,, sorry. . . since i can't delete this comment i just type some suggestions. . sorry again
Aug 15 '13 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Hermes | last post: by
reply views Thread by ClimberBear | last post: by
1 post views Thread by traceable1 | last post: by
kaleeswaran
1 post views Thread by kaleeswaran | last post: by
5 posts views Thread by femina | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.