Skip Headers
Oracle® Objects for OLE C++ Class Library Developer's Guide
10g Release 2 (10.2)

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

Add Method

Applies To

OParameterCollection

Description

This method adds a parameter to a database.

Usage

OParameter Add(const char *name, const char *value, int iotype, int servertype, char* object_name = NULL)

OParameter Add(const char *name, double value, int iotype, int servertype, char* object_name = NULL)

OParameter Add(const char *name, int value, int iotype, int servertype, char* object_name = NULL)

OParameter Add(const char *name, long value, int iotype, int servertype, char* object_name = NULL)

OParameter Add(const char *name, const OValue &value, int iotype, int servertype, char* object_name = NULL)

OParameter Add(const char *name, const char *value, int len, int iotype, int serverType)

OParameter Add(const char *name, const OBlob &value, int iotype, int servertype)

OParameter Add(const char *name, const OClob &value, int iotype, int servertype)

OParameter Add(const char *name, const OBfile &value, int iotype, int servertype)

OParameter Add(const char *name, const OObject &value, int iotype, int servertype, char* object_name)

OParameter Add(const char *name, const ORef &value, int iotype, int servertype, char* object_name = NULL)

OParameter Addconst char *name, const OCollection &value, int iotype, int servertype, char* object_name)

Arguments

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 // This should be used for input variables only.
  • OPARAMETER_OUTVAR // This should be used for output variables only.
  • OPARAMETER_INOUTVAR // This should be used for variables that are both input and output.
You should be careful to make sure that this value is correct. If you set an
incorrect option, such as OPARAMETER_INOUTVAR for a stored procedure parameter type IN, this can result in errors. In other words OPARAMETER_INOUTVAR means "for IN OUT parameters only". It does not mean that you should use the parameter against one stored procedure that has an IN parameter and then use it in another that has an OUT parameter. In such a case you should use two parameters. Errors caused in this way are rare, but in the case of parameter-related errors, you should verify that the IOTYPE is correct.
servertype The Oracle server type of parameter. See the GetServerType method.
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 OParameter 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 value argument is the initial value of the OParameter. The data type of the parameter is set to be the type of the initial value.

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

Return Value

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

Example

This example adds a parameter to an existing ODatabase (odb) and uses it to open an ODynaset:

// open an ODatabase called odb
ODatabase odb("ExampleDB", "scott", "tiger");
// now add a parameter named ourdeptno to the database
OParameterCollection params = odb.GetParameters();
params.Add("ourdeptno ", 20, OPARAMETER_INVAR, OTYPE_NUMBER);

// now create and open a dynaset using that parameter
ODynaset dyn(odb, "select * from emp where deptno = :ourdeptno");