/*
 * RC_BYISSUER.pgc - rc 모듈 서비스 RC_BYISSUER (one service = one file).
 * Moved verbatim from the former inline rc_svr.pgc; runs on the caller's XA
 * branch (no EXEC SQL CONNECT). Advertised by rc_svr at tpsvrinit.
 */
#include "RC_BYISSUER.h"

/* 15. RC_BYISSUER - 발급사별 매입 건수 집계. */
void RC_BYISSUER(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char bizdate[16], issuer[32];
    EXEC SQL BEGIN DECLARE SECTION;
    long h_cnt;
    char h_bizdate[16], h_issuer[32];
    EXEC SQL END DECLARE SECTION;
    gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
    gets_(b, T_ISSUER, issuer, sizeof(issuer)); if (issuer[0] == 0) strcpy(issuer, "BC");
    strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
    strncpy(h_issuer, issuer, sizeof(h_issuer)-1); h_issuer[sizeof(h_issuer)-1] = 0;
    EXEC SQL SELECT count(*) INTO :h_cnt FROM purchase
        WHERE biz_date = :h_bizdate AND issuer = :h_issuer;
    if (sqlca.sqlcode < 0) FAIL(b);
    setl(b, T_COUNT, h_cnt);
    OK(b);
}

/* vim: set ts=4 sw=4 et smartindent: */
