Thread: c++ / mysql?
View Single Post
Old 06-30-2002, 02:49 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,720
redhead is on a distinguished road
I've never tried C++ and mySQL, but I've tried C++ and Oracle SQL.
It was somethign with a pseudo C++ code, you would run through a precompiler, and the code segment you'd use to connect would be like:
Code:
  exec sql begin declare section;
   /* 
       the username/database/fields/etc 
       which you would use in C++ to connect 
       declared. Ie:
    */
    char *uid = "scott/tiger";
    char  name[NAMELEN];
    int   salary, commission;
    short comm_ind;
  exec sql end declare section;
  exec sql whenever sqlerror goto error;

  exec sql connect :uid;
  exec sql declare c cursor for
    select ename, sal, comm from emp where job = 'SALESMAN'
      order by ename;
  exec sql open c;
  exec sql fetch c into :name, :salary, :commission:comm_ind;
  exec sql close c;
  exec sql rollback release;
  exit(0);

error:
  cout << endl << sqlca.sqlerrm.sqlerrmc << endl;
  exec sql rollback release;
  exit(1);
The precompilation would then exchange all the exec sql [something] with the appropriate C++ calls to the SQL database.

But it would be strange, if there wasn't a way to get C++ programs and mySQL to talk with eachother.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote