/*
 * cm_code_like_dbio.pgc - cm 모듈 DB 접근 함수 (cm_code_like_dbio), archived into libcmdbio.a.
 * ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
 * 코드명 패턴 검색 건수.
 */
#include <string.h>
#include <userlog.h>
#include "cm_code_like_dbio.h"

long cmdb_code_name_like(const char *pat)
{
    EXEC SQL BEGIN DECLARE SECTION;
    char h_pat[64];
    long h_v = 0;
    EXEC SQL END DECLARE SECTION;
    strncpy(h_pat, pat, sizeof(h_pat)-1); h_pat[sizeof(h_pat)-1] = 0;
    EXEC SQL SELECT count(*) INTO :h_v FROM cm_code WHERE code_name LIKE :h_pat;
    if (sqlca.sqlcode < 0) return -1;
    return h_v;
}
