Reputation: 11
Here is a sample of a program that I got from the website: http://www.csee.umbc.edu/portal/help/oracle8/server.815/a68022/sql.htm:
#include <stdio.h>
/* declare host variables */
char userid[12] = "SCOTT/TIGER";
char emp_name[10];
int emp_number;
int dept_number;
char temp[32];
void sql_error();
/* include the SQL Communications Area */
//#include <sqlca.h>
main()
{ emp_number = 7499;
/* handle errors */
EXEC SQL WHENEVER SQLERROR do sql_error("Oracle error");
/* connect to Oracle */
EXEC SQL CONNECT :userid;
printf("Connected.\n");
/* declare a cursor */
EXEC SQL DECLARE emp_cursor CURSOR FOR
SELECT ename
FROM emp
WHERE deptno = :dept_number;
Whenever the compiler gets to the EXEC
statement a compile error occurs:
E2451 SQL.CPP 17: Undefined symbol 'EXEC' in function main()
I am using Borland c++ VER 5.5.1 and SQL 2008 R2.
Upvotes: 1
Views: 1230
Reputation: 25073
The code on that page is not C++.
It's a special dialect for use with the Pro*C/C++ Precompiler. (Link copied from @pb2q.)
Upvotes: 0
Reputation: 59627
Those SQL statements aren't valid C code, and need to go through an additional preprocessor before compilation, which knows how to transform the raw SQL statements into C.
Start at the earlier chapters from your link, particularly Chapter 1, What Is an Oracle Precompiler?.
Upvotes: 2