/*
 * mm_holiday_dbio.pgc - 영업일/공휴일 판정 (libmmdbio.a).
 * ECPG functions; run on the caller's XA branch. No EXEC SQL CONNECT.
 */
#include <string.h>
#include <userlog.h>
#include "mm_holiday_dbio.h"

int mmdb_is_holiday(const char *date)
{
    EXEC SQL BEGIN DECLARE SECTION;
    long h_cnt; char h_date[16];
    EXEC SQL END DECLARE SECTION;
    strncpy(h_date, date, sizeof(h_date)-1); h_date[sizeof(h_date)-1] = 0;
    EXEC SQL SELECT count(*) INTO :h_cnt FROM mm_holiday WHERE holiday_date = :h_date;
    if (sqlca.sqlcode < 0) { userlog("mmdb_is_holiday FAIL [%d]", sqlca.sqlcode); return -1; }
    return (h_cnt > 0) ? 1 : 0;
}
