Oracle Objects for OLE C++ Class Library
Release 9.0.1

Part Number A90172-01

Home

Book List

Contents

Master Index

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

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 below:

VarType
Dimension
OTYPE_NUMBER
Valid range from 1 to 1477
OTYPE_SINT

OTYPE_FLOAT

OTYPE_UINT

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

OTYPE_VARCHAR

OTYPE_CHARZ

OTYPE_CHAR

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);

}


 
Oracle
Copyright © 1996-2001, Oracle Corporation.

All Rights Reserved.

Home

Book List

Contents