473,385 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Bug: SQLGetDiagRec returns SQL_SUCCESS_WITH_INFO

We are having problems retrieving diagnostic information from a DB2
database (server is 7.1.x, client is 8.1). The SQLGetDiagRec()
function, when called on a valid DB2 statement handle, always returns
SQL_SUCCESS_WITH_INFO instead of SQL_SUCCESS, as the documentation
says it should. SQL_SUCCESS_WITH_INFO, according to the documentation
excerpt from "The ODBC Programmer's Reference" posted below, means
that the text buffer for retrieving the error message passed to the
function was too small. The docs are quite clear about this. However,
this is never the case, as the buffer is large enough.

Here is the excerpt from the MSDN documentation mentioned above:

<quote>
SQLRETURN SQLGetDiagRec(
SQLSMALLINT HandleType,
SQLHANDLE Handle,
SQLSMALLINT RecNumber,
SQLCHAR * Sqlstate,
SQLINTEGER * NativeErrorPtr,
SQLCHAR * MessageText,
SQLSMALLINT BufferLength,
SQLSMALLINT * TextLengthPtr);
[...]
Returns:
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE.

Diagnostics:
SQLGetDiagRec does not post diagnostic records for itself. It uses the
following return values to report the outcome of its own execution:

- SQL_SUCCESS: The function successfully returned diagnostic
information.
- SQL_SUCCESS_WITH_INFO: The *MessageText buffer was too small
to hold the requested diagnostic message. No diagnostic
records were generated. To determine that a truncation
occurred, the application must compare BufferLength to
the actual number of bytes available, which is
written to *StringLengthPtr.
- SQL_INVALID_HANDLE: The handle indicated by HandleType and
Handle was not a valid handle.
- SQL_ERROR: One of the following occurred:
- RecNumber was negative or 0.
- BufferLength was less than zero.
- SQL_NO_DATA: RecNumber was greater than the number of
diagnostic records that existed for the handle specified
in Handle. The function also returns SQL_NO_DATA for any
positive RecNumber if there are no diagnostic records
for Handle.
</quote>

For those who have ever done ODBC programming with DB2 databases, it
should be obvious that this is NOT how DB2 acts when diagnosing
errors. I consider this to be a bug.

If it's not a bug, can anyone tell me how this is properly done?

Thanks.

Bob
Nov 12 '05 #1
6 4931
bo**********@yahoo.com (Bob Hairgrove) wrote in message news:<67**************************@posting.google. com>...
We are having problems retrieving diagnostic information from a DB2
database (server is 7.1.x, client is 8.1). The SQLGetDiagRec()
function, when called on a valid DB2 statement handle, always returns
SQL_SUCCESS_WITH_INFO instead of SQL_SUCCESS, as the documentation
says it should. [snip]


The silence is deafening ... doesn't anyone have a clue?
Nov 12 '05 #2
Ian
Bob Hairgrove wrote:
We are having problems retrieving diagnostic information from a DB2
database (server is 7.1.x, client is 8.1). The SQLGetDiagRec()
function, when called on a valid DB2 statement handle, always returns
SQL_SUCCESS_WITH_INFO instead of SQL_SUCCESS, as the documentation
says it should. SQL_SUCCESS_WITH_INFO, according to the documentation
excerpt from "The ODBC Programmer's Reference" posted below, means
that the text buffer for retrieving the error message passed to the
function was too small. The docs are quite clear about this. However,
this is never the case, as the buffer is large enough.

Here is the excerpt from the MSDN documentation mentioned above:

<quote>
SQLRETURN SQLGetDiagRec(
SQLSMALLINT HandleType,
SQLHANDLE Handle,
SQLSMALLINT RecNumber,
SQLCHAR * Sqlstate,
SQLINTEGER * NativeErrorPtr,
SQLCHAR * MessageText,
SQLSMALLINT BufferLength,
SQLSMALLINT * TextLengthPtr);
[...]
Returns:
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE.


What do you get in MessageText??

IIRC, you will get SQL_SUCCESS_WITH_INFO when you do an operation and no
rows are affected (i.e. SQLCODE +100, which corresponds to SQLSTATE
'02000'). Are you sure that this is not what you're running into?

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 12 '05 #3
In article <67**************************@posting.google.com >, Bob
Hairgrove (bo**********@yahoo.com) says...
We are having problems retrieving diagnostic information from a DB2
database (server is 7.1.x, client is 8.1). The SQLGetDiagRec()
function, when called on a valid DB2 statement handle, always returns
SQL_SUCCESS_WITH_INFO instead of SQL_SUCCESS, as the documentation
says it should. SQL_SUCCESS_WITH_INFO, according to the documentation
excerpt from "The ODBC Programmer's Reference" posted below, means
that the text buffer for retrieving the error message passed to the
function was too small. The docs are quite clear about this. However,
this is never the case, as the buffer is large enough.


This is copied from the DB2 CLI Guide and Reference, hope it helps.

Usage

An application typically calls SQLGetDiagRec() when a previous call
to a DB2 CLI function has returned anything other than SQL_SUCCESS.
However, any function can post zero or more errors each time it is
called, so an application can call SQLGetDiagRec() after any function
call. An application can call SQLGetDiagRec() multiple times to
return some or all of the records in the diagnostic data structure.

SQLGetDiagRec() returns a character string containing multiple fields
of the diagnostic data structure record. More information about the
data returned can be found in SQLGetDiagField - Get a Field of
Diagnostic Data.

SQLGetDiagRec() cannot be used to return fields from the header of
the diagnostic data structure (the RecNumber argument must be greater
than 0). The application should call SQLGetDiagField() for this
purpose.

SQLGetDiagRec() retrieves only the diagnostic information most
recently associated with the handle specified in the Handle argument.
If the application calls another function, except SQLGetDiagRec() or
SQLGetDiagField(), any diagnostic information from the previous calls
on the same handle is lost.

An application can scan all diagnostic records by looping,
incrementing RecNumber, as long as SQLGetDiagRec() returns
SQL_SUCCESS. Calls to SQLGetDiagRec() are non-destructive to the
header and record fields. The application can call SQLGetDiagRec()
again at a later time to retrieve a field from a record, as long as
no other function, except SQLGetDiagRec() or SQLGetDiagField(), has
been called in the interim. The application can also retrieve a count
of the total number of diagnostic records available by calling
SQLGetDiagField() to retrieve the value of the SQL_DIAG_NUMBER field,
then call SQLGetDiagRec() that many times.

Nov 12 '05 #4
Ian <ia*****@mobileaudio.com> wrote in message news:<40**********@corp.newsgroups.com>...
IIRC, you will get SQL_SUCCESS_WITH_INFO when you do an operation and no
rows are affected (i.e. SQLCODE +100, which corresponds to SQLSTATE
'02000'). Are you sure that this is not what you're running into?


No. The error is generated by a constraint violation after attempting
an INSERT. Running ODBC trace gives us the details. However, in our
own ODBC classes, after the SQL statement generates the error
(returning SQL_ERROR), we call SQLGetDiagRec() and receive
SQL_SUCCESS_WITH_INFO instead of SQL_SUCCESS.

IIRC there is no message written ... but maybe I just didn't look
because the behavior is not as documented.
Nov 12 '05 #5
Just ideas...

v8 client to v7 server 'may' cause some problems.
e.g. i'd visit the incompatibilities sections of the doc like
Supported and non-supported client configuration scenarios
odbc trace says what about your problem?
character expansion problem? unicode/codepages/... ?
I know that some drivers have some internal Retry operations. (maybe it's
causing you problems?)

Maybe you can try this to see if it makes any difference.
In v8 fp1
http://publib.boulder.ibm.com/infoce...help/index.jsp
DESCRIBEINPUTONPREPARE CLI/ODBC Configuration Keyword

By default, DB2 CLI does not request input parameter describe information
1when it prepares an SQL statement. If an application has correctly 1bound
parameters to a statement, then this describe information is unnecessary
1and not requesting it improves performance. If, however, parameters 1have
not been correctly bound, then statement execution will fail and cause 1the
CLI error recovery retry logic to request input parameter describe
1information. The result is an additional server request and reduced
1performance, compared to if the describe information had been requested
with 1the prepare. Setting DESCRIBEINPUTONPREPARE to 1 causes the input
1describe information to be requested with the prepare. This setting may
1improve performance for applications which rely heavily on the CLI retry
logic 1to recover from application binding errors.

v8 incompatibilities with prev rlz section

Some application features and tasks:
a.. The DESCRIBE INPUT statement is not supported with one exception for
ODBC/JDBC applications. In order to support DB2 UDB Version 8 clients
running ODBC/JDBC applications accessing DB2 UDB Version 7 servers, a fix
for DESCRIBE INPUT support must be applied to all DB2 UDB Version 7 servers
where this type of access is required. This fix is associated with APAR
IY30655 and will be available before the DB2 UDB Version 8 General
Availability date. Use the "Contacting IBM" information in any DB2 Universal
Database document to find out how to get the fix associated with APAR
IY30655. The DESCRIBE INPUT statement is a performance and usability
enhancement to allow an application requestor to obtain a description of
input parameter markers in a prepared statement. For a CALL statement, this
includes the parameter markers associated with the IN and INOUT parameters
for the stored procedure.
etc.

