/*
 * cm_grpdistinct_dbio.pgc - cm 모듈 DB 접근 함수 (cm_grpdistinct_dbio), archived into libcmdbio.a.
 * ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
 * 사용중인 고유 코드그룹 수 (count DISTINCT).
 */
#include <string.h>
#include <userlog.h>
#include "cm_grpdistinct_dbio.h"

long cmdb_distinct_grp(void)
{
    EXEC SQL BEGIN DECLARE SECTION;
    long h_v = 0;
    EXEC SQL END DECLARE SECTION;
    EXEC SQL SELECT count(DISTINCT code_grp) INTO :h_v FROM cm_code WHERE use_yn = 'Y';
    if (sqlca.sqlcode < 0) { userlog("cmdb_distinct_grp FAIL [%d]", sqlca.sqlcode); return -1; }
    return h_v;
}
