This function should return a value of 1 if the account description is in the table or
zero if it isn’t.
(
Note: If a SELECT statement doesn’t return any data, it throws a
NO_DATA_FOUND exception that your function can handle.)
Hint: Exception error you need to catch is
NO_DATA_FOUND
Write a Select statement which searches for the
Account description.

CREATE OR REPLACE FUNCTION test_glaccounts_description
(
account_description_param VARCHAR2
)
RETURN NUMBER
AS
duplicate_description_var NUMBER;
BEGIN
SELECT 1
INTO duplicate_description_var
FROM general_ledger_accounts
WHERE account_description = account_description_param;
RETURN duplicate_description_var;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RETURN 0;
END;
/

A procedure displayed in SQL Developer

A procedure in the Edit window

A breakpoint that has been set in SQL Developer
Click the Debug button to start debugging…

The dialog box for specifying input parameters

A procedure that’s being stepped through

TRIGGERS

The syntax of the CREATE TRIGGER statement for a table
CREATE [OR REPLACE] TRIGGER trigger_name
{BEFORE|AFTER}
{DELETE|INSERT|UPDATE [OF col_name1 [, col_name2]...]}
[OR {DELETE|INSERT|UPDATE[OF col_name1 [, col_name2]...]}]...
ON table_name
[FOR EACH ROW [WHEN (trigger_condition)]]
pl_sql_block

A trigger that corrects mixed-case state names
CREATE OR REPLACE TRIGGER vendors_before_update_state
BEFORE INSERT OR UPDATE OF vendor_state
ON vendors
FOR EACH ROW
WHEN (NEW.vendor_state != UPPER(NEW.vendor_state))
BEGIN
:NEW.vendor_state := UPPER(:NEW.vendor_state);
END;
/

An UPDATE statement that fires the trigger
UPDATE vendors
SET vendor_state = 'wi'
WHERE vendor_id = 1;
A SELECT statement that shows the new row
SELECT vendor_name, vendor_state
FROM vendors
WHERE vendor_id = 1;
The result set
