Oracle Sequence Transactionality

后端 未结 4 1655
感情败类
感情败类 2021-01-04 06:15

I need for a particular business scenario to set a field on an entity (not the PK) a number from a sequence (the sequence has to be a number between min and max

I de

4条回答
  •  爱一瞬间的悲伤
    2021-01-04 06:39

    Unfortunately you have to implement you're 'own wheel' - transactional sequence. It is rather simple - just create the table like sequence_name varchar2, value, min_value number, max_value number, need_cycle char and mess around 'select value into variable from your sequence table for update wait (or nowait - it depends from your scenario)'. After it issue update set value = variable from previous step + 1 where sequence_name = the name of your sequence and issue the commit statement from client side. That's it.

提交回复
热议问题