DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Question???

  1. #1
    Join Date
    Sep 2000
    Posts
    56
    1.What is decode statements in Oracle
    2.Can we use wildcards in decode statements.
    Can anyone suggest me good books or sites.
    Thanks in advance

  2. #2
    Join Date
    Jun 2000
    Posts
    417
    Decode statements are sort of like if-then-else statements in programming languages.

    say you have a column "status", which can be either 1 (which would mean active), 2 (which would mean inactive), and (which would mean not available).

    if you didn't use a lookup table, and wanted to select the meanings of the statuses, and not the numeric value, you could say

    select decode(status, 1, "active", 2, "inactive", 3, "not available", "default status") from table where condition;

    the first argument is the column or value, then a string of key/value arguments. the last argument (optional) lists a default value to be returned if the real value isn't in the argument list.

    you can find a good reference in technet's sql reference.

  3. #3
    Join Date
    Sep 2000
    Posts
    56
    Thanks!!!!.But can we use wildcardsd?????? in decode statements

  4. #4
    Join Date
    Jun 2000
    Posts
    417
    Wildcards as in what?

    Depending on your needs, the default argument at the end is a wildcard which will accept any input other than what was explicity specified.

    I don't think you can use generic wildcards for other arguments though, as I think it uses equals as a comparator and not like, but give it a shot and/or check the docs.

Posting Permissions

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


Click Here to Expand Forum to Full Width