/*
 * vl_suspect_query_dbio.pgc - 심각도별 의심거래 건수 (libvldbio.a).
 * ECPG functions; run on the caller's XA branch. No EXEC SQL CONNECT.
 */
#include <string.h>
#include <userlog.h>
#include "vl_suspect_query_dbio.h"

long vldb_suspect_by_sev(const char *sev, const char *bizdate)
{
    EXEC SQL BEGIN DECLARE SECTION;
    long h_cnt; char h_sev[8], h_bizdate[16];
    EXEC SQL END DECLARE SECTION;
    strncpy(h_sev, sev, sizeof(h_sev)-1); h_sev[sizeof(h_sev)-1] = 0;
    strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
    EXEC SQL SELECT count(*) INTO :h_cnt FROM vl_suspect
        WHERE severity = :h_sev AND biz_date = :h_bizdate;
    if (sqlca.sqlcode < 0) { userlog("vldb_suspect_by_sev FAIL [%d]", sqlca.sqlcode); return -1; }
    return h_cnt;
}
