Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-02287 sequence number not allowed here

32685Mar 17 2005 — edited Mar 17 2005
Hello

Could someone tell my why I get this error with the following select?
create sequence dt_test_seq start with 1 increment by 1;

create table dt_test_tab (col1 number,col2 number, col3 number);

insert into dt_test_tab values(1,1,1);
insert into dt_test_tab values(1,1,1);
insert into dt_test_tab values(1,2,2);
insert into dt_test_tab values(2,2,3);
insert into dt_test_tab values(2,2,3);

select
	col1,
	col2,
	col3,
	NVL(next_val,LAG(next_val) over(partition by col1,col2 order by col1,col2))
from
	(
	select
		col1,
		col2,
		col3,
		CASE 
			WHEN  row_number() over (partition by col1,col2 order by col1,col2) = 1 THEN
				dt_test_seq.nextval
		END next_val
	FROM
		dt_test_tab
	);
I came across the problem while trying to come up with a single query answer to the post:923997

The inner query works fine but the error comes when it is turned into an inline view and apply a function to the next_val column.

It's more out of curiosity than anything else as the answer that dmitry posted is obviously the right way to do it?

And yes, I am very bored ;-)

David
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 14 2005
Added on Mar 17 2005
4 comments
7,889 views