Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Parse and change an SQL statement

by chrestomanci (Priest)
on Mar 19, 2012 at 22:09 UTC ( #960482=note: print w/replies, xml ) Need Help??

in reply to Parse and change an SQL statement

Where is this SQL that needs translating coming from? Did you write it (or another programmer on your team). Is it from a legacy codebase? Is it being machine generated by another program that you can't modify?

If you, or a team mate are writing the SQL, them SQL::Abstract might be an option. You write your query in a perl like syntax, and it turns it into SQL in whatever dialect you specify. It can't do everything, but does most thing fairly well, including joins of arbitrary complexity, however it is only practical if you are writing the queries, rather than something else.

If the SQL is hard coded into a legacy codebase, or is being generated by a legacy program, then I think you will have to write a translator yourself. The good news is doing so is a finite problem. If it is old hard coded SQL, then you just need to find them all and write translation. If it is an old generator, then it is unlikely to be generating anything unexpected (like a human programmer might), so again you need to figure out how it is building it's queries, and deconstruct them, so that you can re-generate them in the other dialect.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://960482]
[ambrus]: I added a timer implementation to ambrus's scratchpad as well, again the whole thing is completely untested and probably has more bugs than lines
[choroba]: Anyone using anything to validate json contents of a REST service?
[moritz]: choroba in python I use jsonschema
[moritz]: I'm sure there's a Perl implementation of it too
[choroba]: it seems Kelp and similar help you a lot with dispatching, but how to do something similar with contents?
[moritz]: like JSON::Schema
[Corion]: ambrus++ # more bugs than lines
[Corion]: That's like "works on my machine" ;-)
[choroba]: I mean, I'd like to say "this path should run this sub, but first it should check the user is authenticated, has the following permissions, and the contents is valid against a given schema
[ambrus]: no, that means I haven't even tried to run it, might not even parse

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (14)
As of 2016-12-08 12:49 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (141 votes). Check out past polls.