Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> DECODE statement: is this a reasonable way to do things?

DECODE statement: is this a reasonable way to do things?

From: Benetnasch <benetnasch.spam.begone_at_blimey.co.uk>
Date: Tue, 3 Jul 2001 16:18:13 +0100
Message-ID: <Xml07.4424$A51.1022535@monolith.news.easynet.net>

Just wondered whether this is a reasonable way of doing things:

I have a PL/SQL procedure which has, as an argument, a flag. If this flag is a 'Y', then I want only records with a value of 17 in a specific column to be selected. If the flag isn't "Y", then all records can be selected.

<column name> is a number, so I don't really want to TO_CHAR it, as it has an index on it.

My code is thus:

      AND    <column name> BETWEEN DECODE(p_newflag

, 'Y', 17
, 0)
AND DECODE(p_newflag
, 'Y', 17
, 100)

(the column is only NUMBER(2), so 100 should be big enough)

This is the way I've thought of doing it, but I'd be grateful if anyone can suggest a better way of doing it.

Thanks for any assistance,

--
Benetnasch
Remove ".spam.begone"
Received on Tue Jul 03 2001 - 10:18:13 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US