[Gambas-user] how to manage mysql error in gambas ?

Marc Guillaume alarch at alarch.pw
Tue Mar 31 22:17:28 CEST 2020


Le Tue, 31 Mar 2020 20:15:25 +0200,
Cristiano Guadagnino <criguada at gmail.com> a écrit :

> Hi Marc,
> this does not reply your Gambas question, however the problem you
> face is usually handled directly in-database by using the MERGE
> statement. MySQL does not support MERGE, but it does support
> something similar: see
> https://www.dbrnd.com/2015/08/insert-update-merge-statement-in-mysql/
> 
> Hope this helps
> Bye
> Cris
> 
> 
> 
> Il giorno mar 31 mar 2020 alle ore 18:34 Marc Guillaume
> <alarch at alarch.pw> ha scritto:
> 
> > hi everybody,
> >
> > I would like to use the mysql error handling when I try to make a
> > mysql insert that generates a "Duplacate entry" error in mysql to
> > be able to transform the query into an update of one of the table
> > fields. But Gambas returns the -1 error whatever the mysql error
> > generated. I can parse the mysql error message that is returned,
> > but is there a way to retrieve the specific error number from MySQL?
> >
> > Otherwise I'll try to use a stored procedure.
> >
> > thanks for your help
> >
> > ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> >  

Helo,

in the meantime I had indeed found the ON DUPLICATE KEY UPDATE
statement. 

But now Benoît told me where to find the MySQL error in a generic way,
for all those occasions when there won't be a MySQL statement as handy
as this one. 

Thanks for your help.


More information about the User mailing list