/*
 * mm_bin_count_dbio.pgc - 발급사별 BIN 건수 집계 (libmmdbio.a).
 * ECPG functions; run on the caller's XA branch. No EXEC SQL CONNECT.
 */
#include <string.h>
#include <userlog.h>
#include "mm_bin_count_dbio.h"

long mmdb_bin_by_issuer(const char *issuer)
{
    EXEC SQL BEGIN DECLARE SECTION;
    long h_cnt; char h_issuer[32];
    EXEC SQL END DECLARE SECTION;
    strncpy(h_issuer, issuer, sizeof(h_issuer)-1); h_issuer[sizeof(h_issuer)-1] = 0;
    EXEC SQL SELECT count(*) INTO :h_cnt FROM mm_bin WHERE issuer_cd = :h_issuer AND status = 'ACTIVE';
    if (sqlca.sqlcode < 0) { userlog("mmdb_bin_by_issuer FAIL [%d]", sqlca.sqlcode); return -1; }
    return h_cnt;
}
