Example: Input and Output Arguments in ODBC - 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™

Example: Input and Output Arguments in ODBC

The following example describes the usage of the stored procedures specifying input and output arguments in an ODBC application.

Consider the stored procedure spSample2 defined as follows:

     CREATE PROCEDURE spSample2(
       OUT p1   INTEGER,
       INOUT p2 INTEGER,
       IN p3    INTEGER)
      BEGIN
        SET p1 = p3;
        SET p2 = p2 * p3;
      END;

The arguments can be specified in the following format:

     SQLBindParameter(..., 1, SQL_PARAM_INPUT_OUTPUT, ..., SQLINTEGER,      ..., ..., AppVar2, sizeof(AppVar2), ...);
     SQLBindParameter(..., 2, SQL_PARAM_INPUT, ..., SQLINTEGER, ...,      ..., AppVar3, sizeof(AppVar3), ...);

where the second argument in SQLBindParameter() is the question mark number ordered sequentially from left to right, starting at 1.

Executing the stored procedure:

     {
     constchar *request = "CALL spSample2(p1, ?, ?)";
     ...
     ...
     SQLExecDirect(hstmt, request);
     ...
     ...
     }

Retrieving the output parameter values:

     SQLBindCol(..., 1, ..., AppVar1, ..., ...);
     SQLBindCol(..., 2, ..., AppVar2, ..., ...);

where the second argument in the SQLBindCol() is the parameter number of result data, ordered sequentially left to right, starting at 1.