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

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

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.