Siebel VB Language Reference > Methods Reference for Siebel VB > ODBC Methods >

ODBC Get Query Results Method


The ODBC Get Query Results method is a Siebel VB method that gets the results of a pending query. It returns a variant that contains one of the following values:

  • The number of rows in the result set or the maxRows requested. Indicates success .
  • -1. Unable to get results, or no results pending .
  • 0. The query did not find any data.

It uses a default value of 0 for any argument that you do not include. This is true for all arguments except for the fetchFirst argument.

Format

SQLRetrieve(connection, destination()[, maxColumns][, maxRows]
[, columnNames][, rowNumbers][, fetchFirst])

The following table describes the arguments that you can use with this method.

Argument
Description

connection

The long integer that the ODBC Open Connection method returns.

destination

A two-dimensional array of type variant. The first index of the array cannot exceed 100.

maxColumns

The number of columns that this method gets in the request. If this number specifies fewer columns than the result contains, then it discards the rightmost result columns until the result fits the size that you specify.

maxRows

The number of rows that this method gets in the request.

columnNames

An integer. If the columnNames argument is not zero, then this method does the following work:

  • Sets the first row of the array to the column names according to how the database schema specifies them.
  • Returns the column names as the first row of the array that you identify in the ref argument.

rowNumbers

An integer. If the rowNumbers argument is not zero, then that this method returns the row names as the first column of the array that you identify in the ref argument. It clears the user array before it gets the results.

fetchFirst

A positive integer that causes the result set that this method repositions to the first row of the database.

If the value in the fetchFirst argument is not zero, then it repositions to the first row. If the database does not support repositioning, then it returns a -1 (negative one) error is returned.

Usage

If you do not include the maxColumns argument or the maxRows argument, then the ODBC Get Query Results method does the following:

  • To determine the maximum number of columns and rows to get, it uses the size of the array that you specify in the destination argument.
  • Attempts to return the entire result set.

To get extra rows, you can set the fetchFirst argument to 0 and use the ODBC Get Query Results method again.

Using the ODBC Get Query Results Multiple Times

In some situations, you can use the ODBC Get Query Results method multiple times until the return value is 0. For example, if the result set includes one of the following items:

  • More rows than the array can contain
  • More rows than the value specified in the maxRows argument
Example

The following example gets information from a data source:

Sub Button_Click
' Declarations

    Dim 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)

   ' Run 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 array

   retcode = 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 Sub

Siebel VB Language Reference Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Legal Notices.