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

int mmdb_bin_issuer(const char *bin, char *issuer_out)
{
    EXEC SQL BEGIN DECLARE SECTION;
    char h_bin[16], h_issuer[32];
    EXEC SQL END DECLARE SECTION;
    strncpy(h_bin, bin, sizeof(h_bin)-1); h_bin[sizeof(h_bin)-1] = 0;
    EXEC SQL SELECT issuer_cd INTO :h_issuer FROM mm_bin WHERE bin = :h_bin;
    if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) { userlog("mmdb_bin_issuer FAIL [%d]", sqlca.sqlcode); return -1; }
    strncpy(issuer_out, h_issuer, 31); issuer_out[31] = 0;
    return 0;
}
