Se stai cercando di utilizzare un valore letterale di intervallo in Oracle, ma continui a ricevere l'errore "la precisione principale dell'intervallo è troppo piccola", si spera che questo aiuti.
L'errore
Ecco un esempio dell'errore:
SELECT INTERVAL '125' YEAR
FROM DUAL; Risultato:
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 La soluzione
Ecco come risolvere il problema:
SELECT INTERVAL '125' YEAR(3)
FROM DUAL; Risultato:
+125-00
Tutto quello che ho fatto è stato aggiungere (3) all'YEAR parola chiave. Questo specifica una precisione di 3.
La precisione predefinita è 2, quindi se non specifichiamo una precisione maggiore, si verifica l'errore.
Puoi fornire una precisione fino a 9.
Esempio:
SELECT INTERVAL '123456789' YEAR(9)
FROM DUAL; Risultato:
+123456789-00
Ed ecco cosa succede se riduciamo la precisione mantenendo lo stesso numero:
SELECT INTERVAL '123456789' YEAR(5)
FROM DUAL; Risultato:
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. Stesso errore di prima.
Inoltre, qualsiasi valore superiore a 9 genera un errore:
SELECT INTERVAL '123456789' YEAR(20)
FROM DUAL; Risultato:
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.