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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF statement

Status
Not open for further replies.
Mar 7, 2010
61
Hi Just wondering how you do an if statment. I am using golden bethnic 32 and not sure what version of oracle database. I want to say if a field = a certain value then another field must = a certain value otherwise that other field must = another value to return the results. I hope this makes sense.
thanks
carleen
 
Carleen,

in oracle's on line documentation about SQL and the PL/SQL programming language, you will find a very clear explanation of how to do that.

Once you have read the documentation, and attempted to do this for yourself, post your code (and any error messages) and we will be only too pleased to help.

Google is your friend.

Regards

T
 
Most version of Oracle accept either DECODE or CASE

Decode is a bit convoluted and for your example you would need to nest

Decode(field1, x, y, z) as result

Effectively means if field1 = x then y else z)

CASE is closest to If then else

CASE(when filed1 = x then y else z end) AS result

whenplaced in a select statement will yield a column with name Result.

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top