Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> INSERT with ORDER BY workaround for Oracle <= 8.1.5 ?
The SQL below works on Oracle 8.1.7, but not Oracle 8.1.5. The problem is the "ORDER BY" clause of the last line. If I remove that line, it works in both cases, but with the wrong meaning for me.
Essentially, I would like to record in a table the order of some rows of a complicated SQL query so I can use it in many future queries.
Update to 8.1.7, you say? I am writing for a product, hence cannot assume our customers are that recent.
My current plan is to change to some sort of PL/SQL FOR loop, but I fear that will be deadly slow.
I saw some answers in previous posts (e.g., http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=380393d0.0%40news1), but they leave me a little unsatisfied or confused.
I also looked around in Oracle docs some without success.
Does Oracle document some workaround for earlier versions? Other ideas?
Dan
create table foo (txt varchar(80))
create table bar (id int, txt varchar(80))
insert into foo (txt) values ('m') insert into foo (txt) values ('a') insert into foo (txt) values ('z')
create sequence foo_seq start with 1 increment by 1 cache 200 order CREATE TRIGGER AUTONUMBER_BAR BEFORE INSERT ON BAR for each row declare pkvalue number; begin select foo_SEQ.nextval into pkvalue from dual; :NEW.id := pkvalue; end ;
update bar set id = null
insert into bar (txt)
select txt
from foo
order by txt
Received on Thu Apr 10 2003 - 16:28:06 CDT
![]() |
![]() |