Bernhard Hofmann
Bernhard Hofmann

Reputation: 10411

Finding the cause of ERROR [22001] [IBM][AS] Conversion error on variable or parameter *N

I'm invoking a procedure from C# and get the following error message:

ERROR [22001] [IBM][AS] Conversion error on variable or parameter *N

Is there a way to have DB2 tell me which parameter it is that cannot be converted?

Bonus points of DB2 can tell me what type it attempted to from and to.

Upvotes: 1

Views: 770

Answers (1)

Mike
Mike

Reputation: 1324

Since this error seems to be from inside your SQL procedure, the simplest thing would be to call this procedure from the green-screen environment to get more debugging data. You could call this procedure from inside the STRSQL utility and then hit F1 on the error message and you will sometimes get more details than the error message that was passed back via OLEDB.

If you have the source code for the SQL procedure you can use the STRDBG utility to step through the SQL source code and see specifically what line it faults on and you can inspect the values of the local variables just before the error is thrown. This will often be the most thorough way to find what is going wrong. Debugging an SQL routine

In a well written procedure, this kind of error often implies "garbage in, garbage out" and you should examine your inputs first, but it could also be the SQL code not correctly handling a perfectly valid input and thus a bug in the procedure.

Upvotes: 1

Related Questions