473,467 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to retrieve integer in C prog?

Hi,
I'm new to mySql. I've got a table with an integer field defined like
this:
l_start_wait int(9) not null
I inserted a value into the table using mysql command line client with:
Insert into tbl_wait_list values(12345678);

When I use mysql_fetch_row() to retrieve the column values I am
surprised to see
that mysql_fetch_lengths() returns a length of 8 rather than 4 and
row[0] seems to
point to bytes containing ascii characters "12345678" rather than being
a pointer
to an int.

I've searched the manual and google but apart from occasional references
to blob
data most examples seem to assume that all data is ascii.

What I'd like to be able to do is something like this: int i =
(cast)row[0];

Please tell me what I'm doing wrong - or is this a limitation?
Thanks,
Andy.

Here's my code fragment if it helps:

int checkWaitList(MYSQL *aDb)
{
// aDb connection is already open
MYSQL_RES *rsResult;
MYSQL_ROW row;
char pszSql[256];
int lStartTime;
unsigned long *lengths;

strcpy(pszSql, "SELECT l_start_wait FROM tbl_wait_list");
mysql_query(aDb,pszSql);
rsResult = mysql_use_result(aDb);

if (row = mysql_fetch_row(rsResult)) {
lengths = mysql_fetch_lengths(rsResult);
sprintf(pszSql, ">>%d, %12.12s<<\r\n", lengths[0], row[0]);
// Prints >>8, 12345678<<
return -1;
}
else {
return 0;
}
}


mysql_query(aDb,pszSql);
rsResult = mysql_use_result(aDb);

if (row = mysql_fetch_row(rsResult)) {
lengths = mysql_fetch_lengths(rsResult);
// Found a row
tsOut("Found: " );
tsOut("\r\n");
//lStartTime = *(int *)row[1];
sprintf(pszSql, ">>%ud, %12.12s<<\r\n", lengths[0], row[0]);

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/my***********...ie.nctu.edu.tw

Jul 19 '05 #1
0 1691

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

Similar topics

5
by: Roy Gourgi | last post by:
Hi, I am used to working in Visual FoxPro and I would like to be able to create a database and store and retrieve information from it. What is the simplest way to do it and what should I be...
2
by: Dan | last post by:
All, I need to be able to retrieve a list of Domains that are part of our network: similar to the list you get when you log onto a Windows station that is part of a domain. I assume that I can...
2
by: facicad | last post by:
I would like to set topmost another prog. from my program. Ex: I use AutoCAD, run my prog. from autocad. My prog. is topmost but went I would like to pick some object in autocad, I set TopMost to...
0
by: george_Martinho | last post by:
It seems that the ASP.NET Microsoft team didn't think about this!! The profilemanager class has the following methods: - DeleteInactiveProfiles. Enables you to delete all profiles older than a...
9
by: Don | last post by:
Say I have a class like so: Public Class MyClass Public Prop1 as Integer Public Prop2 As Integer Public Prop3 As Integer End Class Is it possible to retrieve a list of the variables or...
1
by: whidbey | last post by:
Hello friends, I am whidbey, new to thescripts and dot net as well.I am working over Online Shopping Cart,web application.I design a page (webform5.aspx) where user search books then select the books...
8
by: active | last post by:
Guess I'm looking for someone who likes to work difficult puzzles. I can't seem to ever retrieve a palette handle from the clipboard. Below is a simple test program that demonstrates the...
2
by: Cramer | last post by:
Using ASP.NET 3.5... As far as I know, any time we store a value in application or session state, it is stored as a humble 'object' type rather than it's "real" type. For example, if we want...
20
by: Robbie Hatley | last post by:
I needed a quick program called "random" that gives a random positive integer from n1 to n2. For example, if I type "random 38, 43", I want the program to print a random member of the set {38,...
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
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
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...
1
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
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,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.