I am familiar with Oracle PL/SQL and C/C++ language, and I can write code that pulls data from a database and outputs result to console/command/output stream/etc.
However, I am not familiar with openVMS development. But I was able to verify that the CXX
compiler (built in to the operating system) works after compiling/linking and running the following code:
#include <stdio.h>
void main(void) {
printif("Hello World!\n");
}
Now, I tried to my best to connect to the oracle database (which is installed on the same server, and there are a lot of other C/CP files written to pull data from the db and they work fine), but I was not able to compile any code that tries to read from the database. For simplicity, here is the code that tried to access the database:
#include<stdio.h>
void main(void) {
int cnt = -1;
exec sql SELECT count(*) INTO :cnt FROM EMPLOYEES;
printif("Number of employees: %d", cnt);
}
When I compile that, I get:
%CXX-E-UNDECLARED, identifier "exec" is undefined
At first, I thought that I might be missing a library at the header, so I tried the following:
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#ifdef PC
#include <fcntl.h>
#else
#include <unixio.h>
#include <file.h>
#endif
#include <ctype.h>
but none of the above library caused the compiler to stop complaining about the exec sql
statetment.
I went to Oracle technical documents about writing C programs on openVMS and found some sample code that includes <sqlca.h>
and others like <sql_sqlda.h>
but none of them solved my problem.
I am guess, may be the other c files written before are somehow compiled with a special command that takes care of EXEC SQL statement (by attaching a dependency library on the fly at compile time???)
So my question is: what can I do to compile my code and get the count of records in a certain table?