• <legend id='jCe7H'><style id='jCe7H'><dir id='jCe7H'><q id='jCe7H'></q></dir></style></legend>

        <bdo id='jCe7H'></bdo><ul id='jCe7H'></ul>

    1. <tfoot id='jCe7H'></tfoot>

        <i id='jCe7H'><tr id='jCe7H'><dt id='jCe7H'><q id='jCe7H'><span id='jCe7H'><b id='jCe7H'><form id='jCe7H'><ins id='jCe7H'></ins><ul id='jCe7H'></ul><sub id='jCe7H'></sub></form><legend id='jCe7H'></legend><bdo id='jCe7H'><pre id='jCe7H'><center id='jCe7H'></center></pre></bdo></b><th id='jCe7H'></th></span></q></dt></tr></i><div id='jCe7H'><tfoot id='jCe7H'></tfoot><dl id='jCe7H'><fieldset id='jCe7H'></fieldset></dl></div>
      1. <small id='jCe7H'></small><noframes id='jCe7H'>

        带有序列和触发器的 oracle 自动增量无法正常工作

        oracle autoincrement with sequence and trigger is not working correctly(带有序列和触发器的 oracle 自动增量无法正常工作)

          • <bdo id='MfKkz'></bdo><ul id='MfKkz'></ul>

          • <tfoot id='MfKkz'></tfoot>
              <i id='MfKkz'><tr id='MfKkz'><dt id='MfKkz'><q id='MfKkz'><span id='MfKkz'><b id='MfKkz'><form id='MfKkz'><ins id='MfKkz'></ins><ul id='MfKkz'></ul><sub id='MfKkz'></sub></form><legend id='MfKkz'></legend><bdo id='MfKkz'><pre id='MfKkz'><center id='MfKkz'></center></pre></bdo></b><th id='MfKkz'></th></span></q></dt></tr></i><div id='MfKkz'><tfoot id='MfKkz'></tfoot><dl id='MfKkz'><fieldset id='MfKkz'></fieldset></dl></div>

              <small id='MfKkz'></small><noframes id='MfKkz'>

                <legend id='MfKkz'><style id='MfKkz'><dir id='MfKkz'><q id='MfKkz'></q></dir></style></legend>

                  <tbody id='MfKkz'></tbody>

                  本文介绍了带有序列和触发器的 oracle 自动增量无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这是我的问题我有这段代码可以在oracle数据库中创建一个自动增量变量:

                  here is my problemI have this code to make an autoincrement variable in oracle database:

                  CREATE TABLE Korisnici
                      (
                          id_korisnika number PRIMARY KEY,
                          ime_korisnika varchar2(200),
                          prezime_korisnika varchar2(200),
                          broj_telefona varchar2(30),
                          adresa_korisnika varchar2(400)
                      )
                      /
                  
                  create sequence test_seq
                  start with 1 
                  increment by 1;
                  
                  CREATE OR REPLACE TRIGGER test_trigger
                  BEFORE INSERT ON Korisnici FOR EACH ROW
                  BEGIN
                    SELECT test_seq.NEXTVAL
                    INTO :NEW.id_korisnika
                    FROM DUAL;
                  END;
                  /
                  

                  如果我从头开始一切都很好,我的数字为 1,2,3,4....我关闭程序,再次打开,oracle 数据库连接再次启动.我再添加一个输入,我有像 20、21、22、23 这样的数字......我把程序放在我的 android 上并从不同的设备连接,当我输入一个用户时,我有 30,31,33,34...

                  If I start from begining everything works great, I have numbers as 1,2,3,4.... I close the program, open it again, so oracle database connection is once again started. I add one more input and I have numbers like 20,21,22,23... I put program on my android and connect from different device, when I input one user I have 30,31,33,34...

                  为什么会这样?以及如何修复它?

                  Why is this happening? And how to fix it?

                  谢谢

                  这是我从数据库读取数据的过程

                  Here is my proc for reading data from database

                  CREATE OR REPLACE PROCEDURE Citanje_korisnika( p_rc OUT SYS_REFCURSOR )
                  AS
                  BEGIN
                    OPEN p_rc
                     FOR SELECT *
                           FROM Korisnici;
                  END;
                  

                  我是 oracle 数据库的新手.

                  I am a bit of newbie in oracle database.

                  推荐答案

                  使用 NOCACHE 指定 SEQUENCE 将停止一次缓存 20 个数字的会话并提供帮助.

                  Specifying the SEQUENCE with NOCACHE will stop a session caching 20 numbers at a time and help.

                  create sequence test_seq
                  start with 1 
                  increment by 1
                  NOCACHE;
                  

                  但是,如果您希望获得一个完全连续的序列,这很难实现 - 如果(例如)回滚插入,则从序列中获取的数字将丢失".

                  However, if you're hoping for a completely contiguous sequence this is very difficult to achieve - numbers taken from the sequence are "lost" if (for example) an insert is rolled back.

                  根据您的评论,我想知道您是否忘记了 COMMIT?

                  Based on your comment, I wonder if you're forgetting to COMMIT?

                  这篇关于带有序列和触发器的 oracle 自动增量无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Accessing another user#39;s table within an Oracle Stored Procedure(在 Oracle 存储过程中访问另一个用户的表)
                  Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)(超出最大存储过程、函数、触发器或视图嵌套级别(限制 32))
                  How to View Oracle Stored Procedure using SQLPlus?(如何使用 SQLPlus 查看 Oracle 存储过程?)
                  How to debug stored procedure in VS 2015?(如何在 VS 2015 中调试存储过程?)
                  How to Pass Java List of Objects to Oracle Stored Procedure Using MyBatis?(如何使用 MyBatis 将 Java 对象列表传递给 Oracle 存储过程?)
                  Set the variable result, from query(设置变量结果,来自查询)

                      <tbody id='6gpdP'></tbody>

                  1. <small id='6gpdP'></small><noframes id='6gpdP'>

                    • <bdo id='6gpdP'></bdo><ul id='6gpdP'></ul>
                      <i id='6gpdP'><tr id='6gpdP'><dt id='6gpdP'><q id='6gpdP'><span id='6gpdP'><b id='6gpdP'><form id='6gpdP'><ins id='6gpdP'></ins><ul id='6gpdP'></ul><sub id='6gpdP'></sub></form><legend id='6gpdP'></legend><bdo id='6gpdP'><pre id='6gpdP'><center id='6gpdP'></center></pre></bdo></b><th id='6gpdP'></th></span></q></dt></tr></i><div id='6gpdP'><tfoot id='6gpdP'></tfoot><dl id='6gpdP'><fieldset id='6gpdP'></fieldset></dl></div>

                          <legend id='6gpdP'><style id='6gpdP'><dir id='6gpdP'><q id='6gpdP'></q></dir></style></legend>
                            <tfoot id='6gpdP'></tfoot>