Phase 2c: 전 11모듈 per-service 레거시 구조 분해·확장 (실동작 유지)

- 10개 모듈(au py rc st lg cl mm vl mg cm)을 ac 템플릿대로 분해:
  svc/ 30 서비스 .pgc + 카피북 .h, 얇은 <mod>_svr 디스패처
  dbio/ ~25 .pgc(+.h), batch/ ~17 .pgc, run/ ~17 .sh (모듈마다)
- 파일: svc 330 + dbio 276 + batch 187 + run 187, 총 소스 1602본
- 서비스별 고유 실로직(정규화 md5), build.sh 자동발견(inline/split 양립)
- 통합 검증: build DONE modules=11 servers=11 batches=187, 12서버 runok,
  333 서비스 AVAIL, 매입체인 XA 커밋(status=S), prepared_xacts=0

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
forge-bot 2026-07-19 11:58:44 +00:00
parent c3b99a8b75
commit fd8b418c6e
1404 changed files with 30322 additions and 5994 deletions

View file

@ -0,0 +1,45 @@
/*
* cl_approve_batch.pgc - cl 마감완료(C) 일괄 승인 배치 (커서 C->A) (XA 배치).
*
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
* Usage: cl_approve_batch [YYYY-MM-DD]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include "cl_dbio.h"
int main(int argc, char **argv)
{
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
EXEC SQL BEGIN DECLARE SECTION;
char h_bizdate[16];
long h_cid;
EXEC SQL END DECLARE SECTION;
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
long rows = 0;
EXEC SQL DECLARE cab CURSOR FOR
SELECT close_id FROM cl_close_log
WHERE biz_date = :h_bizdate AND status = 'C' ORDER BY close_id;
EXEC SQL OPEN cab;
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
for (;;) {
EXEC SQL FETCH cab INTO :h_cid;
if (sqlca.sqlcode == 100) break;
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE cab; tpabort(0); return 1; }
if (cldb_update_close_status(h_cid, "A") < 0) { EXEC SQL CLOSE cab; tpabort(0); return 1; }
rows++;
}
EXEC SQL CLOSE cab;
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
printf(">>> cl_approve_batch COMMIT: bizdate=%s 승인=%ld건\n", bizdate, rows);
tpclose(); tpterm();
return 0;
}

View file

@ -0,0 +1,35 @@
/*
* cl_archive_batch.pgc - cl 완료마감 아카이브 표시 배치 (dbio update) (XA 배치).
*
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
* Usage: cl_archive_batch [YYYY-MM-DD]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include "cl_dbio.h"
#include "cl_archive_mark_dbio.h"
int main(int argc, char **argv)
{
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
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;
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
long marked;
marked = clqdb_archive_mark(bizdate);
if (marked < 0) { fprintf(stderr, "cl_archive_batch FAIL\n"); tpabort(0); return 1; }
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
printf(">>> cl_archive_batch COMMIT: %s 이전 완료마감 %ld건 아카이브\n", bizdate, marked);
tpclose(); tpterm();
return 0;
}

View file

@ -0,0 +1,47 @@
/*
* cl_lock_batch.pgc - cl 기간 잠금 배치 (커서, 월 close_log 기간 잠금) (XA 배치).
*
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
* Usage: cl_lock_batch [YYYY-MM-DD]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include "cl_dbio.h"
int main(int argc, char **argv)
{
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
EXEC SQL BEGIN DECLARE SECTION;
char h_bizdate[16];
char h_period[16];
EXEC SQL END DECLARE SECTION;
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
long rows = 0;
EXEC SQL DECLARE clb CURSOR FOR
SELECT DISTINCT period_key FROM cl_close_log
WHERE close_type = 'MONTHLY' AND status IN ('A','C') ORDER BY period_key;
EXEC SQL OPEN clb;
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
for (;;) {
EXEC SQL FETCH clb INTO :h_period;
if (sqlca.sqlcode == 100) break;
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE clb; tpabort(0); return 1; }
EXEC SQL INSERT INTO cl_period_lock (period_key, locked) VALUES (:h_period, true)
ON CONFLICT (period_key) DO UPDATE SET locked = true, locked_at = now();
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE clb; tpabort(0); return 1; }
rows++;
}
EXEC SQL CLOSE clb;
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
printf(">>> cl_lock_batch COMMIT: %ld개 기간 잠금\n", rows);
tpclose(); tpterm();
return 0;
}

View file

@ -0,0 +1,38 @@
/*
* cl_midclose_batch.pgc - cl 중간 마감 배치 (접수/대사 A,M 집계 + MID close_log) (XA 배치).
*
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
* Usage: cl_midclose_batch [YYYY-MM-DD]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include "cl_dbio.h"
int main(int argc, char **argv)
{
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
EXEC SQL BEGIN DECLARE SECTION;
char h_bizdate[16];
long h_cnt, h_amt;
EXEC SQL END DECLARE SECTION;
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
long cid;
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :h_cnt, :h_amt
FROM purchase WHERE biz_date = :h_bizdate AND status IN ('A','M');
if (sqlca.sqlcode < 0) { fprintf(stderr, "AGG FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
cid = cldb_next_close_id();
if (cid < 0) { tpabort(0); return 1; }
if (cldb_insert_close(cid, "MID", bizdate, bizdate, "O", h_cnt, h_amt, "중간마감(배치)") < 0) { tpabort(0); return 1; }
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
printf(">>> cl_midclose_batch COMMIT: bizdate=%s cid=%ld 미마감대상=%ld\n", bizdate, cid, h_cnt);
tpclose(); tpterm();
return 0;
}

View file

@ -0,0 +1,40 @@
/*
* cl_monthly_batch.pgc - cl 월 마감 배치 (월 집계 + close_log MONTHLY) (XA 배치).
*
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
* Usage: cl_monthly_batch [YYYY-MM-DD]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include "cl_dbio.h"
int main(int argc, char **argv)
{
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
EXEC SQL BEGIN DECLARE SECTION;
char h_bizdate[16];
char h_period[16];
long h_cnt, h_amt;
EXEC SQL END DECLARE SECTION;
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
long cid;
strncpy(h_period, bizdate, 7); h_period[7] = 0;
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :h_cnt, :h_amt
FROM purchase WHERE to_char(biz_date,'YYYY-MM') = :h_period;
if (sqlca.sqlcode < 0) { fprintf(stderr, "AGG FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
cid = cldb_next_close_id();
if (cid < 0) { tpabort(0); return 1; }
if (cldb_insert_close(cid, "MONTHLY", h_period, bizdate, "C", h_cnt, h_amt, "월마감(배치)") < 0) { tpabort(0); return 1; }
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
printf(">>> cl_monthly_batch COMMIT: period=%s cid=%ld 건수=%ld 총액=%ld\n", h_period, cid, h_cnt, h_amt);
tpclose(); tpterm();
return 0;
}

View file

@ -0,0 +1,35 @@
/*
* cl_purge_batch.pgc - cl 취소(X) 마감 정리 배치 (dbio delete) (XA 배치).
*
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
* Usage: cl_purge_batch [YYYY-MM-DD]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include "cl_dbio.h"
#include "cl_cancel_purge_dbio.h"
int main(int argc, char **argv)
{
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
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;
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
long purged;
purged = clqdb_cancel_purge(bizdate);
if (purged < 0) { fprintf(stderr, "cl_purge_batch FAIL\n"); tpabort(0); return 1; }
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
printf(">>> cl_purge_batch COMMIT: %s 이전 취소마감 %ld건 삭제\n", bizdate, purged);
tpclose(); tpterm();
return 0;
}

View file

@ -0,0 +1,45 @@
/*
* cl_quarter_batch.pgc - cl 분기 마감 배치 (분기 프리픽스 집계) (XA 배치).
*
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
* Usage: cl_quarter_batch [YYYY-MM-DD]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include "cl_dbio.h"
int main(int argc, char **argv)
{
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
EXEC SQL BEGIN DECLARE SECTION;
char h_bizdate[16];
char h_year[8];
long h_cnt, h_amt, h_q;
EXEC SQL END DECLARE SECTION;
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
long cid;
char period[16];
int mm = (bizdate[5]-'0')*10 + (bizdate[6]-'0');
h_q = (mm - 1) / 3 + 1;
strncpy(h_year, bizdate, 4); h_year[4] = 0;
snprintf(period, sizeof(period), "%s-Q%ld", h_year, h_q);
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :h_cnt, :h_amt
FROM purchase WHERE to_char(biz_date,'YYYY') = :h_year
AND (extract(month from biz_date)::int - 1) / 3 + 1 = :h_q;
if (sqlca.sqlcode < 0) { fprintf(stderr, "AGG FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
cid = cldb_next_close_id();
if (cid < 0) { tpabort(0); return 1; }
if (cldb_insert_close(cid, "QUARTER", period, bizdate, "C", h_cnt, h_amt, "분기마감(배치)") < 0) { tpabort(0); return 1; }
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
printf(">>> cl_quarter_batch COMMIT: period=%s cid=%ld 건수=%ld\n", period, cid, h_cnt);
tpclose(); tpterm();
return 0;
}

View file

@ -0,0 +1,48 @@
/*
* cl_recon_batch.pgc - cl 마감 대사 배치 (커서, close_log vs purchase 총액 대사) (XA 배치).
*
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
* Usage: cl_recon_batch [YYYY-MM-DD]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include "cl_dbio.h"
int main(int argc, char **argv)
{
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
EXEC SQL BEGIN DECLARE SECTION;
char h_bizdate[16];
long h_cid, h_tsum, h_asum;
EXEC SQL END DECLARE SECTION;
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
long checked = 0, bad = 0;
EXEC SQL DECLARE cnb CURSOR FOR
SELECT close_id, total_amount FROM cl_close_log
WHERE close_type = 'DAILY' AND biz_date = :h_bizdate AND status <> 'X'
ORDER BY close_id;
EXEC SQL OPEN cnb;
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
for (;;) {
EXEC SQL FETCH cnb INTO :h_cid, :h_tsum;
if (sqlca.sqlcode == 100) break;
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE cnb; tpabort(0); return 1; }
EXEC SQL SELECT coalesce(sum(amount),0) INTO :h_asum FROM purchase WHERE biz_date = :h_bizdate;
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE cnb; tpabort(0); return 1; }
if (h_tsum != h_asum) { bad++; printf(" cid=%ld 총액 불일치 마감=%ld 실제=%ld\n", h_cid, h_tsum, h_asum); }
checked++;
}
EXEC SQL CLOSE cnb;
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
printf(">>> cl_recon_batch COMMIT: bizdate=%s 대사=%ld 불일치=%ld\n", bizdate, checked, bad);
tpclose(); tpterm();
return 0;
}

View file

@ -0,0 +1,46 @@
/*
* cl_report_batch.pgc - cl 마감 리포트 배치 (커서, 마감별 총계 출력) (XA 배치).
*
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
* Usage: cl_report_batch [YYYY-MM-DD]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include "cl_dbio.h"
int main(int argc, char **argv)
{
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
EXEC SQL BEGIN DECLARE SECTION;
char h_bizdate[16];
long h_cid, h_cnt, h_amt;
char h_type[16], h_status[8];
EXEC SQL END DECLARE SECTION;
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
long rows = 0;
EXEC SQL DECLARE crb CURSOR FOR
SELECT close_id, close_type, status, txn_count, total_amount FROM cl_close_log
WHERE biz_date = :h_bizdate ORDER BY close_id;
EXEC SQL OPEN crb;
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
for (;;) {
EXEC SQL FETCH crb INTO :h_cid, :h_type, :h_status, :h_cnt, :h_amt;
if (sqlca.sqlcode == 100) break;
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE crb; tpabort(0); return 1; }
printf(" cid=%ld %-8s [%s] 건수=%ld 총액=%ld\n", h_cid, h_type, h_status, h_cnt, h_amt);
rows++;
}
EXEC SQL CLOSE crb;
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
printf(">>> cl_report_batch COMMIT: bizdate=%s 마감 %ld건\n", bizdate, rows);
tpclose(); tpterm();
return 0;
}

View file

@ -0,0 +1,35 @@
/*
* cl_restore_batch.pgc - cl 취소(X) 마감 복원 배치 (dbio update) (XA 배치).
*
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
* Usage: cl_restore_batch [YYYY-MM-DD]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include "cl_dbio.h"
#include "cl_restore_count_dbio.h"
int main(int argc, char **argv)
{
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
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;
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
long restored;
restored = clqdb_restore_count(bizdate);
if (restored < 0) { fprintf(stderr, "cl_restore_batch FAIL\n"); tpabort(0); return 1; }
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
printf(">>> cl_restore_batch COMMIT: %s 취소마감 %ld건 개시복원\n", bizdate, restored);
tpclose(); tpterm();
return 0;
}

View file

@ -0,0 +1,48 @@
/*
* cl_rollup_batch.pgc - cl 마감 스냅샷 롤업 배치 (커서, 마감별 gross/fee/net 집계) (XA 배치).
*
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
* Usage: cl_rollup_batch [YYYY-MM-DD]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include "cl_dbio.h"
int main(int argc, char **argv)
{
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
EXEC SQL BEGIN DECLARE SECTION;
char h_bizdate[16];
long h_cid, h_gross, h_fee, h_net;
EXEC SQL END DECLARE SECTION;
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
long rows = 0;
EXEC SQL DECLARE crl CURSOR FOR
SELECT s.close_id, coalesce(sum(s.gross_amount),0),
coalesce(sum(s.fee_amount),0), coalesce(sum(s.net_amount),0)
FROM cl_snapshot s JOIN cl_close_log c ON c.close_id = s.close_id
WHERE c.biz_date = :h_bizdate GROUP BY s.close_id ORDER BY s.close_id;
EXEC SQL OPEN crl;
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
for (;;) {
EXEC SQL FETCH crl INTO :h_cid, :h_gross, :h_fee, :h_net;
if (sqlca.sqlcode == 100) break;
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE crl; tpabort(0); return 1; }
if (cldb_update_close_totals(h_cid, 0, h_gross) < 0) { EXEC SQL CLOSE crl; tpabort(0); return 1; }
printf(" cid=%ld gross=%ld fee=%ld net=%ld\n", h_cid, h_gross, h_fee, h_net);
rows++;
}
EXEC SQL CLOSE crl;
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
printf(">>> cl_rollup_batch COMMIT: bizdate=%s 롤업 %ld마감\n", bizdate, rows);
tpclose(); tpterm();
return 0;
}

View file

@ -0,0 +1,38 @@
/*
* cl_seq_batch.pgc - cl 마감유형 순번 일괄 발번 배치 (dbio upsert 반복) (XA 배치).
*
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
* Usage: cl_seq_batch [YYYY-MM-DD]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include "cl_dbio.h"
int main(int argc, char **argv)
{
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
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;
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
const char *types[] = { "DAILY", "MONTHLY", "QUARTER", "YEAREND", NULL };
long seq; int i;
for (i = 0; types[i] != NULL; i++) {
seq = cldb_bump_seq(types[i]);
if (seq < 0) { fprintf(stderr, "bump %s FAIL\n", types[i]); tpabort(0); return 1; }
printf(" %-8s -> seq %ld\n", types[i], seq);
}
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
printf(">>> cl_seq_batch COMMIT: bizdate=%s 유형 %d종 발번\n", bizdate, i);
tpclose(); tpterm();
return 0;
}

View file

@ -0,0 +1,37 @@
/*
* cl_unclosed_batch.pgc - cl 미마감 영업일 점검 배치 (단건 집계) (XA 배치).
*
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
* Usage: cl_unclosed_batch [YYYY-MM-DD]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include "cl_dbio.h"
int main(int argc, char **argv)
{
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
EXEC SQL BEGIN DECLARE SECTION;
char h_bizdate[16];
long h_days, h_alert;
EXEC SQL END DECLARE SECTION;
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
EXEC SQL SELECT count(DISTINCT p.biz_date) INTO :h_days FROM purchase p
WHERE NOT EXISTS (SELECT 1 FROM cl_close_log c
WHERE c.close_type = 'DAILY' AND c.biz_date = p.biz_date AND c.status <> 'X');
if (sqlca.sqlcode < 0) { fprintf(stderr, "DAYS FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
EXEC SQL SELECT count(*) INTO :h_alert FROM purchase WHERE biz_date = :h_bizdate AND status = 'M';
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
printf(">>> cl_unclosed_batch COMMIT: 미마감 영업일=%ld 당일 대사완료 미마감=%ld\n", h_days, h_alert);
tpclose(); tpterm();
return 0;
}

View file

@ -0,0 +1,49 @@
/*
* cl_verify_batch.pgc - cl 마감 검증 배치 (커서, 저장건수 vs 실제 대사) (XA 배치).
*
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
* Usage: cl_verify_batch [YYYY-MM-DD]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include "cl_dbio.h"
int main(int argc, char **argv)
{
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
EXEC SQL BEGIN DECLARE SECTION;
char h_bizdate[16];
long h_cid, h_stored, h_actual;
char h_period[16];
EXEC SQL END DECLARE SECTION;
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
long checked = 0, bad = 0;
EXEC SQL DECLARE cvb CURSOR FOR
SELECT close_id, txn_count, period_key FROM cl_close_log
WHERE close_type = 'DAILY' AND biz_date = :h_bizdate AND status <> 'X'
ORDER BY close_id;
EXEC SQL OPEN cvb;
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
for (;;) {
EXEC SQL FETCH cvb INTO :h_cid, :h_stored, :h_period;
if (sqlca.sqlcode == 100) break;
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE cvb; tpabort(0); return 1; }
EXEC SQL SELECT count(*) INTO :h_actual FROM purchase WHERE biz_date = :h_bizdate;
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE cvb; tpabort(0); return 1; }
if (h_stored != h_actual) { bad++; printf(" cid=%ld 불일치 저장=%ld 실제=%ld\n", h_cid, h_stored, h_actual); }
checked++;
}
EXEC SQL CLOSE cvb;
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
printf(">>> cl_verify_batch COMMIT: bizdate=%s 검증=%ld 불일치=%ld\n", bizdate, checked, bad);
tpclose(); tpterm();
return 0;
}

View file

@ -0,0 +1,40 @@
/*
* cl_yearend_batch.pgc - cl 연말 마감 배치 (연도 집계) (XA 배치).
*
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
* Usage: cl_yearend_batch [YYYY-MM-DD]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <atmi.h>
#include "cl_dbio.h"
int main(int argc, char **argv)
{
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
EXEC SQL BEGIN DECLARE SECTION;
char h_bizdate[16];
char h_year[8];
long h_cnt, h_amt;
EXEC SQL END DECLARE SECTION;
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
long cid;
strncpy(h_year, bizdate, 4); h_year[4] = 0;
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :h_cnt, :h_amt
FROM purchase WHERE to_char(biz_date,'YYYY') = :h_year;
if (sqlca.sqlcode < 0) { fprintf(stderr, "AGG FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
cid = cldb_next_close_id();
if (cid < 0) { tpabort(0); return 1; }
if (cldb_insert_close(cid, "YEAREND", h_year, bizdate, "C", h_cnt, h_amt, "연마감(배치)") < 0) { tpabort(0); return 1; }
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
printf(">>> cl_yearend_batch COMMIT: year=%s cid=%ld 건수=%ld 총액=%ld\n", h_year, cid, h_cnt, h_amt);
tpclose(); tpterm();
return 0;
}