Skip to main content

procedures

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

Overview

Nameprocedures
TypeResource
Idsnowflake.procedure.procedures

Fields

NameDatatypeDescription
namestringName of the procedure
argumentsarrayList of arguments for the function/procedure
bodystringFunction/procedure definition
commentstringSpecifies a comment for the function/procedure
created_onstringThe date and time when the function/procedure was created
database_namestringThe name of the database in which the function/procedure exists.
execute_asstringWhat permissions should the procedure execution be called with
is_builtinbooleanIf the function/procedure is built-in or not (user-defined)
is_securebooleanSpecifies whether the function/procedure is secure or not
language_configobject
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_typeobject
schema_namestringThe name of the schema in which the function/procedure exists.

Methods

NameAccessible byRequired ParamsOptional ParamsDescription
fetch_procedureSELECTdatabase_name, nameWithArgs, schema_name, endpoint-Fetch a procedure
list_proceduresSELECTdatabase_name, schema_name, endpointlikeList procedures
create_procedureINSERTdatabase_name, schema_name, data__arguments, data__body, data__language_config, data__name, data__return_type, endpointcreateMode, copyGrantsCreate a procedure
delete_procedureDELETEdatabase_name, nameWithArgs, schema_name, endpointifExistsDelete a procedure
call_procedureEXECdatabase_name, nameWithArgs, schema_name, data__call_arguments, endpoint-Call a procedure

Optional Parameter Details
NameDescriptionTypeDefault
copyGrantsQuery parameter to enable copy grants when creating the object.booleanfalse
createModeQuery 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.stringerrorIfExists
ifExistsQuery 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.booleanfalse
likeQuery parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.string-

SELECT examples

List procedures

SELECT
name,
arguments,
body,
comment,
created_on,
database_name,
execute_as,
is_builtin,
is_secure,
language_config,
max_num_arguments,
min_num_arguments,
owner,
owner_role_type,
return_type,
schema_name
FROM snowflake.procedure.procedures
WHERE database_name = '{{ database_name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';

INSERT example

Use the following StackQL query and manifest file to create a new procedures resource.

/*+ create */
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
)
SELECT
'{{ name }}',
'{{ execute_as }}',
'{{ is_secure }}',
'{{ arguments }}',
'{{ return_type }}',
'{{ language_config }}',
'{{ comment }}',
'{{ body }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}'
;

DELETE example

Deletes the specified procedures resource.

/*+ delete */
DELETE FROM snowflake.procedure.procedures
WHERE database_name = '{{ database_name }}'
AND nameWithArgs = '{{ nameWithArgs }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';