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

/* 21. ST_REPORT - 당일 정산 건수/합계 리포트. */
void ST_REPORT(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char bizdate[16];
    EXEC SQL BEGIN DECLARE SECTION;
    long h_cnt, h_sum;
    char h_bizdate[16];
    EXEC SQL END DECLARE SECTION;
    gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
    strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
    EXEC SQL SELECT count(*), coalesce(sum(net),0) INTO :h_cnt, :h_sum
        FROM settlement WHERE biz_date = :h_bizdate;
    if (sqlca.sqlcode < 0) FAIL(b);
    setl(b, T_COUNT, h_cnt);
    setl(b, T_GROSS, h_sum);
    OK(b);
}

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