Hello,
I need your help to make a pl sql block to update 2 fields of my table (Order_id and item_id).
I need to use at least cursor, loop and update.
I have the following data:
PREVIOUS:
ORDER_ID ITEM_ID CUSTOMER_ID PRODUCT_ID ACTUAL_PRICE QUANTITY TOTAL ORDER_DAT SHIP_DATE OLD_SYS_REF
---------- ---------- ----------- ---------- ------------ ---------- ---------- --------- --------- -----------------------
3997 1 222 100860 12 08-OCT-00 20-MAR-01 TX-75205-JB:3997-1
3997 2 222 100860 7 08-OCT-00 20-MAR-01 TX-75205-JB:3997-2
4244 3 222 100890 5 08-OCT-00 20-MAR-01 CA-97544-JT:4244-3
4244 2 222 100870 500 08-OCT-00 20-MAR-01 CA-97544-JT:4244-2
4244 1 222 100861 100 08-OCT-00 20-MAR-01 CA-97544-JT:4244-1
4260 2 222 100870 500 20-MAR-01 25-MAR-01 CA-97544-JT:4244-2
4260 1 222 100861 100 20-MAR-01 25-MAR-01 CA-97544-JT:4244-1
I need the maximum id of an existing table to start the new order_id->
select max(order_id) from sales_order;
MAX(ORDER_ID)
-------------
621
I need to change the order_id, I will give the same order_id for all the order_id for the same customer_id with the same
order_date and Ship_date.
I need at final to have to data in the good chronological order for the order_date.
After:
ORDER_ID ITEM_ID CUSTOMER_ID PRODUCT_ID ACTUAL_PRICE QUANTITY TOTAL ORDER_DAT SHIP_DATE OLD_SYS_REF
---------- ---------- ----------- ---------- ------------ ---------- ---------- --------- --------- -----------------------
622 1 222 100860 12 08-OCT-00 20-MAR-01 TX-75205-JB:3997-1
622 2 222 100860 7 08-OCT-00 20-MAR-01 TX-75205-JB:3997-2
622 3 222 100890 5 08-OCT-00 20-MAR-01 CA-97544-JT:4244-3
622 4 222 100870 500 08-OCT-00 20-MAR-01 CA-97544-JT:4244-2
622 5 222 100861 100 08-OCT-00 20-MAR-01 CA-97544-JT:4244-1
623 1 222 100870 500 20-MAR-01 25-MAR-01 CA-97544-JT:4244-2
623 2 222 100861 100 20-MAR-01 25-MAR-01 CA-97544-JT:4244-1
For all the same order_id, I'll same the item_id from 1 to 3 if there is 3 items,....
I really don't know how to process and I need to have finish it tomorrow :(
Start Free Trial