in reply to Parse SQL in Stored Procedures

Your post is pretty hard to understand. I think you're trying build some sort of dynamic SQL query that creates stored procedures...? Hmm... It seems like you want to be able to modify 'testProc_hist' after it's been created?

My suggestions is to use a template engine like HTML::Template to create your stored procedure template. When you need to change a stored procedure, find replace TOKEN values in the template (e.g. $SELECT_CLASE, $WHERE_CLAUSE, etc.) and then execute it as an 'ALTER PROCEDURE' statement.

The idea of 'parsing SQL in Sybase stored procedure' is WAY WAY to complicated - instead do your processing outside of the stored procedure and then execute an ALTER PROCEDURE statement instead.

Good luck?

Kurt