Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Look ahead 2 rows
The following is an example of a plsql procedure which "looks ahead" two rows on the user_table view. It is not very useful, but shows how you might use plsql index-by tables to do what you want.
As others have mentioned, doing this only with sql may not be possible.
create or replace procedure lookahead
is
cursor c is
select table_name
from user_tables;
type mytable is table of varchar2(30) index by binary_integer;
tab mytable;
begin
for cur in c loop
tab(tab.count) := cur.table_name;
end loop;
if tab.count > 0 then
for i in tab.first .. tab.last loop if i > 2 then dbms_output.put_line('Table: ' || tab(i-2) || ' adjacent table ' || tab(i)); end if; end loop; else dbms_output.put_line('no data');
Frank Hubeny
craibuc wrote:
> When processing a cursor, I need to look ahead two rows from the
> current row to compare values. What's the syntax for doing this?
>
> Craig Buchanan
> Cogniza, Business Intelligence Specialists
> www.cogniza.com
> +1.612.824.5858
>
> -----------------------------------------------------------
>
> Got questions? Get answers over the phone at Keen.com.
> Up to 100 minutes free!
> http://www.keen.com
Received on Wed Jul 12 2000 - 00:00:00 CDT
![]() |
![]() |