/*
 * vl_batchchk_dbio.pgc - 영업일 매입 건수 (배치 정합용) (libvldbio.a).
 * ECPG functions; run on the caller's XA branch. No EXEC SQL CONNECT.
 */
#include <string.h>
#include <userlog.h>
#include "vl_batchchk_dbio.h"

long vldb_purchase_day_count(const char *bizdate)
{
    EXEC SQL BEGIN DECLARE SECTION;
    long h_cnt; char h_bizdate[16];
    EXEC SQL END DECLARE SECTION;
    strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
    EXEC SQL SELECT count(*) INTO :h_cnt FROM purchase WHERE biz_date = :h_bizdate;
    if (sqlca.sqlcode < 0) { userlog("vldb_purchase_day_count FAIL [%d]", sqlca.sqlcode); return -1; }
    return h_cnt;
}
