Results 1 to 3 of 3

Thread: Variable name and table column name same

  1. #1
    Contributing Member
    Join Date
    Mar 2008
    Answers
    66

    Variable name and table column name same

    I defined variables with same name as that of table columns in a procedure.

    UPDATE student SET first_name = first_name WHERE id = 2000;

    Here it is treating both first_name as column names.

    can anyone explain when it treat it as variable? When it treat it as a column name?


  2. #2
    Junior Member
    Join Date
    Mar 2008
    Answers
    2

    Re: Variable name and table column name same

    Hi,
    Whenever the variable names are same as column names of the table, oracle treats them as columns rather than variables.

    This is coz, values are assigned to variables using the assignment operator ":=" while columns using "=".
    So, when the variable name and column name is same and is updated as "update table_name set first_name=first_name" it considers it as column and updates the column.

    Regards,
    Savitha


  3. #3
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Variable name and table column name same

    It is strongly recommended not to use same name for coulmn and a variable.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact