Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL LOOP where statement not matching

Re: PL/SQL LOOP where statement not matching

From: Bosco Ng <boscong_at_leccotech.com>
Date: Sat, 3 May 2003 16:26:45 +0800
Message-ID: <3eb37c70$1@shknews01>


Can it just be a SQL?

Assume the table is

create table parts
(id number,
ship_date date,
quantity number);

And assume the 13 dates all exist in the parts table, so the following query will try to insert a record for each id that does not have that particular date, with quantity 0

insert into parts
select id.id,

         dates.ship_date,
         0

from

(select distinct id from parts) id,
(select distinct ship_date from parts) dates
where not exists (select 'X'

                  from parts b
                  where b.id = id.id
                  and   b.ship_date = dates.ship_date);

If that 13 dates are hardcoded or been stored in just another table, then just replace the dates inline view in the from clause with that table will do. Received on Sat May 03 2003 - 03:26:45 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US