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

Home -> Community -> Usenet -> c.d.o.misc -> Re: pl/sql dynamic where

Re: pl/sql dynamic where

From: Tiernan Mc Guigan <tmcguigan_at_bfsec.bt.co.uk>
Date: 1998/10/21
Message-ID: <01bdfd16$feea07a0$67429284@Avatar>#1/1

You could use Dynamic SQL (start reading up on DBMS_SQL) or something like

--

IF criteria1 IS NULL
THEN
   criteria1 := '1';
END IF;

IF criteria2 IS NULL
THEN
   criteria2 := '1';
END IF;
...

SELECT *
FROM mytable
WHERE field1 LIKE NVL(criteria1, '%')
AND field2 LIKE NVL(criteria2, '%');

However if performance is an issue and you're not likely to have more than
5 clauses, write them seperately, giving Oracle a chance to cache the
parsed versions of them.

PS: Out of interest, how do you do such a thing in Pro*C?
Received on Wed Oct 21 1998 - 00:00:00 CDT

Original text of this message

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