procedures
Creates, updates, deletes, gets or lists a procedures
resource.
Overview
Name | procedures |
Type | Resource |
Id | snowflake.procedure.procedures |
Fields
The following fields are returned by SELECT
queries:
- list_procedures
- fetch_procedure
A Snowflake procedure
Name | Datatype | Description |
---|---|---|
name | string | Name of the procedure (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
database_name | string | The name of the database in which the function/procedure exists. (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
schema_name | string | The name of the schema in which the function/procedure exists. (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
arguments | array | List of arguments for the function/procedure |
body | string | Function/procedure definition |
comment | string | Specifies a comment for the function/procedure |
created_on | string (date-time) | The date and time when the function/procedure was created |
execute_as | string | What permissions should the procedure execution be called with |
is_builtin | boolean | If the function/procedure is built-in or not (user-defined) |
is_secure | boolean | Specifies whether the function/procedure is secure or not |
language_config | object | |
max_num_arguments | integer | The maximum number of arguments |
min_num_arguments | integer | The minimum number of arguments |
owner | string | Role that owns the function/procedure |
owner_role_type | string | The type of role that owns the function/procedure |
return_type | object |
A Snowflake procedure
Name | Datatype | Description |
---|---|---|
name | string | Name of the procedure (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
database_name | string | The name of the database in which the function/procedure exists. (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
schema_name | string | The name of the schema in which the function/procedure exists. (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$) |
arguments | array | List of arguments for the function/procedure |
body | string | Function/procedure definition |
comment | string | Specifies a comment for the function/procedure |
created_on | string (date-time) | The date and time when the function/procedure was created |
execute_as | string | What permissions should the procedure execution be called with |
is_builtin | boolean | If the function/procedure is built-in or not (user-defined) |
is_secure | boolean | Specifies whether the function/procedure is secure or not |
language_config | object | |
max_num_arguments | integer | The maximum number of arguments |
min_num_arguments | integer | The minimum number of arguments |
owner | string | Role that owns the function/procedure |
owner_role_type | string | The type of role that owns the function/procedure |
return_type | object |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
list_procedures | select | database_name , schema_name , endpoint | like | List procedures |
fetch_procedure | select | database_name , schema_name , nameWithArgs , endpoint | Fetch a procedure | |
create_procedure | insert | database_name , schema_name , endpoint | createMode , copyGrants | Create a procedure |
delete_procedure | delete | database_name , schema_name , nameWithArgs , endpoint | ifExists | Delete a procedure |
call_procedure | exec | database_name , schema_name , nameWithArgs , endpoint | Call a procedure |
Parameters
Parameters can be passed in the WHERE
clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
Name | Datatype | Description |
---|---|---|
database_name | string | Identifier (i.e. name) for the database to which the resource belongs. You can use the /api/v2/databases GET request to get a list of available databases. |
endpoint | string | Organization and Account Name (default: orgid-acctid) |
nameWithArgs | string | Function's name with Args |
schema_name | string | Identifier (i.e. name) for the schema to which the resource belongs. You can use the /api/v2/databases/{database}/schemas GET request to get a list of available schemas for the specified database. |
copyGrants | boolean | Query parameter to enable copy grants when creating the object. |
createMode | string | Query parameter allowing support for different modes of resource creation. Possible values include: - errorIfExists : Throws an error if you try to create a resource that already exists. - orReplace : Automatically replaces the existing resource with the current one. - ifNotExists : Creates a new resource when an alter is requested for a non-existent resource. |
ifExists | boolean | Query parameter that specifies how to handle the request for a resource that does not exist: - true : The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false : The endpoint throws an error if the resource doesn't exist. |
like | string | Query parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters. |
SELECT
examples
- list_procedures
- fetch_procedure
List procedures
SELECT
name,
database_name,
schema_name,
arguments,
body,
comment,
created_on,
execute_as,
is_builtin,
is_secure,
language_config,
max_num_arguments,
min_num_arguments,
owner,
owner_role_type,
return_type
FROM snowflake.procedure.procedures
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
AND like = '{{ like }}';
Fetch a procedure
SELECT
name,
database_name,
schema_name,
arguments,
body,
comment,
created_on,
execute_as,
is_builtin,
is_secure,
language_config,
max_num_arguments,
min_num_arguments,
owner,
owner_role_type,
return_type
FROM snowflake.procedure.procedures
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND nameWithArgs = '{{ nameWithArgs }}' -- required
AND endpoint = '{{ endpoint }}' -- required;
INSERT
examples
- create_procedure
- Manifest
Create a procedure
INSERT INTO snowflake.procedure.procedures (
data__name,
data__execute_as,
data__is_secure,
data__arguments,
data__return_type,
data__language_config,
data__comment,
data__body,
database_name,
schema_name,
endpoint,
createMode,
copyGrants
)
SELECT
'{{ name }}' --required,
'{{ execute_as }}',
{{ is_secure }},
'{{ arguments }}' --required,
'{{ return_type }}' --required,
'{{ language_config }}' --required,
'{{ comment }}',
'{{ body }}' --required,
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}',
'{{ copyGrants }}'
;
# Description fields are for documentation purposes
- name: procedures
props:
- name: database_name
value: string
description: Required parameter for the procedures resource.
- name: schema_name
value: string
description: Required parameter for the procedures resource.
- name: endpoint
value: string
description: Required parameter for the procedures resource.
- name: name
value: string
description: >
Name of the procedure
- name: execute_as
value: string
description: >
What permissions should the procedure execution be called with
valid_values: ['CALLER', 'OWNER']
- name: is_secure
value: boolean
description: >
Specifies whether the function/procedure is secure or not
- name: arguments
value: array
description: >
List of arguments for the function/procedure
- name: return_type
value: object
- name: language_config
value: object
- name: comment
value: string
description: >
Specifies a comment for the function/procedure
- name: body
value: string
description: >
Function/procedure definition
- name: createMode
value: string
description: Query parameter allowing support for different modes of resource creation. Possible values include: - `errorIfExists`: Throws an error if you try to create a resource that already exists. - `orReplace`: Automatically replaces the existing resource with the current one. - `ifNotExists`: Creates a new resource when an alter is requested for a non-existent resource.
- name: copyGrants
value: boolean
description: Query parameter to enable copy grants when creating the object.
DELETE
examples
- delete_procedure
Delete a procedure
DELETE FROM snowflake.procedure.procedures
WHERE database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND nameWithArgs = '{{ nameWithArgs }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}';
Lifecycle Methods
- call_procedure
Call a procedure
EXEC snowflake.procedure.procedures.call_procedure
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@nameWithArgs='{{ nameWithArgs }}' --required,
@endpoint='{{ endpoint }}' --required
@@json=
'{
"call_arguments": "{{ call_arguments }}"
}';