GetValue

Retrieves the value of a column in a cursor or retrieves the value of a session variable.

To get the value of

Use

A column in a cursor

Syntax 1 For PSCursorClass objects

A session variable

Syntax 2 For the PSSessionClass object


Syntax 1 For PSCursorClass objects

Description

Retrieves the value of a column in a cursor.

Applies to

PSCursorClass objects

Syntax

cursorobject.GetValue( field )

Argument

Description

cursorobject

A variable that contains a reference to an instance of PSCursorClass.

field

The name or number of a column in the cursor. If you specify a number, you need to keep in mind that the array of column numbers starts with zero.

For cursors with aggregate functions If your cursor's SQL statement performs a SELECT with an aggregate function, you must specify a column number (not a column name) for field.

Returns

The value of the specified column

Usage

At runtime, GetValue has the following behavior:

Application server

Runtime behavior

ASP

Accesses the named item in the Fields collection of the RecordSet object

JSP

Not supported

For JSP targets, use the GetColumn<DataType> methods instead, where <DataType> is the datatype of the value you want to retrieve.

Examples

Example 1

The following example retrieves the values of the “prod_id” and “prod_name” columns:

myquery = "SELECT products.prod_id, products.prod_name
		FROM DBA.products"; 
mycursor = myconnect.CreateCursor(myquery);
if ( myconnect.GetError() == null )
		{
		for (i=0; (!mycursor.EOF()); i++)
			{
			psDocument.Write(mycursor.GetValue(0) + " " +
				mycursor.GetValue(1));
			psDocument.Write("<BR>");
			mycursor.MoveNext();
			}
		}
else {
		dberror = true;
		}
if ( dberror == true )
		{
		errobj = myconnect.GetError(); 
		str = errobj.GetCode() + " " + errobj.GetMessage();
		psDocument.Write ( str );
		}

Syntax 2 For the PSSessionClass object

Description

Retrieves the value of a session variable.

Applies to

PSSessionClass object

Syntax

psSession.GetValue( propname )

Argument

Description

propname

The name of a session variable

Returns

String. Returns the value of the specified session variable. If the property does not exist, GetValue returns null.

Usage

At runtime, GetValue accesses a user-defined property of the session object.

Examples

Example 2

The following example retrieves the values of the UserID and Password session variables:

userid = psSession.GetValue("UserID");
password = psSession.GetValue("Password");