Method One,
Just define the "ordinal" as a formula, and set the formula to: Get_block_property (' Block_name ', Current_record) can be implemented, or put this line of statements into the "When-create-record" trigger.
Disadvantage: The line number cannot be refreshed automatically when the increment is deleted.
Method Two,
Add the appropriate code to the block's three triggers:
Key-crerec:
DECLARE Line Number;BEGINLine :=: SYSTEM. Cursor_record; LOOPIF: SYSTEM. Last_record= 'TRUE' Then EXIT; ELSENext_record; : blk.id:=: SYSTEM. Cursor_record+ 1; END IF; ENDLOOP; Go_record (line); Create_record; : blk.id:=: SYSTEM. Cursor_record;END;
Key-delrec:
DECLARE Line Number;BEGINDelete_record; Line:=: SYSTEM. Cursor_record; LOOP:blk.ID:=: SYSTEM. Cursor_record; IF: SYSTEM. Last_record= 'TRUE' Then EXIT; ELSENext_record;END IF; ENDLOOP; Go_record (line);END;
When-create-record:
: blk.id:= : SYSTEM. Trigger_record;
Disadvantage: For a table with a small number of records, when there are many records in table, because of the use of cyclic operation, it will affect efficiency.
To prevent the F11 from being generated by an ordinal, which affects the query, the following conditions can be added before the build:
IF (: SYSTEM. MODE! = ' enter-query ') then
How to implement the automatic numbering (line number) function in Oracle form