Oracle Objects for OLE C++ Class Library
Release 9.2

Part Number A95896-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

Feedback

GetValue Method

Applies To

OField

OParameter

Description

This method gets the current value of the object.

Usage

oresult GetValue(OValue *val) const

oresult GetValue(int *val) const

oresult GetValue(long *val) const

oresult GetValue(double *val) const

oresult GetValue(const char **cvalp) const

oresult GetValue(const char **val, int *len) const

oresult GetValue(void __huge *blobp, long bloblen, long *blobread) const (for OField only)

oresult GetValue(ODynaset *odyn) const (for OParameter class of type OTYPE_CURSOR)

oresult GetValue(OBlob *val) const

oresult GetValue(OClob *val) const

oresult GetValue(OBfile *val) const

oresult GetValue(ORef *val) const

oresult GetValue(OObject *val) const

oresult GetValue(OCollection *val) const

Arguments
Description
val
A variable of one of a number of types, which will receive the value.
cvalp
Pointer that will be set to point at a text string.
blobp
A caller-provided buffer that will be filled with data from a long or long raw field.
bloblen
The number of bytes to be read into blobp.
blobread
To be set to the number of bytes that were read into blobp.
Remarks

These methods obtain the current value of the object. Simple data can be extracted into any of the following types: int, long, double, and OValue.

When the value is obtained as a const char *, the pointer cvalp is set to point at memory that is managed by the object. That memory should not be freed by the caller; it will be freed when the object is destroyed, closed, or another GetValue call is made to get a string. The string is null-terminated.

You can read data from a long or long raw field as a string if the length is less than 64K. If the length is greater than 64K (or simply if you want to), you can read the field into a buffer that you provide. The number of bytes that is actually read from the database is returned in the blobread argument. You can use the form of GetValue that read blobs only on fields whose server type is OTYPE_LONGRAW or OTYPE_LONG.

The method attempts to convert from one type to another. For example, asking for the value as an integer when it is a character string with the value "23" will return the integer 23.

The method fails if the data cannot be coerced into the desired type.

For OParameter class of type OTYPE_CURSOR, this method returns a read only dynaset as a ODynaset class. You can treat this dynaset in the same way as any other dynaset object.

Return Value

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

Example

This example is a routine that copies the values from one field (infield) to another (outfield) for all the records in a dynaset.

// open the database

ODatabase odb("t:inetserver", "gopher", "web");

// open the dynaset

ODynaset odyn(odb, "select * from table1");

// Get OField variables on the two fields for transferring values

OField infield = odyn.GetField("infield");

OField outfield = odyn.GetField("outfield");

// declare an OValue variable to hold the values

OValue transferval;

// do the work

while (!odyn.IsEOF())

{ // for every record

// get the value

infield.GetValue(&transferval);

// put the value in the other column

odyn.StartEdit(); // edit this record

outfield.SetValue(transferval);

odyn.Update(); // save the change to the Oracle database

// go to the next record

odyn.MoveNext();

}

/*

Note that we didn't have to worry about the types of infield and outfield (other than the fact that they can go from one to the other) because the OValue variable can hold anything.

*/


 
Oracle
Copyright © 1998, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

Feedback