views:

73

answers:

1

hi,

i want to update the following procedure in the oracle table..but it is throwing error

CREATE OR REPLACE PROCEDURE update_keywords (aKEYWORD IN VARCHAR2, aCOUNT IN NUMBER)
AS BEGIN
   update searchable_keywords  
   set KEYWORD =:new.aKEYWORD or COUNT =:new.aCOUNT 
   where KEUWORD_ID = : old.KEYWORD_ID;
  END;

this is my procedure, i want to update the keyword & count in the searchable_keywords table with keyword_id(primary key) but it is throwing error as follows...

LINE/COL ERROR
-------- -----------------------------------------------------------------
3/4      PL/SQL: SQL Statement ignored
4/17     PLS-00049: bad bind variable 'NEW.AKEYWORD'
4/31     PL/SQL: ORA-00933: SQL command not properly ended
4/41     PLS-00049: bad bind variable 'NEW.ACOUNT'

can you pls help me slove this problem..thanks

+4  A: 

This looks like a trigger... You don't need the ":new" for acount/akeyword, and you need to pass in the ID you want update. Eg.

CREATE OR REPLACE
PROCEDURE UPDATE_KEYWORDS(
    AKEYWORD    IN VARCHAR2,
    ACOUNT      IN NUMBER,
    AKEYWORD_ID IN NUMBER)
AS
BEGIN
  UPDATE
    SEARCHABLE_KEYWORDS
  SET
    KEYWORD =  AKEYWORD
  , "COUNT"  = ACOUNT
  WHERE
    KEYWORD_ID = AKEYWORD_ID
END;

I'm not sure why you would have a column named "COUNT".. unless you are trying to do something different in that update, its obviously wrong with that "or" in there..

Matthew Watson
hi, i am not yaking keyword_id as input parameter.....it is primary id and it is incremeted automatically
murali
Are you trying to move trigger code into a procedure to be called from the trigger? If so, you can't just move the text including :new and :old keywords into the procedure as they are only meaningful within trigger code.
Tony Andrews
@murali - You are issuing an UPDATE statement. Therefore you need to know the access path of the row(s) you want to update. Hence the need to pass the primary key to the procedure. I profoundly hope you are not really incrementing your primary key whenever the row is updated.
APC