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

/* 29. CM_STATUS - 모듈 상태: 파라미터 건수 조회로 DB 연결 확인. */
void CM_STATUS(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    EXEC SQL BEGIN DECLARE SECTION;
    long h_cnt;
    EXEC SQL END DECLARE SECTION;
    EXEC SQL SELECT count(*) INTO :h_cnt FROM cm_param;
    if (sqlca.sqlcode < 0) FAIL(b);
    setl(b, T_COUNT, h_cnt);
    setl(b, T_RC, 0);
    sets_(b, T_STATUS, "UP");
    OK(b);
}
