473,406 Members | 2,713 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,406 software developers and data experts.

FETCH into sqlda structure

I am using DB2 UDB V8.2 on AIX. We recently added some VARCHAR fields
into our database and I found an issue with how we are reading data
when retrieving it into an sqlda structure using dynamic sql. Here is
the issue:

This particular table has several VARCHAR(256) fields. I set up a few
records that spanned all 256 char bytes then ran the debugger. I
found that I am only receiving the first 254 bytes of data in sqlda-
>sqvar.sqldata. I understand that the first two bytes in sqldata are
for the length but can anyone tell me why all 256 bytes of data are
not coming through?

Sample of the data in the database where two columns that are both
VARCHAR(256) with a record that has all 256 bytes inserted in each
field:

USERNAME
PASSWORD
-------------- --------------
22222222222222222222222222222222222222222222222222 222222222222222222222222222222
22222222222222222222222222222222222222222222222222 222222222222222222222222222222
22222222222222222222222222222222222222222222222222 222222222222222222222222222222
2222222222222456
77777777777777777777777777777777777777777777777777 7777777777777
77777777777777777777777777777777777777777777777777 777777777777777777777777777777
77777777777777777777777777777777777777777777777777 777777777777777777777777777777
777777777777777777777777777777768

So now I run my program that fetches the data into the sqlda-
>sqlvar.sqldata and this is what I see:

(dbx) p sqldata[0]
'^A' <----length is 256
(dbx) p sqldata[1]
'\0' <---part of length field?
(dbx) p sqldata[2]
'2' <----start of the USERNAME
data
(dbx) p sqldata[3]
'2'
(dbx) p sqldata[253]
'2'
(dbx) p sqldata[254]
'2'
(dbx) p sqldata[255]
'4' <-----254th byte of the data (or
253rd if you are looking at the index)
(dbx) p sqldata[256]
'^A' <---this should be a value of 5
but instead it is the length for the PASSWORD field
(dbx) p sqldata[257]
'\0'
(dbx) p sqldata[258]
'7' <---start of the PASSWORD field
(dbx) p sqldata[259]
'7'

so it seems I am only getting back a total of 256 bytes including the
length fields and that truncates the data. I found the following
statement by Knut in a different post and it brought up some
questions:

"No, not for VARCHAR data. The string 'some text' requires 12 bytes
on disc
(2 length + 1 null-indicator + 9 data bytes) whereas 'some more text'
uses
17 bytes on disc (2 + 1 + 14 data bytes). "
1) does this mean there could be 2-3 fields for length + null and that
this could vary depending on the length?
2) does this also mean that even though I could insert 256 bytes of
data into the VARCHAR(256) we can only use 253 for data to account for
the 3 extra bytes in sqldata? ( would be suprised if the answer is
yes!)

or

did we just do something wrong with the lengths somewhere in the
call? sqllen is set to 256 after the DESCRIBE...should the
application set this to 259?

I appreciate your time.
Jul 22 '08 #1
1 4469
Has anyone had any experience with this? I would appreciate any help
if you are using this technique.
Jul 25 '08 #2

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

Similar topics

2
by: Max M | last post by:
I am using the fetch command from the imaplib to fetch messages. I get a result, but I am a bit uncertain as to how I should interpret it. The result is described at...
0
by: tom | last post by:
I am new to DB2. I do not know how to set the SQLDA variables. I am using SQR through Brio to select a CLOB field from a table. I have read the examples for C programs using prepare from and...
1
by: Rob | last post by:
I'd like to be able to identify IDENTITY columns via the SQLDA. Looking up the DESCRIDE TABLE statement in DB2 OS/390 Ver7.1 SQL Reference doesn't mention that the SQLDA will contain any...
8
by: Evan Smith | last post by:
During a routine performance check using an event monitor, I discovered a class of query whose performance has me baffled. The monitor captured: SELECT * FROM EWM_CASE fetch first 1 rows only...
7
by: Bernard Lebel | last post by:
Hello, I'm stumbled at a serious problem, and quite frankly getting desparate. This is a rather long-winded one so I'll try to get straight to the point. I have this Python program, that...
10
by: scoonie999 | last post by:
I'm having a problem that I can't seem to find any solution for online. I'm using a cursor in a cobol program to fetch some data. I know for a fact that the select should return 2 rows. The...
9
by: weirdwoolly | last post by:
Hopefully someone will be able to help. I have written a stored procedure in C++ called from a Java test harness to validate the graphic data types in C++ and their use. I have declared the...
7
by: Frank Swarbrick | last post by:
Is there a way to do a multi-row fetch in to a COBOL table with DB2/LUW? Apparently the following is supported in z/OS, but not LUW (or at least I couldn't get it to work): WORKING-STORAGE...
2
by: Parnamwulan | last post by:
Hello guys, Pls dont laugh - it is not funny (actually it is, but it is causing me problems) I have problem with SQLDA data type specification. I need to create some counted columns, so I...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
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...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.