How can I create a "dynamic" WHERE clause?

Posted by TheChange on Stack Overflow See other posts from Stack Overflow or by TheChange
Published on 2010-03-25T09:20:43Z Indexed on 2010/03/25 9:23 UTC
Read the original article Hit count: 277

Filed under:
|
|

Hello there,

First: Thanks!

I finished my other project and the big surprise: now everything works as it should :-) Thanks to some helpful thinkers of SO!

So here I go with the next project.

I'd like to get something like this:

SELECT * FROM tablename WHERE field1=content AND field2=content2 ...

As you noticed this can be a very long where-clause. tablename is a static property which does not change. field1, field2 , ... (!) and the contents can change.

So I need an option to build up a SQL statement in PL/SQL within a recursive function. I dont really know what to search for, so I ask here for links or even a word to search for..

Please dont start to argue about wether the recursive function is really needed or what its disadvanteges - this is not in question ;-)

If you could help me to create something like an SQL-String which will later be able to do a successful SELECT this would be very nice!

Iam able to go through the recursive function and make a longer string each time, but I cannot make an SQL statement from it..

Oh, one additional thing: I get the fields and contents by a xmlType (xmldom.domdocument etc) I can get the field and the content for example in a clob from the xmltype

© Stack Overflow or respective owner

Related posts about plsql

Related posts about select