This statement can only be used in the triggered action of a trigger.
None required.
SIGNAL SQLSTATE sqlstate-string-constant
(diagnostic-string-constant)
A character string of up to 70 bytes that describes the error condition. If the string is longer than 70 bytes, it is truncated.
Consider a trigger for an order system that allows orders to be recorded in an ORDERS table (ORDERNO, CUSTNO, PARTNO, QUANTITY) only if there is sufficient stock in the PARTS tables. When there is insufficient stock for an order, SQLSTATE '75001' is returned along with an appropriate error description.
CREATE TRIGGER CK_AVAIL
NO CASCADE BEFORE INSERT ON ORDERS
REFERENCING NEW AS NEW_ORDER
FOR EACH ROW MODE DB2SQL
WHEN (NEW_ORDER.QUANTITY > (SELECT ON_HAND FROM PARTS
WHERE NEW_ORDER.PARTNO = PARTS.PARTNO))
BEGIN ATOMIC
SIGNAL SQLSTATE '75001' ('Insufficient stock for order');
END
sqlstate-string-constant
Represents an SQLSTATE. It must be a character string constant with exactly 5 characters that follow these rules for application-defined SQLSTATEs: