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

ODBC Run Query Method


The ODBC Run Query method is a Siebel VB method that runs an SQL statement on a connection that the ODBC Open method establishes. It returns the number of columns in the result set for SQL SELECT statements as a variant. The value that it returns depends which of the following statements you use:

  • You use the SELECT statement with UPDATE, INSERT, or DELETE. It returns the number of rows that the statement affected.
  • You use any other SQL statement. It returns 0.

If it cannot run the query on the data source, or if the connection is not valid, then it returns a negative error code.

If there are any pending results on the connection, then it replaces the pending results with the new results.

Format

SQLExecQuery(connection, query)

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

Argument
Description

connection

A long integer that the ODBC Open method returns.

query

A string that contains a valid SQL statement.

Example

The following example performs a query on the 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 © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.