Friday, August 11, 2006
From the Edge:
Managing Selective Messages and ERROR Messages in R:BASE
Section: Programming
Chapter: Running R:BASE Your Way!
Platform: R:BASE 7.5 and V-8 Turbo for Windows
Builds: R:BASE 7.5 (7.5.25.30811 or higher ...)
R:BASE V-8 Turbo (8.0.12.30811 or higher ...)
Background:
SET MESSAGES command either displays or suppresses system
messages. You may set MESSAGES to OFF when ERROR is set ON
to display only -ERROR- messages. The default is ON.
SET ERROR MESSAGES displays or suppresses an error message
when a system -ERROR- occurs. The default is ON.
On June 15, 2001, the official release version of R:BASE
2000 (Version 6.5++), Build: 1.842xRT03, included an
enhancement to selectively turn OFF/ON -ERROR- message(s).
You can selectively turn OFF/ON any message or even an
-ERROR- message in your command file by using the
following command:
SET ERROR MESSAGE Error# OFF
To turn it back ON:
SET ERROR MESSAGE Error# ON
For example, to suppress the <WARNING> No rows exist
or satisfy the specified clause. (2059) error message,
you could use the following command:
SET VARIABLE vRows INTEGER = 0
SET ERROR MESSAGE 2059 OFF
SELECT COUNT(*) INTO vRows INDIC ivRows +
FROM tablename WHERE whereclause ...
SET ERROR MESSAGE 2059 ON
Similarly:
To suppress the -ERROR- tablename is an undefined table
(2038) message:
SET ERROR MESSAGE 2038 OFF
DROP TABLE tablename
CREATE TEMPORARY TABLE tablename ...
SET ERROR MESSAGE 2038 ON
To suppress the -ERROR- viewname is an undefined
view (677) message:
SET ERROR MESSAGE 677 OFF
DROP VIEW viewname
CREATE TEMPORARY VIEW viewname ...
SET ERROR MESSAGE 677 OFF
To suppress the -ERROR- The cursor [cursor] could
not be found (705) message:
SET ERROR MESSAGE 705 OFF
DROP CURSOR c1
SET ERROR MESSAGE 705 ON
DECLARE c1 CURSOR FOR SELECT ... FROM ...WHERE ...
Until now you could only turn OFF up to 5 -ERROR-
messages in any given R:BASE session, and to turn
the error message ON, each one required a separate
command. Also, if you tried to suppress the sixth
-ERROR- message, you would get the -ERROR- Syntax
is incorrect for the command SET (2045) until you
turned the previously turned OFF message back ON.
R:BASE 7.5 and V-8 Turbo for Windows:
Using the SET ERROR MESSAGE #### OFF command, now
you may turn off up to 50 -ERROR- messages in any
given R:BASE 7.5 or V-8 session. Previously, you
could only turn off up to 5 error messages.
Use SET ERROR MESSAGE #### ON command to turn the
-ERROR- message back on.
Use SET ERROR MESSAGE * ON command to turn on all
-ERROR- messages that had been turned off in a
current R:BASE session using the SET ERROR MESSAGE
#### OFF command.
Note:
Any message related to RULES/CONSTRAINTS will not
be suppressed. This is to ensure the data integrity.
New (GETVAL('CheckMessageStatus','####')) Function:
Syntax: (GETVAL('CheckMessageStatus','####'))
Where:
. CheckMessageStatus is the keyword for GETVAL function
. #### is the exact -ERROR- message number
Example:
SET VAR vStatus TEXT = NULL
SET VAR vStatus = (GETVAL('CheckMessageStatus','2059'))
Variable vStatus will return the text value of current
message status (ON/OFF) in a given R:BASE 7.5 or V-8
session.
New (CVAL('OFFMESS')) Function:
Syntax: (CVAL('OFFMESS'))
Where:
OFFMESS is the keyword to return a text string,
separated by a comma, with a list of all turned off
-ERROR- message numbers in a current R:BASE session.
Example:
SET VAR vTurnedOffMessages TEXT = NULL
SET VAR vTurnedOffMessages = (CVAL('OFFMESS'))
Variable vTurnedOffMessages will return a text string,
separated by a comma, with a list of all turned off
-ERROR- messages in a current R:BASE session.
A PDF version of this document is also available at:
From The Edge: http://www.razzak.com/fte
Enjoy and make sure to have fun!
Very Best R:egards,
Razzak.