This batch SQL command displays a message or terminates the batch process if the SQL command retrieves or affects at least one record.
The syntax is:
IF SUCCEED {"message" | EXIT};
where message is the message displayed. After displaying the message, the system waits for the user to press Enter or click OK before continuing with the batch file.
If EXIT is used, the system terminates the batch process.
The IF SUCCEED command must be placed after the query statement to which it will apply. If other batch commands are associated with this statement (e.g., DISPLAY, TERSE), IF SUCCEED must be placed after them.
For example:
UPDATE partsupp SET qty=qty*1.25 WHERE sno IN (SELECT sno FROM supplier WHERE city = 'LONDON'); NODISPLAY; IF SUCCEED "Update successful.";
This example updates the partsupp table and displays a message if the UPDATE command updates any record. Processing continues when the user acknowledges the message.