2017-02-03 24 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

相關問題