我有一個表格,其中的列類型是varchar2,並保存諸如'22:00'或「13:30」之類的數據。 我試圖將該數字與當前時間進行比較,如果當前時間在該時間之前,請選擇數據。Oracle SQL字符串到數字轉換
這裏是我當前的代碼:
select DISTINCT BBT_JOURNEYSTOPS.SERVICE "Service", BBT_JOURNEYSTOPS.STOP_REFERENCE "StopNo",
STOP_NAME "Near", BBT_STOPS.ROAD_NAME "On", BBT_JOURNEYSTOPS.JOURNEYTIME "Duration"
from BBT_JOURNEYSTOPS
inner join BBT_WEEKLYSCHEDULE
on BBT_WEEKLYSCHEDULE.SERVICE = BBT_JOURNEYSTOPS.SERVICE
inner join BBT_STOPS
on BBT_JOURNEYSTOPS.STOP_REFERENCE = BBT_STOPS.STOPREF
where (UPPER(BBT_JOURNEYSTOPS.SERVICE) LIKE UPPER('%'|| :route || '%')) AND
(TO_NUMBER(SUBSTR(BBT_WEEKLYSCHEDULE.TIMEUNTIL, 1, 2)) > (SELECT TO_NUMBER(SYSDATE, 'HH24') "NOW" FROM DUAL));
這是有問題的WHERE語句。我得到的錯誤代碼是
ORA-01481: invalid number format model
01481. 00000 - "invalid number format model"
*Cause: The user is attempting to either convert a number to a string
via TO_CHAR or a string to a number via TO_NUMBER and has
supplied an invalid number format model parameter.
*Action: Consult your manual.