Skip to main content

procedures

Creates, updates, deletes, gets or lists a procedures resource.

Overview

Nameprocedures
TypeResource
Idsnowflake.functions.procedures

Fields

The following fields are returned by SELECT queries:

successful

NameDatatypeDescription
namestringName of the procedure (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
database_namestringThe name of the database in which the function/procedure exists. (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
schema_namestringThe name of the schema in which the function/procedure exists. (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
argumentsarrayList of arguments for the function/procedure
bodystringFunction/procedure definition
commentstringSpecifies a comment for the function/procedure
created_onstring (date-time)The date and time when the function/procedure was created
execute_asstringWhat permissions should the procedure execution be called with (CALLER, OWNER)
is_builtinbooleanIf the function/procedure is built-in or not (user-defined)
is_securebooleanSpecifies whether the function/procedure is secure or not
language_configobjectLanguage that the function/procedure is written in
max_num_argumentsintegerThe maximum number of arguments
min_num_argumentsintegerThe minimum number of arguments
ownerstringRole that owns the function/procedure
owner_role_typestringThe type of role that owns the function/procedure
return_typeobjectReturn type of the function/procedure. Should be a SQL data type or a table

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectdatabase_name, schema_name, name_with_args, endpointFetch a procedure
listselectdatabase_name, schema_name, endpointlikeList procedures
createinsertdatabase_name, schema_name, endpoint, name, arguments, return_type, language_config, bodycreateMode, copyGrantsCreate a procedure
deletedeletedatabase_name, schema_name, name_with_args, endpointifExistsDelete a procedure
callexecdatabase_name, schema_name, name_with_args, endpoint, call_argumentsCall 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.

NameDatatypeDescription
database_namestringIdentifier (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.
endpointstringOrganization and account identifier (orgname-accountname) (default: orgname-accountname)
name_with_argsstringFunction's name with Args
schema_namestringIdentifier (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.
copyGrantsbooleanParameter to enable copy grants when creating the object.
createModestringParameter 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.
ifExistsbooleanParameter 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.
likestringParameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.

SELECT examples

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.functions.procedures
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND name_with_args = '{{ name_with_args }}' -- required
AND endpoint = '{{ endpoint }}' -- required
;

INSERT examples

Create a procedure

INSERT INTO snowflake.functions.procedures (
name,
execute_as,
is_secure,
arguments,
return_type,
language_config,
comment,
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 }}'
RETURNING
status
;

DELETE examples

Delete a procedure

DELETE FROM snowflake.functions.procedures
WHERE database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND name_with_args = '{{ name_with_args }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}'
;

Lifecycle Methods

Call a procedure

EXEC snowflake.functions.procedures.call
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name_with_args='{{ name_with_args }}' --required,
@endpoint='{{ endpoint }}' --required
@@json=
'{
"call_arguments": "{{ call_arguments }}"
}'
;