|
-
here's what i'm doing
--create customer table
create table customer (
customer_id number(6),
customer_name varchar2(100),
recently_purchased varchar2(1));
-- describe to see if it is created as required
desc customer
--populate customer table with random values
Begin
For i in 1..10
Loop
Insert into customer(customer_id,customer_name)
values(i, dbms_random.string('U',5));
If mod(i, 10) = 0 then
Commit;
End if;
End loop;
End;
--create cust_products table
create table cust_products
(product_id number (6),
customer_id number(6),
date_purchased date);
--describe to see if table is created as required
desc cust_products
--populate cust_products with custome_id 1 to 10 and dates
Begin
For i in 1..10
Loop
Insert into cust_products
values(10-i,i,add_months('04-nov-09',i));
If mod(i, 10) = 0 then
Commit;
End if;
End loop;
End;
--update customer table as required
Begin
For i in 1..10
Loop
update customer
set recently_purchased = 'N' where (select date_purchased from cust_products where customer_id = i) > '02-Feb-2010' and customer_id =i;
End loop;
End;
i'm worried this doesn't look professional..any suggestions please..the logic is working though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|