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

void ACQ_APPRMAP(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    EXEC SQL BEGIN DECLARE SECTION;
    long h_pid, h_cnt;
    EXEC SQL END DECLARE SECTION;
    h_pid = getl(b, T_PURCHASE_ID);
    EXEC SQL SELECT count(*) INTO :h_cnt FROM approval WHERE purchase_id = :h_pid;
    if (sqlca.sqlcode < 0) FAIL(b);
    setl(b, T_COUNT, h_cnt);
    OK(b);
}
