Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

DECODE Statement

DECODE Statement

DECODE Statement

Can you please tell me if I can use <, >, or = operator in a DECODE statement.  Example:

DECODE(tbl.Payment > 0, tbl.Payment, NULL)


DECODE(tbl.Payment, tbl.Payment > 0, tbl.Payment, NULL)

DECODE(tbl.Payment, > 0 tbl.Payment, NULL)

None of these statement work!!! I understand the DECODE statement but can't seems to get the stored proc to compile because of the DECODE statement.

DECODE(expr, cond1, val1, cond2, val2...def)
by the way, the database is Oracle 8.  Your help is greatly appreciated.

RE: DECODE Statement

You need actual values to decode, try DECODE(SIGN(tbl.Payment), 1, tbl.payment,NULL)

You may find more help if one of the Oracle Database threads, rather than the ERP thread

I tried to remain child-like, all I acheived was childish.

RE: DECODE Statement

If you want to compare only with 0 then use sign function, otherwise you can write a user defined database function to compare with a particular value and use in the select statement.

RE: DECODE Statement

If you want to compare, for instance, tbl.Payment with 200,
use this code:
decode(sign(tbl.Payment -200),0,'two hundred',1,'Greater than 200','less than 200').
This is a nice shortcut rather than writing the procedure.
The value of sign(tbl.Payment -200) is 0 if  tbl.Payment = 200.
The value of sign(tbl.Payment -200) is 1 if  tbl.Payment > 200.
otherwise, or
The value of sign(tbl.Payment -200) is -1 if  tbl.Payment < 200.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close