Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2007
    Posts
    2

    Unanswered: automated update using database name

    Hi All,

    This might be the easiest question for DBAs but my knowledge in this domain is really really low. I am writting a sql script (not PL/SQL or T-SQL) that will go in update some values in few tables looking at their database name first. i.e. using if statement.

    I know that we can get name of database using statement "select name from v$database; " but how to store that name in a value.. using sql only... I need help on that.

    Can any one help me on that. I will appreciate your response. my script is all ready ..just this small piece is missing.

    Thanks,
    Consultant

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    > I am writting a sql script (not PL/SQL or T-SQL) that will go in update some values in few tables looking at their database name first. i.e. using if statement.
    How can this be true when SQL language does NOT contain/support/include IF statement?
    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
    Mar 2007
    Posts
    2
    Quote Originally Posted by anacedent
    > I am writting a sql script (not PL/SQL or T-SQL) that will go in update some values in few tables looking at their database name first. i.e. using if statement.
    How can this be true when SQL language does NOT contain/support/include IF statement?
    Exactly!!! this is question... if is not supported by SQL then what's the other way.. any one plz!!!! ( I was just giving hint that.. like we do in programming using if statements.. sorry for confusion )

  4. #4
    Join Date
    Dec 2003
    Posts
    1,074
    Code:
    update table
    set field = SYSDATE
    where 'MYDB' = (select name from v$database);
    I guess you could have a string of these which would behave like an IF/THEN statement

    Code:
    update table
    set field = SYSDATE
    where 'MYDB' = (select name from v$database);
    
    update table
    set field = SYSDATE
    where 'YOURDB' = (select name from v$database);
    
    update table
    set field = SYSDATE
    where 'THEIRDB' = (select name from v$database);
    -=cf

Posting Permissions

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