#include #include #include #include #include typedef void * sql_context; void* test_func(void* input); int main(int argc, char* argv[]) { int ret = 0; pthread_t tid1, tid2, tid3; ret = pthread_create(&tid1, NULL, test_func, NULL); if(ret == 0) { printf("\npthread_create success tid1"); } else { printf("\npthread_create error tid1. ret =[%d]", ret); } ret = pthread_join(tid1, NULL); if(ret == 0) { printf("\npthread_join success"); } else { printf("\npthread_join fail"); } while(1) { sleep(100); } return(0); } void* test_func(void* input) { EXEC SQL BEGIN DECLARE SECTION; char dest[128]; char user[128]; char pass[128]; int isKind; int nCnt; sql_context ctx; EXEC SQL END DECLARE SECTION; EXEC SQL ENABLE THREADS; EXEC SQL CONTEXT ALLOCATE :ctx; memset(user, 0x00, sizeof(user)); memset(pass, 0x00, sizeof(pass)); strcpy(user, "userid"); strcpy(pass, "passwd"); EXEC SQL CONTEXT USE :ctx ; EXEC SQL CONNECT :user IDENTIFIED BY :pass ; while(1) { memset(dest, 0x00, sizeof(dest)); strcpy(dest, "www.mmo.co.kr"); isKind = 0; nCnt = 0; EXEC SQL CONTEXT USE :ctx ; EXEC SQL SELECT COUNT(*) INTO :nCnt FROM TB_TEST_TABLE WHERE DEST = :dest AND DEST_TYPE = :isKind; if((sqlca.sqlcode==0) && (nCnt==1)) { printf("\nthread_test::SUCCESS 1"); } else if((sqlca.sqlcode==1403) && (nCnt==0)) { printf("\nthread_test::SUCCESS 0"); } else { printf("\nthread_test::ERROR"); } } return 0; }