#include <stdio.h> #include <stdlib.h> #include <string.h> EXEC SQL INCLUDE SQLCA; #define CHECKRR(CE_STR) if(sqlca.sqlcode != 0)\ {printf("%s.sqlcode=[%d]\n",CE_STR,sqlca.sqlcode); return 1} int main(int argc,char *argv[]) { EXEC SQL BEGIN DECLARE SECTION; char category[30]; char userid[9]; char passwd[19]; EXEC SQL END DECLARE SECTION; printf("Sample C program:STATIC\n"); if(argc == 1) { EXEC SQL CONNECT TO sample; CHECKRR("CONNECT TO SAMPLE"); } else if(argc == 3) { strcpy(userid,argv[1]); strcpy(passwd,argv[2]); EXEC SQL CONNECT TO sample USER :userid USING :passwd; CHECKERR("CONNECT TO SAMPLE"); } else { printf("\nUSAGE: static [userid passwd]\n\n"); } EXEC SQL SELECT CATEGORY INTO :category FROM CAREER_LEADERS WHERE PLAYER = 'Dwyane Wade' and ; CHECKERR("SELECT statement"); printf("Category = %s\n",firstname); EXEC SQL CONNECT RESET; CHECKERR("SELECT statement"); return 0; }
预编译出现了如下的报错,是什么原因,求指教。 [db2inst1@localhost ~]$ db2 prep /tmp/Demo/static.sqc BINDFILE
LINE MESSAGES FOR static.sqc ------ -------------------------------------------------------------------- SQL0060W The "C" precompiler is in progress. SQL0031C File "/tmp/Demo/static.bnd" could not be opened. SQL0095N No bind file was created because of previous errors. SQL0091W Precompilation or binding was ended with "2" errors and "0" warnings.
bnd文件里面好像就是sqc文件的文件名 应该是在预编译期间与.c文件一起生成的 难道是目录没权限? 找到原因了,是没有权限的问题。 .sqc文件放在目录/tmp/Demo/,该目录在db2inst1登录的情况下是不能生成文件的。于是我把.sqc文件换到了目录/home/db2inst1/db2inst1中,这个问题就不再出现了。
|