Reputation: 349
I have a table- Event_name.
select * from Event_name
I have to truncate the data and insert fresh data daily.
Can someone tell me how to write a stored procedure for truncating and inserting data into table-Event_name?
Upvotes: 0
Views: 10742
Reputation: 13700
The generic approach is
Create procedure proc_name
as
Begin
Truncate table Event_name;
insert into Event_name(col_list)
select col_list from source_table;
End;
Upvotes: 3
Reputation: 172528
Try this:
create or replace procedure myProcedure
AS
BEGIN
execute immediate 'truncate table Event_name';
insert into Event_name select * from Event_name;
END;
Upvotes: 0