In MariaDB, OCT() è una funzione incorporata che restituisce una rappresentazione di stringa del valore ottale del suo argomento.
Sintassi
La sintassi è questa:
OCT(N)
Dove N è un longlong (BIGINT ) numero.
La funzione restituisce una rappresentazione di stringa del valore ottale di N . È equivalente a CONV(N,10,8) .
Esempio
Ecco un esempio da dimostrare:
SELECT OCT(9); Risultato:
+--------+ | OCT(9) | +--------+ | 11 | +--------+
Rispetto a CONV()
OCT() equivale a usare CONV() funzione per convertire da base 10 a base 8, in questo modo:CONV(N,10,8)
Esempio:
SELECT
OCT(84),
CONV(84, 10, 8); Risultato:
+---------+-----------------+ | OCT(84) | CONV(84, 10, 8) | +---------+-----------------+ | 124 | 124 | +---------+-----------------+
Argomento non numerico
Ecco un esempio di cosa succede quando forniamo un argomento non numerico:
SELECT OCT('Brush'); Risultato:
+--------------+
| OCT('Brush') |
+--------------+
| 0 |
+--------------+ Argomenti nulli
OCT() restituisce null se il suo argomento è null :
SELECT OCT(null); Risultato:
+-----------+ | OCT(null) | +-----------+ | NULL | +-----------+
Argomenti mancanti
Chiamando OCT() con il numero errato di argomenti o senza argomenti genera un errore:
SELECT OCT(); Risultato:
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'OCT'
E:
SELECT OCT(10, 2); Risultato:
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'OCT'