Skip Headers

Oracle Objects for OLE C++ Class Library
10g Release 1 (10.1)

Part Number B10119-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Feedback

AddTable Method

Applies To

OParameterCollection

Description

This method adds a parameter to a database.

Usage

OParamArray AddTable(const char *name, int iotype, int servertype, int ArraySize, int ElementSize)

OParamArray AddTable(const char *name, int iotype, int serverType, int Dimension, int Size=0, char* object_name = NULL);

Arguments
Description
name
The parameter name.
value
The initial value of the parameter.
iotype
Specifies whether this parameter is an input variable, an output variable, or both. The value should be one of:
OPARAMETER_INVAR // in parameter
OPARAMETER_OUTVAR // out parameter
OPARAMETER_INOUTVAR // in/out parameter
servertype
The Oracle server type of parameter. See the GetServerType method.
ArraySize
Defines the number of elements in the parameter array. The maximum length of the buffer is 32512 bytes. This parameter is used to calculate the maximum buffer length. The valid range for this parameter depends on the VarType parameter as shown:

VarType and Dimension

OTYPE_NUMBER
-Valid range from 1 to 1477

OTYPE_SINT
-Valid range from 1 to 1477

OTYPE_FLOAT
-Valid range from 1 to 1477

OTYPE_UINT
-Valid range from 1 to 1477

OTYPE_VARCHAR2
-Valid range from 1 to 32512. The maximum legal value of Dimension depends on the Size parameter. Size * Dimension should be less than 32512 bytes.

OTYPE_STRING
-Valid range from 1 to 32512. The maximum legal value of Dimension depends on the Size parameter. Size * Dimension should be less than 32512 bytes.

OTYPE_VARCHAR
-Valid range from 1 to 32512. The maximum legal value of Dimension depends on the Size parameter. Size * Dimension should be less than 32512 bytes.

OTYPE_CHARZ
-Valid range from 1 to 32512. The maximum legal value of Dimension depends on the Size parameter. Size * Dimension should be less than 32512 bytes.

OTYPE_CHAR
-Valid range from 1 to 32512. The maximum legal value of Dimension depends on the Size parameter. Size * Dimension should be less than 32512 bytes.

OTYPE_DATE
-Valid range from 1 to 4644.

ElementSize
Defines the size of the array element for character or string type table parameters.
Dimension
Dimension of the array.
object_name
A case-sensitive string containing the name of the Object. This is only required if servertype is OTYPE_OBJECT, OTYPE_VARRAY, and OTYPE_TABLE. It is required for OTYPE_REF when the REF will be used in PL/SQL.

Remarks

These methods attach an OParamArray to an ODatabase. The name argument specifies the name of the parameter. To refer to the value of the OParameter within SQL statements, use :name.

The parameter that is created is referenced by the returned OParamArray object.

Return Value

An OParamArray, which will be open on success, closed on failure.

Example

OSession ses;

ODatabase odb;

long dbopt = 0; //the default is either no option, or the default set

char Msg[255];

char *pCharBuff = NULL;

int empno;

if (ses.Open() != OSUCCESS)

{

AfxMessageBox("session failed to open");

return;

}

odb.Open(ses, "ExampleDb", "scott", "tiger");

if(odb.IsOpen() != TRUE)

{

AfxMessageBox("database failed to open");

return;

}

else

AfxMessageBox("database open succeeded");

OParameterCollection params = odb.GetParameters();

params.Add("ArraySize", 3, OPARAMETER_INVAR, OTYPE_NUMBER);

OParamArray empnoarray = params.AddTable("EMPNOS", OPARAMETER_INVAR, OTYPE_NUMBER, 3);

OParamArray empnamesarray = params.AddTable("ENAMES", OPARAMETER_OUTVAR, OTYPE_VARCHAR2, 3, 10);

// Initialize EMPNOS array elements

empnoarray.SetValue(7698,0);

empnoarray.SetValue(7782,1);

empnoarray.SetValue(7654,2);

if(odb.ExecuteSQL("Begin Employee.GetEmpNamesInArray(:ArraySize, :EMPNOS, :ENAMES); End;" ) != OSUCCESS){

MessageBox("ExecuteSQL failed");

MessageBox(odb.GetServerErrorText());}

else

MessageBox("ExecuteSQL passed");

for (int count=0;count<3;count++){

empnamesarray.GetValue((const char **)&pCharBuff,count) ;

empnoarray.GetValue(&empno,count);

sprintf(Msg, "Emp name for emp#: %d is %s ", empno, pCharBuff);

MessageBox(Msg);

}