http://blog.naver.com/julymorning4/100024943047
Pro*C를 이용한 간단 Data Select |
|
|
#include <stdio.h> #include <sqlca.h>
void sqlerror();
EXEC SQL BEGIN DECLARE SECTION; char *connstr = "myscott/mytiger"; char db_ename[30]; intdb_deptno; EXEC SQL END DECLARE SECTION;
void main() { EXEC SQL WHENEVER SQLERROR DO sqlerror(); EXEC SQL WHENEVER SQLWARNING CONTINUE; EXEC SQL CONNECT :connstr;
EXEC SQL WHENEVER NOTFOUND GOTO notfound; EXEC SQL SELECT ENAME, DEPTNO INTO db_ename, db_deptno FROM EMP WHEREEMPNO = 1004;
found: printf("%s is in department %i\n", db_ename, db_deptno); return;
notfound: printf("Employee record not found in database.\n"); return; }
void sqlerror() { printf("Stop Error:\t%25i\n", sqlca.sqlcode); return; }
|
|
RECENT COMMENT