/*
 * mm_limit_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_limit_query_dbio.h"

long mmdb_daily_limit(const char *merch)
{
    EXEC SQL BEGIN DECLARE SECTION;
    long h_lim = 0; char h_merch[64];
    EXEC SQL END DECLARE SECTION;
    strncpy(h_merch, merch, sizeof(h_merch)-1); h_merch[sizeof(h_merch)-1] = 0;
    EXEC SQL SELECT daily_limit INTO :h_lim FROM mm_limit WHERE merchant_id = :h_merch;
    if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) { userlog("mmdb_daily_limit FAIL [%d]", sqlca.sqlcode); return -1; }
    return h_lim;
}
