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

C API question: using mysql_bind_result to fetch string data of variable length (text, blob)

Hi,
In the C API, is there any way to execute a query, store all the
results, and somehow find the maximum realized width for each of the
fields before fetching each row?

Otherwise there is no way to efficiently retrieve string data. The
best you can do is either allocate a static buffer of 64K (max size
for a blob) or some smaller buffer that may not actually be able to
contain all the data.

In fact, all the mysql documentation examples, both on in the manual
and in the test/client_test.c file that comes with the source
distribution, seem to choose the latter approach, arbitrarily fixing
the max size of their strings to, say, 255 bytes, binding using that
as the buffer_length, and then fetch()ing. In my application I need to
ensure that I get all the data, so this is unacceptable.

I have tried using mysql_get_metadata() after
mysql_stmt_store_result(), but even then the max_length value for the
fields in question is always set to 0, not the maximum size of the
field for the returned results.

What I would love to do is somehow get the field width right before
fetching each row so that I can allocate the right-sized buffer for
it. Or, less ideally, tell mysql to allocate memory for me.

Does anyone know of a way to do this?

I am using MySQL version 4.1.1-alpha-standard on RedHat Linux 9,
installed from the RPMs (server, client, devel) on the mysql.com
website.

Thanks very much,
AJ
Jul 19 '05 #1
0 2173

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

Similar topics

15
by: Good Man | last post by:
Hey there I have a dumb question.... Let's say i have a database full of 4000 people.... I select everything from the database by: $result = mysql_query("SELECT * FROM People");
0
by: AJ Shankar | last post by:
Hi, In the C API, is there any way to execute a query, store all the results, and somehow find the maximum realized width for each of the fields before fetching each row? Otherwise there is no...
4
by: annoyingmouse2002 | last post by:
Hi there, sorry if this a long post but I'm really just starting out. I've been using MSXML to parse an OWL but would like to use a different solution. Basically it reads the OWL (Based on XML)...
1
by: Randy Howard | last post by:
Suppose you want to have a large number of items (as an array of struct) wherein one field is "record-specific" and of variable length, yet not violate standard C (C90 probably, since C99 isn't...
29
by: MP | last post by:
Greets, context: vb6/ado/.mdb/jet 4.0 (no access)/sql beginning learner, first database, planning stages (I think the underlying question here is whether to normalize or not to normalize this...
5
by: Bhavesh | last post by:
Hello genious people, I m trying to insert a LARGE text from Multiline Textbox into my table of sqlserver2000. I m using vs-2005. Please note that I dont want to store blob data From FILE...
1
by: Bhavesh | last post by:
Hi Bruce, Thanks For Reply. U were right, Needed to pass string , but also need to pass size of Data( instead of 16, passed actual length of data). So that worked for me & didn't get any...
5
by: DonnaDarko | last post by:
I need help again if possible! I want to offer two options for a future user of my program. In Option1(0), the variable resSat must be known and is then used to calculate the variable Mass_BLOB....
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.