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

/* 9. RC_REMATCH - 재대사 원장 기록. (KEEP) */
void RC_REMATCH(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char bizdate[16];
    EXEC SQL BEGIN DECLARE SECTION;
    long h_pid, h_net;
    char h_bizdate[16];
    EXEC SQL END DECLARE SECTION;
    h_pid = getl(b, T_PURCHASE_ID); h_net = getl(b, T_NET);
    gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
    strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
    EXEC SQL INSERT INTO ledger (ledger_id, purchase_id, entry_type, amount, biz_date)
        VALUES (nextval('ledger_seq'), :h_pid, 'REMATCH', :h_net, :h_bizdate);
    if (sqlca.sqlcode < 0) FAIL(b);
    OK(b);
}

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