Oracle getting started Tutorial: Solve the sequence disconnection problem in the ADF

Source: Internet
Author: User

When the Sequence is defined, if the cache is used, a Sequence jump occurs when the database is closed or down.

To solve the sequence disconnection number in the ADF program, make sure that the Oracle database does not generate a disconnection number.

1. For infrequently used Sequence, you can add NOCACHE in the definition, that is, no cache. In this way, the database will not be disconnected.

2. For frequently-used Sequence, CACHE is used for definition. You can use DBMS_SHARED_POOL to cache keep sequence.

The command is as follows:

  1. ExecDbms_shared_pool.keep (Name=>'Myseq', Flag =>'Q')

Test:

1) DBMS_SHARED_POOL is not set

  1. SQL>Create SequenceMyseq cache 100;
  2. The sequence has been created.
  3. SQL>SelectMyseq. nextvalFromDual;
  4. NEXTVAL
  5. ----------
  6. 1
  7. SQL> conn/AsSysdba
  8. Connected.
  9. SQL>AlterSystem flush shared_pool;
  10. The system has been changed.
  11. SQL> conn hr/hr
  12. Connected.
  13. SQL>SelectMyseq. nextvalFromDual;
  14. NEXTVAL
  15. ----------
  16. 101
2) Set DBMS_SHARED_POOL
  1. SQL> conn/AsSysdba
  2. Connected.
  3. SQL>ExecDbms_shared_pool.keep (Name=>'Hr. myseq', Flag =>'Q');
  4. The PL/SQL process is successfully completed.
  5. SQL>AlterSystem flush shared_pool;
  6. The system has been changed.
  7. SQL> conn hr/hr
  8. Connected.
  9. SQL>SelectMyseq. nextvalFromDual;
  10. NEXTVAL
  11. ----------
  12. 102

3. To avoid the Sequence break generated by clicking the new button in the ADF application, you can use the technique of defining the field type as DBSequence and combining Trigger.

For the method of using DBSequence In the ADF, refer to my other article: summary of the method of using Sequence in the ADF.

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.