Application Programming Interface Guide > REST API > TDV Server REST APIs > Execute
 
Execute
The execute API provides the ability to execute queries, procedures and multiple DSL statements.
POST/execute/DSL
POST/execute/sqlscript
POST/execute/query
POST/execute/procedure
POST/execute/DSL
This API is used to execute the specified list of DSL statements.
Parameters:
None
Request Body
Example Value - Schema
[
"string"
]
Example to Drop a Sql script procedure and create one using two DSL statements.
curl -d "[\"CREATE SCRIPT /shared/examples/ctasScript DEFINE AS PROCEDURE ctasScript() BEGIN CREATE TABLE /shared/examples/ds_inventory/tutorial/sampleTable as select OrderId, ProductID, Discount, OrderDate, CompanyName, CustomerContactFirstName, CustomerContactLastName, CustomerContactPhone FROM /shared/examples/ViewOrder; END\",\"DROP SCRIPT /shared/examples/ctasScript\"]" -u "admin:admin" -X POST "http://localhost:9400/rest/execute/v1/actions/dsl/invoke" -H
POST/execute/sqlscript
This API is used to execute procedure specified by scriptText.
Parameters:
None
Request Body
Example Value - Schema
[
"includeMetadata": true,
“parameterBeanList”: [
{
“definition”: “string”,
“value”: “string”
}
],
“scriptText”: “string”,
“blocking”: true
]
Example to execute procedure using script text
curl -X POST -u admin:admin "http://localhost:9400/rest/execute/v1/actions/sqlscript/invoke" -H "Content-Type:application/json" -d "{\"blocking\":\"true\",\"includeMetadata\":\"true\", \"parameterBeanList\":[{\"definition\":\"INTEGER\", \"value\":\"1\"}],\"scriptText\":\"PROCEDURE LookupProduct(IN desiredProduct INTEGER,OUT result CURSOR (ProductName VARCHAR(50),ProductID INTEGER,ProductDescription VARCHAR(255))) BEGIN OPEN result FOR SELECT products.ProductName, products.ProductID, products.ProductDescription FROM /shared/examples/ds_inventory/tutorial/products products WHERE products.ProductID = desiredProduct; END\"}"
POST/execute/query
This API is used to execute a SQL query against the TDV server.
Parameters:
None
Request Body
Contains the sql statement, an optional 'standardSQL' flag that defaults to true. Set the 'standardSQL' flag to false for performing a data preview, and the query must be a composite query i.e., non-standard.
 
Example Value - Schema
[
"standardSQL": true,
“query”: “string”,
“system”: true
]
Example to execute a query to get a property of a sql script procedure.
curl -u "admin:admin" -X POST "http://localhost:9400/rest/execute/v1/actions/query/invoke" -H "Content-Type:application/json" -d "{\"query\":\"SELECT * FROM model.ALL_RESOURCE_PROPERTIES WHERE property_name = 'script' AND metadata_id = (SELECT PROCEDURE_ID FROM model.ALL_PROCEDURES WHERE PROCEDURE_NAME = 'ctasScript' AND parent_path = '/shared/examples')\", \"standardSQL\":true}"
POST/execute/procedure
This API is used to execute procedure specified by path / type.
Parameters:
None
Request Body
Example Value - Schema
[
"includeMetadata": true,
“parameterBeanList”: [
{
“definition”: “string”,
“value”: “string”
}
],
“path”: “string”,
“type”: “string”,
“blocking”: true
]
Example to execute procedure "/shared/examples/LookupProduct"
curl -X POST -u admin:admin "http://localhost:9400/rest/execute/v1/actions/procedure/invoke" -H "Content-Type:application/json" -d "{\"blocking\":\"true\",\"includeMetadata\":\"true\", \"parameterBeanList\":[{\"definition\":\"INTEGER\", \"value\":\"1\"}],\"path\":\"/shared/examples/LookupProduct\", \"type\":\"PROCEDURE\"}"