如何使用 HH:MI 作为变量将 HH:MI 添加到 PLSQL 代码中的 systimestamp

how to add HH:MI to systimestamp in PLSQL code with a HH:MI as variable

我想在 PLSQL 过程中用以下代码中的变量替换“02:00”。

SELECT SYSTIMESTAMP + interval '02:00' HOUR TO MINUTE 
  INTO est_close_date 
FROM DUAL;

将变量定义为小时数,那么你可以这样做:

declare
  l_number_of_hours integer;
  ...
begin
 ...
 l_number_of_hours := 6;

 SELECT SYSTIMESTAMP + interval '1' HOUR * l_number_of_hours
   INTO est_close_date 
 FROM DUAL;
end;

如果您需要更细的粒度,请使用分钟:

declare
  l_number_of_minutes integer;
  ...
begin
 ...
 l_number_of_minutes := 2 * 60 + 30;

 SELECT SYSTIMESTAMP + interval '1' minute * l_number_of_minutes
   INTO est_close_date 
 FROM DUAL;
end;