DEFAULT PARAMETERS

This article is about the current transformation of the default parameters and how their functionality is being emulated.

Description

A default parameter is a parameter that has a value in case an argument is not passed in the procedure or function call. Since Snowflake doesn't support default parameters, SnowConvert inserts the default value in the procedure or function call.

In the declaration, the DEFAULT VALUE clause of the parameter is removed. Both syntaxes, the := symbol and the DEFAULT clause, are supported.

Sample Source Patterns

Sample auxiliary code

CREATE TABLE TABLE1(COL1 NUMBER, COL2 NUMBER);
CREATE TABLE TABLE2(COL1 NUMBER, COL2 NUMBER, COL2 NUMBER);

Default parameter declaration

Oracle

CREATE OR REPLACE PROCEDURE PROC_WITH_DEFAULT_PARAMS1 (param1 NUMBER, param2 NUMBER default TO_NUMBER(1))
AS
BEGIN 
	INSERT INTO TABLE1 (COL1, COL2) VALUES(param1, param2);
END;

CREATE OR REPLACE PROCEDURE PROC_WITH_DEFAULT_PARAMS2 (param1 NUMBER default 1, param2 NUMBER default 2)
AS
BEGIN 
	INSERT INTO TABLE1 (COL1, COL2) VALUES(param1, param2);
END;

CREATE OR REPLACE PROCEDURE PROCEDURE_WITH_DEAFAULT_PARAMS3 (param1 NUMBER DEFAULT 100, param2 NUMBER, param3 NUMBER DEFAULT 1000)
IS
BEGIN
	INSERT INTO TABLE2(COL1, COL2, COL3) VALUES (param1, param2, param3);
END;

Snowflake Scripting

Calling procedures with default parameters

Oracle

Snowflake Scripting

In order to check that the functionality is being emulated correctly the following query is going to execute the procedure and a SELECT from the table mentioned before.

Oracle

Snowflake Scripting

Calling procedures with named arguments and default parameters

Oracle

Snowflake Scripting

In order to check that the functionality is being emulated correctly the following query is going to execute the procedure and a SELECT from the table mentioned before.

Oracle

Snowflake Scripting

Known Issues

1. No issues found

  1. MSCEWI1079: Parameter names were removed from the call.

  2. MSCEWI1087: Arguments do not match the called procedure parameters count, default parameters are not supported yet.

  3. MSCEWI1089: Default Value Removed.

  4. MSCEWI1090: Default value added.

Last updated

Was this helpful?