Updated on 2023-11-27 GMT+08:00

Saving a SQL template

Function

This API is used to store specified SQL statements for future reuse.

URI

  • URI format

    POST /v1.0/{project_id}/sqls

  • Parameter description
    Table 1 URI parameter

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Project ID, which is used for resource isolation. For details about how to obtain its value, see Obtaining a Project ID.

Request

Table 2 Parameters

Parameter

Mandatory

Type

Description

sql

Yes

String

New SQL template.

sql_name

Yes

String

Name of the SQL template you want to save. The name must be unique in the current project.

description

No

String

Description of the SQL template. The value can be an empty string.

group

No

String

Name of the template group

Response

Table 3 Parameters

Parameter

Type

Description

is_success

Boolean

Whether the request is successful

message

String

System prompt. If execution succeeds, the message may be left blank. If the execution fails, the value is the cause of the failure.

sql_id

String

ID of the SQL template

group

String

Name of the template group

Example Request

Create a SQL template.

{
    "sql": "select * from t1",
    "sql_name": "sql1",
    "description": "use to select t1",
    "group": ""
}

Example Response

{
  "is_success": true,
  "message": "",
  "sql_id": "1994b029-3f76-4281-9e35-e370cb4ee26d1501998934432"
}

Status Codes

Status Code

Description

200

OK

Error Codes

For details, see Error Codes.