ADDRESS SQL Always returning RC=0
search cancel

ADDRESS SQL Always returning RC=0

book

Article ID: 266721

calendar_today

Updated On:

Products

OPS/MVS Event Management & Automation

Issue/Introduction

Using Address SQL to retrieve items from a table with a where clause like below:

ADDRESS SQL "SELECT ITEM FROM TABLE WHERE LOCATION = 'TEST' 

Say 'RC ' RC

If I inspect the RC variable it is always 0 no matter if the rows were found or not.

 

Environment

Release : 14.0

Resolution

You need to test the value of the SQLCODE variable. Besides the value itself, OPS puts messages in the EDQ when an error occurs.

So, add to your REXX just after the SQL statement:

if sqlcode <> 0 then

      do
       say 'SQLCODE' sqlcode
       pull errmesssage
       say errmessage
      end