Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DECODE?

Status
Not open for further replies.

MicahDB

Programmer
Jul 15, 2004
96
US
I'm new to PL/SQL, so bear with me. I'm wanting to use the decode function in the following manner:

DECODE(ORD.NOTE,'Order exported%','TRUE','FALSE') AS ORDER_NOTE

I'm obviously looking for anything with the ORD.NOTE field starting with "Order exported". But right now I'm getting back everything listed as FALSE. When I put the entire field value in the decode statement (Order exported: 08012004) it does define those fields as true. So when I'm using the decode function, A) can I use a wildcard like this and B) do I have to use a like statement or something along those lines.

Thanks much,
MicahDB
 
Micah,

First item: DECODE is a function that is available only within a SQL statement. If you truly mean PL/SQL, you cannot use DECODE...you must use either "IF...ELSIF...END IF" syntax or (in Oracle9) "CASE WHEN..." syntax.

Second, the "%" (wildcard) character performs only in conjunction with the "LIKE" operator.

Third, to resolve your need, you can use the following workaround:
Code:
DECODE(substr(ORD.NOTE,1,14),'Order exported','TRUE','FALSE') AS ORDER_NOTE

Let us know if this resolves your need.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA @ 18:53 (23Aug04) UTC (aka "GMT" and "Zulu"), 11:53 (23Aug04) Mountain Time)
 
Hmmmm, looks like that worked. Thanks for the clarification...

MicahDB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top