Mentre testare PostgreSQL's md5()
function ho notato molto bizzarro comportamento:md5() funziona con letterale, ma non con i dati della colonna
funziona come previsto
SELECT md5('abc')
--"900150983cd24fb0d6963f7d28e17f72"
Ma usando la funzione md5() in una query:
SELECT request_id, md5(request_id)
FROM Request
ORDER BY request_id
risultati in questo errore:
ERROR: function md5(integer) does not exist
LINE 1: SELECT request_id, md5(request_id)
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
********** Error **********
ERROR: function md5(integer) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Character: 20
Come può la funzione non esistere se ha funzionato nella prima query? Cosa sto sbagliando; qual è il modo corretto di utilizzare md5()
in una query SELECT?
Questo non sembra affatto strano. Nella prima query, hai passato il testo, mentre nel secondo stai cercando di passare interi. – us2012
@ us2012: sì, questa è la differenza. –
In generale non ha molto senso prendere l'md5 di un intero, quindi sarei interessato al motivo per cui stai provando a farlo. –