querydata
(Apply a query to a table and get results)
The querydata
transaction applies a query to a table and gets the
results as if you called a query and a single getdata
transaction.
querydata
takes the union of parameters from query
and
getdata
respectively and returns the union of results from both
query
and getdata
. querydata
is
convenient and useful when you know the resulting dataset will be smaller than your maximum
allowed download from a single transaction. Otherwise, you will still have to subsequently
call getdata
to receive all of the results.
Query string
The query string in the HTTP header must contain the following parameters:
api
- Specify the name of the API transaction.
apiversion
- Specify the version of the API that should handle the requested transaction.
For the most up-to-date version, use apiversion=3.
uid
- Specify a valid 1010data user name.
pswd
- Specify a valid password for the 1010data user name provided to the
uid
parameter.Note: Thepswd
value should be the encrypted password returned from thelogin
transaction. sid
- The session ID for the current API session.
This value is returned by the
login
transaction and must be provided to every transaction (exceptlogin
). kill
(optional)- Valid values for
kill
are as follows:yes
- Terminate the existing session and start a new one.
no
- Do not terminate the existing session.
If no session exists, a new one will be created. If a session does exist, an error is returned.
Note: Ifkill=no
and a session is active, the system returns an error. possess
- Log in and possess the existing session.
auth
- Authenticate with the system but do not kill, possess, or start any session.
The default is
yes
.
XML Input to Server
The specifications must contain the following elements:
See XML input to query
and getdata
, as the querydata
transaction requires
the input of both query
and getdata
transactions.
XML response from server
A successful querydata
contains the following elements:
<rc>
- The return code generated by the transaction. For a list of return codes, see Return codes.
<msg>
- The message returned by the system. Specific messages correspond to specific return codes.
<nrows>
- The number of rows in the table returned.
<table>
- A 1010data XML table tree. To see the full XML specification for the table tree, see Table Tree.
Query string example
https://www2.1010data.com/gw.k?api=querydata&apiversion=3&uid=$UID&pswd=$PSWD&sid=$SID
XML input example
<in> <name>pub.doc.retail.salesdetail</name> <ops> <sel value="i_<10"/> <colord cols="trans_date,store,xsales"/> </ops> <cols> <col>trans_date</col> <col>store</col> <col>xsales</col> </cols> <rows mode="1"> <next>3</next> </rows> <format type="xml"/> </in>
XML response example
<out> <rc>0</rc> <msg>querydata successful</msg> <table> <cols> <th name="trans_date" type="i" fixed="0">Date</th> <th name="store" type="i" fixed="0">Store</th> <th name="xsales" type="f" fixed="0">Extended Sales</th> </cols> <data> <tr> <td>20140101</td> <td>15</td> <td>0.44</td> </tr> <tr> <td>20140101</td> <td>15</td> <td>0.64</td> </tr> <tr> <td>20140101</td> <td>11</td> <td>2.31</td> </tr> </data> </table> <nrows>9</nrows> </out>