How to parse out an order by and leave the rest of a where clause HELP?

From: steve deno <sldcrew2k_at_yahoo.com>
Date: 14 Feb 2003 15:01:57 -0800
Message-ID: <8e6b14d8.0302141501.151da96b_at_posting.google.com>


Hi all,

I am having trouble with some string parsing. I need to take in a sql statement with a where clause and get rid of an order by clause(if it exists) and everything before the where clause I have been trying the following

SELECT
substr('SELECT * FROM table WHERE ID IS NOT NULL ORDER BY ID ASC', INSTR('SELECT * FROM BODYGEM_SOURCE WHERE ID IS NOT NULL ORDER BY ID ASC', ' WHERE '), length('SELECT * FROM table WHERE ID IS NOT NULL ORDER BY ID ASC') INSTR('SELECT * FROM table WHERE ID IS NOT NULL ORDER BY ID ASC', ' ORDER BY ') )
 from dual

OR something like it forever now and can not get it to work.

Does anyone have any better ways to do this? Other functions, etc.

Help is appreciated very much. Received on Sat Feb 15 2003 - 00:01:57 CET

Original text of this message