/*
 * RC_DIFFRPT.pgc - rc 모듈 서비스 RC_DIFFRPT (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_DIFFRPT.h"

/* 19. RC_DIFFRPT - 당일 차이 라인 건수 조회. */
void RC_DIFFRPT(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(diff_amt),0) INTO :h_cnt, :h_sum
        FROM rc_diff WHERE biz_date = :h_bizdate;
    if (sqlca.sqlcode < 0) FAIL(b);
    setl(b, T_COUNT, h_cnt);
    setl(b, T_DELTA, h_sum);
    OK(b);
}

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