feat: acquire-core full legacy C corpus (~2066 files, build-verified) + generator + inventory
This commit is contained in:
commit
b96cf702ee
2897 changed files with 264970 additions and 0 deletions
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
build/
|
||||
bin/
|
||||
*.o
|
||||
*.a
|
||||
113
Makefile
Normal file
113
Makefile
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
# ==========================================================================
|
||||
# acquire-core-full / TxCore Makefile (생성기 산출물)
|
||||
#
|
||||
# .pgc --ecpg--> .c --gcc--> build/*.o --ar--> libtxcore.a --ld--> bin/*
|
||||
#
|
||||
# ~1000개 .c/.pgc 를 build/*.o 로 컴파일하는 것이 빌드 검증의 핵심.
|
||||
# 와일드카드로 전체 소스를 수집하고, 대표 데모 바이너리 몇 개를 링크한다.
|
||||
# ==========================================================================
|
||||
CC := gcc
|
||||
ECPG := ecpg
|
||||
AR := ar
|
||||
PG_INCDIR := $(shell pg_config --includedir 2>/dev/null)
|
||||
|
||||
INCLUDES := -Iframework/txcore/include \
|
||||
-Iframework/txcore/dbio \
|
||||
-Iapp/include \
|
||||
-Iapp/shared/include \
|
||||
-I$(PG_INCDIR)
|
||||
|
||||
# 고정길이 관용구 경고만 억제 (-Werror 없음)
|
||||
CFLAGS := -g -O2 -Wall -Wextra -Wno-unused-parameter \
|
||||
-Wno-stringop-truncation -Wno-format-truncation \
|
||||
-Wno-unused-variable -Wno-unused-but-set-variable $(INCLUDES)
|
||||
ECPGFLAGS := -Iframework/txcore/include -Iframework/txcore/dbio \
|
||||
-Iapp/include -Iapp/shared/include
|
||||
LDLIBS := -lecpg -lpq
|
||||
|
||||
BUILD := build
|
||||
BIN := bin
|
||||
|
||||
# ---- 소스 수집 (와일드카드) ----------------------------------------------
|
||||
ONLINE_PGC := $(wildcard app/online/*.pgc)
|
||||
BATCH_PGC := $(wildcard app/batch/*.pgc)
|
||||
DBIO_PGC := $(wildcard app/dbio/*.pgc)
|
||||
COMMON_C := $(wildcard app/common/*.c)
|
||||
SHARED_C := $(wildcard app/shared/common/*.c)
|
||||
|
||||
PGC_ALL := $(ONLINE_PGC) $(BATCH_PGC) $(DBIO_PGC)
|
||||
GEN_C := $(PGC_ALL:.pgc=.c)
|
||||
|
||||
PGC_OBJ := $(patsubst %,$(BUILD)/%.o,$(basename $(notdir $(PGC_ALL))))
|
||||
COMMON_OBJ := $(patsubst %,$(BUILD)/%.o,$(basename $(notdir $(COMMON_C))))
|
||||
SHARED_OBJ := $(patsubst %,$(BUILD)/%.o,$(basename $(notdir $(SHARED_C))))
|
||||
ALL_OBJ := $(PGC_OBJ) $(COMMON_OBJ) $(SHARED_OBJ)
|
||||
|
||||
LIBTXCORE := $(BUILD)/libtxcore.a
|
||||
|
||||
DEMO_BINS := $(BIN)/demo_mg_server $(BIN)/demo_ac_server $(BIN)/demo_rc_server $(BIN)/demo_st_server $(BIN)/demo_rc_batch $(BIN)/demo_cl_batch
|
||||
|
||||
.SECONDARY:
|
||||
.PHONY: all clean dirs gen objs demos
|
||||
|
||||
all: dirs $(LIBTXCORE) objs demos
|
||||
@echo "==> 빌드 완료"
|
||||
@echo "오브젝트: $(words $(ALL_OBJ)) 개"
|
||||
|
||||
dirs:
|
||||
@mkdir -p $(BUILD) $(BIN)
|
||||
|
||||
gen: $(GEN_C)
|
||||
objs: $(ALL_OBJ)
|
||||
demos: $(DEMO_BINS)
|
||||
|
||||
# ---- ecpg: .pgc -> .c (디렉토리별) ---------------------------------------
|
||||
app/online/%.c: app/online/%.pgc
|
||||
$(ECPG) $(ECPGFLAGS) -o $@ $<
|
||||
app/batch/%.c: app/batch/%.pgc
|
||||
$(ECPG) $(ECPGFLAGS) -o $@ $<
|
||||
app/dbio/%.c: app/dbio/%.pgc
|
||||
$(ECPG) $(ECPGFLAGS) -o $@ $<
|
||||
|
||||
# ---- 컴파일: build/<basename>.o (gen 선행 보장) --------------------------
|
||||
$(BUILD)/%.o: app/online/%.c | gen
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
$(BUILD)/%.o: app/batch/%.c | gen
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
$(BUILD)/%.o: app/dbio/%.c | gen
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
$(BUILD)/%.o: app/common/%.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
$(BUILD)/%.o: app/shared/common/%.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# ---- TxCore 정적 라이브러리 ----------------------------------------------
|
||||
$(BUILD)/txcore.o: framework/txcore/src/txcore.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
$(LIBTXCORE): $(BUILD)/txcore.o
|
||||
$(AR) rcs $@ $^
|
||||
|
||||
# ---- 대표 데모 바이너리 (링크 검증) --------------------------------------
|
||||
$(BIN)/demo_mg_server: $(BUILD)/demo_mg_main.o $(BUILD)/mg_ol_0001.o $(BUILD)/mg_dbio_main.o $(SHARED_OBJ) $(LIBTXCORE)
|
||||
$(CC) $(CFLAGS) -o $@ $(BUILD)/demo_mg_main.o $(BUILD)/mg_ol_0001.o $(BUILD)/mg_dbio_main.o $(SHARED_OBJ) -L$(BUILD) -ltxcore $(LDLIBS)
|
||||
|
||||
$(BIN)/demo_ac_server: $(BUILD)/demo_ac_main.o $(BUILD)/ac_ol_0001.o $(BUILD)/ac_dbio_main.o $(SHARED_OBJ) $(LIBTXCORE)
|
||||
$(CC) $(CFLAGS) -o $@ $(BUILD)/demo_ac_main.o $(BUILD)/ac_ol_0001.o $(BUILD)/ac_dbio_main.o $(SHARED_OBJ) -L$(BUILD) -ltxcore $(LDLIBS)
|
||||
|
||||
$(BIN)/demo_rc_server: $(BUILD)/demo_rc_main.o $(BUILD)/rc_ol_0001.o $(BUILD)/rc_dbio_main.o $(SHARED_OBJ) $(LIBTXCORE)
|
||||
$(CC) $(CFLAGS) -o $@ $(BUILD)/demo_rc_main.o $(BUILD)/rc_ol_0001.o $(BUILD)/rc_dbio_main.o $(SHARED_OBJ) -L$(BUILD) -ltxcore $(LDLIBS)
|
||||
|
||||
$(BIN)/demo_st_server: $(BUILD)/demo_st_main.o $(BUILD)/st_ol_0001.o $(BUILD)/st_dbio_main.o $(SHARED_OBJ) $(LIBTXCORE)
|
||||
$(CC) $(CFLAGS) -o $@ $(BUILD)/demo_st_main.o $(BUILD)/st_ol_0001.o $(BUILD)/st_dbio_main.o $(SHARED_OBJ) -L$(BUILD) -ltxcore $(LDLIBS)
|
||||
|
||||
$(BIN)/demo_rc_batch: $(BUILD)/rc_bt_0001.o $(BUILD)/rc_dbio_main.o $(SHARED_OBJ) $(LIBTXCORE)
|
||||
$(CC) $(CFLAGS) -o $@ $(BUILD)/rc_bt_0001.o $(BUILD)/rc_dbio_main.o $(SHARED_OBJ) -L$(BUILD) -ltxcore $(LDLIBS)
|
||||
|
||||
$(BIN)/demo_cl_batch: $(BUILD)/cl_bt_0001.o $(BUILD)/cl_dbio_main.o $(SHARED_OBJ) $(LIBTXCORE)
|
||||
$(CC) $(CFLAGS) -o $@ $(BUILD)/cl_bt_0001.o $(BUILD)/cl_dbio_main.o $(SHARED_OBJ) -L$(BUILD) -ltxcore $(LDLIBS)
|
||||
|
||||
# ==========================================================================
|
||||
clean:
|
||||
rm -rf $(BUILD) $(BIN)
|
||||
rm -f $(GEN_C)
|
||||
|
||||
247
app/batch/ac_bt_0001.c
Normal file
247
app/batch/ac_bt_0001.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0001.pgc"
|
||||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0001.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0001 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0001.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0001(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0001.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0001.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0001.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0001.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0001.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0001.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0001 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0001.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0001.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0001 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0001.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0001");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0001] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0001", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0001.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0001");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0001] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0001", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0001.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0001] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0001] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0001] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0001] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0001(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0001] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0001.pgc
Normal file
138
app/batch/ac_bt_0001.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0001.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0001 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0001(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0001 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0001;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0001");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0001] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0001 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0001");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0001] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0001;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0001] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0001] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0001] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0001] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0001(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0001] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0002.c
Normal file
247
app/batch/ac_bt_0002.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0002.pgc"
|
||||
/* @tier medium @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0002.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0002 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0002.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0002(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0002.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0002.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0002.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0002.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0002.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0002.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0002 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0002.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0002.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0002 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0002.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0002");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0002] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0002", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0002.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0002");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0002] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0002", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0002.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0002] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0002] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0002] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0002] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0002(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0002] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0002.pgc
Normal file
138
app/batch/ac_bt_0002.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0002.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0002 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0002(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0002 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0002;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0002");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0002] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0002 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0002");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0002] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0002;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0002] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0002] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0002] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0002] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0002(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0002] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0003.c
Normal file
247
app/batch/ac_bt_0003.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0003.pgc"
|
||||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0003.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0003 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0003.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0003(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0003.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0003.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0003.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0003.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0003.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0003.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0003 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0003.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0003.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0003 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0003.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0003");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0003] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0003", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0003.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0003");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0003] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0003", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0003.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0003] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0003] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0003] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0003] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0003(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0003] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0003.pgc
Normal file
138
app/batch/ac_bt_0003.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0003.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0003 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0003(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0003 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0003;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0003");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0003] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0003 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0003");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0003] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0003;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0003] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0003] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0003] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0003] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0003(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0003] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0004.c
Normal file
247
app/batch/ac_bt_0004.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0004.pgc"
|
||||
/* @tier medium @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0004.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0004 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0004.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0004(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0004.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0004.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0004.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0004.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0004.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0004.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0004 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0004.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0004.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0004 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0004.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0004");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0004] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0004", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0004.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0004");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0004] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0004", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0004.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0004] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0004] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0004] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0004] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0004(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0004] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0004.pgc
Normal file
138
app/batch/ac_bt_0004.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0004.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0004 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0004(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0004 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0004;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0004");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0004] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0004 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0004");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0004] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0004;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0004] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0004] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0004] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0004] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0004(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0004] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0005.c
Normal file
247
app/batch/ac_bt_0005.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0005.pgc"
|
||||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0005.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0005 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0005.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0005(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0005.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0005.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0005.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0005.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0005.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0005.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0005 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0005.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0005.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0005 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0005.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0005");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0005] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0005", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0005.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0005");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0005] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0005", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0005.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0005] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0005] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0005] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0005] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0005(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0005] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0005.pgc
Normal file
138
app/batch/ac_bt_0005.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0005.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0005 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0005(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0005 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0005;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0005");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0005] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0005 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0005");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0005] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0005;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0005] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0005] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0005] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0005] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0005(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0005] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0006.c
Normal file
247
app/batch/ac_bt_0006.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0006.pgc"
|
||||
/* @tier hard @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0006.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=hard]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0006 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0006.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0006(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0006.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0006.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0006.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0006.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0006.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0006.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0006 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0006.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0006.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0006 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0006.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0006");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0006] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0006", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0006.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0006");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0006] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0006", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0006.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0006] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0006] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0006] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0006] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0006(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0006] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0006.pgc
Normal file
138
app/batch/ac_bt_0006.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier hard @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0006.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=hard]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0006 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0006(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0006 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0006;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0006");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0006] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0006 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0006");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0006] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0006;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0006] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0006] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0006] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0006] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0006(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0006] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0007.c
Normal file
247
app/batch/ac_bt_0007.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0007.pgc"
|
||||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0007.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0007 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0007.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0007(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0007.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0007.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0007.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0007.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0007.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0007.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0007 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0007.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0007.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0007 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0007.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0007");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0007] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0007", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0007.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0007");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0007] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0007", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0007.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0007] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0007] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0007] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0007] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0007(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0007] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0007.pgc
Normal file
138
app/batch/ac_bt_0007.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0007.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0007 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0007(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0007 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0007;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0007");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0007] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0007 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0007");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0007] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0007;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0007] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0007] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0007] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0007] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0007(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0007] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0008.c
Normal file
247
app/batch/ac_bt_0008.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0008.pgc"
|
||||
/* @tier hard @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0008.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=hard]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0008 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0008.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0008(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0008.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0008.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0008.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0008.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0008.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0008.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0008 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0008.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0008.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0008 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0008.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0008");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0008] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0008", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0008.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0008");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0008] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0008", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0008.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0008] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0008] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0008] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0008] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0008(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0008] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0008.pgc
Normal file
138
app/batch/ac_bt_0008.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier hard @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0008.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=hard]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0008 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0008(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0008 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0008;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0008");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0008] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0008 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0008");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0008] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0008;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0008] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0008] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0008] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0008] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0008(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0008] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0009.c
Normal file
247
app/batch/ac_bt_0009.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0009.pgc"
|
||||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0009.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0009 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0009.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0009(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0009.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0009.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0009.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0009.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0009.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0009.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0009 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0009.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0009.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0009 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0009.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0009");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0009] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0009", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0009.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0009");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0009] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0009", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0009.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0009] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0009] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0009] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0009] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0009(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0009] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0009.pgc
Normal file
138
app/batch/ac_bt_0009.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0009.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0009 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0009(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0009 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0009;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0009");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0009] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0009 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0009");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0009] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0009;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0009] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0009] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0009] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0009] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0009(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0009] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0010.c
Normal file
247
app/batch/ac_bt_0010.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0010.pgc"
|
||||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0010.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0010 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0010.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0010(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0010.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0010.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0010.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0010.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0010.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0010.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0010 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0010.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0010.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0010 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0010.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0010");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0010] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0010", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0010.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0010");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0010] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0010", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0010.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0010] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0010] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0010] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0010] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0010(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0010] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0010.pgc
Normal file
138
app/batch/ac_bt_0010.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0010.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0010 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0010(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0010 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0010;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0010");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0010] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0010 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0010");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0010] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0010;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0010] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0010] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0010] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0010] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0010(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0010] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0011.c
Normal file
247
app/batch/ac_bt_0011.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0011.pgc"
|
||||
/* @tier medium @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0011.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0011 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0011.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0011(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0011.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0011.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0011.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0011.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0011.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0011.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0011 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0011.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0011.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0011 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0011.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0011");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0011] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0011", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0011.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0011");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0011] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0011", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0011.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0011] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0011] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0011] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0011] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0011(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0011] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0011.pgc
Normal file
138
app/batch/ac_bt_0011.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0011.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0011 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0011(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0011 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0011;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0011");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0011] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0011 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0011");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0011] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0011;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0011] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0011] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0011] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0011] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0011(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0011] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0012.c
Normal file
247
app/batch/ac_bt_0012.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0012.pgc"
|
||||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0012.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0012 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0012.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0012(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0012.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0012.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0012.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0012.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0012.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0012.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0012 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0012.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0012.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0012 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0012.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0012");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0012] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0012", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0012.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0012");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0012] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0012", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0012.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0012] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0012] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0012] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0012] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0012(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0012] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0012.pgc
Normal file
138
app/batch/ac_bt_0012.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0012.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0012 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0012(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0012 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0012;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0012");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0012] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0012 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0012");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0012] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0012;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0012] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0012] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0012] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0012] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0012(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0012] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0013.c
Normal file
247
app/batch/ac_bt_0013.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0013.pgc"
|
||||
/* @tier medium @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0013.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0013 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0013.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0013(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0013.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0013.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0013.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0013.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0013.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0013.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0013 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0013.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0013.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0013 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0013.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0013");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0013] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0013", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0013.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0013");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0013] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0013", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0013.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0013] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0013] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0013] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0013] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0013(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0013] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0013.pgc
Normal file
138
app/batch/ac_bt_0013.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0013.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0013 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0013(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0013 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0013;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0013");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0013] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0013 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0013");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0013] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0013;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0013] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0013] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0013] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0013] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0013(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0013] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0014.c
Normal file
247
app/batch/ac_bt_0014.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0014.pgc"
|
||||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0014.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0014 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0014.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0014(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0014.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0014.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0014.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0014.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0014.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0014.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0014 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0014.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0014.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0014 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0014.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0014");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0014] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0014", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0014.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0014");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0014] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0014", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0014.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0014] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0014] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0014] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0014] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0014(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0014] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0014.pgc
Normal file
138
app/batch/ac_bt_0014.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0014.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0014 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0014(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0014 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0014;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0014");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0014] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0014 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0014");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0014] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0014;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0014] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0014] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0014] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0014] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0014(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0014] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0015.c
Normal file
247
app/batch/ac_bt_0015.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0015.pgc"
|
||||
/* @tier medium @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0015.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0015 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0015.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0015(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0015.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0015.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0015.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0015.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0015.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0015.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0015 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0015.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0015.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0015 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0015.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0015");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0015] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0015", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0015.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0015");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0015] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0015", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0015.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0015] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0015] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0015] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0015] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0015(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0015] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0015.pgc
Normal file
138
app/batch/ac_bt_0015.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0015.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0015 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0015(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0015 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0015;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0015");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0015] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0015 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0015");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0015] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0015;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0015] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0015] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0015] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0015] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0015(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0015] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0016.c
Normal file
247
app/batch/ac_bt_0016.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0016.pgc"
|
||||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0016.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0016 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0016.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0016(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0016.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0016.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0016.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0016.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0016.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0016.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0016 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0016.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0016.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0016 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0016.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0016");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0016] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0016", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0016.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0016");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0016] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0016", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0016.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0016] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0016] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0016] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0016] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0016(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0016] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0016.pgc
Normal file
138
app/batch/ac_bt_0016.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0016.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0016 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0016(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0016 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0016;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0016");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0016] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0016 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0016");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0016] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0016;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0016] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0016] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0016] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0016] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0016(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0016] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/ac_bt_0017.c
Normal file
247
app/batch/ac_bt_0017.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/ac_bt_0017.pgc"
|
||||
/* @tier hard @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0017.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=hard]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0017 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/ac_bt_0017.pgc"
|
||||
|
||||
|
||||
static int run_ac_bt_0017(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/ac_bt_0017.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/ac_bt_0017.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/ac_bt_0017.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/ac_bt_0017.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/ac_bt_0017.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/ac_bt_0017.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_ac_bt_0017 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/ac_bt_0017.pgc"
|
||||
|
||||
#line 42 "app/batch/ac_bt_0017.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_bt_0017 cursor for select key , merch_id , amount from ac_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/ac_bt_0017.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0017");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0017] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_bt_0017", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/ac_bt_0017.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0017");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0017] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_bt_0017", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/ac_bt_0017.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0017] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0017] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0017] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0017] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0017(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0017] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/ac_bt_0017.pgc
Normal file
138
app/batch/ac_bt_0017.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier hard @module ac @transform acquire-batch */
|
||||
/*
|
||||
* ac_bt_0017.pgc - 매입 배치 (커서 순회 + 상태전이) [tier=hard]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: ac_bt_0017 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "ac_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_ac_bt_0017(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_ac_bt_0017 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM ac_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_ac_bt_0017;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_ac_bt_0017");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ac_bt_0017] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_ac_bt_0017 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_ac_bt_0017");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AC_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AC_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = ac_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0017] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_ac_bt_0017;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[ac_bt_0017] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 매입 배치 결과 [ac_bt_0017] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0017] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = ac_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[ac_bt_0017] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_ac_bt_0017(biz_date);
|
||||
|
||||
ac_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ac_bt_0017] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0001.c
Normal file
247
app/batch/au_bt_0001.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0001.pgc"
|
||||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0001.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0001 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0001.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0001(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0001.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0001.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0001.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0001.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0001.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0001.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0001 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0001.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0001.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0001 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0001.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0001");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0001] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0001", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0001.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0001");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0001] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0001", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0001.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0001] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0001] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0001] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0001] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0001(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0001] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0001.pgc
Normal file
138
app/batch/au_bt_0001.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0001.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0001 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0001(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0001 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0001;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0001");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0001] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0001 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0001");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0001] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0001;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0001] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0001] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0001] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0001] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0001(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0001] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0002.c
Normal file
247
app/batch/au_bt_0002.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0002.pgc"
|
||||
/* @tier medium @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0002.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0002 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0002.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0002(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0002.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0002.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0002.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0002.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0002.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0002.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0002 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0002.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0002.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0002 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0002.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0002");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0002] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0002", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0002.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0002");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0002] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0002", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0002.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0002] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0002] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0002] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0002] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0002(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0002] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0002.pgc
Normal file
138
app/batch/au_bt_0002.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0002.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0002 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0002(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0002 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0002;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0002");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0002] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0002 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0002");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0002] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0002;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0002] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0002] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0002] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0002] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0002(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0002] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0003.c
Normal file
247
app/batch/au_bt_0003.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0003.pgc"
|
||||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0003.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0003 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0003.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0003(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0003.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0003.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0003.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0003.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0003.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0003.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0003 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0003.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0003.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0003 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0003.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0003");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0003] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0003", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0003.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0003");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0003] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0003", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0003.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0003] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0003] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0003] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0003] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0003(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0003] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0003.pgc
Normal file
138
app/batch/au_bt_0003.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0003.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0003 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0003(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0003 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0003;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0003");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0003] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0003 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0003");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0003] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0003;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0003] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0003] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0003] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0003] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0003(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0003] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0004.c
Normal file
247
app/batch/au_bt_0004.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0004.pgc"
|
||||
/* @tier medium @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0004.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0004 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0004.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0004(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0004.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0004.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0004.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0004.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0004.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0004.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0004 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0004.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0004.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0004 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0004.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0004");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0004] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0004", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0004.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0004");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0004] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0004", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0004.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0004] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0004] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0004] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0004] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0004(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0004] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0004.pgc
Normal file
138
app/batch/au_bt_0004.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0004.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0004 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0004(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0004 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0004;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0004");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0004] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0004 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0004");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0004] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0004;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0004] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0004] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0004] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0004] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0004(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0004] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0005.c
Normal file
247
app/batch/au_bt_0005.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0005.pgc"
|
||||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0005.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0005 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0005.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0005(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0005.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0005.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0005.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0005.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0005.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0005.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0005 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0005.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0005.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0005 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0005.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0005");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0005] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0005", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0005.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0005");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0005] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0005", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0005.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0005] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0005] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0005] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0005] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0005(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0005] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0005.pgc
Normal file
138
app/batch/au_bt_0005.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0005.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0005 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0005(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0005 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0005;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0005");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0005] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0005 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0005");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0005] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0005;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0005] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0005] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0005] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0005] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0005(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0005] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0006.c
Normal file
247
app/batch/au_bt_0006.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0006.pgc"
|
||||
/* @tier medium @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0006.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0006 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0006.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0006(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0006.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0006.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0006.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0006.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0006.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0006.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0006 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0006.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0006.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0006 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0006.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0006");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0006] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0006", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0006.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0006");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0006] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0006", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0006.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0006] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0006] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0006] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0006] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0006(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0006] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0006.pgc
Normal file
138
app/batch/au_bt_0006.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0006.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0006 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0006(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0006 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0006;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0006");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0006] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0006 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0006");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0006] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0006;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0006] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0006] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0006] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0006] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0006(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0006] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0007.c
Normal file
247
app/batch/au_bt_0007.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0007.pgc"
|
||||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0007.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0007 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0007.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0007(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0007.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0007.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0007.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0007.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0007.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0007.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0007 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0007.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0007.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0007 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0007.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0007");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0007] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0007", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0007.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0007");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0007] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0007", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0007.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0007] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0007] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0007] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0007] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0007(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0007] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0007.pgc
Normal file
138
app/batch/au_bt_0007.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0007.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0007 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0007(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0007 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0007;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0007");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0007] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0007 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0007");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0007] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0007;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0007] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0007] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0007] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0007] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0007(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0007] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0008.c
Normal file
247
app/batch/au_bt_0008.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0008.pgc"
|
||||
/* @tier hard @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0008.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=hard]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0008 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0008.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0008(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0008.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0008.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0008.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0008.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0008.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0008.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0008 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0008.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0008.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0008 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0008.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0008");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0008] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0008", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0008.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0008");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0008] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0008", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0008.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0008] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0008] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0008] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0008] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0008(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0008] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0008.pgc
Normal file
138
app/batch/au_bt_0008.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier hard @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0008.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=hard]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0008 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0008(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0008 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0008;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0008");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0008] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0008 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0008");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0008] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0008;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0008] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0008] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0008] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0008] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0008(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0008] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0009.c
Normal file
247
app/batch/au_bt_0009.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0009.pgc"
|
||||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0009.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0009 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0009.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0009(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0009.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0009.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0009.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0009.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0009.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0009.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0009 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0009.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0009.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0009 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0009.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0009");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0009] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0009", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0009.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0009");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0009] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0009", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0009.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0009] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0009] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0009] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0009] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0009(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0009] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0009.pgc
Normal file
138
app/batch/au_bt_0009.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0009.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0009 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0009(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0009 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0009;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0009");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0009] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0009 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0009");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0009] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0009;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0009] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0009] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0009] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0009] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0009(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0009] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0010.c
Normal file
247
app/batch/au_bt_0010.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0010.pgc"
|
||||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0010.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0010 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0010.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0010(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0010.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0010.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0010.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0010.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0010.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0010.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0010 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0010.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0010.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0010 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0010.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0010");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0010] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0010", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0010.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0010");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0010] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0010", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0010.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0010] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0010] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0010] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0010] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0010(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0010] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0010.pgc
Normal file
138
app/batch/au_bt_0010.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0010.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0010 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0010(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0010 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0010;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0010");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0010] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0010 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0010");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0010] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0010;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0010] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0010] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0010] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0010] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0010(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0010] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0011.c
Normal file
247
app/batch/au_bt_0011.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0011.pgc"
|
||||
/* @tier medium @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0011.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0011 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0011.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0011(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0011.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0011.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0011.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0011.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0011.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0011.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0011 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0011.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0011.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0011 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0011.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0011");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0011] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0011", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0011.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0011");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0011] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0011", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0011.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0011] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0011] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0011] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0011] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0011(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0011] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0011.pgc
Normal file
138
app/batch/au_bt_0011.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0011.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0011 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0011(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0011 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0011;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0011");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0011] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0011 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0011");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0011] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0011;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0011] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0011] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0011] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0011] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0011(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0011] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0012.c
Normal file
247
app/batch/au_bt_0012.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0012.pgc"
|
||||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0012.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0012 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0012.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0012(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0012.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0012.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0012.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0012.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0012.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0012.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0012 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0012.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0012.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0012 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0012.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0012");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0012] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0012", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0012.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0012");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0012] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0012", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0012.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0012] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0012] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0012] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0012] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0012(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0012] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0012.pgc
Normal file
138
app/batch/au_bt_0012.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0012.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0012 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0012(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0012 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0012;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0012");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0012] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0012 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0012");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0012] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0012;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0012] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0012] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0012] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0012] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0012(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0012] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0013.c
Normal file
247
app/batch/au_bt_0013.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0013.pgc"
|
||||
/* @tier medium @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0013.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0013 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0013.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0013(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0013.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0013.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0013.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0013.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0013.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0013.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0013 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0013.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0013.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0013 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0013.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0013");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0013] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0013", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0013.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0013");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0013] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0013", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0013.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0013] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0013] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0013] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0013] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0013(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0013] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0013.pgc
Normal file
138
app/batch/au_bt_0013.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0013.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0013 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0013(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0013 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0013;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0013");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0013] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0013 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0013");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0013] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0013;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0013] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0013] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0013] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0013] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0013(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0013] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0014.c
Normal file
247
app/batch/au_bt_0014.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0014.pgc"
|
||||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0014.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0014 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0014.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0014(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0014.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0014.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0014.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0014.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0014.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0014.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0014 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0014.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0014.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0014 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0014.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0014");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0014] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0014", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0014.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0014");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0014] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0014", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0014.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0014] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0014] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0014] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0014] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0014(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0014] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0014.pgc
Normal file
138
app/batch/au_bt_0014.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0014.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0014 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0014(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0014 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0014;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0014");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0014] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0014 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0014");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0014] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0014;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0014] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0014] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0014] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0014] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0014(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0014] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0015.c
Normal file
247
app/batch/au_bt_0015.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0015.pgc"
|
||||
/* @tier medium @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0015.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0015 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0015.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0015(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0015.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0015.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0015.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0015.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0015.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0015.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0015 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0015.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0015.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0015 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0015.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0015");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0015] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0015", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0015.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0015");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0015] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0015", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0015.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0015] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0015] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0015] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0015] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0015(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0015] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0015.pgc
Normal file
138
app/batch/au_bt_0015.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0015.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0015 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0015(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0015 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0015;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0015");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0015] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0015 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0015");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0015] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0015;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0015] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0015] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0015] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0015] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0015(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0015] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0016.c
Normal file
247
app/batch/au_bt_0016.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0016.pgc"
|
||||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0016.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0016 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0016.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0016(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0016.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0016.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0016.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0016.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0016.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0016.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0016 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0016.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0016.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0016 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0016.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0016");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0016] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0016", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0016.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0016");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0016] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0016", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0016.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0016] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0016] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0016] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0016] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0016(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0016] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0016.pgc
Normal file
138
app/batch/au_bt_0016.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0016.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0016 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0016(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0016 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0016;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0016");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0016] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0016 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0016");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0016] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0016;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0016] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0016] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0016] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0016] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0016(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0016] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/au_bt_0017.c
Normal file
247
app/batch/au_bt_0017.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/au_bt_0017.pgc"
|
||||
/* @tier hard @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0017.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=hard]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0017 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/au_bt_0017.pgc"
|
||||
|
||||
|
||||
static int run_au_bt_0017(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/au_bt_0017.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/au_bt_0017.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/au_bt_0017.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/au_bt_0017.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/au_bt_0017.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/au_bt_0017.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_au_bt_0017 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/au_bt_0017.pgc"
|
||||
|
||||
#line 42 "app/batch/au_bt_0017.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_bt_0017 cursor for select key , merch_id , amount from au_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/au_bt_0017.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0017");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0017] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_bt_0017", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/au_bt_0017.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0017");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0017] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_bt_0017", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/au_bt_0017.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0017] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0017] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0017] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0017] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0017(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0017] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/au_bt_0017.pgc
Normal file
138
app/batch/au_bt_0017.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier hard @module au @transform authorization-batch */
|
||||
/*
|
||||
* au_bt_0017.pgc - 승인한도 배치 (커서 순회 + 상태전이) [tier=hard]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: au_bt_0017 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "au_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_au_bt_0017(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_au_bt_0017 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM au_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_au_bt_0017;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_au_bt_0017");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[au_bt_0017] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_au_bt_0017 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_au_bt_0017");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, AU_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, AU_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = au_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0017] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_au_bt_0017;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[au_bt_0017] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 승인한도 배치 결과 [au_bt_0017] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0017] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = au_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[au_bt_0017] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_au_bt_0017(biz_date);
|
||||
|
||||
au_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[au_bt_0017] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/cl_bt_0001.c
Normal file
247
app/batch/cl_bt_0001.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/cl_bt_0001.pgc"
|
||||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0001.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0001 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/cl_bt_0001.pgc"
|
||||
|
||||
|
||||
static int run_cl_bt_0001(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/cl_bt_0001.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/cl_bt_0001.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/cl_bt_0001.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/cl_bt_0001.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/cl_bt_0001.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/cl_bt_0001.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_cl_bt_0001 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/cl_bt_0001.pgc"
|
||||
|
||||
#line 42 "app/batch/cl_bt_0001.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cl_bt_0001 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/cl_bt_0001.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0001");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0001] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cl_bt_0001", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/cl_bt_0001.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0001");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0001] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cl_bt_0001", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/cl_bt_0001.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0001] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0001] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0001] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0001] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0001(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0001] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/cl_bt_0001.pgc
Normal file
138
app/batch/cl_bt_0001.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0001.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0001 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_cl_bt_0001(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_cl_bt_0001 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_cl_bt_0001;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0001");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0001] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_cl_bt_0001 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0001");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0001] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_cl_bt_0001;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0001] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0001] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0001] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0001] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0001(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0001] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/cl_bt_0002.c
Normal file
247
app/batch/cl_bt_0002.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/cl_bt_0002.pgc"
|
||||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0002.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0002 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/cl_bt_0002.pgc"
|
||||
|
||||
|
||||
static int run_cl_bt_0002(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/cl_bt_0002.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/cl_bt_0002.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/cl_bt_0002.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/cl_bt_0002.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/cl_bt_0002.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/cl_bt_0002.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_cl_bt_0002 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/cl_bt_0002.pgc"
|
||||
|
||||
#line 42 "app/batch/cl_bt_0002.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cl_bt_0002 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/cl_bt_0002.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0002");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0002] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cl_bt_0002", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/cl_bt_0002.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0002");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0002] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cl_bt_0002", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/cl_bt_0002.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0002] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0002] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0002] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0002] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0002(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0002] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/cl_bt_0002.pgc
Normal file
138
app/batch/cl_bt_0002.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0002.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0002 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_cl_bt_0002(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_cl_bt_0002 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_cl_bt_0002;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0002");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0002] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_cl_bt_0002 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0002");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0002] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_cl_bt_0002;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0002] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0002] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0002] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0002] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0002(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0002] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/cl_bt_0003.c
Normal file
247
app/batch/cl_bt_0003.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/cl_bt_0003.pgc"
|
||||
/* @tier medium @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0003.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0003 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/cl_bt_0003.pgc"
|
||||
|
||||
|
||||
static int run_cl_bt_0003(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/cl_bt_0003.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/cl_bt_0003.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/cl_bt_0003.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/cl_bt_0003.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/cl_bt_0003.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/cl_bt_0003.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_cl_bt_0003 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/cl_bt_0003.pgc"
|
||||
|
||||
#line 42 "app/batch/cl_bt_0003.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cl_bt_0003 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/cl_bt_0003.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0003");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0003] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cl_bt_0003", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/cl_bt_0003.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0003");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0003] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cl_bt_0003", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/cl_bt_0003.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0003] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0003] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0003] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0003] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0003(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0003] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/cl_bt_0003.pgc
Normal file
138
app/batch/cl_bt_0003.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0003.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0003 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_cl_bt_0003(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_cl_bt_0003 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_cl_bt_0003;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0003");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0003] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_cl_bt_0003 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0003");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0003] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_cl_bt_0003;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0003] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0003] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0003] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0003] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0003(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0003] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/cl_bt_0004.c
Normal file
247
app/batch/cl_bt_0004.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/cl_bt_0004.pgc"
|
||||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0004.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0004 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/cl_bt_0004.pgc"
|
||||
|
||||
|
||||
static int run_cl_bt_0004(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/cl_bt_0004.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/cl_bt_0004.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/cl_bt_0004.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/cl_bt_0004.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/cl_bt_0004.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/cl_bt_0004.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_cl_bt_0004 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/cl_bt_0004.pgc"
|
||||
|
||||
#line 42 "app/batch/cl_bt_0004.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cl_bt_0004 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/cl_bt_0004.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0004");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0004] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cl_bt_0004", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/cl_bt_0004.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0004");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0004] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cl_bt_0004", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/cl_bt_0004.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0004] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0004] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0004] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0004] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0004(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0004] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/cl_bt_0004.pgc
Normal file
138
app/batch/cl_bt_0004.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0004.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0004 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_cl_bt_0004(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_cl_bt_0004 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_cl_bt_0004;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0004");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0004] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_cl_bt_0004 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0004");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0004] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_cl_bt_0004;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0004] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0004] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0004] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0004] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0004(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0004] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/cl_bt_0005.c
Normal file
247
app/batch/cl_bt_0005.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/cl_bt_0005.pgc"
|
||||
/* @tier medium @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0005.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0005 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/cl_bt_0005.pgc"
|
||||
|
||||
|
||||
static int run_cl_bt_0005(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/cl_bt_0005.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/cl_bt_0005.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/cl_bt_0005.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/cl_bt_0005.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/cl_bt_0005.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/cl_bt_0005.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_cl_bt_0005 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/cl_bt_0005.pgc"
|
||||
|
||||
#line 42 "app/batch/cl_bt_0005.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cl_bt_0005 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/cl_bt_0005.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0005");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0005] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cl_bt_0005", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/cl_bt_0005.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0005");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0005] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cl_bt_0005", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/cl_bt_0005.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0005] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0005] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0005] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0005] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0005(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0005] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/cl_bt_0005.pgc
Normal file
138
app/batch/cl_bt_0005.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0005.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0005 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_cl_bt_0005(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_cl_bt_0005 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_cl_bt_0005;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0005");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0005] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_cl_bt_0005 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0005");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0005] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_cl_bt_0005;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0005] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0005] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0005] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0005] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0005(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0005] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/cl_bt_0006.c
Normal file
247
app/batch/cl_bt_0006.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/cl_bt_0006.pgc"
|
||||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0006.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0006 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/cl_bt_0006.pgc"
|
||||
|
||||
|
||||
static int run_cl_bt_0006(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/cl_bt_0006.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/cl_bt_0006.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/cl_bt_0006.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/cl_bt_0006.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/cl_bt_0006.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/cl_bt_0006.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_cl_bt_0006 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/cl_bt_0006.pgc"
|
||||
|
||||
#line 42 "app/batch/cl_bt_0006.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cl_bt_0006 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/cl_bt_0006.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0006");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0006] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cl_bt_0006", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/cl_bt_0006.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0006");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0006] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cl_bt_0006", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/cl_bt_0006.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0006] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0006] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0006] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0006] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0006(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0006] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/cl_bt_0006.pgc
Normal file
138
app/batch/cl_bt_0006.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0006.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0006 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_cl_bt_0006(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_cl_bt_0006 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_cl_bt_0006;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0006");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0006] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_cl_bt_0006 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0006");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0006] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_cl_bt_0006;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0006] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0006] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0006] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0006] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0006(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0006] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/cl_bt_0007.c
Normal file
247
app/batch/cl_bt_0007.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/cl_bt_0007.pgc"
|
||||
/* @tier medium @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0007.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0007 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/cl_bt_0007.pgc"
|
||||
|
||||
|
||||
static int run_cl_bt_0007(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/cl_bt_0007.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/cl_bt_0007.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/cl_bt_0007.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/cl_bt_0007.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/cl_bt_0007.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/cl_bt_0007.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_cl_bt_0007 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/cl_bt_0007.pgc"
|
||||
|
||||
#line 42 "app/batch/cl_bt_0007.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cl_bt_0007 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/cl_bt_0007.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0007");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0007] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cl_bt_0007", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/cl_bt_0007.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0007");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0007] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cl_bt_0007", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/cl_bt_0007.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0007] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0007] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0007] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0007] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0007(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0007] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/cl_bt_0007.pgc
Normal file
138
app/batch/cl_bt_0007.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0007.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0007 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_cl_bt_0007(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_cl_bt_0007 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_cl_bt_0007;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0007");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0007] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_cl_bt_0007 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0007");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0007] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_cl_bt_0007;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0007] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0007] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0007] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0007] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0007(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0007] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/cl_bt_0008.c
Normal file
247
app/batch/cl_bt_0008.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/cl_bt_0008.pgc"
|
||||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0008.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0008 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/cl_bt_0008.pgc"
|
||||
|
||||
|
||||
static int run_cl_bt_0008(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/cl_bt_0008.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/cl_bt_0008.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/cl_bt_0008.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/cl_bt_0008.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/cl_bt_0008.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/cl_bt_0008.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_cl_bt_0008 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/cl_bt_0008.pgc"
|
||||
|
||||
#line 42 "app/batch/cl_bt_0008.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cl_bt_0008 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/cl_bt_0008.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0008");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0008] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cl_bt_0008", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/cl_bt_0008.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0008");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0008] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cl_bt_0008", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/cl_bt_0008.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0008] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0008] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0008] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0008] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0008(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0008] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/cl_bt_0008.pgc
Normal file
138
app/batch/cl_bt_0008.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0008.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0008 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_cl_bt_0008(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_cl_bt_0008 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_cl_bt_0008;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0008");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0008] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_cl_bt_0008 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0008");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0008] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_cl_bt_0008;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0008] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0008] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0008] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0008] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0008(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0008] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/cl_bt_0009.c
Normal file
247
app/batch/cl_bt_0009.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/cl_bt_0009.pgc"
|
||||
/* @tier hard @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0009.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=hard]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0009 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/cl_bt_0009.pgc"
|
||||
|
||||
|
||||
static int run_cl_bt_0009(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/cl_bt_0009.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/cl_bt_0009.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/cl_bt_0009.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/cl_bt_0009.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/cl_bt_0009.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/cl_bt_0009.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_cl_bt_0009 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/cl_bt_0009.pgc"
|
||||
|
||||
#line 42 "app/batch/cl_bt_0009.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cl_bt_0009 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/cl_bt_0009.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0009");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0009] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cl_bt_0009", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/cl_bt_0009.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0009");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0009] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cl_bt_0009", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/cl_bt_0009.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0009] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0009] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0009] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0009] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0009(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0009] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/cl_bt_0009.pgc
Normal file
138
app/batch/cl_bt_0009.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier hard @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0009.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=hard]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0009 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_cl_bt_0009(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_cl_bt_0009 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_cl_bt_0009;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0009");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0009] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_cl_bt_0009 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0009");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0009] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_cl_bt_0009;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0009] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0009] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0009] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0009] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0009(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0009] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/cl_bt_0010.c
Normal file
247
app/batch/cl_bt_0010.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/cl_bt_0010.pgc"
|
||||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0010.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0010 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/cl_bt_0010.pgc"
|
||||
|
||||
|
||||
static int run_cl_bt_0010(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/cl_bt_0010.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/cl_bt_0010.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/cl_bt_0010.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/cl_bt_0010.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/cl_bt_0010.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/cl_bt_0010.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_cl_bt_0010 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/cl_bt_0010.pgc"
|
||||
|
||||
#line 42 "app/batch/cl_bt_0010.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cl_bt_0010 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/cl_bt_0010.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0010");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0010] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cl_bt_0010", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/cl_bt_0010.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0010");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0010] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cl_bt_0010", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/cl_bt_0010.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0010] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0010] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0010] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0010] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0010(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0010] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/cl_bt_0010.pgc
Normal file
138
app/batch/cl_bt_0010.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0010.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0010 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_cl_bt_0010(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_cl_bt_0010 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_cl_bt_0010;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0010");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0010] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_cl_bt_0010 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0010");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0010] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_cl_bt_0010;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0010] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0010] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0010] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0010] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0010(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0010] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/cl_bt_0011.c
Normal file
247
app/batch/cl_bt_0011.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/cl_bt_0011.pgc"
|
||||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0011.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0011 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/cl_bt_0011.pgc"
|
||||
|
||||
|
||||
static int run_cl_bt_0011(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/cl_bt_0011.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/cl_bt_0011.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/cl_bt_0011.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/cl_bt_0011.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/cl_bt_0011.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/cl_bt_0011.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_cl_bt_0011 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/cl_bt_0011.pgc"
|
||||
|
||||
#line 42 "app/batch/cl_bt_0011.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cl_bt_0011 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/cl_bt_0011.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0011");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0011] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cl_bt_0011", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/cl_bt_0011.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0011");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0011] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cl_bt_0011", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/cl_bt_0011.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0011] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0011] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0011] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0011] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0011(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0011] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/cl_bt_0011.pgc
Normal file
138
app/batch/cl_bt_0011.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0011.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0011 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_cl_bt_0011(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_cl_bt_0011 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_cl_bt_0011;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0011");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0011] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_cl_bt_0011 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0011");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0011] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_cl_bt_0011;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0011] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0011] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0011] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0011] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0011(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0011] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/cl_bt_0012.c
Normal file
247
app/batch/cl_bt_0012.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/cl_bt_0012.pgc"
|
||||
/* @tier medium @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0012.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0012 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/cl_bt_0012.pgc"
|
||||
|
||||
|
||||
static int run_cl_bt_0012(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/cl_bt_0012.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/cl_bt_0012.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/cl_bt_0012.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/cl_bt_0012.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/cl_bt_0012.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/cl_bt_0012.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_cl_bt_0012 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/cl_bt_0012.pgc"
|
||||
|
||||
#line 42 "app/batch/cl_bt_0012.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cl_bt_0012 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/cl_bt_0012.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0012");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0012] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cl_bt_0012", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/cl_bt_0012.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0012");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0012] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cl_bt_0012", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/cl_bt_0012.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0012] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0012] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0012] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0012] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0012(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0012] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/cl_bt_0012.pgc
Normal file
138
app/batch/cl_bt_0012.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0012.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0012 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_cl_bt_0012(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_cl_bt_0012 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_cl_bt_0012;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0012");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0012] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_cl_bt_0012 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0012");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0012] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_cl_bt_0012;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0012] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0012] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0012] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0012] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0012(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0012] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/cl_bt_0013.c
Normal file
247
app/batch/cl_bt_0013.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/cl_bt_0013.pgc"
|
||||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0013.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0013 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/cl_bt_0013.pgc"
|
||||
|
||||
|
||||
static int run_cl_bt_0013(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/cl_bt_0013.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/cl_bt_0013.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/cl_bt_0013.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/cl_bt_0013.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/cl_bt_0013.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/cl_bt_0013.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_cl_bt_0013 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/cl_bt_0013.pgc"
|
||||
|
||||
#line 42 "app/batch/cl_bt_0013.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cl_bt_0013 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/cl_bt_0013.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0013");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0013] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cl_bt_0013", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/cl_bt_0013.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0013");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0013] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cl_bt_0013", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/cl_bt_0013.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0013] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0013] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0013] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0013] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0013(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0013] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/cl_bt_0013.pgc
Normal file
138
app/batch/cl_bt_0013.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0013.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0013 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_cl_bt_0013(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_cl_bt_0013 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_cl_bt_0013;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0013");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0013] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_cl_bt_0013 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0013");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0013] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_cl_bt_0013;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0013] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0013] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0013] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0013] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0013(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0013] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/cl_bt_0014.c
Normal file
247
app/batch/cl_bt_0014.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/cl_bt_0014.pgc"
|
||||
/* @tier medium @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0014.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0014 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/cl_bt_0014.pgc"
|
||||
|
||||
|
||||
static int run_cl_bt_0014(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/cl_bt_0014.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/cl_bt_0014.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/cl_bt_0014.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/cl_bt_0014.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/cl_bt_0014.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/cl_bt_0014.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_cl_bt_0014 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/cl_bt_0014.pgc"
|
||||
|
||||
#line 42 "app/batch/cl_bt_0014.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cl_bt_0014 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/cl_bt_0014.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0014");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0014] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cl_bt_0014", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/cl_bt_0014.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0014");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0014] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cl_bt_0014", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/cl_bt_0014.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0014] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0014] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0014] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0014] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0014(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0014] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/cl_bt_0014.pgc
Normal file
138
app/batch/cl_bt_0014.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier medium @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0014.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=medium]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0014 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_cl_bt_0014(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_cl_bt_0014 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_cl_bt_0014;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0014");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0014] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_cl_bt_0014 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0014");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0014] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_cl_bt_0014;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0014] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0014] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0014] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0014] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0014(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0014] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
247
app/batch/cl_bt_0015.c
Normal file
247
app/batch/cl_bt_0015.c
Normal file
|
|
@ -0,0 +1,247 @@
|
|||
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
||||
/* These include files are added by the preprocessor */
|
||||
#include <ecpglib.h>
|
||||
#include <ecpgerrno.h>
|
||||
#include <sqlca.h>
|
||||
/* End of automatic include section */
|
||||
|
||||
#line 1 "app/batch/cl_bt_0015.pgc"
|
||||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0015.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0015 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
||||
#line 1 "/usr/include/postgresql/sqlca.h"
|
||||
#ifndef POSTGRES_SQLCA_H
|
||||
#define POSTGRES_SQLCA_H
|
||||
|
||||
#ifndef PGDLLIMPORT
|
||||
#if defined(WIN32) || defined(__CYGWIN__)
|
||||
#define PGDLLIMPORT __declspec (dllimport)
|
||||
#else
|
||||
#define PGDLLIMPORT
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* PGDLLIMPORT */
|
||||
|
||||
#define SQLERRMC_LEN 150
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct sqlca_t
|
||||
{
|
||||
char sqlcaid[8];
|
||||
long sqlabc;
|
||||
long sqlcode;
|
||||
struct
|
||||
{
|
||||
int sqlerrml;
|
||||
char sqlerrmc[SQLERRMC_LEN];
|
||||
} sqlerrm;
|
||||
char sqlerrp[8];
|
||||
long sqlerrd[6];
|
||||
/* Element 0: empty */
|
||||
/* 1: OID of processed tuple if applicable */
|
||||
/* 2: number of rows processed */
|
||||
/* after an INSERT, UPDATE or */
|
||||
/* DELETE statement */
|
||||
/* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
char sqlwarn[8];
|
||||
/* Element 0: set to 'W' if at least one other is 'W' */
|
||||
/* 1: if 'W' at least one character string */
|
||||
/* value was truncated when it was */
|
||||
/* stored into a host variable. */
|
||||
|
||||
/*
|
||||
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
||||
*/ /* 3: empty */
|
||||
/* 4: empty */
|
||||
/* 5: empty */
|
||||
/* 6: empty */
|
||||
/* 7: empty */
|
||||
|
||||
char sqlstate[5];
|
||||
};
|
||||
|
||||
struct sqlca_t *ECPGget_sqlca(void);
|
||||
|
||||
#ifndef POSTGRES_ECPG_INTERNAL
|
||||
#define sqlca (*ECPGget_sqlca())
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#line 19 "app/batch/cl_bt_0015.pgc"
|
||||
|
||||
|
||||
static int run_cl_bt_0015(const char *biz_date)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 24 "app/batch/cl_bt_0015.pgc"
|
||||
char h_biz_date [ 9 ] ;
|
||||
|
||||
#line 25 "app/batch/cl_bt_0015.pgc"
|
||||
char h_key [ 16 ] ;
|
||||
|
||||
#line 26 "app/batch/cl_bt_0015.pgc"
|
||||
char h_merch_id [ 16 ] ;
|
||||
|
||||
#line 27 "app/batch/cl_bt_0015.pgc"
|
||||
long h_amount ;
|
||||
|
||||
#line 28 "app/batch/cl_bt_0015.pgc"
|
||||
char h_new_status [ 2 ] ;
|
||||
/* exec sql end declare section */
|
||||
#line 29 "app/batch/cl_bt_0015.pgc"
|
||||
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
ECPGset_var( 0, ( h_biz_date ), __LINE__);\
|
||||
/* declare cur_cl_bt_0015 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key */
|
||||
#line 42 "app/batch/cl_bt_0015.pgc"
|
||||
|
||||
#line 42 "app/batch/cl_bt_0015.pgc"
|
||||
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cl_bt_0015 cursor for select key , merch_id , amount from cl_ledger where biz_date = $1 and status = 'R' order by key",
|
||||
ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 44 "app/batch/cl_bt_0015.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0015");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0015] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cl_bt_0015", ECPGt_EOIT,
|
||||
ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 54 "app/batch/cl_bt_0015.pgc"
|
||||
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0015");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0015] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cl_bt_0015", ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 82 "app/batch/cl_bt_0015.pgc"
|
||||
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0015] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0015] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0015] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0015] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0015(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0015] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
138
app/batch/cl_bt_0015.pgc
Normal file
138
app/batch/cl_bt_0015.pgc
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/* @tier easy @module cl @transform closing-batch */
|
||||
/*
|
||||
* cl_bt_0015.pgc - 마감 배치 (커서 순회 + 상태전이) [tier=easy]
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 건을 커서로 순회하며 업무규칙에 따라
|
||||
* 완료('M')/불일치('U') 로 상태를 전이한다. 배치 main 엔트리 포함.
|
||||
*
|
||||
* 실행: cl_bt_0015 <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_cl_bt_0015(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_key[16];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, done = 0, unmatch = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
EXEC SQL DECLARE cur_cl_bt_0015 CURSOR FOR
|
||||
SELECT key, merch_id, amount
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY key;
|
||||
|
||||
EXEC SQL OPEN cur_cl_bt_0015;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_cl_bt_0015");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[cl_bt_0015] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_cl_bt_0015 INTO :h_key, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_cl_bt_0015");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 금액 유효성으로 완료/불일치 판정 */
|
||||
if (amount_is_valid(h_amount)) {
|
||||
strncpy(h_new_status, CL_ST_DONE, sizeof(h_new_status));
|
||||
done++;
|
||||
} else {
|
||||
strncpy(h_new_status, CL_ST_FAIL, sizeof(h_new_status));
|
||||
unmatch++;
|
||||
}
|
||||
|
||||
rc = cl_rec_update_status(h_key, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0015] 상태전이 실패 key=%s rc=%d", h_key, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_cl_bt_0015;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[cl_bt_0015] 요약 date=%s 대상=%ld 완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, done, unmatch, errcnt);
|
||||
|
||||
printf("========== 마감 배치 결과 [cl_bt_0015] ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 완료(M) : %ld\n", done);
|
||||
printf(" 불일치(U) : %ld\n", unmatch);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0015] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = cl_dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[cl_bt_0015] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_cl_bt_0015(biz_date);
|
||||
|
||||
cl_dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[cl_bt_0015] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue