Using id instead of id_mat
Using id instead of serial.
Fixing query to show proper log.
Using id instead of serial.
Adding a validation to update the row instead of creating a new one. Serials will not be repeated on database anymore.