| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.tools -> DECODE statement: is this a reasonable way to do things?
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
![]() |
![]() |