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;
}