TECH
QUESTION
자주하는 질문답변 입니다.
Oracle
작성자 | 유건데이타 | 등록일 | 2015-05-21 |
제목 | Dynamic SQL Method 2 : UPDATE | ||
---|---|---|---|
/**************************************************************
Dynamic SQL Method 2 : UPDATE This program uses dynamic SQL Method 2 to update a record on EMP table **************************************************************/ #define USERNAME "SCOTT" #define PASSWORD "TIGER" #include #include EXEC SQL INCLUDE sqlca; EXEC SQL BEGIN DECLARE SECTION; char *username = USERNAME; char *password = PASSWORD; varchar sqlstmt[80]; int empno = 1234; int deptno1 = 30; EXEC SQL END DECLARE SECTION; main() { EXEC SQL WHENEVER SQLERROR GOTO sqlerror; EXEC SQL CONNECT :username IDENTIFIED BY :password; puts((char *) "\nConnected to ORACLE.\n"); sprintf(sqlstmt.arr, "UPDATE emp SET %s = :v%s WHERE %s = :v%s", "empno","1","deptno","2"); sqlstmt.len=strlen(sqlstmt.arr); EXEC SQL PREPARE S FROM :sqlstmt; EXEC SQL EXECUTE S USING :empno, :deptno1; EXEC SQL COMMIT RELEASE; puts((char *) "\nHave a good day!\n"); exit(0); sqlerror: printf("\n%.*s\n", sqlca.sqlerrm.sqlerrml, sqlca.sqlerrm.sqlerrmc); } |
Comment | |||
---|---|---|---|
등록된 코멘트가 없습니다. |