Auto Insert with Procedure or trigger [message #55554] |
Fri, 31 January 2003 04:37 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
mangesh
Messages: 28 Registered: May 2002
|
Junior Member |
|
|
HI all ,
I need to write a procedure to insert the the data in to the table
the table structure is as follows :
TABLE BUCKETDETAIL_ALL
(
BUCKETID NUMBER,
STARTDATE DATE,
ENDDATE DATE
)
total records in the table are always 54 ( i.e. count)
value of bucketID is 1 to 54. The the 1st record ( for buckid =1) is always 1 ,3/10/2003,4/14/2003
and reming records should get inserted automatically as per following formula
STARTDATE of BUCKETID n = ENDFDATE of BUCKETID (n-1)
ENDDATE of BUCKETID n = (STARTDATE of BUCKETID n) +7
also BUCKETID get increamented by 1
n=2 till 54
e.g. .....
BUCKETID-----------STARTDATE----------ENDDATE
1-------------------------3/10/2003--------------- 4/14/2003----<-1st record(fix)
2------------------------- 4/14/2003--------------- 4/21/2003---<-2nd record based on 1st record
so on ...till 54 BUCKETID
Pls Help me in
Thanks in Advance
|
|
|
|
Re: Auto Insert with Procedure or trigger [message #55564 is a reply to message #55554] |
Fri, 31 January 2003 09:40 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
mangesh
Messages: 28 Registered: May 2002
|
Junior Member |
|
|
Thkns Mahesh ,
I did it in diff way with ref to ur procedure
create or replace procedure insert_BKTDT_ALL is
strdt DATE;
begin
delete from ODS_BUCKETDETAIL_ALL ;
insert into ODS_BUCKETDETAIL_ALL (ENTERPRISE,BUCKETNAME,BUCKETID,STARTDATE,ENDDATE)
(select 'ICM MP','SCP_WEEKLY_BUCKETS',1,EFFSTARTDATE,EFFSTARTDATE+35 from ODS_PLANMASTER_ALL where planid=1);
select ENDDATE into strdt from ODS_BUCKETDETAIL_ALL where BUCKETID=1;
for i in 2..54 loop
insert into ODS_BUCKETDETAIL_ALL (ENTERPRISE,BUCKETNAME,BUCKETID,STARTDATE,ENDDATE)values
('ICM MP','SCP_WEEKLY_BUCKETS',i,strdt ,strdt+7);
strdt := strdt+7;
commit;
end loop;
end;
/
Many thanks
|
|
|