Thanks - I will check it out.

On Friday, 24 May 2013 17:35:46 UTC+2, Niels van Klaveren wrote:
>
> If you need to do join like operations on database tables from different 
> sources that you can't join through SQL, there's a nice library called 
> table-utils<http://stackoverflow.com/questions/13009939/outer-join-in-clojure>that
>  you can use. Since it's not released on clojars there's some steps 
> you'd need to take to use it, but it's all explained in the link.
>
> After you've put it in your project, you can use it by putting the result 
> sets in a map by just putting a doall over the result set, and join them 
> like you would in SQL. It has support for inner, outer and full joins.
>
>     (let [db2 (sql/with-connection db
>                    (sql/with-query-results rs ["select fields from table"]
>                       (doall rs)))
>            sql (sql/with-connection db
>                   (sql/with-query-results rs ["select fields from table"]
>                      (doall rs)))]
>            (left-outer-join db2 sql :db2field :sqlfield))
>
>  
> On Friday, May 24, 2013 4:55:17 PM UTC+2, Mond Ray wrote:
>>
>> I am starting out to use Clojure to combine and verify data between DB2 
>> on a Mainframe, SQL Server and an Atom Feed. Yes, it's such fun working in 
>> a start-up ;-)
>>
>> Database wise, all is connecting OK after some Leiningen shenanigans and 
>> I am now stuck on the mapping part ;-)
>>
>> The code is below.  I want to generate a set of maps that show the 
>> following:
>>
>> #({:a2pid 269, :uuid nil}
>> {:a2pid 270, :uuid nil}
>> {:a2pid 258, :uuid nil}
>> {:a2pid 261, :uuid nil}
>> {:a2pid 251, :uuid E7D4262C-62B3-4129-9CE4-B342DC1C39FC})
>>
>> The idea is to have a list of maps that can show where there are gaps 
>> between the two DBs and, coming next, the Atom feed.
>>
>> It is essentially a join operation - and maybe that's what I need but I 
>> cannot figure out where to plonk the magic words.
>>
>> (defn a2p-records-by-date [query from-date to-date dh-sub-query]
>>   (sql/with-connection db2
>>       (sql/with-query-results rs [query from-date to-date]
>>         (doseq [row rs] (println (str " " (:project_id row) (dh-sub-query 
>> (:project_id row))))))))
>>
>> (defn dh-records-by-a2p-id [query a2p-id]
>>   (sql/with-connection mssql
>>       (sql/with-query-results rs [query a2p-id]
>>         (dorun (map #(print (:project_uuid %)) rs)))))
>>
>> (defn dh-sub-query [a2p-id] (dh-records-by-a2p-id "select PROJECT_UUID 
>> from PROJECT where A2P_PROJECT_ID = ?" a2p-id))
>>
>> (a2p-records-by-date "select project_id from PROJECT where timestamp > ? 
>> and timestamp < ?" "2012-03-02" "2012-03-07" dh-sub-query)
>>
>> The output looks like this, so I am close!
>>
>>  269
>>  270
>>  258
>>  261
>> E7D4262C-62B3-4129-9CE4-B342DC1C39FC 251
>>
>> Can anyone help me out about how to generate the maps?
>>
>> This is just the start as I have many queries to run for many entities, 
>> so doubtless I will be back again ;-)
>>
>> Thanks in advance
>>
>> Ray
>>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to