PM
"Bob Hairgrove" <bo**********@yahoo.com> a écrit dans le message de
news:67**************************@posting.google.c om...
We are having problems retrieving diagnostic information from a DB2
database (server is 7.1.x, client is 8.1). The SQLGetDiagRec()
function, when called on a valid DB2 statement handle, always returns
SQL_SUCCESS_WITH_INFO instead of SQL_SUCCESS, as the documentation
says it should. SQL_SUCCESS_WITH_INFO, according to the documentation
excerpt from "The ODBC Programmer's Reference" posted below, means
that the text buffer for retrieving the error message passed to the
function was too small. The docs are quite clear about this. However,
this is never the case, as the buffer is large enough.

Here is the excerpt from the MSDN documentation mentioned above:

<quote>
SQLRETURN SQLGetDiagRec(
SQLSMALLINT HandleType,
SQLHANDLE Handle,
SQLSMALLINT RecNumber,
SQLCHAR * Sqlstate,
SQLINTEGER * NativeErrorPtr,
SQLCHAR * MessageText,
SQLSMALLINT BufferLength,
SQLSMALLINT * TextLengthPtr);
[...]
Returns:
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, or SQL_INVALID_HANDLE.

Diagnostics:
SQLGetDiagRec does not post diagnostic records for itself. It uses the
following return values to report the outcome of its own execution:

- SQL_SUCCESS: The function successfully returned diagnostic
information.
- SQL_SUCCESS_WITH_INFO: The *MessageText buffer was too small
to hold the requested diagnostic message. No diagnostic
records were generated. To determine that a truncation
occurred, the application must compare BufferLength to
the actual number of bytes available, which is
written to *StringLengthPtr.
- SQL_INVALID_HANDLE: The handle indicated by HandleType and
Handle was not a valid handle.
- SQL_ERROR: One of the following occurred:
- RecNumber was negative or 0.
- BufferLength was less than zero.
- SQL_NO_DATA: RecNumber was greater than the number of
diagnostic records that existed for the handle specified
in Handle. The function also returns SQL_NO_DATA for any
positive RecNumber if there are no diagnostic records
for Handle.
</quote>

For those who have ever done ODBC programming with DB2 databases, it
should be obvious that this is NOT how DB2 acts when diagnosing
errors. I consider this to be a bug.

If it's not a bug, can anyone tell me how this is properly done?

Thanks.

Bob

Nov 12 '05 #6
bo**********@yahoo.com (Bob Hairgrove) wrote in message news:<67**************************@posting.google. com>...
We are having problems retrieving diagnostic information from a DB2
database

[snip]

OK, it was my own fault ... I was passing sizeof(myBuffer) for the
BufferLength parameter. Originally it was declared as an array, but
somewhere down the line it got changed to a pointer to dynamically
allocated memory. sizeof(a pointer) returns 4, of course (at least on
32-bit machines).

Sorry for wasting your time (I really did look a long time for that
bug! <g>).
Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mage | last post by:
Hello! create or replace function trigger_keywords_maintain() returns trigger as $$ return 'MODIFY' $$ language plpythonu; update table set id = id where id = 7; ERROR: invalid input...
0
by: washingtonirving | last post by:
Hi. I sent this bug to the bugs mailing list. But the email never turned up on the list. Could somebody here tell me what I'm doing wrong, and why the email won't show up? Am I breaking some...
1
by: Koen | last post by:
Hi all, I created a little database to manage my e-books. The program will synchronize a table with the contents of a directory. Works great. Because I keep additional info (like keywords) to...
34
by: Marcel van Kervinck | last post by:
Dear all, I would like to confirm my suspicion of a compiler bug in gcc4 for MacOSX. The code example below expects that the initializer of 'v' sets all elements in v.u.bytes to zero, as...
9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
7
by: Nathan Truhan | last post by:
All, I think I may have uncovered a bug in the IsNumeric function, or at least a misunderstanding on functionality. I am writing a Schedule Of Classes Application for our campus and have a...
0
by: CountDraculla | last post by:
Fixing Multiple Database bug in adoDB popular data access layer for php, adoDB can support multiple databases from different provider at time, but not from same provider. what I mean is if you...
0
by: M1Sports20 | last post by:
Here is a class i have expanded off of microsoft picturebox array in msdn. I have found a problem and I am thinking its not my fault. Here is how to reproduce the error 1. Create an instance of...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 385 open (+21) / 3790 closed (+21) / 4175 total (+42) Bugs : 1029 open (+43) / 6744 closed (+43) / 7773 total (+86) RFE : 262 open...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.