Ако се опитвате да използвате интервален литерал в Oracle, но продължавате да получавате грешката „основната прецизност на интервала е твърде малка“, да се надяваме, че това помогне.
Грешката
Ето пример за грешката:
SELECT INTERVAL '125' YEAR
FROM DUAL; Резултат:
ORA-01873: the leading precision of the interval is too small
01873. 00000 - "the leading precision of the interval is too small"
*Cause: The leading precision of the interval is too small to store the
specified interval.
*Action: Increase the leading precision of the interval or specify an
interval with a smaller leading precision.
Error at Line: 9 Column: 17 Решението
Ето как да отстраните проблема:
SELECT INTERVAL '125' YEAR(3)
FROM DUAL; Резултат:
+125-00
Всичко, което направих, беше да добавя (3) до YEAR ключова дума. Това определя точност от 3.
Прецизността по подразбиране е 2 и така, ако не посочим по-висока точност, възниква грешката.
Можете да предоставите точност до 9.
Пример:
SELECT INTERVAL '123456789' YEAR(9)
FROM DUAL; Резултат:
+123456789-00
И ето какво се случва, ако намалим прецизността, като запазим числото същото:
SELECT INTERVAL '123456789' YEAR(5)
FROM DUAL; Резултат:
Error starting at line : 1 in command -
SELECT INTERVAL '123456789' YEAR(5)
FROM DUAL
Error at Command Line : 1 Column : 17
Error report -
SQL Error: ORA-01873: the leading precision of the interval is too small
01873. 00000 - "the leading precision of the interval is too small"
*Cause: The leading precision of the interval is too small to store the
specified interval.
*Action: Increase the leading precision of the interval or specify an
interval with a smaller leading precision. Същата грешка като преди.
Освен това, всичко по-високо от 9 води до грешка:
SELECT INTERVAL '123456789' YEAR(20)
FROM DUAL; Резултат:
Error starting at line : 1 in command - SELECT INTERVAL '123456789' YEAR(20) FROM DUAL Error at Command Line : 1 Column : 34 Error report - SQL Error: ORA-30088: datetime/interval precision is out of range 30088. 00000 - "datetime/interval precision is out of range" *Cause: The specified datetime/interval precision was not between 0 and 9. *Action: Use a value between 0 and 9 for datetime/interval precision.