-
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
-
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.
-
Thanks!!!!.But can we use wildcardsd?????? in decode statements
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|