0

sendCommand

To send a SQL command to a connected SQL database

In case you want to send a command to a connected SQL database, use this function to send your command as a string through a specified connection.

💡 Learn more about SQL connections.

Syntax

sendCommand(string, string)

Return

JSON

Examples

sendCommand(connectionName, command) To send a given SQL command to a connected SQL database by specifying the connection name.

do as server
    formatJSON(sendCommand("MySQLConnection", "SELECT 1"))
end

Result:

{result: {"recordsets":[[{"id":2,"name":"feature a","price":99.99,"created_at":"2021-06-02T08:00:00.000Z"}]],"recordset":[{"id":2,"name":"feature a","price":99.99,"created_at":"2021-06-02T08:00:00.000Z"}],"output":{},"rowsAffected":[1]}}

{
  "result": {
    "recordsets": [
      [
        {
          "id": 2,
          "name": "feature a",
          "price": 99.99,
          "created_at": "2021-06-02T08:00:00.000Z"
        }
      ]
    ],
    "recordset": [
      {
        "id": 2,
        "name": "feature a",
        "price": 99.99,
        "created_at": "2021-06-02T08:00:00.000Z"
      }
    ],
    "output": {},
    "rowsAffected": [
      1
    ]
  }
}

See also

queryConnection which sends a SQL command to a connected SQL database and returns the record data.

Reply

null