编写 PL/SQL 序列的验证步骤
我正在为我的一个代码编写启动计划。其中,对于每个步骤,我都必须编写一个验证步骤,该步骤将告诉您部署/更改是否已正确进行。就像如果有一个 alter table 命令来添加新列然后作为验证一样,我将使用 select column_name from table 作为验证步骤。
我正在为我的序列脚本寻找验证步骤。我的序列脚本正在删除旧序列并重新创建它,并更改初始值。假设我的最后一个序列位于 10071 - 新序列将从 100710 开始。
我编写了以下查询
SELECT LAST_NUMBER
FROM all_sequences
WHERE sequence_name = 'SEQNAME';
现在,我的问题是,这会给出新序列还是旧序列的最后一个数字吗?
附: 我不能使用序列 NextValue - 它会导致系统丢失 1 个数字,并会搞乱整个系统。不过,我愿意接受可以自动使用我的 *next_value* 的选项。
I am writing the launch plan for one of my code. In which, for each step i have to write a verification step which will tell if the deployment/change has been made properly. Like if there is an alter table command to add a new column then as a verification, I would be using select column_name from table as verification step.
I am looking for a verification step for my sequence script. My sequence scripts is dropping the old sequence and re-creating it with initial value changed. lets say if my last sequece was on 10071 - the new sequece would start from 100710.
I wrote the following query
SELECT LAST_NUMBER
FROM all_sequences
WHERE sequence_name = 'SEQNAME';
Now, my question is, would that give the last number of my new sequence or the old sequence?
P.S:
I can't use sequence NextValue - it would cause the system to miss 1 number and will mess up the whole system. However, I am open for the options in which my *next_value* can be utlizied, automatically.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
呃...为什么不按照兰迪在评论中的建议尝试一下呢?
Err ... Why not just try it as suggested by Randy in the comments ?
如果您的序列使用缓存(默认),LAST_NUMBER 将不准确
LAST_NUMBER will not be accurate if your sequence uses a cache (which is the default)