In Oracle, il UPPER() la funzione restituisce il suo argomento con tutte le lettere maiuscole.
Sintassi
La sintassi è questa:
UPPER(char)
Dove char può essere di qualsiasi tipo di dati CHAR , VARCHAR2 , NCHAR , NVARCHAR2 , CLOB o NCLOB .
Esempio
Ecco un semplice esempio da dimostrare:
SELECT UPPER('speak louder please')
FROM DUAL; Risultato:
UPPER('SPEAKLOUDERPLEASE')
_____________________________
SPEAK LOUDER PLEASE Lo stesso vale quando l'argomento usa maiuscole e minuscole:
SELECT UPPER('Speak Louder Please')
FROM DUAL; Risultato:
UPPER('SPEAKLOUDERPLEASE')
_____________________________
SPEAK LOUDER PLEASE E se l'argomento è già maiuscolo, il risultato è lo stesso dell'input:
SELECT UPPER('SPEAK LOUDER PLEASE')
FROM DUAL; Risultato:
UPPER('SPEAKLOUDERPLEASE')
_____________________________
SPEAK LOUDER PLEASE Valori Nulli
Passaggio null restituisce null :
SET NULL 'null';
SELECT UPPER(null)
FROM DUAL; Risultato:
UPPER(NULL) ______________ null
Per impostazione predefinita, SQLcl e SQL*Plus restituiscono uno spazio vuoto ogni volta che null si verifica come risultato di un SQL SELECT dichiarazione.
Tuttavia, puoi utilizzare SET NULL per specificare una stringa diversa da restituire. Qui ho specificato che la stringa null deve essere restituito.
Conteggio argomenti errato
Chiamando UPPER() senza passare alcun argomento restituisce un errore:
SELECT UPPER()
FROM DUAL; Risultato:
Error starting at line : 1 in command - SELECT UPPER() FROM DUAL Error at Command Line : 1 Column : 8 Error report - SQL Error: ORA-00909: invalid number of arguments 00909. 00000 - "invalid number of arguments" *Cause: *Action:
E il passaggio del numero errato di argomenti genera un errore:
SELECT UPPER('Speak', 'Louder')
FROM DUAL; Risultato:
Error starting at line : 1 in command -
SELECT UPPER('Speak', 'Louder')
FROM DUAL
Error at Command Line : 1 Column : 8
Error report -
SQL Error: ORA-00909: invalid number of arguments
00909. 00000 - "invalid number of arguments"
*Cause:
*Action: