/*
 * rc_resolveall_dbio.pgc - rc 모듈 DB 접근 함수 세트 (rc_resolveall_dbio), archived into librcdbio.a.
 * ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
 * 당일 예외 일괄 해소 - UPDATE 후 영향 행수(sqlerrd) 반환.
 */
#include <string.h>
#include <userlog.h>
#include "rc_resolveall_dbio.h"

long rcdb_resolve_all(const char *bizdate)
{
    EXEC SQL BEGIN DECLARE SECTION;
    char h_bizdate[16];
    EXEC SQL END DECLARE SECTION;
    strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
    EXEC SQL UPDATE rc_exception SET resolved = true
        WHERE biz_date = :h_bizdate AND resolved = false;
    if (sqlca.sqlcode < 0) { userlog("rcdb_resolve_all FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
    return (long)sqlca.sqlerrd[2];
}
