Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Remove rows from a cursor?
Not sure, what exactly you want, but maybe the following helps:
set feedback off
set pages 5000
alter session set nls_date_format = 'dd.mm.yyyy';
create table prod_price (
product varchar2(10),
price number(5,2),
thru date
);
insert into prod_price values
('A', 0.00, to_date('01.01.0001','dd.mm.yyyy'));
insert into prod_price values
('A', 0.10, to_date('28.12.2001','dd.mm.yyyy'));
insert into prod_price values
('A', 0.10, to_date('15.01.2002','dd.mm.yyyy'));
insert into prod_price values
('A', 0.10, to_date('25.01.2002','dd.mm.yyyy'));
insert into prod_price values
('A', 0.15, to_date('20.03.2002','dd.mm.yyyy'));
insert into prod_price values
('A', 0.20, to_date('30.04.2002','dd.mm.yyyy'));
insert into prod_price values
('A', 0.00, to_date('31.12.9999','dd.mm.yyyy'));
select date_from, date_thru,price from (
select lag(thru,1) over (order by thru) date_from, thru date_thru, price
from
prod_price
where product = 'A')
where
date_from between to_date('01.01.2002') and to_date('31.01.2002')
or
date_thru between to_date('01.01.2002') and to_date('31.01.2002');
drop table prod_price;
Rene
> I have a table that contains product prices and end dates as in:
> 1) product: A price: .10 thru: Jan 15
> 2) product: A price: .15 thru: Mar 20
> 3) product: A price: .20 thru: Apr 30
>
> I want to select all rows that contain prices for January. In this
> case, row 1 contains the price for Jan 1 to Jan 15. Row 2 contains
> the price for the remainder of January.
>
> It seems the most efficient way to do this is to select all rows
> where THRU >= Jan 1 and then loop through the rows in a cursor
> and decide which rows are needed. My question is, how can I delete
> rows from the cursor that I don't need or create a new cursor of
> just the rows I want?
>
> Thanks!
-- Recherchen im schweizerischen Handelsregister: http://www.adp-gmbh.ch/SwissCompanies/Search.php3Received on Tue Jul 02 2002 - 15:09:11 CDT
![]() |
![]() |