Results 1 to 3 of 3

Thread: Update error

  1. #1
    Join Date
    Oct 2005
    Posts
    15

    Unanswered: Update error

    Hi, can someone tell me why this update procedure compiles with compilation error?

    CREATE OR REPLACE PROCEDURE updateName
    (fname IN varchar2, newname IN varchar2)
    IS
    BEGIN
    Select fname FROM name_tab WHERE fname = fname
    UPDATE name_tab
    SET newname = newname
    END;

    Thank you very much

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >why this update procedure compiles with compilation error?
    ERROR? What error? I don't see any error.
    It looks OK to me.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jan 2004
    Posts
    492
    1) In pl/sql, you must select INTO a variable.

    2) Secondly, do not name your parameters the same as column names. This confuses Oracle.

    3) You realize you are updating every single row in name_tab with whatever you pass in.

    4) You are selecting fname, but not doing anything with it? Not sure why?

    You want something more like this perhaps?
    Code:
    CREATE OR REPLACE PROCEDURE updateName
    (p_fname IN varchar2, p_newname IN varchar2)
    IS
      v_fname name_tab.fname%type;
    BEGIN
    --I have no idea why this select is even in here?
    Select fname 
      into  v_fname
     FROM name_tab WHERE fname = p_fname;
    
    UPDATE name_tab
    SET newname = p_newname
    where fname = p_fname;
    
    END;
    Oracle OCPI (Certified Practicing Idiot)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •