/*
 * cm_holiday_ex_dbio.pgc - cm 모듈 DB 접근 함수 (cm_holiday_ex_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_holiday_ex_dbio.h"

int cmdb_holiday_present(const char *key)
{
    EXEC SQL BEGIN DECLARE SECTION;
    char h_key[64];
    long h_v = 0;
    EXEC SQL END DECLARE SECTION;
    strncpy(h_key, key, sizeof(h_key)-1); h_key[sizeof(h_key)-1] = 0;
    EXEC SQL SELECT count(*) INTO :h_v FROM cm_holiday WHERE holi_date = :h_key;
    if (sqlca.sqlcode < 0) return -1;
    return h_v > 0 ? 1 : 0;
}
