Click to See Complete Forum and Search --> : plsql hell (need urgent help)


Stanton
10-13-2000, 11:50 AM
Hi, Ive got the simplest question on earth, hell i should be able to answer it but for some reason it wont work.

I have this line in my plsql program

insert into migrate.apc_call_details
select * from migrate.apc_call_details_07
where rownum between from_row_num and to_row_num;


where from_row_num and to_row_num are variables.

Theses variables are being populated right.

When I get to this insert my plsql program just hangs.

tamilselvan
10-13-2000, 12:56 PM
I do not know there is a bug while using rownum.

Try to use < operator with rownum.

First of all it is not a good idea to use rownum in insert statement.

carp
10-13-2000, 09:46 PM
You cannot use ">" or "BETWEEN" with rownum. However, I would have hoped it would do something a little more graceful than hanging!

If you're sure you really want to use rownum as your search criteria, you could try

insert into migrate.apc_call_details
select * from migrate.apc_call_details_07
where rownum < to_row_num
MINUS
select * from migrate.apc_call_details_07
where rownum < from_row_num;

However, be advised that since this is actually doing two queries plus a sort (due to the MINUS operation), (a) it may take a while to run, depending on the size of your table and (b) the order that rows are returned may differ between queries (hence the questioning of this technique) and you may get anomalous results.