/*
 * vl_report_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_report_dbio.h"

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