Re: re-formulating sql statements

2010-10-05 Thread Avram
Making progress but still in the trenches… On Oct 5, 3:29 pm, Alan wrote: > No, that compiler message is the one that comes up when your Clojure > parens don't line up; problems in the regex wouldn't appear until > runtime. It looks like I put too many close-parens after .find. Try > changing the

Re: re-formulating sql statements

2010-10-05 Thread Alan
No, that compiler message is the one that comes up when your Clojure parens don't line up; problems in the regex wouldn't appear until runtime. It looks like I put too many close-parens after .find. Try changing the offending line to: (re-groups (doto (re-matcher pattern line) .find)) Also it occ

Re: re-formulating sql statements

2010-10-05 Thread Avram
Alan, thanks for your response, I'm still new at this. Running it, the part with refer had an issue, but I tinkered and got past that on line #3. I also added a print statement to see what the output looks like, but there appears to be a hidden unmatched delimiter somewhere (??). I'm digging aroun

Re: re-formulating sql statements

2010-10-05 Thread Alan
(use 'clojure.java.io) (require 'clojure.string) (refer 'clojure.string :only [split]) (let [pattern #"case when (\\S+) in \\(([^)]+)\\) then (\\S+) as (\\S +)"] (with-open [sql-in (reader "/path/to/file")] (doseq [line (line-seq reader)] (let [[_ in-str then-str as-str]

re-formulating sql statements

2010-10-05 Thread Avram
Hello Clojurians, I'm a beginner with clojure, but feel I have a situation that macros might be well-suited. The problem description is that I have a few sql files with a couple hundred lines of ANSI SQL. These files contain many SQL statements like the following: case when a in ('Q1', 'Q3'