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

ODBC Save Results to File Method


This Siebel VB method gets the results of a query and stores them in a file. It returns one of the following values:

  • Successful. It returns a variant that contains the number of rows that exist in the result set.
  • Not successful. It returns -1 (negative one).

The arguments must be named arguments. For information about named arguments, see Comments and Call Subroutine Method.

Format

SQLRetrieveToFile(connection, destination[, columnNames][, columnDelimiter])

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 string or string variable that contains the file name and path to this file. This method stores the results in this file.

columnNames

This argument can include one of the following values:

  • Not zero. The first row contains the column headers according to database schema requirements.
  • 0. Does not get the column headers.

The default value is 0.

columnDelimiter

The string this method uses to separate each field in a row. If you do not include the columnDelimiter argument, then it uses a tab character to separate each field.

Example

The following example opens a connection to a data source and saves information to a file:

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)

   'Place the results of the previous query in the file
   'named by filename and put the column names in the file
   'as the first row.
   'The field delimiter is %

      filename = "c:\myfile.txt"
      columnDelimiter = "%"
      retcode = SQLRetrieveToFile(connection: = connection, _
      destination: = filename, columnNames: = 1, _
      columnDelimiter: = columnDelimiter)

      retcode = SQLClose(connection)

End Sub

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