/*
 * ST_CONFIRM.pgc - st 모듈 서비스 ST_CONFIRM (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_CONFIRM.h"

/* 29. ST_CONFIRM - 정산 확정 (SETTLED -> CONFIRMED). */
void ST_CONFIRM(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    EXEC SQL BEGIN DECLARE SECTION;
    long h_pid;
    EXEC SQL END DECLARE SECTION;
    h_pid = getl(b, T_PURCHASE_ID);
    EXEC SQL UPDATE settlement SET status = 'CONFIRMED'
        WHERE purchase_id = :h_pid AND status = 'SETTLED';
    if (sqlca.sqlcode < 0) FAIL(b);
    Bchg(b, T_STATUS, 0, "C", 0L);
    OK(b);
}

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