Purpose

Execute an arbitrary Sql query using the connection string from the agent configuration.

For certain aggregators, the request is forwarded to r_k Cloud. No agent connected is required.

Request typeAsynchronous
Supported agent versionv2
PluggetSystemTypeSql

Request format


JSON

{
  "taskType": "ExecuteSqlQuery",
  "params": {
    "async": {
      "objectId": number,
       "timeout": number
    },
    "sync": {
      "objectId": number,
       "timeout": number
    },
    "connectionStringName": "string",
    "procName": "string",
    "procType": "enum",
    "params": [
      {
        "name": "string",
        "value": "string"
      }
    ]
  }
}

Parameter

Type

Mandatory

Description

taskTypestringyesTask type, for this method the value is ExecuteSqlQuery.
-async

Asynchronous method call: either synchronous or asynchronous
-sync

Synchronous method call: either synchronous or asynchronous
--timeoutintnoAgent response timeout in seconds, default is 120 seconds
--objectIdintyesRestaurant code in the licensing system
-connectionStringNamestringnoThe name of the database connection string in the agent configuration. If not specified, the RKeeperReportService connection is searched for in the configuration.
-procTypestringyes

Command type, options:

  • storedProcedure
  • function
-procNamestringyesName of the stored procedure or function
-params
noParameters for the called procedure/function
--namestringyesParameter name
--valuestringyesParameter value

Response format


JSON

{
   "responseCommon":{
      "taskGuid":"guid",
      "taskType":"ExecuteSqlQuery",
      "objectId": 0
   },
   "error":{
      "wsError":{
         "code":"string",
         "desc":"string"
      }
   }
}

Parameter

Type

Description

--taskGuidguidUnique code for this task. Used when receiving a task via the queue
--taskTypestring enumTask type
--objectIdintRestaurant code in the licensing system
-error
Error container, for more details see the article Error Description

Asynchronous response format

Successful response


JSON

// Successful response
{
  "taskResponse": {
     "queryResult": {
        "rows": [
            // Array of records
        ]
     }
  },
  "responseCommon": {
    "taskGuid": "string",
    "taskType": "SqlCommand",
    "objectId": 0
  }
}


Answer with error


JSON

{
  "responseCommon": {
    "taskGuid": "string",
    "taskType": "ExecuteSqlQuery",
    "objectId": 0
  },
  "error": {
    "wsError": {
      "code": "string",
      "desc": "string"
    },
    "agentError": {
      "code": 0,
      "desc": "string"
    }
  }
}

Parameter

Parameter type

Mandatory

Description

-rowsarray
Array of records of the query execution result
errorstring enum
Error container, for more details see the article Error Description

Example answer


JSON

{
    "taskResponse": {
        "queryResult": {
            "rows": [
                {
                    "col_1": true,
                    "col_2": 2,
                    "col_3": "str"
                },
                {
                    "col_1": false,
                    "col_2": 3,
                }
            ]
        }
    },
    "responseCommon": {
        "taskGuid": "464ca191-8d3a-439b-ad5b-485f628275e6",
        "taskType": "SqlCommand",
        "objectId": 199997075
    }
}