Skip to content

QSQL

This API is intended to run on a data access process and execute the command sent in from the client.

Parameter:

Name Type Description
query string The q-sql command to run on a target data access process

Response:

The response is dependant on the query parameter itself and the result of executing it on the target.

Application Codes

AC Description
INPUT If a non-string is passed in for the query argument
TYPE A q-sql statement results in a type error. e.g "where id=`a", when id is an int column
LENGTH A q-sql `length error. e.g "where id= 1 2", when column doesn't have a count of 2

Examples:

For these examples assume the table t was created in a target process with

t:([]id:til 10)

In this example we do a simple select from the target table t for the id of 4. Response and application codes are both OK.

q)res: h (`.da.execute;`.kxi.qsql; hdr; enlist[`query]!enlist"select from t where id=4")
q)res 0
rc| 0
ac| 0
q)res 1
id
--
4

Here we run a badly formatted query with a where clause that checks equality between a long column and a character resulting in a type error. Response payload is null and has a header with an RC of APP_DB and an AC of TYPE.

q)res: h (`.da.execute;`.kxi.qsql; hdr; enlist[`query]!enlist"select from t where id=`a")
q)res 0
rc| 6
ac| 11
q)(::)~res 1
1b