Execute Procedures


Execute Procedures


The execute operation allows you to execute stored procedures for any of the data sources configured in your CData Connect Cloud account.

Request Format

POST /exec

Request Body

All requests must include a JSON body like the following:

{
  "procedure": "<string>",
  "defaultSchema": "<string>",
  "parameters": {
    "@p1": { "dataType": <int>, "direction": <int>, "value": <any> },
    "@p2": { "dataType": <int>, "direction": <int>, "value": <any> },
    ...
  }
}

Fields

procedure Required The name of the stored procedure to execute.
defaultSchema Optional If the name specified with procedure is not prefixed with a schema name, this property must be used to specify a default schema.
parameters Optional A JSON object containing a list of procedure parameters. All parameter names must begin with @.
  dataType Required The parameter’s data type.
  direction Optional The parameter’s direction (see notes, below). Default is 1 (input parameter).
  value Optional The parameter’s value, if applicable (see notes, below).

Notes

Valid values for direction are:

  • 1: Input parameter (value is required)
  • 2: In/out parameter (value is optional; treated as null if absent)
  • 4: Output parameter (value is ignored)
  • 5: Return value (value is ignored)

Response Format

The results of the stored procedure execution are returned using our standard JSON result object. Any parameters with a direction of 2, 4, or 5 are included in the result.

Example

POST https://cloud.cdata.com/api/exec

Request Body

{
  "procedure": "UploadDocument",
  "defaultSchema": "Salesforce1",
  "timeout": 60,
  "parameters": {
    "Base64Data": {
      "dataType": 5,
      "direction": 1,
      "value": "VGhpcyBpcyBhIHNhbXBsZSB0ZXh0IGRvY3VtZW50"
    },
    "Name": {
      "dataType": 5,
      "direction": 1,
      "value": "SampleText.txt"
    },
    "FolderId": {
      "dataType": 5,
      "direction": 1,
      "value": "00l40000001Z4HtAAK"
    },
    "Description": {
      "dataType": 5,
      "direction": 1,
      "value": "A Sample txt file uploaded with base 64 data."
    }
  }
}

Response

{
  "results": [
    {
      "schema": [
        {
          "ordinal": 0,
          "catalogName": "CData",
          "schemaName": "Salesforce1",
          "tableName": "UploadDocument",
          "columnName": "Id",
          "columnLabel": "Id",
          "dataType": 5,
          "dataTypeName": "varchar",
          "length": 2000,
          "precision": 2000,
          "scale": 0,
          "nullable": true
        }
      ],
      "rows": [
        [
          "0151W000004EKT8QAO"
        ]
      ]
    }
  ]
}