473,396 Members | 1,785 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,396 software developers and data experts.

Data Types in Embedded C queries - problems

2
I have very little experience with DB2, but am writing a simple C program, with
embedded SQL, that has among other things
[The original code compiles fine, any typing errors below are my fault in posting]

EXEC SQL BEGIN DECLARE SECTION;
double F;
/*...*/
EXEC SQL END DECLARE SECTION;
...

Then do a DECLARE a cursor, OPEN it and FETCH a "REAL" column
into this host variable F.

Printing it out (printf( ".. %7.2f .. "); does not yield the expected values (2.5, or such, which is returned by a straight DB2 query from the commandline)
but either 0.00, -0.00 or some some massive string of digits (100 or so).

It looks like I am reading the data types wrong, but can't see where.
The DB2 server instance is running on the same machine where the client
program is compiled and run. I have tested this on two separate machines,
with similar results.

I've written a similar program, that looks the same to me, for all intents and
puroses, but that one works. I would appreciate any pointers to the solution
from more experienced DB2 users.
Sep 27 '07 #1
1 2125
edwald
2
Turns out this was my own clumsiness.

I had *two* variables with the same name, one EXEC SQL-declared as
an SQL short, in the embedded-SQL section, the other a normal C
array of type float**. Printing out the contents of this variable didn't
produce the expected results, reasonably so.
I didn't notice, because my program has a large number of variables,
and the compiler didn't complain either, I guess the compiler doesn't
'see' the variables declared inside the EXEC SQL section, and hence
couldn't complain. This was a useful thing to find out, if a little expensive.

So, my faith in the DB2 server is restored,
regards
Sep 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Henry | last post by:
Hi experts of Oracle, I used Oracle for small queries, but now I have a task to create WEB-based report by getting data, summarying ( several counts, min and max) and re-formatting, where the...
1
by: RobM | last post by:
Greetings Am embarking on new project creating PDF using Apache FOP; XML + XSL:FO to PDF. Just looking at my data, designing XML layout, I have a string of text that currently (this is a rewrite...
13
by: Shailesh Humbad | last post by:
I wrote a short page as a quick reference to c++ integer data types. Any feedback welcome: http://www.somacon.com/blog/page11.php
5
by: charlies224 | last post by:
Hi, I am using SQL 2000 and has a table that contains more than 2 million rows of data (and growing). Right now, I have encountered 2 problems: 1) Sometimes, when I try to query against this...
0
by: s_gregory | last post by:
The mdb is considerable size 70 +- mb. A complex union query was working well, but when an additional union select... was added into the query, selecting identical fields from a different source,...
4
by: Bill Stock | last post by:
The few times in the past that I've loaded unbound data, I've tended to cheat and use temp tables (not really unbound) or use code for small datasets. I'm currently involved in a project that...
8
by: Buddy | last post by:
Hello, We are using DataTable to store our data that we retrieve from SQL because it provides us with ROW/COLUMN concept. Due to DataTable been memory hungary we are finding that at least 40MB...
30
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
Let's say we had a simple function for returning the amount of days in a month: unsigned DaysInMonth(unsigned const month) { switch (month) { case 8: case 3: case 5:
5
by: Cromulent | last post by:
Okay I'm having a few issues with this and I can't seem to get it sorted out (most likely due to my inexperience with Python). Here is my Python code: def fileInput(): data = s =...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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
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...

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.