Skip Headers

Oracle® Objects for OLE C++ Class Library Developer's Guide
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

SetValue Method

Applies To

OField

OParameter

OValue

Description

This method sets the value of the object. Setting an OField value also sets a database field value.

Usage

oresult SetValue(const OValue &val)

oresult SetValue(int val)

oresult SetValue(long val)

oresult SetValue(double val)

oresult SetValue(const char *val)

oresult SetValue(const char *val, int len)

oresult SetValue(const void __huge *blobp, long bloblen) (OField only)

oresult SetValue(const OBlob &val)

oresult SetValue(const OClob &val)

oresult SetValue(const OBfile &val)

oresult SetValue(const ORef &val)

oresult SetValue(const OObject &val)

oresult SetValue(const OCollection &val)

Arguments
Description
val
The new value, in one of a variety of types.
blobp
Pointer to the long data to be placed in the field.
bloblen
The number of bytes from blobp to be placed into the field.
Remarks

These methods set the value of the object.

If the new value is passed in as a string, the object copies the string. The caller does not have to retain the string.

Setting the value invalidates any pointers returned from a previous (const char *) cast.

Setting the value of an OField is legal only when the related dynaset has an edit mode of ODYNASET_EDIT_NEWRECORD (from an AddNewRecord or DuplicateRecord) or ODYNASET_EDIT_EDITING (from StartEdit). Setting the value of an OField sets the value of the field the OField is on, in the current record, in the Oracle database.

The last method (the one with the blobp argument) is used to place more than 64K bytes of data into a long or long raw field. It is valid only for fields with server types of OTYPE_LONG or OTYPE_LONGRAW. Such fields can also have their values set with (const char *), but only up to 64K.

Return Value

An oresult indicating whether the operation succeeded (OSUCCESS) or not (OFAILURE).

Example

Set the values of some objects:

// open a database

ODatabase odb("ExampleDB", "scott", "tiger");

// add a parameter to odb

OParameterCollection params = odb.GetParameters();

OParameter deptp;

deptp = params.Add("dno", 20, OPARAMETER_INVAR, OTYPE_NUMBER);

// set the parameter's value to 10 instead

deptp.SetValue(10);

// use it

ODynaset empdyn;

oresult ores;

empdyn.Open(odb, "select * from emp where deptno = :dno");

// get an OField on the salary field

OField salf = empdyn.GetField("sal");

// and change the salary of the current record

empdyn.StartEdit();

salf.SetValue(4500.0);

empdyn.Update();