PSSRXSQL external function


The PSSRXSQL external function sets values according to the SQL statement. You can call PSSRXSQL from REXX exec whenever you need to execute SQL.

In each example that the following table presents, the argument in parentheses is an SQL statement. When PSSRXSQL runs, it sets the variable rc to the return code of the command that ran. The value in the rc variable determines subsequent processing. Using this external PSSRXSQL function, you can perform any SQL statement.

PSSRXSQL external function

SQL statement

Example

Description

OPEN CURSOR

<rc> = pssrxsql("OPEN <cursorName> CURSOR FOR" <sqlStatement>)

Prepare the SQL SELECT statement and open the specified cursor.

FETCH CURSOR

<rc> = pssrxsql("FETCH <cursorName>")

<rc> = pssrxsql("FETCH <cursorName> INTO <v1, v2, . . . vn>")

Fetch the first or next row.

Return SQLCODE = 100 when all rows have been fetched. The first form of the function puts the data into variables whose names are cursorName.columnName. It also puts values into variables like cursorName.n, where n is the column number of the query.

The second form puts values into the specified variables. The maximum length of a variable name is 250 characters. Variable names can contain @, #, $, ¢, ., !, ?,or _.

CLOSE CURSOR

<rc> = pssrxsql("CLOSE <cursorName>")

Close the specified cursor.

EXECUTE

<rc> = pssrxsql(<sqlStatement>)

Prepare and run the SQL statement.

If the statement is SELECT, return no more than one row. The function sets variables as it does for FETCH. If the SELECT statement has no INTO clause, the stem name is always SELECT.

COMMIT

<rc> = pssrxsql("COMMIT")

Commit uncommitted work, and close all open cursors.

ROLLBACK

<rc> = pssrxsql("ROLLBACK")

Back out relational database changes made since the last commit.

Warning

Important

The current version of the PSSRXSQL external function does not support the following items:

  • More than three open cursors at the same time
  • Parameter markers
  • The DESCRIBE command
  • Mixed-case commands
  • LOBs

Commands must be all lowercase or all uppercase. For example, either open or OPEN is acceptable, but oPeN is not valid.



 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC AMI SQL Explorer for Db2 13.1