• It's possible get sql error code using TDBC ?

    From Luis Alejandro Muzzachiodi@aleccp@yahoo.com to comp.lang.tcl on Thu Mar 27 23:02:59 2025
    From Newsgroup: comp.lang.tcl

    Hello,

    I am using the TDBC mysql driver. Maybe I'm not getting it but I can't
    find how to retrieve the sql error message that a transaction returns.
    That is, if I capture (for example, with catch) the error shows me all a
    lot of data that, for practical purposes, it is too much information and
    in English, of curse. Can the SQL code from the error be recovered?. In
    this way, it could show a simpler message and in Spanish.

    Example:

    instead of show this ...
    Cannot delete or update a parent row: a foreign key constraint fails (`xxxx_DB01`.`xxx`, CONSTRAINT `RI_xxid` FOREIGN KEY (`xxid`) REFERENCES `xx_xxx` (`xxid`) ON UPDATE CASCADE)

    because i received the error number 1451, i would show :
    "No se puede borrar este blabla porque tiene bleble asociados"

    Thanks,

    Alejandro
    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Harald Oehlmann@wortkarg3@yahoo.com to comp.lang.tcl on Fri Mar 28 14:55:25 2025
    From Newsgroup: comp.lang.tcl

    Am 28.03.2025 um 03:02 schrieb Luis Alejandro Muzzachiodi:
    Hello,

    I am using the TDBC mysql driver. Maybe I'm not getting it but I can't
    find how to retrieve the sql error message that a transaction returns.
    That is, if I capture (for example, with catch) the error shows me all a
    lot of data that, for practical purposes, it is too much information and
    in English, of curse. Can the SQL code from the error be recovered?. In
    this way, it could show a simpler message and in Spanish.

    Example:

    instead of show this ...
    Cannot delete or update a parent row: a foreign key constraint fails (`xxxx_DB01`.`xxx`, CONSTRAINT `RI_xxid` FOREIGN KEY (`xxid`) REFERENCES `xx_xxx` (`xxid`) ON UPDATE CASCADE)

    because i received the error number 1451, i would show :
    "No se puede borrar este blabla porque tiene bleble asociados"

    Thanks,

    Alejandro

    Alejandro,
    I have no answer, sorry. The funny thing is, that TDBC defines the error
    codes for all rivers, but only the ODBC driver follows it.
    But that is easy, as the TDBC error reporting is defined as to be the
    same for all platforms.

    At the end, I have a big driver-dependent if to catch some errors, I am intersted in (like "record exists" on insert).

    Sorry for the non-related noise.

    Consider to register a ticket in tdbc::mysql fossil. Massimo has
    eventually more insights...

    Harald
    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Luis Alejandro Muzzachiodi@aleccp@yahoo.com to comp.lang.tcl on Fri Mar 28 22:52:42 2025
    From Newsgroup: comp.lang.tcl

    El 28/03/2025 a las 10:55, Harald Oehlmann escribió:
    Am 28.03.2025 um 03:02 schrieb Luis Alejandro Muzzachiodi:
    Hello,

    I am using the TDBC mysql driver. Maybe I'm not getting it but I can't
    find how to retrieve the sql error message that a transaction returns.
    That is, if I capture (for example, with catch) the error shows me all
    a lot of data that, for practical purposes, it is too much information
    and in English, of curse. Can the SQL code from the error be
    recovered?. In this way, it could show a simpler message and in Spanish.

    Example:

    instead of show this ...
    Cannot delete or update a parent row: a foreign key constraint fails
    (`xxxx_DB01`.`xxx`, CONSTRAINT `RI_xxid` FOREIGN KEY (`xxid`)
    REFERENCES `xx_xxx` (`xxid`) ON UPDATE CASCADE)

    because i received the error number 1451, i would show :
    "No se puede borrar este blabla porque tiene bleble asociados"

    Thanks,

    Alejandro

    Alejandro,
    I have no answer, sorry. The funny thing is, that TDBC defines the error codes for all rivers, but only the ODBC driver follows it.
    But that is easy, as the TDBC error reporting is defined as to be the
    same for all platforms.

    At the end, I have a big driver-dependent if to catch some errors, I am intersted in (like "record exists" on insert).

    Sorry for the non-related noise.

    Consider to register a ticket in tdbc::mysql fossil. Massimo has
    eventually more insights...

    Harald
    Hello Harald,

    i've created a ticket.
    I hope it can be implemented, if I can help, I will be happy to.

    Saludos,

    Alejandro



    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Harald Oehlmann@wortkarg3@yahoo.com to comp.lang.tcl on Sat Mar 29 11:13:30 2025
    From Newsgroup: comp.lang.tcl

    Am 29.03.2025 um 02:52 schrieb Luis Alejandro Muzzachiodi:
    El 28/03/2025 a las 10:55, Harald Oehlmann escribió:
    Am 28.03.2025 um 03:02 schrieb Luis Alejandro Muzzachiodi:
    Hello,

    I am using the TDBC mysql driver. Maybe I'm not getting it but I
    can't find how to retrieve the sql error message that a transaction
    returns. That is, if I capture (for example, with catch) the error
    shows me all a lot of data that, for practical purposes, it is too
    much information and in English, of curse. Can the SQL code from the
    error be recovered?. In this way, it could show a simpler message and
    in Spanish.

    Example:

    instead of show this ...
    Cannot delete or update a parent row: a foreign key constraint fails
    (`xxxx_DB01`.`xxx`, CONSTRAINT `RI_xxid` FOREIGN KEY (`xxid`)
    REFERENCES `xx_xxx` (`xxid`) ON UPDATE CASCADE)

    because i received the error number 1451, i would show :
    "No se puede borrar este blabla porque tiene bleble asociados"

    Thanks,

    Alejandro

    Alejandro,
    I have no answer, sorry. The funny thing is, that TDBC defines the
    error codes for all rivers, but only the ODBC driver follows it.
    But that is easy, as the TDBC error reporting is defined as to be the
    same for all platforms.

    At the end, I have a big driver-dependent if to catch some errors, I
    am intersted in (like "record exists" on insert).

    Sorry for the non-related noise.

    Consider to register a ticket in tdbc::mysql fossil. Massimo has
    eventually more insights...

    Harald
    Hello Harald,

    i've created a ticket.
    I hope it can be implemented, if I can help, I will be happy to.

    Saludos,

    Alejandro




    Great !
    https://core.tcl-lang.org/tdbcmysql/info/3eaf36b1491ec71d

    Wizard Christian Werner already answered and gave an idea.

    Take care,
    Harald
    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Luis Alejandro Muzzachiodi@aleccp@yahoo.com to comp.lang.tcl on Sat Mar 29 23:22:35 2025
    From Newsgroup: comp.lang.tcl

    El 29/03/2025 a las 7:13, Harald Oehlmann escribió:
    Am 29.03.2025 um 02:52 schrieb Luis Alejandro Muzzachiodi:
    El 28/03/2025 a las 10:55, Harald Oehlmann escribió:
    Am 28.03.2025 um 03:02 schrieb Luis Alejandro Muzzachiodi:
    Hello,

    I am using the TDBC mysql driver. Maybe I'm not getting it but I
    can't find how to retrieve the sql error message that a transaction
    returns. That is, if I capture (for example, with catch) the error
    shows me all a lot of data that, for practical purposes, it is too
    much information and in English, of curse. Can the SQL code from the
    error be recovered?. In this way, it could show a simpler message
    and in Spanish.

    Example:

    instead of show this ...
    Cannot delete or update a parent row: a foreign key constraint fails
    (`xxxx_DB01`.`xxx`, CONSTRAINT `RI_xxid` FOREIGN KEY (`xxid`)
    REFERENCES `xx_xxx` (`xxid`) ON UPDATE CASCADE)

    because i received the error number 1451, i would show :
    "No se puede borrar este blabla porque tiene bleble asociados"

    Thanks,

    Alejandro

    Alejandro,
    I have no answer, sorry. The funny thing is, that TDBC defines the
    error codes for all rivers, but only the ODBC driver follows it.
    But that is easy, as the TDBC error reporting is defined as to be the
    same for all platforms.

    At the end, I have a big driver-dependent if to catch some errors, I
    am intersted in (like "record exists" on insert).

    Sorry for the non-related noise.

    Consider to register a ticket in tdbc::mysql fossil. Massimo has
    eventually more insights...

    Harald
    Hello Harald,

    i've created a ticket.
    I hope it can be implemented, if I can help, I will be happy to.

    Saludos,

    Alejandro




    Great !
    https://core.tcl-lang.org/tdbcmysql/info/3eaf36b1491ec71d

    Wizard Christian Werner already answered and gave an idea.

    Take care,
    Harald

    The answer is correct.
    The information I was looking for is returned in the $::errorCode variable. Thanks to both of you.

    Alejandro




    --- Synchronet 3.20c-Linux NewsLink 1.2