ODBC Commands

Overview

Use of ODBC requires knowledge of SQL and installation of the administrative program and driver utilities specific to the database used. The database files to be accessed, must be accessible from a Worldspan workstation. In addition, an ODBC-compliant database with defined control files is necessary.

 

While Worldspan provides the ODBC functionality for ScriptPro Plus subscribers, support for the numerous database and ODBC software products must be directed to the vendor providing these products. Worldspan provides the support for the ScriptPro Plus commands.

 

The SQL extensions for ScriptPro Plus are ODBC SDK2.0 and some miscellaneous support functions to provide the ability to update, query, delete, and process databases of different types in a script. Coupled with existing host connectivity and future use of databases in ScriptPro Plus, these extensions provide a solid foundation for automating many agency tasks.

 

Commands

The following scripting commands are used to interface scripting with a database. Any functions which use an expression to narrow search conditions allow the use of the following operands: AND, NOT, OR, <, >, <=, >=, =, and <>.

 

WSQLCLOSE

Terminates the connection between the script and the database file. If this function has not been called for an opened data source, the database may remain unavailable until the user closes Res Manager.

 

WSQLCOLUMNS

Returns the number of columns in the connected table.

 

WSQLCONNECTTABLE

Follows the WSQLOPEN statement and connects the SQL handle to a particular table within the database. Using an empty string for the table name disconnects the handle from all tables.

 

WSQLDELETE

Deletes a row or rows that match the search criteria from the connected table.

 

WSQLERROR

Returns a string associated with a 0 (WSQL_ERROR) or 2 (WSQL_SUCCESS_WITH_INFO) return code from a previous SQL function. To retrieve multiple errors for a function, call this function multiple times. For each such error, the function returns 3 (WSQL_SUCCESS).

 

WSQLGETCOLUMNINFO

Returns the column identifier and the data type of a column or columns. If there is not an active connected table this function chooses from all columns in the data source.

 

WSQLGETDATA

Returns the first and subsequent rows of data generated by the select statement. The first call to this function after a WSQLSELECT or WSQLSTATEMENT function returns the first row of data returned. Repeated calls return the next and subsequent rows of data until all rows have been depleted. This command should be repeated until it returns a value of 1 (ID_WSQL_NO_DATA_FOUND).

 

WSQLGETTABLES

Returns all the table names within an open database.

 

WSQLINSERT

Adds a new row of data to the connected table.

 

WSQLOPEN

Opens and connects the script to a database file.

 

WSQLROWS

Returns the number of rows affected by the last WSQLINSERT, WSQLDELETE, WSQLUPDATE, or WSQLSTATEMENT function.

 

WSQLSELECT

Returns a number of rows that match the search criteria from the connected table. The WSQLGETDATA function must be called after a successful WSQLSELECT until a RET_CODE value of 0 (ID_WSQL_NO_DATA_FOUND) is received.

 

WSQLSELECTOPEN

Opens and connects the script to a data source, taking input parameters from the end-users. The dialog generated by this function may differ for each database driver. Each data source that is opened with this command must be closed with the WSQLCLOSE command.

 

WSQLSTATEMENT

Executes a passed string as an SQL statement. (Requires a much broader knowledge of SQL syntax.)

 

WSQLUPDATE

Updates a record in the selected table. To change a record without changing the value in every column, use the column's name in place of an actual value.