/*
 * vl_purgelog_dbio.pgc - vl 모듈 DB 접근 함수 (vl_purgelog_dbio), archived into libvldbio.a.
 * ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
 * 기준일 이전 정상(result_code=0) 검증로그 삭제 후 삭제건수 반환 (DELETE 범위).
 */
#include <string.h>
#include <userlog.h>
#include "vl_purgelog_dbio.h"

long vldb_purge_checklog(const char *cutoff)
{
    EXEC SQL BEGIN DECLARE SECTION;
    char h_cut[16];
    EXEC SQL END DECLARE SECTION;
    strncpy(h_cut, cutoff, sizeof(h_cut)-1); h_cut[sizeof(h_cut)-1] = 0;
    EXEC SQL DELETE FROM vl_check_log
        WHERE biz_date < :h_cut AND result_code = 0;
    if (sqlca.sqlcode < 0) { userlog("vldb_purge_checklog FAIL [%d]", sqlca.sqlcode); return -1; }
    return (long) sqlca.sqlerrd[2];
}
