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

how to develop embedded SQL program by C language?

Hi there,

The following is my first embedded SQL program on Windows, which is
coded by C language.

/* sample.sqc */
#include <stdio.h>
EXEC SQL INCLUDE SQLCA;
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL INCLUDE 'staff.h'; /* generated by db2dclgn */
EXEC SQL END DECLARE SECTION;
int main(int argc, char *argv[])
{
EXEC SQL
select dept into :staff.dept
from staff
where id = 10;
printf("The ID no. of Sanders is: %d\n", staff.dept);
return 0;
}

I did db2 prep and bind commands successfully. But when I did the
compiling as below,

D:\Dev-Cpp\bin>gcc.exe "D:\Dev-Cpp\c\sample.c" -o "D:\Dev-Cpp\c
\sample.exe" -I"D:\SQLLIB\include" -L"D:\SQLLIB\lib"

The execution was terminated. It threw the messages as below,

C:\DOCUME~1\db2admin\LOCALS~1\Temp/ccCMaaaa.o(.text+0x42):sample.c:
undefined reference to `sqlastrt@12'
C:\DOCUME~1\db2admin\LOCALS~1\Temp/ccCMaaaa.o(.text+0x69):sample.c:
undefined reference to `sqlaaloc@16'
C:\DOCUME~1\db2admin\LOCALS~1\Temp/ccCMaaaa.o(.text+0xba):sample.c:
undefined reference to `sqlasetda@24'
C:\DOCUME~1\db2admin\LOCALS~1\Temp/ccCMaaaa.o(.text+0xe9):sample.c:
undefined reference to `sqlacall@20'
C:\DOCUME~1\db2admin\LOCALS~1\Temp/ccCMaaaa.o(.text+0xf8):sample.c:
undefined reference to `sqlastop@4'
collect2: ld returned 1 exit status

I don't konw hot to fix it....

Could somebody help me? I'll appreciate that.

Laurence
Jun 27 '08 #1
4 6179
By the way, I'm using DB2 V7.2 Enterprise Edition.

Is there something I lose to link during compiling?
Please~
Jun 27 '08 #2
To compile that C program you have to run the file through a
precompiler.

It's unlikely you'll be able to use gcc - unless the DB2 libraries you
access are compatible with DB2.

Look for a C compiler and for C header files in your DB2 EE.
Jun 27 '08 #3
Laurence wrote:
Hi there,

The following is my first embedded SQL program on Windows, which is
coded by C language.
[snip]
>
I did db2 prep and bind commands successfully. But when I did the
compiling as below,

D:\Dev-Cpp\bin>gcc.exe "D:\Dev-Cpp\c\sample.c" -o "D:\Dev-Cpp\c
\sample.exe" -I"D:\SQLLIB\include" -L"D:\SQLLIB\lib"
[snip]

gcc isn't a supported compiler for building C with embedded SQL in the
Windows environment; I can't remember what the supported environments
were for v7.2, but for 9.5 you can find the list at:

http://publib.boulder.ibm.com/infoce.../com.ibm.db2.l
uw.apdv.embed.doc/doc/r0020877.html

IIRC, the MSVC environment has always been supported - not sure about
the Intel compiler. You might want to try this with MSVC 2005 express
(which is free). BTW, gcc is supported for use with DB2 on Linux.

As to what's actually wrong here - different object formats perhaps? I
recall running into something similar when I tried to get Borland's C++
compiler working with DB2 many years ago.
Cheers,

Dave.
Jun 27 '08 #4
Hi,

I did it after tried over and over again. Both Visual C++ 2005 Express
and Dev C++ (gcc) are supported.

With Visual C++ 2005 Express:
Compile Syntax =cl -Zi -Od -c -W2 -DWIN32 sample.c
Link Syntax =link -debug -out:sample.exe sample.obj db2api.lib

With Dev C++ (gcc):
Compile & Link Syntax =gcc.exe "sample.c" -o "sample.exe" -I"%DB2PATH
%\include" -L"%DB2PATH%\lib" -l"db2api"
For your information, and thanks for all your replies.
Jun 27 '08 #5

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

Similar topics

12
by: Brandon | last post by:
Java seems to have taken off as the platform and language of choice for many embedded devices. Would it be feasible for Python(perhaps running on an embedded version of Linux) to act in such a...
10
by: John Underwood | last post by:
Can I use python23_d and python23 to develop an extension for a commercial application uses python22.dll? (Providing that I do not use any new features found only in 2.3.) I would bulld version...
66
by: Prashant | last post by:
There are lot of dicussion on C# is much better than C++. Why there is no language to compute C#. This way we are accepting monopoly of M$. Why there is no group which seriously tring to develop...
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
12
by: Bill Hanna | last post by:
C is inadequate for embedded systems for the following reasons: 1) Direct addressing of memory mapped I/O is not supported simply and easily. You have to find work-arounds that are compiler...
35
by: David Mathog | last post by:
Every so often one of my fgets() based programs encounters an input file containing embedded nulls. fgets is happy to read these but the embedded nulls subsequently cause problems elsewhere in...
0
by: Gabriel Genellina | last post by:
En Tue, 03 Jun 2008 16:58:12 -0300, Pau Freixes <pfreixes@milnou.net> escribió: So the above code corresponds to the standalone version - what about the embedded version? Are you sure it is...
20
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
There are a few guarantees I exploit in the C Standard. For instance, I might write (unsigned)-1 to get the maximum value for an unsigned integer. Also, I might rely on things such as: ...
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:
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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...

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.