17.05 - Example: Stored Procedures and Embedded SQL Input and Output Arguments - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Release Date
January 2021
Content Type
Programming Reference
Publication ID
B035-1146-175K
Language
English (United States)

Consider the stored procedure spSample2. The arguments can be specified in the following format:

Format 1:

  • In a stored procedure:
         SET AppVar2 = 30 + AppVar3;
         SET AppVar3 = 40;
         CALL spSample1(:AppVar1, :AppVar2, :AppVar3);
  • In a C program using embedded SQL:
         AppVar2 = 30 + AppVar3;
         AppVar3 = 40;
         EXEC SQL CALL spSample1(:AppVar1, :AppVar2, :AppVar3);

The values specified for AppVar2 and AppVar3 are passed as arguments to p2 and p3, respectively. When the stored procedure execution completes, the output parameter values are returned in AppVar1 and AppVar2. ACTIVITY_COUNT is set to 1.

Format 2:

  • In a stored procedure:
         SET AppVar2 = 30 + AppVar3;
         SET AppVar3 = 40;
         CALL spSample1(:AppVar1, :AppVar2, :AppVar3 + 3);
  • In a C program using embedded SQL:
         AppVar2 = 30 + AppVar3;
         AppVar3 = 40;
         EXEC SQL CALL spSample1(:AppVar1, :AppVar2, :AppVar3 + 3);

The values for p2 and p3 are AppVar2 and (3 + AppVar3), respectively. When the stored procedure execution completes, the output parameter values are returned in AppVar1 and AppVar2. ACTIVITY_COUNT is set to 1.