In Oracle form, how does one implement the automatic number (row number) function?

Source: Internet
Author: User

Method 1,

You only need"Serial number"Define it as a formula and set it:Get_block_property ('block _ name', current_record)This can be done, or put this line of statement into"When-create-record"Trigger.

Disadvantage: the row number cannot be automatically refreshed when adding, modifying, or deleting data.

Method 2,

InBlockAdd the correspondingCode:

Key-crerec:

Declare
Line number;
Begin
Line: =: system. cursor_record;
Loop
If: system. last_record = 'true' then
Exit;
Else
Next_record;
: BLK. ID: =: system. cursor_record + 1;
End if;
End loop;
Go_record (line );
Create_record;
: BLK. ID: =: system. cursor_record;
End;

Key-delrec:

Declare
Line number;
Begin
Delete_record;
Line: =: system. cursor_record;
Loop
: BLK. ID: =: system. cursor_record;
If: system. last_record = 'true' then
Exit;
Else
Next_record;
End if;
End loop;
Go_record (line );
End;
When-create-record:

: BLK. ID: =: system. trigger_record;

Disadvantage: the number of records is small.TableApplicable whenTableWhen many records exist, the efficiency is affected due to the use of loop operations.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.