http://blog.naver.com/julymorning4/100024942920
Pro*c로 PL/SQL 실행하기 |
|
|
pro*C를 이용하여 PL/SQL을 실행하기 위해서는 컴파일 옵션에서
sqlcheck=semantics 라고 해주어야 합니다.
==========================================================
EXEC SQL include sqlca.h;
char* connstr = "test/test@test";
EXEC SQL BEGIN DECLARE SECTION; VARCHAR v_ename[20]; EXEC SQL END DECLARE SECTION;
/*===========================================================*/ /* Main 선언 */ /*==========================================================*/ void main(int argc, char *argv[]) { EXEC SQL CONNECT :connstr;
/********** PL/SQL Test **********/ printf("Embedded PL/SQL\n");
EXEC SQL EXECUTE BEGIN SELECT ENAME INTO :v_ename FROM emp WHERE EMPNO=9999; END; END-EXEC;
memset(&v_ename.arr[v_ename.len],'\0',1);
printf("%s\n\n",v_ename.arr); EXEC SQL COMMIT WORK RELEASE; }
===============================================
Stored Procedure를 호출하기 위해선 아래처럼 하면 되구요...
EXEC SQL EXECUTE BEGIN upcall(:v_loc1);/* procedure name */ END; END-EXEC;
|
|
RECENT COMMENT