bad bind variable trigger

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • umesh049
    New Member
    • Dec 2007
    • 17

    bad bind variable trigger

    [code=oracle]

    CREATE OR REPLACE TRIGGER "NEO".TEMP_ TR BEFORE
    INSERT ON TEMP FOR EACH ROW
    declare
    c_id number:=0;
    BEGIN
    select :new_ID into c_id from dual ;
    dbms_output.put _line(c_id);


    End;
    [/code]

    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
    Last edited by amitpatel66; Dec 13 '07, 12:20 PM. Reason: code tags
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Hi,

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

    Thanks
    MODERATOR

    Comment

    • amitpatel66
      Recognized Expert Top Contributor
      • Mar 2007
      • 2358

      #3
      Originally posted by umesh049
      [code=oracle]

      CREATE OR REPLACE TRIGGER "NEO".TEMP_ TR BEFORE
      INSERT ON TEMP FOR EACH ROW
      declare
      c_id number:=0;
      BEGIN
      select :new_ID into c_id from dual ;
      dbms_output.put _line(c_id);


      End;
      [/code]

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

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        What exactly you are trying to do in trigger ?

        What is that :new_ID ???

        Comment

        • gnanda
          New Member
          • Dec 2007
          • 2

          #5
          Dear Friend,

          Syntax for old and new keywords in Triggers were :Old.<Column_na me> referes the existing value of the column in a record. :New.<Column_Na me> 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

          [code=oracle]

          SQL> create table temp (id varchar2(15));

          Table created.

          SQL> ed
          Wrote file afiedt.buf

          line 9 truncated.
          1 CREATE OR REPLACE TRIGGER TEMP_TR BEFORE
          2 INSERT ON TEMP FOR EACH ROW
          3 DECLARE
          4 c_id varchar2(15);
          5 BEGIN
          6 c_id :=:new.id;
          7 dbms_output.put _line('Output from the Trigger c_id : '||c_id);
          8* END;
          9 /

          Trigger created.

          SQL> set serveroutput on;
          SQL> insert into temp values('Gnk');
          Output from the Trigger c_id : Gnk

          1 row created.

          SQL>

          [/code]



          Regards
          GNK
          Last edited by amitpatel66; Dec 18 '07, 10:36 AM. Reason: code tags

          Comment

          • amitpatel66
            Recognized Expert Top Contributor
            • Mar 2007
            • 2358

            #6
            Hi Gnanda ,

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

            MODERATOR

            Comment

            • nani909090
              New Member
              • Aug 2013
              • 1

              #7
              Originally posted by amitpatel66
              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??
              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...

              Comment

              • Exequiel
                Contributor
                • Jul 2012
                • 288

                #8
                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

                Comment

                Working...