RETURN

Description

The RETURN statement returns back to the caller from a stored procedure. (Redshift SQL Language Reference Return).

The conversion of the return statement from Amazon Redshift to Snowflake is straightforward, only considering adding a NULL to the return statement on Snowflake.

Grammar Syntax

RETURN;

Sample Source Patterns

Simple Case

Input Code:

IN -> Redshift_01.sql
CREATE OR REPLACE PROCEDURE procedure1 ()
AS
$$
BEGIN
   RETURN;
END
$$ LANGUAGE plpgsql;

Output Code:

OUT -> Redshift_01.sql
CREATE OR REPLACE PROCEDURE procedure1 ()
RETURNS VARCHAR
LANGUAGE SQL
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "redshift",  "convertedOn": "02/12/2025",  "domain": "test" }}'
AS
$$
BEGIN
  RETURN NULL;
END
$$;

When the procedure has out parameters

SnowConvert returns a variant with parameters set up as output parameters. So, for each return, Snowconvert will add a variant as a return value.

Input Code:

IN -> Redshift_02.sql
CREATE OR REPLACE PROCEDURE procedure1 (OUT output_value VARCHAR)
AS
$$
BEGIN
   RETURN;
END
$$ LANGUAGE plpgsql;

Output Code:

OUT -> Redshift_02.sql
CREATE OR REPLACE PROCEDURE procedure1 (output_value VARCHAR)
RETURNS VARIANT
LANGUAGE SQL
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "redshift",  "convertedOn": "02/12/2025",  "domain": "test" }}'
AS
$$
BEGIN
  RETURN OBJECT_CONSTRUCT('output_value', :output_value);
END
$$;

Known Issues

There are no known issues.

There are no related EWIs.

Last updated