proc lines=yes char_map=string MODE=ORACLE RELEASE_CURSOR=NO HOLD_CURSOR=YES PARSE=NONE practice.pc
With PARSE=FULL
This option means that the C parser is used to parse the code.
You need not use EXEC SQL DECLARE BEGIN SECTION; and EXEC SQL DECLARE END SECTION;
Since the file is getting parsed you need to include the path of the header files.
proc MODE=ORACLE SQLCHECK=SEMANTICS CHAR_MAP=VARCHAR2 CLOSE_ON_COMMIT=NO AUTO_CONNECT=NO DEFINE=UNIX INCLUDE=/usr/lib/gcc/x86_64-redhat-linux/4.1.2/include INCLUDE=/app/vector/include INCLUDE=/app/oracle/product/10.2.0/db_1/rdbms/public INCLUDE=/app/oracle/product/10.2.0/db_1/lib INCLUDE=/usr/include/linux RELEASE_CURSOR=NO HOLD_CURSOR=YES THREADS=NO example_sqlgls.pc PARSE=FULL practice.pc
To compile on VC++ 8
proc
PARSE=FULL DEFINE=_WSTDIO_DEFINED CHAR_MAP=VARCHAR2 CLOSE_ON_COMMIT=NO
AUTO_CONNECT=NO DEFINE=WIN32 MODE=ORACLE SQLCHECK=SEMANTIC include=("C:\Program
Files (x86)\Microsoft Visual Studio 9.0\VC\include",C:\vector_dms\vector_dms)
C:\vector_dms\vector_dms\vector_dms_sql.pc
To compile on VC++ 6
proc PARSE=FULL CHAR_MAP=VARCHAR2 CLOSE_ON_COMMIT=NO AUTO_CONNECT=NO DEFINE=WIN32 MODE=ORACLE SQLCHECK=SEMANTIC include=("C:\Program Files\Microsoft Visual Studio\VC98\Include",C:\vector_dms) C:\vector_dms\vector_dms_sql.pc
gcc -g -I/app/oracle/product/10.2.0/db_1/precomp/public -L/app/oracle/product/10.2.0/db_1/lib -lclntsh practice.c -o practice
Text of practic.pc
#include
#include
#include
#include
void sql_warning();
void sql_notfound();
void sql_error();
/*exec sql begin declare section;*/
char username[20];
char password[20];
char o_value[3];
char server_name[20] ="oltpdev";
char buff[300];
int buff_len,msg_len;
long SQLCODE;
exec sql declare DB_NAME DATABASE;
/*exec sql end declare section;*/
EXEC SQL WHENEVER SQLWARNING DO sql_warning();
EXEC SQL WHENEVER SQLERROR DO sql_error();
EXEC SQL WHENEVER NOT FOUND DO sql_notfound();
exec sql whenever sqlerror do sql_error();
exec sql whenever sqlwarning do sql_warning();
exec sql whenever not found do sql_notfound();
int main()
{
strcpy(username,"pbatch_md_int");
strcpy(password,"pbatch_md_int");
o_value[0]=o_value[1]=' ';
o_value[2]='\0';
exec sql connect :username identified by :password at DB_NAME using :server_name;
printf("sqlocde %ld \n",SQLCODE);
exec sql at DB_NAME select 'XE' into :o_value from t_dmv_file;
printf("sqlocde %ld \n",SQLCODE);
printf("connected and %s \n",o_value);
return 0;
}
void sql_warning()
{
printf("sqlocde %ld \n",SQLCODE);
buff_len=sizeof(buff);
sqlglm(buff, &buff_len, &msg_len);
printf( "SQL ERROR %s\n",buff);
printf("SQL_WARNING\n");
EXEC SQL WHENEVER SQLWARNING DO sql_warning();
return;
}
void sql_notfound()
{
printf("sqlocde %ld \n",SQLCODE);
buff_len=sizeof(buff);
sqlglm(buff, &buff_len, &msg_len);
printf( "SQL ERROR %s\n",buff);
printf("NOT FOUND\n");
EXEC SQL WHENEVER NOT FOUND DO sql_notfound();
return;
}
void sql_error()
{
printf("sqlocde %ld \n",SQLCODE);
buff_len=sizeof(buff);
sqlglm(buff, &buff_len, &msg_len);
printf( "SQL ERROR %s\n",buff);
EXEC SQL WHENEVER SQLERROR DO sql_error();
return;
}
No comments:
Post a Comment