473,792 Members | 2,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bug: SQLGetDiagRec returns SQL_SUCCESS_WIT H_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_WIT H_INFO instead of SQL_SUCCESS, as the documentation
says it should. SQL_SUCCESS_WIT H_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_WIT H_INFO, SQL_ERROR, or SQL_INVALID_HAN DLE.

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_WIT H_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 *StringLengthPt r.
- SQL_INVALID_HAN DLE: 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 4959
bo**********@ya hoo.com (Bob Hairgrove) wrote in message news:<67******* *************** ****@posting.go ogle.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_WIT H_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_WIT H_INFO instead of SQL_SUCCESS, as the documentation
says it should. SQL_SUCCESS_WIT H_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_WIT H_INFO, SQL_ERROR, or SQL_INVALID_HAN DLE.


What do you get in MessageText??

IIRC, you will get SQL_SUCCESS_WIT H_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**********@y ahoo.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_WIT H_INFO instead of SQL_SUCCESS, as the documentation
says it should. SQL_SUCCESS_WIT H_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*****@mobile audio.com> wrote in message news:<40******* ***@corp.newsgr oups.com>...
IIRC, you will get SQL_SUCCESS_WIT H_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_WIT H_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 incompatibiliti es 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
DESCRIBEINPUTON PREPARE 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 DESCRIBEINPUTON PREPARE 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 incompatibiliti es 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**********@y ahoo.com> a écrit dans le message de
news:67******** *************** ***@posting.goo gle.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_WIT H_INFO instead of SQL_SUCCESS, as the documentation
says it should. SQL_SUCCESS_WIT H_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_WIT H_INFO, SQL_ERROR, or SQL_INVALID_HAN DLE.

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_WIT H_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 *StringLengthPt r.
- SQL_INVALID_HAN DLE: 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**********@ya hoo.com (Bob Hairgrove) wrote in message news:<67******* *************** ****@posting.go ogle.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
2420
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 syntax for type timestamp: "2005-05-03 14:07:33,279213"
0
1743
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 unwritten rule of the bugs list? I would really like to see an answer to this. Thanks a lot! -w ---
1
2564
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 the created records in the database and I don't want to lose all that info when I rename a file and synchronise, I've added some code to the program. It works like this: when the filename of a DB records
34
1916
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 specified by the C99 standard: """21 If there are fewer initializers in a brace-enclosed list than there are elements or members of an aggregate, the remainder of the aggregate shall
9
3976
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 will not set the value of the control and will leave the checked status of the checkbox to false when a user selects a new date. this works fine when using the control on a win2k machine but if we use it on a win XP box and call
7
2385
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 section that lists the Times, Buildings and rooms for courses. In this section I have a function called PadCell that takes3 parameters, one the value, one a padd count and one a a boolean input called StripNumeric, that if true, checks if the value...
0
3248
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 instantiate two adoDB connection like this $db1 = &NewAdoConnection ("mysql"); $db1 = &NewAdoConnection ("oracle"); then you can run queries simultaneously from these connections. but if
0
1267
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 this object. 2. Add 2-9 images to the object. 3. Click on object 2. (It should select using a rectangler box) 4. Click on picturebox 1. (It should select using a rectangler box) 5. Click on picturebox 2. (it should select using a...
0
1985
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 ( +4) / 291 closed ( +4) / 553 total ( +8) New / Reopened Patches ______________________
0
9670
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9518
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10430
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10211
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10159
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.