Example: Specifying a RETURNS or RETURNS STYLE Clause for an OUT Parameter Return Type - Advanced SQL Engine - Teradata Database

SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
qtb1554762060450.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata Vantage™

The first example shows how to use a RETURNS clause when invoking an external stored procedure. The RETURNS clause explicitly specifies a return type of INTEGER for the result_1 OUT parameter.

For this example to be valid, the OUT parameter result_1 must be defined with a data type of TD_ANYTYPE in xsp_1.

     CALL xsp_1(10.25, result_1 RETURNS INTEGER);

The second example shows how to specify a RETURNS STYLE clause when invoking an external stored procedure.

This example refers to table t1, which has the following definition.

     CREATE TABLE t1 (
       int_col     INTEGER,
       varchar_col VARCHAR(40) CHARACTER SET UNICODE);

The RETURNS STYLE clause implicitly specifies a return type of VARCHAR(40) CHARACTER SET UNICODE for the result_1 OUT parameter of xsp_2 because that is the data type for column varchar_col in table t1.

For this example to be valid, the OUT parameter result_1 must be defined with a data type of TD_ANYTYPE in xsp_2.

     CALL xsp_2(10, 'abc', result_1 RETURNS STYLE t1.varchar_col);