我正在尝试执行此查询(在oracle中),但我遇到了一些问题:
SELECT CASE
WHEN deptno = '10' THEN scott.seq.nextval
|| 'next10'
WHEN deptno = '20' THEN scott.seqnextval
|| 'next20'
WHEN deptno = '30' THEN scott.seq.currval
|| 'curr'
END col_1
FROM scott.emp;
我得到了这个结果:
COL_1
----------------------------------------------
191next20
192curr
193curr
194next20
195curr
196curr
197next10
198next20
199next10
200curr
201next20
202curr
203next20
204next10
205next20
206next10
207next10
这就是我认为它们应该是:
COL_1
----------------------------------------------
191next20
192curr
193curr
194next20
194curr
194curr
197next10
198next20
199next10
199curr
201next20
201curr
203next20
204next10
205next20
206next10
207next10
那么,为什么我在得到当前值时获得序列的下一个值,而不仅仅是当案例选择下一个值时?
是的,这可以用plsql脚本完成,但我不能.
谢谢!