This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-09
Channels
- # announcements (1)
- # aws-lambda (3)
- # babashka (6)
- # beginners (91)
- # bristol-clojurians (5)
- # calva (25)
- # chlorine-clover (8)
- # cider (6)
- # clj-kondo (13)
- # cljdoc (10)
- # cljsrn (1)
- # clojure (80)
- # clojure-berlin (6)
- # clojure-europe (29)
- # clojure-nl (4)
- # clojure-spec (18)
- # clojure-uk (51)
- # clojurescript (41)
- # conjure (55)
- # cursive (3)
- # datomic (58)
- # emacs (9)
- # events (1)
- # figwheel-main (2)
- # fulcro (29)
- # graphql (12)
- # helix (4)
- # jobs (4)
- # klipse (8)
- # london-clojurians (1)
- # malli (5)
- # off-topic (13)
- # portal (9)
- # re-frame (30)
- # shadow-cljs (44)
- # spacemacs (7)
- # specter (3)
- # sql (11)
- # tools-deps (71)
- # windows (1)
- # xtdb (10)
Is it possible to do this via next.jdbc? (Processing more than one ResultSet)
String SQL = "SELECT 1; SELECT * FROM nonexistentTable;";
try (Statement statement = connection.createStatement();) {
// Does not throw an exception on execute().
boolean hasResult = statement.execute(SQL);
while (hasResult) {
try (ResultSet rs = statement.getResultSet()) {
while (rs.next()) {
System.out.println(rs.getString(1));
}
}
// Moves the next result set that generates the exception.
hasResult = statement.getMoreResults();
}
} catch (SQLException e) {
e.printStackTrace();
}
@isak The test suite only tests that against MS SQL Server, although it does have a test on stored procs returning multiple result sets that runs on a few more types of DB https://github.com/seancorfield/next-jdbc/blob/develop/test/next/jdbc_test.clj#L446
seancorfield/next.jdbc {:mvn/version "1.1.588"}
-- https://github.com/seancorfield/next-jdbc -- adds next.jdbc.plan/select!
and next.jdbc.plan/select-one!
to make some common usages of plan
easier to write (based on my usage on next.jdbc/plan
at work). See next.jdbc.plan
docs https://cljdoc.org/d/seancorfield/next.jdbc/1.1.588/api/next.jdbc.plan and updated examples in the second half of https://cljdoc.org/d/seancorfield/next.jdbc/1.1.588/doc/getting-started#plan--reducing-result-sets
I found I was writing (reduce (fn [_ row] (reduced (f row))) nil (jdbc/plan ...))
all over the place...
...and then I looked at all my plan
uses and found that (into [] (map f) (jdbc/plan ...))
was also pretty common. Except in a few places where it was (into #{} (map f) (jdbc/plan ...))
...and then I realized that we also commonly turn some result sets into lookup hash maps based on the primary key and one other column... so that is now (plan/select! ds (juxt :id :name) ["select..."] {:into {}})
It's the first thing that's really grown out of daily usage...