2017-02-03 60 views
1

我试图运行简单的匿名PL/SQL预期,它失败了,当我运行一个查询,它工作正常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 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 

回答

3

你有一个语法问题。

选择多列到变量是这样的:

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; 
+0

AAH ..所以哑我..谢谢 – Zeus

相关问题