Rational Developer for System z
COBOL for Windows, Version 7.5, Programming Guide


Example: passing pointers as arguments in ODBC calls

The following example program fragment shows how to invoke the SQLAllocHandle function.

. . .
WORKING-STORAGE SECTION.
    COPY ODBC3.
    . . .
01  SQL-RC     COMP-5    PIC S9(4).
01  Henv       POINTER.
. . .
PROCEDURE DIVISION.
. . .
    CALL “SQLAllocHandle”
        USING
        By VALUE     sql=handle-env
                     sql-null-handle
        By REFERENCE Henv
        RETURNING      SQL-RC
    IF SQL-RC NOT = (SQL-SUCCESS or SQL-SUCCESS-WITH-INFO)
        THEN
            DISPLAY “SQLAllocHandle failed.”
            . . .
        ELSE
        . . .

You can use any one of the following examples for calling the SQLConnect function.

Example 1

. . .
CALL “SQLConnect” USING BY VALUE     ConnectionHandle
                        BY REFERENCE ServerName
                        BY VALUE     SQL-NTS
                        BY REFERENCE UserIdentifier
                        BY VALUE     SQL-NTS
                        BY REFERENCE AuthentificationString
                        BY VALUE     SQL-NTS
                  RETURNING          SQL-RC
. . .
Example 2

. . .
SET Ptr-to-ServerName             TO ADDRESS OF ServerName
SET Ptr-to-UserIdentifier         TO ADDRESS OF UserIdentifier
SET Ptr-to-AuthentificationString TO ADDRESS OF AuthentificationString
CALL “SQLConnect” USING BY VALUE     ConnectionHandle
                                     Ptr-to-ServerName
                                     SQL-NTS
                                     Ptr-to-UserIdentifier
                                     SQL-NTS
                                     Ptr-to-AuthentificationString
                                     SQL-NTS
                  RETURNING          SQL-RC
. . .
Example 3

. . .
CALL “SQLConnect” USING BY VALUE     ConnectionHandle
                                     ADDRESS OF ServerName
                                     SQL-NTS
                                     ADDRESS OF UserIdentifier
                                     SQL-NTS
                                     ADDRESS OF AuthentificationString
                                     SQL-NTS
                  RETURNING          SQL-RC
. . .

In Example 3, you must define Servername, UserIdentifier, and AuthentificationString as level-01 items in the LINKAGE SECTION.

The BY REFERENCE or BY VALUE phrase applies to all arguments until another BY REFERENCE, BY VALUE, or BY CONTENT phrase overrides it.


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)