mridoni / gixsql

GixSQL is an ESQL preprocessor and a series of runtime libraries to enable GnuCOBOL to access PostgreSQL, ODBC, MySQL, Oracle and SQLite databases.
GNU General Public License v3.0
16 stars 8 forks source link

Return more details on the actual error instead of "invalid column data" #109

Open mridoni opened 2 years ago

mridoni commented 2 years ago

BTW: Would there be the option to return more details on the actual error (maybe in SQLERRM and only use "invalid column data" as fallback)? I think other sql environments provide the source / target parameter count that has wrong data in some of the SQLERRD fields (but I'm not sure), maybe this would additionally be possible, too?

Note: I'm sure that seeing this error is only a side effect of a previous error, still looking... (but that's unrelated to this issue).

Originally posted by @GitMensch in https://github.com/mridoni/gixsql/issues/107#issuecomment-1225747198

mridoni commented 2 years ago

I have to look at what information is available for the various drivers, but this can probably be done.

GitMensch commented 1 year ago

How is this solved now? Do you have this covered in the testing code already?

mridoni commented 1 year ago

Actually some work for this stayed out, I am reopening it

GitMensch commented 1 year ago

This may need to be moved out to a separate issue - not sure, but Oracle provides an additional library call that can be used to get the error message of up to 200 characters - SQLGLM and a CALLable wrapper around that for DSNTIAR (the DB2 variant=.

It likely will also be useful to be provided for migrations.

GitMensch commented 10 months ago

Addition to the one above: MicroFocus' (now OpenText, now RocketSoftware) OpenESQL (which references "open systems" like GNU/Linux) has one extension, that their last addition COBOL-IT's new CitOESQL also supports. It would be good to support that as well.

From MF's docs:

If you declare the data item MFSQLMESSAGETEXT, it is updated with a description of the exception condition whenever SQLCODE is non-zero.c must be declared as a character data item, PIC X(n), where n can be any legal value. This is particularly useful, as ODBC error messages often exceed the 70-byte SQLCA message field.

Adding both this extension and SQLGLM would mean:

Possibly interesting from CitOESQL:

ODBC error messages start with one or more component names in square brackets followed by the message text. These identify where the error message was detected, for example, by the ODBC Driver Manager or the ODBC driver, or the database server. CitOESQL removes any text in square brackets from SQLERRMC, but not from MFSQLMESSAGETEXT.