DOCUMENTS 5 - PortalScripting API
Public Member Functions | List of all members
DBResultSet Class Reference

The DBResultSet class contains a list of resultset rows. More...

Public Member Functions

boolean close ()
 Close the DBResultSet and free the server ressources. More...
 
boolean getBool (int colNo)
 Read the indicated column of the current row of the DBResultSet as a boolean value. More...
 
String getColName (int colNo)
 Function returns the name of a column. More...
 
Date getDate (int colNo)
 Read the indicated column of the current row of the DBResultSet as a Date object. More...
 
float getFloat (int colNo)
 Read the indicated column of the current row of the DBResultSet as a float value. More...
 
int getInt (int colNo)
 Read the indicated column of the current row of the DBResultSet as an integer value. More...
 
String getLastError ()
 Function to get the description of the last error that occurred. More...
 
int getNumCols ()
 Function returns the amount of columns of the DBResultSet. More...
 
String getString (int colNo)
 Read the indicated column of the current row of the DBResultSet as a String. More...
 
Date getTimestamp (int colNo)
 Read the indicated column of the current row of the DBResultSet as a Date object including the time. More...
 
String getUCString (int colNo)
 Read the indicated column of the current row of the DBResultSet on a x64/UTF-8 DOCUMENTS as a String. More...
 
boolean next ()
 Move the resultset pointer to the next row of the DBResultSet. More...
 

Detailed Description

The DBResultSet class contains a list of resultset rows.

You need an active DBConnection object to execute an SQL query which is used to create a DBResultSet.

Note
Important: Please consider the restrictions according the order of reading of the columns of the DBResultSet. Read the example!

The following data types for database columns will be supported:

SQL data typeaccess method
SQL_INTEGERgetInt(), getString()
SQL_SMALLINTgetInt(), getString()
SQL_BIGINTgetInt(), getString()
SQL_FLOATgetFloat(), getInt(), getString()
SQL_DECIMALgetFloat(), getInt(), getString()
SQL_NUMERICgetFloat(), getInt(), getString()
SQL_BITgetBool(), getString()
SQL_TIMESTAMPgetTimestamp(), getString()
SQL_DATEgetDate(), getString()
SQL_GUIDgetString()
SQL_VARCHARgetString()
SQL_CHARgetString()
all other typesgetString()
Example:
// create DB-Connection to ODBC-64 Datasource "Nordwind"
var myDB = new DBConnection("odbc", "Nordwind");
if (myDB && myDB.getLastError() == null)
{
var myRS = myDB.executeQuery("SELECT Nachname, Vorname FROM Personal");
if (myRS)
{
// read all persons from the result set
while (myRS.next())
{
var fullName = myRS.getString(0) + ", " + myRS.getString(1);
// var fullName = myRS.getString(1) + ", " + myRS.getString(0); // Fails, because you must read the columns in the correct order!
// var fullName = myRS.getString(0) + ", " + myRS.getString(0); // Fails, because it is not allowed to read a value twice!
util.out(fullName);
}
// Important: free resource!
myRS.close()
}
else
util.out("Error in SELECT statement: " + myDB.getLastError());
// Important: free resource!
myDB.close();
}
else
util.out("Error connection the database: " + myDB.getLastError())
Since
ELC 3.50 / otrisPORTAL 5.0
DOCUMENTS 5.0c HF1 (support for SQL_GUID)
See also
DBConnection

Member Function Documentation

◆ close()

boolean DBResultSet::close ( )

Close the DBResultSet and free the server ressources.

Note
It is strongly recommanded to close each DBResultSet object you have created, since database connections and resultsets are so-called expensive ressources and should be used carefully.
Returns
true if successful, false in case of any error
Since
ELC 3.50 / otrisPORTAL 5.0
See also
DBConnection.close()

◆ getBool()

boolean DBResultSet::getBool ( int  colNo)

Read the indicated column of the current row of the DBResultSet as a boolean value.

Parameters
colNointeger value (zero based) indicating the desired column of the current row of the DBResultSet
Returns
boolean value representing the indicated column of the current row
Since
ELC 3.50 / otrisPORTAL 5.0

◆ getColName()

String DBResultSet::getColName ( int  colNo)

Function returns the name of a column.

