Contents IndexWSQL HLI and Visual Basic Part VI.  SQL Anywhere Reference

User's Guide
   Part V. The SQL Anywhere Programming Interfaces
     Chapter 38. The WSQL HLI Interface
      WSQL HLI and REXX

There is a special entry point in the WSQL HLI for OS/2 specifically for REXX that can be called directly from REXX and allows REXX variables to be used in SQL commands as host variables (see "Host variables with WSQL HLI"). This function must be registered by any REXX program that uses WSQL HLI. Put the following statement in your REXX program:

     call RXFUNCADD 'SQLEXEC', 'WSQLCAL2', 'WSQLEXECREXX'

WSQL HLI is very similar to the IBM DB/2 REXX programming interface. START USING DATABASE and STOP USING DATABASE are supported by the wsqlexecrexx entry point. You may wish to register the function a second time to make your REXX program more portable:

     all RXFUNCADD 'SQLDBS', 'WSQLCAL2', 'WSQLEXECREXX'

WSQL HLI only contains a subset of the IBM DB/2 REXX programming interface.

Top of page


Error codes and messages

The REXX interface function returns an error code. The error code is also assigned to the REXX stem variable SQLCA.SQLCODE. See "SQL Anywhere Database Error Messages" for a complete list of error codes. An error message is assigned to the REXX variable SQLMSG.

Top of page


REXX examples

The following short REXX program fetches 10 employees from the sample database using WSQL HLI.

     * WSQL HLI from REXX */
     call RXFUNCADD 'SQLDBS', 'WSQLCAL2', 'WSQLEXECREXX'
     call RXFUNCADD 'SQLEXEC', 'WSQLCAL2', 'WSQLEXECREXX'
     call sqldbs 'START DATABASE MANAGER'
     call sqldbs 'START USING DATABASE SADEMO USER DBA IDENTIFIED BY SQL'
     stmt = "select emp_lname from employee"
     call sqlexec "PREPARE s1 FROM :stmt"
     call CheckSQLError
     call sqlexec "DECLARE c1 CURSOR FOR s1"
     call CheckSQLError
     call sqlexec "OPEN c1"
     call CheckSQLError
     do 10
     /* fetch a row */
     call sqlexec "FETCH c1 INTO :lname:Indlname"
     call CheckSQLError
     say lname Indlname
     end
     call sqlexec "CLOSE c1"
     call CheckSQLError
     call sqldbs "STOP USING DATABASE ALL"
     exit
     CheckSQLError:
     if SQLCA.SQLCODE = 0 then do
         say SQLCA.SQLCODE SQLMSG
     end
     return

There is a more substantial example in the ACCXMP\REXX subdirectory of the SQL Anywhere installation directory (usually C:\SQLANY50).

Top of page


Contents IndexWSQL HLI and Visual Basic Part VI.  SQL Anywhere Reference