Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mridoni opened this issue Aug 24, 2022 · 5 comments
Open
Milestone

Comments

@mridoni
Copy link
Owner

mridoni commented Aug 24, 2022

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 #107 (comment)

@mridoni
Copy link
Owner Author

mridoni commented Aug 24, 2022

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

@GitMensch
Copy link
Contributor

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

@mridoni
Copy link
Owner Author

mridoni commented Feb 10, 2023

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

@mridoni mridoni reopened this Feb 10, 2023
@GitMensch
Copy link
Contributor

GitMensch commented Aug 21, 2023

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
Copy link
Contributor

GitMensch commented Jan 27, 2024

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:

  • at runtime:
    • if SQLCODE is non-zero, then set an internal static variable (either 1024 or 500 chars) with the error message as C string
    • add an SQLGLM entry point that will just copy that to the passed text with strncpy and then sets the passed size var, if its pointer isn't NULL
  • at compile time:
    • check in the program and EXEC SQL INCLUDEs if MFSQLMESSAGETEXT is defined
    • if yes either:
      • include a CALL "SQLGLM" USING MFSQLMESSAGETEXT, LENGTH OF MFSQLMESSAGETEXT, OMITTED after each call (=no ABI change at all)
    • or:
      • set a pointer "somewhere" in the structure(s) from this program to this field, as well as the length (likely an ABI change, which I personally currently won't mind)
      • if the structure for the caller contains that pointer, use this information to copy it, space-fill with spaces

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants