Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

G++ compiler not regonizing embedded sql tags/keywords on Red hat 4.5

865860Mar 23 2012 — edited Mar 23 2012
Hi,

i can compile a simple hello world script but what i want to achieve is to have embedded sql in the script as well but as soon as i do that i get the following errors for which i cant find a solution on the web:

error: `EXEC' does not name a type
error: `VARCHAR' does not name a type
error: `username' was not declared in this scope
error: expected `;' before "SQL"

Any form of help will be appreciated.

Regards,
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <unistd.h>   
#include <fstream>

using namespace std;
#define     UNAME_LEN 10
#define     PWD_LEN   13

                  
EXEC SQL INCLUDE sqlca; 
EXEC SQL INCLUDE sqlda;
EXEC SQL INCLUDE sqlcpr;


EXEC SQL BEGIN DECLARE SECTION;
  VARCHAR username[UNAME_LEN];
  VARCHAR password[PWD_LEN];
  VARCHAR dbname[4];
EXEC SQL END DECLARE SECTION;

int main() {
char hello[15];
  username.len = (unsigned short)strlen(strcpy((char *)username.arr, "xx"));
  password.len = (unsigned short)strlen(strcpy((char *)password.arr, "xx"));
  dbname.len = (unsigned short)strlen(strcpy((char *)dbname.arr, "xx"));

EXEC SQL CONNECT :username IDENTIFIED BY :password USING :dbname;

EXEC SQL SELECT 'Hello World' INTO :hello FROM DUAL;

printf("%s\n", hello);

EXEC SQL COMMIT RELEASE;

return 0;
}
This post has been answered by Steve.Clamage-Oracle on Mar 23 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 20 2012
Added on Mar 23 2012
1 comment
450 views