RAISE_APPLICATION_ERROR
ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated
It raises a custom error with a number in the -20000..-20999 range and your own message text.
How it works
RAISE_APPLICATION_ERROR(num, message [, keep_stack]) stops the current block with an application-defined error that reaches the client as ORA-num plus your text — the way to signal a business-rule violation. num must be between -20000 and -20999. Pass TRUE as the third argument to add to (rather than replace) the existing error stack. Message is limited to about 2048 bytes. Callers can trap it with a named exception bound via PRAGMA EXCEPTION_INIT.
How it works
CREATE OR REPLACE PROCEDURE withdraw(p_acct NUMBER, p_amt NUMBER) AS
v_balance NUMBER;
BEGIN
SELECT balance INTO v_balance FROM accounts WHERE account_id = p_acct FOR UPDATE;
IF p_amt > v_balance THEN
RAISE_APPLICATION_ERROR(-20101,
'Insufficient funds: balance ' || v_balance || ', requested ' || p_amt);
END IF;
UPDATE accounts SET balance = balance - p_amt WHERE account_id = p_acct;
END;
/Related questions
GroundingGenerated
Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.