Parameters
colNointeger value (zero based) indicating the desired column
Returns
Column name as String
Since
DOCUMENTS 5.0

◆ getDate()

Date DBResultSet::getDate ( int  colNo)

Read the indicated column of the current row of the DBResultSet as a Date object.

Note
The return value will be null if the content of the indicated column cannot be converted to a Date object.
Parameters
colNointeger value (zero based) indicating the desired column of the current row of the DBResultSet
Returns
Date object representing the indicated column of the current row or NULL if is null-value
Since
ELC 3.50 / otrisPORTAL 5.0
Note
every value of a DBResultSet can only be read one time and in the correct order!

◆ getFloat()

float DBResultSet::getFloat ( int  colNo)

Read the indicated column of the current row of the DBResultSet as a float value.

Note
The return value will be NaN if the content of the indicated column cannot be converted to a float value.
Parameters
colNointeger value (zero based) indicating the desired column of the current row of the DBResultSet
Returns
float value representing the indicated column of the current row or NULL if is null-value
Since
ELC 3.50 / otrisPORTAL 5.0
Note
every value of a DBResultSet can only be read one time and in the correct order!

◆ getInt()

int DBResultSet::getInt ( int  colNo)

Read the indicated column of the current row of the DBResultSet as an integer value.

Note
The return value will be NaN if the content of the indicated column cannot be converted to an integer value.
Parameters
colNointeger value (zero based) indicating the desired column of the current row of the DBResultSet
Returns
integer value representing the indicated column of the current row or NULL if is null-value
Since
ELC 3.50 / otrisPORTAL 5.0
Note
every value of a DBResultSet can only be read one time and in the correct order!

◆ getLastError()

String DBResultSet::getLastError ( )

Function to get the description of the last error that occurred.

Returns
Text of the last error as String
Since
ELC 3.50 / otrisPORTAL 5.0
See also
DocFile.getLastError()

◆ getNumCols()

int DBResultSet::getNumCols ( )

Function returns the amount of columns of the DBResultSet.

Returns
Column count as int
Since
DOCUMENTS 5.0

◆ getString()

String DBResultSet::getString ( int  colNo)

Read the indicated column of the current row of the DBResultSet as a String.

Parameters
colNointeger value (zero based) indicating the desired column of the current row of the DBResultSet
Returns
String representing the indicated column of the current row or NULL if is null-value
Since
ELC 3.50 / otrisPORTAL 5.0
Note
x64/UTF-8 DOCUMENTS version: since DOCUMENTS 4.0a HF2 the method transcode the fetched data to UTF-8
every value of a DBResultSet can only be read one time and in the correct order!

◆ getTimestamp()

Date DBResultSet::getTimestamp ( int  colNo)

Read the indicated column of the current row of the DBResultSet as a Date object including the time.

Note
The return value will be null if the content of the indicated column cannot be converted to a Date object.
Parameters
colNointeger value (zero based) indicating the desired column of the current row of the DBResultSet
Returns
Date object (including time) representing the indicated column of the current row or NULL if is null-value
Since
ELC 3.50 / otrisPORTAL 5.0
Note
every value of a DBResultSet can only be read one time and in the correct order!

◆ getUCString()

String DBResultSet::getUCString ( int  colNo)

Read the indicated column of the current row of the DBResultSet on a x64/UTF-8 DOCUMENTS as a String.

Parameters
colNointeger value (zero based) indicating the desired column of the current row of the DBResultSet
Returns
String representing the indicated column of the current row or NULL if is null-value
Since
DOCUMENTS 4.0
Deprecated:
since DOCUMENTS 4.0a HF2 use DBResultSet.getString() instead
Note
every value of a DBResultSet can only be read one time and in the correct order!

◆ next()

boolean DBResultSet::next ( )

Move the resultset pointer to the next row of the DBResultSet.

The method must be called at least once after retrieving a DBResultSet, because the newly created object does not point to the first result row but to BOF (beginning of file).

Returns
true if the DBResultSet now points to the next row, false if there is no further result row
Since
ELC 3.50 / otrisPORTAL 5.0
Note
every value of a DBResultSet can only be read one time and in the correct order!

This documentation refers DOCUMENTS 5.0e (2105).
Created at 11-09-2019. - © 1998-2019 otris software AG, Königswall 21, D-44137 Dortmund. support@otris.de