/*
 * rc_instatus_dbio.pgc - rc 모듈 DB 접근 함수 세트 (rc_instatus_dbio), archived into librcdbio.a.
 * ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
 * 종료 상태 집합(CONFIRMED/RELEASED) IN 필터 건수.
 */
#include <string.h>
#include <userlog.h>
#include "rc_instatus_dbio.h"

long rcdb_match_closed_count(const char *bizdate)
{
    EXEC SQL BEGIN DECLARE SECTION;
    char h_bizdate[16];
    long h_v = 0;
    EXEC SQL END DECLARE SECTION;
    strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
    EXEC SQL SELECT count(*) INTO :h_v FROM rc_match_log
        WHERE biz_date = :h_bizdate AND status IN ('CONFIRMED', 'RELEASED');
    if (sqlca.sqlcode < 0) return -1;
    return h_v;
}
