http://www.perlmonks.org?node_id=960473

philgoetz has asked for the wisdom of the Perl Monks concerning the following question:

I know the module SQL::Statement can parse an SQL statement. But I need to automatically convert statements back and forth between Sybase and SQLite, so I need to parse a statement, then CHANGE parts of it (e.g., change column names to avoid reserved words or to emulate Sybase functions), and then construct a new SQL statement for the other database type to execute.

For instance, I would want to convert

"SELECT len(ec#), getdate(), user_name() FROM ident"

into

"SELECT length(ec_num), date(), $ENV{USER} FROM identity"

(SQLite does not allow the column names 'ec#' or 'ident'.)

As far as I can tell, SQL::Statement doesn't let you construct a new statement out of constituent parts. Any idea what can?