/*
 * vl_dbio.h - vl 모듈 (정합성검증/validation) DB 접근 계층 (libvldbio.a).
 * ECPG (EXEC SQL) functions compiled into a static library and linked into
 * vl_svr and the vl 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/>=0 = ok, -1 = SQL error (caller may also inspect sqlca).
 */
#ifndef VL_DBIO_H
#define VL_DBIO_H

/* 의심거래/검증로그 (vl_check_dbio) */
long vldb_next_suspect_id(void);
long vldb_insert_suspect(long purchase_id, const char *rule_code,
                         const char *severity, const char *detail,
                         const char *bizdate);
long vldb_insert_check_log(const char *check_type, long target_id,
                           long result_code, const char *detail,
                           const char *bizdate);
long vldb_suspect_count(const char *bizdate);

/* 검증규칙 (vl_rule_dbio) */
int  vldb_get_rule(const char *rule_code, long *threshold_out,
                   char *severity_out /* >= 8 */);
int  vldb_upsert_rule(const char *rule_code, const char *rule_name,
                      long threshold, const char *severity);

#endif /* VL_DBIO_H */
