/*
 * st_paystatuscnt_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_paystatuscnt_dbio), archived into libstdbio.a.
 * ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
 * 지급 상태별 건수 조회.
 */
#include <string.h>
#include <userlog.h>
#include "st_paystatuscnt_dbio.h"

long stdb_payment_status_count(const char *bizdate, const char *status)
{
    EXEC SQL BEGIN DECLARE SECTION;
    char h_bizdate[16], h_status[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;
    strncpy(h_status, status, sizeof(h_status)-1); h_status[sizeof(h_status)-1] = 0;
    EXEC SQL SELECT count(*) INTO :h_v FROM st_payment
        WHERE biz_date = :h_bizdate AND status = :h_status;
    if (sqlca.sqlcode < 0) return -1;
    return h_v;
}
