Cubrid C 프로그래밍 사용 예제
Posted 2009/09/09 16:58|
|
|
댓글 하나가 운영자에겐 커다란 힘이 됩니다!
아래의 글은 권진호님 블로그(http://blog.daum.net/aswip)에서 스크랩한 내용입니다.
다음은 "Cubrid C 라이브러리를 사용해서, 레코드를 조회하는 방법"에 대해서 설명하고 있습니다.
[내용참고] http://www.cubrid.com/online_manual/cubrid_813/gs/gs_app_cci_sample.htm
#include <windows.h>
#include "cas_cci.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#pragma comment(lib, "cascci.lib")
int main(int argc, char **argv)
{
int nColCount = 0, nLen = 0;
int i = 0, nDB = 0, nRet = 0, nReq = 0;
char *pszBuff = NULL;
T_CCI_ERROR cciErr;
T_CCI_COL_INFO *pcciCol;
T_CCI_SQLX_CMD cciCmdType;
assert((nDB = cci_connect("127.0.0.1", 33000, "tempDB", "admin", "1111")) >= 0);
assert((nReq = cci_prepare(nDB, "SELECT * FROM Account", 0, &cciErr)) >= 0);
assert((pcciCol = cci_get_result_info(nReq, &cciCmdType, &nColCount)) != NULL);
for (i = 1; i <= nColCount; i++)
{
printf("%s\t", CCI_GET_RESULT_INFO_NAME(pcciCol, i));
}
printf("\n");
assert(cci_execute(nReq, 0, 0, &cciErr) >= 0);
while (1)
{
if ( cci_cursor(nReq, 1, CCI_CURSOR_CURRENT, &cciErr) == CCI_ER_NO_MORE_DATA )
break;
assert(cci_fetch(nReq, &cciErr) >= 0);
for (i = 1; i<= nColCount; i++)
{
assert(cci_get_data(nReq, i, CCI_A_TYPE_STR, &pszBuff, &nLen) >= 0);
printf("%s\t", pszBuff);
}
printf("\n");
}
assert(cci_close_req_handle(nReq) >= 0);
assert(cci_disconnect(nDB, &cciErr) >= 0);
return 0;
}
다음은 "Cubrid C 라이브러리를 사용해서, 레코드를 조회하는 방법"에 대해서 설명하고 있습니다.
[내용참고] http://www.cubrid.com/online_manual/cubrid_813/gs/gs_app_cci_sample.htm
※ 설명의 편의상, 현재 접속하려는 데이터베이스의 명칭은 "tempDB"라고 가정하며,
데이터베이스 접근시 계정 아이디는 "admin", 패스워드는 "1111"이라고 가정합니다.
#include <windows.h>
#include "cas_cci.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#pragma comment(lib, "cascci.lib")
int main(int argc, char **argv)
{
int nColCount = 0, nLen = 0;
int i = 0, nDB = 0, nRet = 0, nReq = 0;
char *pszBuff = NULL;
T_CCI_ERROR cciErr;
T_CCI_COL_INFO *pcciCol;
T_CCI_SQLX_CMD cciCmdType;
assert((nDB = cci_connect("127.0.0.1", 33000, "tempDB", "admin", "1111")) >= 0);
assert((nReq = cci_prepare(nDB, "SELECT * FROM Account", 0, &cciErr)) >= 0);
assert((pcciCol = cci_get_result_info(nReq, &cciCmdType, &nColCount)) != NULL);
for (i = 1; i <= nColCount; i++)
{
printf("%s\t", CCI_GET_RESULT_INFO_NAME(pcciCol, i));
}
printf("\n");
assert(cci_execute(nReq, 0, 0, &cciErr) >= 0);
while (1)
{
if ( cci_cursor(nReq, 1, CCI_CURSOR_CURRENT, &cciErr) == CCI_ER_NO_MORE_DATA )
break;
assert(cci_fetch(nReq, &cciErr) >= 0);
for (i = 1; i<= nColCount; i++)
{
assert(cci_get_data(nReq, i, CCI_A_TYPE_STR, &pszBuff, &nLen) >= 0);
printf("%s\t", pszBuff);
}
printf("\n");
}
assert(cci_close_req_handle(nReq) >= 0);
assert(cci_disconnect(nDB, &cciErr) >= 0);
return 0;
}
위의 정보가 도움이 되셨나요? 그렇다면 댓글 하나만 남겨주세요.
댓글 하나가 운영자에겐 커다란 힘이 됩니다!
- Filed under : 프로그래밍/Database
- Comment Trackback

