[TOC] [Prev] [Next] [Bottom]

<@BIND>

Syntax

<@BIND NAME=varname [DATATYPE=datatype] [SCOPE=scope] [BINDTYPE=bindtype] [PRECISION=number] [SCALE=number] [BINDNAME=bindname]>

Description

The <@BIND> meta tag is used to pass a value in the Direct DBMS action using the parameter binding capabilities of ODBC or OCI. This meta tag instructs Tango Server to generate the appropriate binding calls based on the assigned data source type. Binding is useful for passing values to, and retrieving values from, stored procedures.

The NAME attribute is the name of a Tango variable to be used for parameter binding. The SCOPE attribute is an optional attribute defining the scope of the variable named in the NAME attribute.

The BINDTYPE attribute can have one of the following values:

Limitations

Since Tango Server does not parse the SQL inside a Direct DBMS action other than to perform the above substitutions, the OUT parameters of one stored procedure call cannot be used as input to another stored procedure call within the same action.

For example, if the same Direct DBMS action specified above also called another function:

CALL UpdatePersonalExpenses(<@VAR premium>);

The value for premium that was calculated by the CalculateMortgagePremium() function would not be available for this stored procedure.


! Caution: Only ODBC v2.0 or above drivers support IN/OUT parameters through the SQLBindParameter() call.If BINDTYPE=IN/OUT is specified for the TIMESTAMP datatype, the Oracle ODBC driver returns an error message. The bind type IN works correctly.


Example

Create a SQL Server stored procedure sp_testproc:

create procedure sp_testproc
@param1 varchar(64) output,
@param2 integer output,
@param3 float output,
@param4 numeric(10,2) output,
@param5 datetime output
as
select @param1 = @param1 + ': param1'
select @param2 = @param2 + 2
select @param3 = @param3 + 3.3
select @param4 = @param4 + 4.4
select @param5 = CONVERT(datetime, getdate())

The preceding stored procedure can be called using this syntax:

{CALL sp_testproc(
<@BIND NAME=Param1 BINDTYPE=IN/OUT BINDNAME=StringParam PRECISION=32>,
<@BIND NAME=Param2 BINDTYPE=IN/OUT DATATYPE=INTEGER>,
<@BIND NAME=Param3 BINDTYPE=IN/OUT DATATYPE=FLOAT SCALE=3>,
<@BIND NAME=Param4 BINDTYPE=IN/OUT DATATYPE=DECIMAL PRECISION=6 SCALE=2>,
<@BIND NAME=Param5 BINDTYPE=IN/OUT DATATYPE=TIMESTAMP>
)}



[TOC] [Prev] [Next] [Bottom]

docs@pervasive.com
Copyright © 1999, Pervasive Software. All rights reserved.