Wednesday, February 3, 2021

How to increment time in Oracle Database SQL using cursor loop

 show parameter nls_date_format 

alter session set nls_date_format='DD-MON-RR HH24:MI:SS';

create table attime
(
ID                                                                                                                 VARCHAR2(6),
ITIME                                                                                                              VARCHAR2(20)
)

declare
cursor c1 is select emp_id from hrm.emp_mast ;
x number:=1;
begin
for cr in c1 loop
insert into attime(id,itime)
values(cr.emp_id,(to_date('10-AUG-19 09:00:00','DD-MON-RR HH24:MI:SS') +x/24/60/60));
x:=x+1;
end loop;
end;


//

declare
cursor c1 is select emp_id from hrm.emp_mast ;
x number:=1;
begin
for cr in c1 loop
insert into attime(id,itime)
values(cr.emp_id,to_char(to_date(to_char(to_date('09:00:00','HH24:MI:SS') +x/24/60/60),'DD-MON-RR HH24:MI:SS'),'HH24:MI:SS'));
x:=x+1;
end loop;
end;
/




No comments:

Post a Comment

To generate a PDF using JavaScript in Oracle APEX from a collection

  To generate a PDF using JavaScript in Oracle APEX from a collection, you can follow these steps: 1. Create a button or link on your APEX p...