Example: Creating a Procedure with Parameters and Local Variables - Analytics Database - Teradata Vantage

SQL Data Definition Language Syntax and Examples

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
jco1628111346878.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
mdr1472255012272
lifecycle
latest
Product Category
Teradata Vantage™

The following example creates a valid SQL procedure named sp_sample1 with the following parameters and local variables:

Variable Type Variable Name
IN ip
OUT op
local variable var1

Because the parameter type for ip is not specified, it defaults to IN. This procedure does not contain any condition handlers.

    CREATE PROCEDURE sp_sample1(   ip INTEGER, 
                               OUT op INTEGER) 
    BEGIN DECLARE var1 INTEGER;
      SELECT col1 INTO var1 
         FROM tab1 
         WHERE col2 = ip;
      SET op = var1 * 10;
    END;