/*
 * mm_issuer_count_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_issuer_count_dbio.h"

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