Example: Stored Procedures and Embedded SQL Input and Output Arguments - Analytics Database - Teradata Vantage

SQL Data Manipulation Language

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-04-05
dita:mapPath
pon1628111750298.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
esx1472246586715
lifecycle
latest
Product Category
Teradata Vantage™

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.