/*
 * mm_issuer_query_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_query_dbio.h"

int mmdb_issuer_country(const char *cd, char *country_out)
{
    EXEC SQL BEGIN DECLARE SECTION;
    char h_cd[32], h_country[8];
    EXEC SQL END DECLARE SECTION;
    strncpy(h_cd, cd, sizeof(h_cd)-1); h_cd[sizeof(h_cd)-1] = 0;
    EXEC SQL SELECT country INTO :h_country FROM mm_issuer WHERE issuer_cd = :h_cd;
    if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) { userlog("mmdb_issuer_country FAIL [%d]", sqlca.sqlcode); return -1; }
    strncpy(country_out, h_country, 7); country_out[7] = 0;
    return 0;
}
