 # * `cb`: {Function} callback that'll get called with errors or our results.
 executeQuery = (session, id, hql, cb) ->
   rows = []
-  session.call('execute', [id, hql])
-   .then((topic) ->
-     session.subscribe(topic, ([event, row]) ->
-       if event == "row"
-         rows.push JSON.parse(row)
-       else
-         cb null,
+  session.call('execute', [], connectionId: id, sql: hql)
+  .then(({args: [topic, streamProc]}) ->
+    session.subscribe(topic, ([event, row]) ->
+      switch event
+        when "row" then rows.push JSON.parse(row)
+        when "update_count" then cb null, updateCount: row
+        else
+          cb null,
           rows: rows.map(normalizeRow)
           rowCount: rows.map.length
           fields: rows[0].map((data) -> _.pick data, ['name', 'type'])

# * `host`: {String} hostname of affqis server.
# * `port`: {Number} port number of affqis server.
# * `cb`: {Function} callback to get called with an error if we
#         fail to establish a connection, or a session if we succeed.
connect = (realm, host, port, cb) ->
  affqisUrl = "ws://#{host}:#{port}/affqis"
  connection = new autobahn.Connection

    port: realmConfig.port
    user: realmConfig.user

  session.id = jdbcId
  session

# Public: Disconnect Affqis's JDBC connection and the Affqis connection itself.
#
