/*
 * mm_dbio.h - mm 모듈 (마스터/master) DB 접근 계층 (libmmdbio.a).
 * ECPG (EXEC SQL) functions compiled into a static library and linked into
 * mm_svr and the mm batches. They run on the caller's XA branch/connection
 * (no EXEC SQL CONNECT); sqlca is the shared per-thread ECPG SQLCA.
 * Return convention: 0 = ok, -1 = SQL error (caller may also inspect sqlca).
 */
#ifndef MM_DBIO_H
#define MM_DBIO_H

/* 가맹점 마스터 (mm_merch_dbio) */
long mmdb_next_hist_id(void);
int  mmdb_insert_merchant(const char *merch, const char *name, const char *grade,
                          const char *acct, const char *status);
int  mmdb_get_merchant(const char *merch, char *name_out /*>=64*/,
                       char *grade_out /*>=8*/, char *status_out /*>=16*/);
int  mmdb_update_merchant_status(const char *merch, const char *status);
int  mmdb_update_merchant_grade(const char *merch, const char *grade);
int  mmdb_insert_merch_hist(const char *merch, const char *action,
                            const char *before_val, const char *after_val,
                            const char *memo);

/* 수수료율 마스터 (mm_feerate_dbio) */
int  mmdb_set_fee_rate(const char *merch, const char *card_type, long rate_bps);
int  mmdb_get_fee_rate(const char *merch, const char *card_type, long *bps_out);
long mmdb_feerate_hist_count(const char *merch);

#endif /* MM_DBIO_H */
