Operating System - HP-UX
1832785 Members
3360 Online
110045 Solutions
New Discussion

Re: SQL commands in C-code ????

 
SOLVED
Go to solution
Paul Murray
Occasional Contributor

SQL commands in C-code ????

Gurus,

I am trying to write a small C program which will perform sqlplus "select" and "insert" commands.

Does anyone know of a reference site (pref. with examples) on how to accomplish this as simply as possible ??

As you probably have ascertained -- I am totally new to C-programming, so no laughing please !! :-)


Cheers in advance,
PaulM.

PS -- OS = HPUXv11, N/L-Class Servers.
My Brain Hurts !!!!!
2 REPLIES 2
Dan Hetzel
Honored Contributor

Re: SQL commands in C-code ????

Hi Paul,

Here is a nice URL to start with.
You'll find plenty of links to tutorials ans examples for embedded SQL.

http://cplus.about.com/compute/cplus/msub10.htm

Best regards,

Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com
Andreas Voss
Honored Contributor
Solution

Re: SQL commands in C-code ????

Hi,

if you want to get stdout from sqlplus you can use the popen() call ie:

#include

main()
{
char cmd[1024];
char linebuf[1024];
FILE *fp;

sprintf(cmd, "sqlpus ......");
fp = popen(cmd, "r");
while(fgets(linebuf, sizeof(linebuf), fp) != NULL)
{
/* do what ever you will do with the data */
}
pclose(fp);
}

Regards