/*
 * lg_draft_count_dbio.pgc - lg 모듈 DB 접근 함수 (lg_draft_count_dbio), archived into liblgdbio.a.
 * 작성(D) 상태 미전기 전표 건수.
 * ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
 */
#include <string.h>
#include <userlog.h>
#include "lg_draft_count_dbio.h"

/* 전기(P) 되지 않은 작성(D) 전표 수 (전 기간). */
long lgqdb_draft_count(void)
{
    EXEC SQL BEGIN DECLARE SECTION;
    long h_cnt = 0;
    EXEC SQL END DECLARE SECTION;
    EXEC SQL SELECT count(*) INTO :h_cnt FROM lg_voucher WHERE status = 'D';
    if (sqlca.sqlcode < 0) { userlog("lgqdb_draft_count FAIL [%d]", sqlca.sqlcode); return -1; }
    return h_cnt;
}
