in reply to Help SQL::Tidy

Instead of having to have a list of all functions, you can just look at the next token. If the next token is '(' then assume you have a function and format appropriately.

While I won't be using this module (because I already write my SQL in a nicely formatted form), I should point out that one thing you need to figure out how to format is a CASE statement. I say this because I frequently write things like this:

SELECT e.eventid , SUM(c.revenue) as total_revenue , SUM( CASE WHEN c.cart_type = 'ST' THEN c.revenue END ) as standard_revenue FROM event e JOIN cart c ON e.eventid = c.eventid GROUP BY e.eventid
and the expressions within the CASE statement can get surprisingly complicated...

Replies are listed 'Best First'.
Re^2: Help SQL::Tidy
by eric256 (Parson) on Feb 19, 2008 at 22:02 UTC

    Thanks. This is for autodocumenting an oracle system where I don't write all the SQL, but I still want it to look nice. I've got a new version i'll post up afer some more testing, re-arranged completly and its getting pretty nice. At least acceptable enough for this document (thats probably going to end up sitting in a safe and never looked at agian. lmao).


    ___________
    Eric Hodges
      Hi There, I am wondering where this stands? I sure could use a nice SQL Formatter and I saw that you were working on this. Any plans for a CPAN release? Or at least making your new code available? Thanks for letting me know! Eric J