/*
 * mm_limit_bump_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_bump_dbio.h"

int mmdb_bump_daily_limit(const char *merch, long delta)
{
    EXEC SQL BEGIN DECLARE SECTION;
    long h_delta = delta; 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 UPDATE mm_limit SET daily_limit = daily_limit + :h_delta, updated_at = now()
        WHERE merchant_id = :h_merch;
    if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) { userlog("mmdb_bump_daily_limit FAIL [%d]", sqlca.sqlcode); return -1; }
    return 0;
}
