/*
 * MG_HEALTH.pgc - mg 모듈 서비스 MG_HEALTH (one service = one file).
 * Split out of the former inline mg_svr.pgc; runs on the caller's XA
 * branch (no EXEC SQL CONNECT). Advertised by mg_svr at tpsvrinit.
 */
#include "MG_HEALTH.h"

/* 16. MG_HEALTH - 게이트웨이 헬스: 활성 채널 수 조회. */
void MG_HEALTH(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    EXEC SQL BEGIN DECLARE SECTION;
    long h_up;
    EXEC SQL END DECLARE SECTION;
    EXEC SQL SELECT count(*) INTO :h_up FROM mg_channel WHERE status IN ('UP','SIGNON');
    if (sqlca.sqlcode < 0) FAIL(b);
    setl(b, T_COUNT, h_up);
    setl(b, T_RC, 0);
    OK(b);
}
