Oracle SQL, PLSQL, APEX How To's by Dr. S. Raghunathan - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

----------------             --------

 

bank account BANK ACCOUNT

 

Here, new  word select is found, It is another  command word like CREATE, ALTER    SELECT means pick records, Select followed by column names  and  FROM is the must word to decide and should be followed with << table name >> ,

Another business rule needs to be incorporated in the same trigger, At the time of inserting new record, Ledger-code should be generated and

inserted in the Ledger code, Ledger Code length is 10,

 

Report Code

Ledger-Sequence

Group Code

 

B

S

-

0

0

0

1

-

0

0

 

 

 

How to use before insert or update trigger CREATE OR REPLACE TRIGGER "RAAK-ledger-MASTER-BI" BEFORE

INSERT OR UPDATE on "RAAK-LEDGER-MASTER" for each row

begin

if :NEW,"RECORD-ID" IS NULL THEN

:NEW,"RECORD-ID" :=

TO-NUMBER(SYS-GUID(),'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');

select :NEW,"REPORT-TYPE" II'-'IILPAD(LEDGER-SEQ,NExTVAL,4,'0')II'-00' int:NEW,"LEDGER-CODE" from dual;

END IF;

:NEW."LEDGER_NAME" : UPPER(:NEW."LEDGER_NAME");

:NEW."REPORT_TYPE") : UPPER(:NEW."REPORT_TYPE"); end;