在双 table 预期的位置找不到 FROM 关键字

FROM keyword not found where expected with dual table

我正在尝试 运行 简单的匿名 pl/sql,它失败了,当我 运行 它作为查询时,它工作正常

declare
     c_minute number;
      c_hour number;
begin
     select
          case when (17 - to_char(systimestamp,'HH24')) < 0 then 0 else 17 - to_char(systimestamp,'HH24') end hours into c_hour,
          case when (17 - to_char(systimestamp,'HH24')) < 0 then 0 else 60 - to_char(systimestamp,'MI') end into c_minute
        from dual;
end;

错误

ORA-06550: line 7, column 103:
PL/SQL: ORA-00923: FROM keyword not found where expected
ORA-06550: line 5, column 6:
PL/SQL: SQL Statement ignored

你的语法有问题。

将多列选入变量是这样的:

select col1, col2, col3 into v1, v2, v3 from . . .

试试这个:

declare
     c_minute number;
      c_hour number;
begin
     select
          case when (17 - to_char(systimestamp,'HH24')) < 0 then 0 else 17 - to_char(systimestamp,'HH24') end hours ,
          case when (17 - to_char(systimestamp,'HH24')) < 0 then 0 else 60 - to_char(systimestamp,'MI') end 
          into c_hour,c_minute
        from dual;
end;