I wrote a procedure as you can see below:
create or replace procedure truncate_test is hour_part char(40); begin <*** Other Parts***> select to_char(sysdate, 'HH24') into hour_part from dual; -- Check the time here if (hour_part >= 16) then execute immediate 'truncate table cust_modern_channel_branch'; end if; <*** Other Parts***> end;
This procedure is a part of an ETL which runs everyday.The aim of this part of the procedure is to check the time
and if it’s after 4:00 PM in the afternoon
, it truncates the table (ETL might reach the truncate part at different hours). I’m using this query to extract the hour part of sysdate select to_char(sysdate, 'HH24')
. The problem is that this query select sysdate from dual
returns this 3:28:43 PM
(I’ve omitted the date part) so the above query returns 15
, but the system clock (bottom right corner) shows 4:08 PM
!!So I’m expecting that the procedure truncates my table when I execute it cause it’s 4:08 PM but sysdate is showing a different time and nothing happens! why is this happening? Why the sysdate and system clock shows different hours?
Thanks in advance