Implement time window in procedures in Oracle -
the procedure unable execute,i invalid error statement
create or replace procedure test declare current_time1 varchar(10); begin select to_char(systimestamp,'hh:mi.am') current_time1 dual if(current_time1 between '09:00.am' , '05:00.pm')then dbms_output.put_line (current_time1); else dbms_output.put_line ('unable insert'); end if; end;
sql> select sysdate dual; sysdate ------------------- 20.03.2014 18:17:13 sql> create or replace procedure test 2 3 begin 4 5 if sysdate between trunc(sysdate,'dd')+interval '9' hour 6 , trunc(sysdate,'dd')+interval '17' hour 7 8 9 dbms_output.put_line(sysdate); 10 11 else 12 13 dbms_output.put_line ('unable insert'); 14 15 end if; 16 17 end; 18 / sql> exec test unable insert sql> create or replace procedure test 2 3 begin 4 5 if sysdate between trunc(sysdate,'dd')+interval '9' hour 6 , trunc(sysdate,'dd')+interval '19' hour 7 8 9 dbms_output.put_line(sysdate); 10 11 else 12 13 dbms_output.put_line ('unable insert'); 14 15 end if; 16 17 end; 18 / sql> exec test 20.03.2014 18:18:01
p.s.
sql> select trunc(sysdate) + interval '9' hour + interval '15' minute dual; trunc(sysdate)+inte ------------------- 21.03.2014 09:15:00 sql> select trunc(sysdate) + numtodsinterval(9.25,'hour') dual; trunc(sysdate)+numt ------------------- 21.03.2014 09:15:00 sql> select trunc(sysdate) + numtodsinterval(9,'hour')+numtodsinterval(15,'minute') dual; trunc(sysdate)+numt ------------------- 21.03.2014 09:15:00
Comments
Post a Comment