473,396 Members | 1,992 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.

Error compiling DB2 C++ application.

Hi Everyone,

I am learning how to write C++ programs for DB2. My primary area of
concern would be the administrative level DB2 APIs.

For the time being, I am also looking at how to create packages and
bindfiles for DB2. I have the below mentioned code which is giving me
the following error:

########################################

#include <string.h>
#include <sqlenv.h>
#include <sqlutil.h>
#include "utilemb.h"
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{

EXEC SQL BEGIN DECLARE SECTION;

char PID[11];
sqlint32 quantity;
char location[128];

EXEC SQL END DECLARE SECTION;

cout << "Hopefully this will also work!!" << endl ;

EXEC SQL CONNECT TO SAMPLE ;

EXEC SQL CONNECT RESET ;

return 0 ;

}
########################################
ERROR:

[db2inst1@meridius embed]$ g++ sample2.C -I$DB2PATH/include
sample2.sqC: In function `int main()':
sample2.sqC:23: error: expected primary-expression before ')' token
sample2.sqC:25: error: expected primary-expression before ')' token
[db2inst1@meridius embed]$

I have copied utilemb.h to $DB2PATH/include directory.

Environment:

DB2 9.1 Fixpak 2
Linux 2.6
CentOS 4.4
GCC/G++ -->
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --
infodir=/usr/share/info --enable-shared --enable-threads=posix --
disable-checking --with-system-zlib --enable-__cxa_atexit --disable-
libunwind-exceptions --enable-java-awt=gtk --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)
I have noticed that if I remove the following lines from the code, it
compiles successfully:

EXEC SQL CONNECT TO SAMPLE ;

EXEC SQL CONNECT RESET ;

I am only creating the database connection and disconnecting from it.
Can you shed some light as to what am I missing here?

Thanks!!.

dotyet

Feb 27 '07 #1
8 3839
Ian
dotyet wrote:
Hi Everyone,

I am learning how to write C++ programs for DB2. My primary area of
concern would be the administrative level DB2 APIs.

For the time being, I am also looking at how to create packages and
bindfiles for DB2. I have the below mentioned code which is giving me
the following error:
When you write programs with embedded SQL, you have to run them through
the DB2 Precompiler, first. By convention, your source file would be
named 'test.sqC'. You'd then use the 'PREP' command:

db2 prep test.sqC bindfile

This produces the files 'test.C' and 'test.bnd'. You'd then use the
compiler to compile/link the test.C file, and the BIND command to add
the package to the database.

A word to the wise: Do *not* change the generated .C file after
executing the PREP command: The generated .C file is tied closely
to the corresponding .bnd file, and you'll create issues for yourself.
(Typically timestamp mismatch issues).

Good luck,
Feb 27 '07 #2
oops!!... sorry forgot to mention that i did use the prep command....

db2 "prep sample2.sqC bindfile"

which generated the .C file.

Anyways, advise taken and still waiting for more of them. For the time
being, the problem persists.

rgds,
dotyet.

On Feb 26, 10:46 pm, Ian <ianb...@mobileaudio.comwrote:
dotyet wrote:
Hi Everyone,
I am learning how to write C++ programs for DB2. My primary area of
concern would be the administrative level DB2 APIs.
For the time being, I am also looking at how to create packages and
bindfiles for DB2. I have the below mentioned code which is giving me
the following error:

When you write programs with embedded SQL, you have to run them through
the DB2 Precompiler, first. By convention, your source file would be
named 'test.sqC'. You'd then use the 'PREP' command:

db2 prep test.sqC bindfile

This produces the files 'test.C' and 'test.bnd'. You'd then use the
compiler to compile/link the test.C file, and the BIND command to add
the package to the database.

A word to the wise: Do *not* change the generated .C file after
executing the PREP command: The generated .C file is tied closely
to the corresponding .bnd file, and you'll create issues for yourself.
(Typically timestamp mismatch issues).

Good luck,

Feb 27 '07 #3
In article <11*********************@8g2000cwh.googlegroups.co m>,
do****@yahoo.com says...
Hi Everyone,

I am learning how to write C++ programs for DB2. My primary area of
concern would be the administrative level DB2 APIs.
Did you use the sample bld script to compile yout program. You can find
it at http://tinyurl.com/2evjlh .
Feb 27 '07 #4
Hi Gert,

Yes, I tried the build script as well. But that also led to the same
error.

Is it required that the code HAS to be in a class and not just a
function?

rgds,
dotyet

On Feb 27, 7:36 am, Gert van der Kooij <nom...@invalid.nlwrote:
In article <1172542691.232236.70...@8g2000cwh.googlegroups.co m>,
dot...@yahoo.com says...
Hi Everyone,
I am learning how to write C++ programs for DB2. My primary area of
concern would be the administrative level DB2 APIs.

Did you use the sample bld script to compile yout program. You can find
it athttp://tinyurl.com/2evjlh.

Feb 27 '07 #5
Ian
dotyet wrote:
oops!!... sorry forgot to mention that i did use the prep command....

db2 "prep sample2.sqC bindfile"

which generated the .C file.

Anyways, advise taken and still waiting for more of them. For the time
being, the problem persists.
Oh, and you have to include a definition for variable called 'sqlca'
in your code, because the precompiler will generate code that depends
on this variable's existence.

Add:

struct sqlca sqlca = { 0 };

Then you should be OK.

Feb 27 '07 #6
Hi Ian,

Thanks for the tip, that did the magic. the file compiled with the
following warning only.. :) .... (which i will try to
"understand" )...

/home/db2inst1/sqllib/lib64/libimf.so: warning: warning: feupdateenv
is not implemented and will always fail
/usr/bin/ld: warning: libstdc++.so.5, needed by /home/db2inst1/sqllib/
lib/libdb2.so, may conflict with libstdc++.so.6

I am yet to read the document on how to use the struct though.

Interesting stuff...

Thanks a lot.

rgds,
dotyet
On Feb 27, 3:53 pm, Ian <ianb...@mobileaudio.comwrote:
dotyet wrote:
oops!!... sorry forgot to mention that i did use the prep command....
db2 "prep sample2.sqC bindfile"
which generated the .C file.
Anyways, advise taken and still waiting for more of them. For the time
being, the problem persists.

Oh, and you have to include a definition for variable called 'sqlca'
in your code, because the precompiler will generate code that depends
on this variable's existence.

Add:

struct sqlca sqlca = { 0 };

Then you should be OK.

Feb 28 '07 #7
On Feb 26, 9:18 pm, "dotyet" <dot...@yahoo.comwrote:
Hi Everyone,

I am learning how to write C++ programs for DB2. My primary area of
concern would be the administrative level DB2 APIs.
Hi dotyet;
You may already be aware of this, but the ADMIN_CMD stored procedure
(shipped with DB2 with lots of table functions), surfaces alot of the
things you could only get to via the admin APIs. More is being added
with each release. I only mention it because I went to some trouble
coding C programs for external routines and am in the process of
converting them to use the new ADMIN_CMD interface...

Pete H

Feb 28 '07 #8
OK. Sounds good. I will have a look at that too.

regards,
dotyet

On Feb 28, 10:01 am, "peteh" <phazz...@intellicare.comwrote:
On Feb 26, 9:18 pm, "dotyet" <dot...@yahoo.comwrote:
Hi Everyone,
I am learning how to write C++ programs for DB2. My primary area of
concern would be the administrative level DB2 APIs.

Hi dotyet;
You may already be aware of this, but the ADMIN_CMD stored procedure
(shipped with DB2 with lots of table functions), surfaces alot of the
things you could only get to via the admin APIs. More is being added
with each release. I only mention it because I went to some trouble
coding C programs for external routines and am in the process of
converting them to use the new ADMIN_CMD interface...

Pete H

Feb 28 '07 #9

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

Similar topics

0
by: RichG | last post by:
I have a problem where DB2 is returning error 'DIA9999E An internal error occurred. Report the following error code : "error code -32"'. This is happening on DB2 for Windows, v7.2.9 when compiling...
1
by: Avery Fong | last post by:
The following program will result in a compile error when building under Debug but will compile under Release. Why does is work under Release mode but not under Debug This program is developed...
2
by: Qiao Yun | last post by:
I used vc++.net (visual studio .net ) to open a project which can work well in vc++6.0. I succeeded in compiling the project in vc++.net in release mode . But when I tried to compile the project...
25
by: n3crius | last post by:
hi, i just got a web host with asp.net , seemed really cool. aspx with the c# or vb IN the actual main page run fine, but when i use codebehind and make another source file ( a .cs) to go with...
8
by: pmud | last post by:
Hi, I am using a compare validator in asp.net application(c# code). This Custom validator is used for comparing a value enterd by the user against the primary key in the SQL database. IF the...
4
by: Al Williams | last post by:
Hi, I have error handling in place throughout my application. I also start the application wrapped in error handling code to catch any unexpected exceptions (i.e. exceptions that occur where I...
0
by: Herman Jones | last post by:
I'm getting the following error when I build a Class Library project: Embedding manifest... Project : error PRJ0002 : Error result 1 returned from 'C:\WINDOWS\system32\cmd.exe'. It happens with...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
3
RobH
by: RobH | last post by:
I am trying to generate a complied version of my Application by clicking on the "Make ACCDE" in Access 2007. It asks me where and with what file name to save the ACCDE however it quickly returns with...
5
by: kp | last post by:
Hi, I am compiling on an AIX 5.1 box and my test machine is AIX 5.3. I run the foll. steps for compiling my test binary "test" /usr/vacpp/bin/xlC test.c -c -o test.o -I/home/jag/progs/include...
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
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?
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...
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.