Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference > Siebel VB Language Reference >
SQLRetrieve Function
This custom VB function fetches the results of a pending query on the connection specified by connection and returns the results in the destination() array.
NOTE: Siebel VB SQLxxxx functions are supported for non-Unicode databases only.
Syntax
SQLRetrieve(connection, destination()[, maxColumns][, maxRows]
[, columnNames][, rowNumbers][, fetchFirst])Returns
A variant containing the following values:
Result Returns Success The number of rows in the result set or the maxRows requested Unable to retrieve results, or no results pending -1 No data found by the query 0Usage
If maxColumns or maxRows is omitted, the array size is used to determine the maximum number of columns and rows retrieved, and an attempt is made to return the entire result set. Extra rows can be retrieved by using SQLRetrieve again and by setting fetchFirst to 0. If maxColumns specifies fewer columns than are available in the result, SQLRetrieve discards the rightmost result columns until the results fit the specified size.
When columnNames is nonzero, the first row of the array is set to the column names as they are specified by the database schema. When rowNumbers is nonzero, row numbers are returned in the first column of destination(). SQLRetrieve clears the user's array prior to fetching the results.
When fetchFirst is nonzero, it causes the result set to be repositioned to the first row if the database supports the function. If the database does not support repositioning, the result set -1 error is returned.
If there are more rows in the result set than can be contained in the destination() array or than have been requested using maxRows, the user can make repeated calls to SQLRetrieve until the return value is 0.
CAUTION: This function, as well as the other SQL functions available in Siebel VB, should not be used to query the underlying database. Use the Siebel Object Interfaces to query Siebel data. Use the SQL functions only to query non-Siebel data.
Example
This example retrieves information from a data source.
Sub Button_Click
' DeclarationsDim connection As Long
Dim destination(1 To 50, 1 To 125) As Variant
Dim retcode As long
' open the connection
connection = SQLOpen("DSN = SblTest",outputStr,prompt: = 3)
' Execute the query
query = "select * from customer"
retcode = SQLExecQuery(connection,query)' retrieve the first 50 rows with the first 6 columns of
' each row into the array destination, omit row numbers and
' put column names in the first row of the arrayretcode = SQLRetrieve(connection: = connection, _
destination: = destination, columnNames: = 1, _
rowNumbers: = 0, maxRows: = 50, maxColumns: = 6, _
fetchFirst: = 0)' Get the next 50 rows of from the result set
retcode = SQLRetrieve(connection: = connection, _
destination: = destination, columnNames: = 1, _
rowNumbers: = 0, maxRows: = 50, maxColumns: = 6)' Close the connection
retcode = SQLClose(connection)
End SubSee Also
SQLClose Function
SQLError Function
SQLExecQuery Function
SQLGetSchema Function
SQLOpen Function
SQLRequest Function
SQLRetrieveToFile Function
Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference Published: 18 June 2003 |