Phase 2c: 전 11모듈 per-service 레거시 구조 분해·확장 (실동작 유지)
- 10개 모듈(au py rc st lg cl mm vl mg cm)을 ac 템플릿대로 분해: svc/ 30 서비스 .pgc + 카피북 .h, 얇은 <mod>_svr 디스패처 dbio/ ~25 .pgc(+.h), batch/ ~17 .pgc, run/ ~17 .sh (모듈마다) - 파일: svc 330 + dbio 276 + batch 187 + run 187, 총 소스 1602본 - 서비스별 고유 실로직(정규화 md5), build.sh 자동발견(inline/split 양립) - 통합 검증: build DONE modules=11 servers=11 batches=187, 12서버 runok, 333 서비스 AVAIL, 매입체인 XA 커밋(status=S), prepared_xacts=0 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c3b99a8b75
commit
fd8b418c6e
1404 changed files with 30322 additions and 5994 deletions
12
app/src/mg/dbio/mg_amount_spread_dbio.h
Normal file
12
app/src/mg/dbio/mg_amount_spread_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_amount_spread_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_amount_spread_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_AMOUNT_SPREAD_DBIO_H
|
||||
#define MG_AMOUNT_SPREAD_DBIO_H
|
||||
|
||||
/* 전문 금액 최대-최소 스프레드. */
|
||||
long mgdb_msg_amount_spread(const char *bizdate);
|
||||
|
||||
#endif /* MG_AMOUNT_SPREAD_DBIO_H */
|
||||
21
app/src/mg/dbio/mg_amount_spread_dbio.pgc
Normal file
21
app/src/mg/dbio/mg_amount_spread_dbio.pgc
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* mg_amount_spread_dbio.pgc - mg 모듈 DB 접근 함수 (mg_amount_spread_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 전문 금액 최대-최소 스프레드.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_amount_spread_dbio.h"
|
||||
|
||||
long mgdb_msg_amount_spread(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_max = 0, h_min = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(max(amount),0), coalesce(min(amount),0)
|
||||
INTO :h_max, :h_min FROM mg_msg_log WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_max - h_min;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_avg_amount_dbio.h
Normal file
12
app/src/mg/dbio/mg_avg_amount_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_avg_amount_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_avg_amount_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_AVG_AMOUNT_DBIO_H
|
||||
#define MG_AVG_AMOUNT_DBIO_H
|
||||
|
||||
/* 전문 건당 평균 금액. */
|
||||
long mgdb_msg_avg_amount(const char *bizdate);
|
||||
|
||||
#endif /* MG_AVG_AMOUNT_DBIO_H */
|
||||
22
app/src/mg/dbio/mg_avg_amount_dbio.pgc
Normal file
22
app/src/mg/dbio/mg_avg_amount_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* mg_avg_amount_dbio.pgc - mg 모듈 DB 접근 함수 (mg_avg_amount_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 전문 건당 평균 금액.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_avg_amount_dbio.h"
|
||||
|
||||
long mgdb_msg_avg_amount(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_sum = 0, h_cnt = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(sum(amount),0), count(*) INTO :h_sum, :h_cnt
|
||||
FROM mg_msg_log WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
if (h_cnt <= 0) return 0;
|
||||
return h_sum / h_cnt;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_big_pct_dbio.h
Normal file
12
app/src/mg/dbio/mg_big_pct_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_big_pct_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_big_pct_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_BIG_PCT_DBIO_H
|
||||
#define MG_BIG_PCT_DBIO_H
|
||||
|
||||
/* 고액 전문 비율(%). */
|
||||
long mgdb_msg_big_pct(const char *bizdate);
|
||||
|
||||
#endif /* MG_BIG_PCT_DBIO_H */
|
||||
22
app/src/mg/dbio/mg_big_pct_dbio.pgc
Normal file
22
app/src/mg/dbio/mg_big_pct_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* mg_big_pct_dbio.pgc - mg 모듈 DB 접근 함수 (mg_big_pct_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 고액 전문 비율(%).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_big_pct_dbio.h"
|
||||
|
||||
long mgdb_msg_big_pct(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_hi = 0, h_all = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(sum(CASE WHEN amount > 1000000 THEN 1 ELSE 0 END),0), count(*)
|
||||
INTO :h_hi, :h_all FROM mg_msg_log WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
if (h_all <= 0) return 0;
|
||||
return h_hi * 100 / h_all;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_bump_stan_dbio.h
Normal file
12
app/src/mg/dbio/mg_bump_stan_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_bump_stan_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_bump_stan_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_BUMP_STAN_DBIO_H
|
||||
#define MG_BUMP_STAN_DBIO_H
|
||||
|
||||
/* 활동 채널 last_stan 증가. */
|
||||
long mgdb_channel_bump_stan(const char *bizdate);
|
||||
|
||||
#endif /* MG_BUMP_STAN_DBIO_H */
|
||||
20
app/src/mg/dbio/mg_bump_stan_dbio.pgc
Normal file
20
app/src/mg/dbio/mg_bump_stan_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* mg_bump_stan_dbio.pgc - mg 모듈 DB 접근 함수 (mg_bump_stan_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 활동 채널 last_stan 증가.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_bump_stan_dbio.h"
|
||||
|
||||
long mgdb_channel_bump_stan(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL UPDATE mg_channel SET last_stan = last_stan + 1
|
||||
WHERE channel IN (SELECT channel FROM mg_msg_log WHERE biz_date = :h_bizdate);
|
||||
if (sqlca.sqlcode < 0) { userlog("mgdb_channel_bump_stan FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return sqlca.sqlerrd[2];
|
||||
}
|
||||
12
app/src/mg/dbio/mg_chan_sum_dbio.h
Normal file
12
app/src/mg/dbio/mg_chan_sum_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_chan_sum_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_chan_sum_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_CHAN_SUM_DBIO_H
|
||||
#define MG_CHAN_SUM_DBIO_H
|
||||
|
||||
/* 채널 그룹 금액 커서 누적. */
|
||||
long mgdb_msg_chan_sum(const char *bizdate);
|
||||
|
||||
#endif /* MG_CHAN_SUM_DBIO_H */
|
||||
30
app/src/mg/dbio/mg_chan_sum_dbio.pgc
Normal file
30
app/src/mg/dbio/mg_chan_sum_dbio.pgc
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* mg_chan_sum_dbio.pgc - mg 모듈 DB 접근 함수 (mg_chan_sum_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 채널 그룹 금액 커서 누적.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_chan_sum_dbio.h"
|
||||
|
||||
long mgdb_msg_chan_sum(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16], h_key[32];
|
||||
long h_amt = 0, total = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL DECLARE qc CURSOR FOR
|
||||
SELECT channel, coalesce(sum(amount),0) FROM mg_msg_log
|
||||
WHERE biz_date = :h_bizdate GROUP BY channel;
|
||||
EXEC SQL OPEN qc;
|
||||
if (sqlca.sqlcode < 0) { userlog("mgdb_msg_chan_sum OPEN [%d]", sqlca.sqlcode); return -1; }
|
||||
for (;;) {
|
||||
EXEC SQL FETCH qc INTO :h_key, :h_amt;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE qc; return -1; }
|
||||
total += h_amt;
|
||||
}
|
||||
EXEC SQL CLOSE qc;
|
||||
return total;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_channel_up_dbio.h
Normal file
12
app/src/mg/dbio/mg_channel_up_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_channel_up_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_channel_up_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_CHANNEL_UP_DBIO_H
|
||||
#define MG_CHANNEL_UP_DBIO_H
|
||||
|
||||
/* 채널 UP 상태 여부. */
|
||||
int mgdb_channel_is_up(const char *key);
|
||||
|
||||
#endif /* MG_CHANNEL_UP_DBIO_H */
|
||||
21
app/src/mg/dbio/mg_channel_up_dbio.pgc
Normal file
21
app/src/mg/dbio/mg_channel_up_dbio.pgc
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* mg_channel_up_dbio.pgc - mg 모듈 DB 접근 함수 (mg_channel_up_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 채널 UP 상태 여부.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_channel_up_dbio.h"
|
||||
|
||||
int mgdb_channel_is_up(const char *key)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_key[32], h_st[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_key, key, sizeof(h_key)-1); h_key[sizeof(h_key)-1] = 0;
|
||||
EXEC SQL SELECT status INTO :h_st FROM mg_channel WHERE channel = :h_key;
|
||||
if (sqlca.sqlcode == 100) return -1;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
if (strcmp(h_st, "UP") == 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -38,4 +38,30 @@ int mgdb_enqueue(long queue_id, long stan, const char *channel, const char *mti
|
|||
const char *payload, const char *bizdate);
|
||||
int mgdb_set_queue_status(long queue_id, const char *status);
|
||||
|
||||
|
||||
/* ----- expanded query/analytics dbio (each in its own mg_*_dbio.pgc) ----- */
|
||||
long mgdb_msg_amount_sum(const char *bizdate); /* 당일 전문 금액 합계. */
|
||||
long mgdb_queue_backlog(const char *status); /* 상태별 큐 적체 건수. */
|
||||
long mgdb_msg_amount_spread(const char *bizdate); /* 전문 금액 최대-최소 스프레드. */
|
||||
long mgdb_msg_err_ratio(const char *bizdate); /* 오류 전문 비율(bps). */
|
||||
long mgdb_msg_chan_sum(const char *bizdate); /* 채널 그룹 금액 커서 누적. */
|
||||
long mgdb_msg_avg_amount(const char *bizdate); /* 전문 건당 평균 금액. */
|
||||
long mgdb_msg_inbound_amount(const char *bizdate); /* 수신(IN) 전문 금액 합계. */
|
||||
long mgdb_queue_purge_sent(const char *bizdate); /* 송신완료(S) 큐 정리 삭제. */
|
||||
long mgdb_queue_mark_stale(const char *bizdate); /* 대기(Q) 오래된 큐 실패(F) 전이. */
|
||||
int mgdb_route_channel_exists(const char *key); /* 채널 라우팅 존재 여부. */
|
||||
int mgdb_queue_payload(long id, char *out); /* 큐 ID 페이로드 조회. */
|
||||
long mgdb_queue_weighted(const char *bizdate); /* STAN x 재시도수 가중 합. */
|
||||
long mgdb_msg_peak_count(const char *bizdate); /* 최고 금액 전문 건수. */
|
||||
long mgdb_msg_pan_like(const char *pat); /* PAN 접두 패턴 전문 건수. */
|
||||
long mgdb_msg_distinct_chan(const char *bizdate); /* 당일 고유 채널 수. */
|
||||
long mgdb_msg_routed_amount(const char *bizdate); /* 라우팅 매칭 전문 금액(조인). */
|
||||
long mgdb_msg_min_amount(const char *bizdate); /* 당일 최소 전문 금액. */
|
||||
long mgdb_msg_big_pct(const char *bizdate); /* 고액 전문 비율(%). */
|
||||
int mgdb_channel_is_up(const char *key); /* 채널 UP 상태 여부. */
|
||||
long mgdb_channel_bump_stan(const char *bizdate); /* 활동 채널 last_stan 증가. */
|
||||
long mgdb_msg_insert_marker(const char *bizdate, long amount); /* 마커 전문 채번 후 적재. */
|
||||
long mgdb_queue_load(const char *bizdate); /* 큐 STAN+재시도 합산 부하지표. */
|
||||
long mgdb_msg_positive_count(const char *bizdate); /* 금액>0 전문 건수(커서). */
|
||||
|
||||
#endif /* MG_DBIO_H */
|
||||
|
|
|
|||
12
app/src/mg/dbio/mg_distinct_chan_dbio.h
Normal file
12
app/src/mg/dbio/mg_distinct_chan_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_distinct_chan_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_distinct_chan_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_DISTINCT_CHAN_DBIO_H
|
||||
#define MG_DISTINCT_CHAN_DBIO_H
|
||||
|
||||
/* 당일 고유 채널 수. */
|
||||
long mgdb_msg_distinct_chan(const char *bizdate);
|
||||
|
||||
#endif /* MG_DISTINCT_CHAN_DBIO_H */
|
||||
20
app/src/mg/dbio/mg_distinct_chan_dbio.pgc
Normal file
20
app/src/mg/dbio/mg_distinct_chan_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* mg_distinct_chan_dbio.pgc - mg 모듈 DB 접근 함수 (mg_distinct_chan_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 당일 고유 채널 수.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_distinct_chan_dbio.h"
|
||||
|
||||
long mgdb_msg_distinct_chan(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT count(DISTINCT channel) INTO :h_v FROM mg_msg_log WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_err_ratio_dbio.h
Normal file
12
app/src/mg/dbio/mg_err_ratio_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_err_ratio_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_err_ratio_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_ERR_RATIO_DBIO_H
|
||||
#define MG_ERR_RATIO_DBIO_H
|
||||
|
||||
/* 오류 전문 비율(bps). */
|
||||
long mgdb_msg_err_ratio(const char *bizdate);
|
||||
|
||||
#endif /* MG_ERR_RATIO_DBIO_H */
|
||||
23
app/src/mg/dbio/mg_err_ratio_dbio.pgc
Normal file
23
app/src/mg/dbio/mg_err_ratio_dbio.pgc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* mg_err_ratio_dbio.pgc - mg 모듈 DB 접근 함수 (mg_err_ratio_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 오류 전문 비율(bps).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_err_ratio_dbio.h"
|
||||
|
||||
long mgdb_msg_err_ratio(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_a = 0, h_b = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT count(*) INTO :h_a FROM mg_msg_log WHERE biz_date = :h_bizdate AND status = 'N';
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
EXEC SQL SELECT count(*) INTO :h_b FROM mg_msg_log WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
if (h_b <= 0) return 0;
|
||||
return h_a * 10000 / h_b;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_inbound_amt_dbio.h
Normal file
12
app/src/mg/dbio/mg_inbound_amt_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_inbound_amt_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_inbound_amt_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_INBOUND_AMT_DBIO_H
|
||||
#define MG_INBOUND_AMT_DBIO_H
|
||||
|
||||
/* 수신(IN) 전문 금액 합계. */
|
||||
long mgdb_msg_inbound_amount(const char *bizdate);
|
||||
|
||||
#endif /* MG_INBOUND_AMT_DBIO_H */
|
||||
21
app/src/mg/dbio/mg_inbound_amt_dbio.pgc
Normal file
21
app/src/mg/dbio/mg_inbound_amt_dbio.pgc
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* mg_inbound_amt_dbio.pgc - mg 모듈 DB 접근 함수 (mg_inbound_amt_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 수신(IN) 전문 금액 합계.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_inbound_amt_dbio.h"
|
||||
|
||||
long mgdb_msg_inbound_amount(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(sum(CASE WHEN direction = 'IN' THEN amount ELSE 0 END),0)
|
||||
INTO :h_v FROM mg_msg_log WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_insert_mark_dbio.h
Normal file
12
app/src/mg/dbio/mg_insert_mark_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_insert_mark_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_insert_mark_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_INSERT_MARK_DBIO_H
|
||||
#define MG_INSERT_MARK_DBIO_H
|
||||
|
||||
/* 마커 전문 채번 후 적재. */
|
||||
long mgdb_msg_insert_marker(const char *bizdate, long amount);
|
||||
|
||||
#endif /* MG_INSERT_MARK_DBIO_H */
|
||||
23
app/src/mg/dbio/mg_insert_mark_dbio.pgc
Normal file
23
app/src/mg/dbio/mg_insert_mark_dbio.pgc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* mg_insert_mark_dbio.pgc - mg 모듈 DB 접근 함수 (mg_insert_mark_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 마커 전문 채번 후 적재.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_insert_mark_dbio.h"
|
||||
|
||||
long mgdb_msg_insert_marker(const char *bizdate, long amount)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_id = 0, h_amt = amount;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT nextval('mg_msg_seq') INTO :h_id;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
EXEC SQL INSERT INTO mg_msg_log (msg_id, amount, biz_date)
|
||||
VALUES (:h_id, :h_amt, :h_bizdate);
|
||||
if (sqlca.sqlcode < 0) { userlog("mgdb_msg_insert_marker FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_id;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_min_amount_dbio.h
Normal file
12
app/src/mg/dbio/mg_min_amount_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_min_amount_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_min_amount_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_MIN_AMOUNT_DBIO_H
|
||||
#define MG_MIN_AMOUNT_DBIO_H
|
||||
|
||||
/* 당일 최소 전문 금액. */
|
||||
long mgdb_msg_min_amount(const char *bizdate);
|
||||
|
||||
#endif /* MG_MIN_AMOUNT_DBIO_H */
|
||||
21
app/src/mg/dbio/mg_min_amount_dbio.pgc
Normal file
21
app/src/mg/dbio/mg_min_amount_dbio.pgc
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* mg_min_amount_dbio.pgc - mg 모듈 DB 접근 함수 (mg_min_amount_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 당일 최소 전문 금액.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_min_amount_dbio.h"
|
||||
|
||||
long mgdb_msg_min_amount(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT min(amount) INTO :h_v FROM mg_msg_log WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode == 100) return 0;
|
||||
if (sqlca.sqlcode < 0) { userlog("mgdb_msg_min_amount FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_msg_amount_dbio.h
Normal file
12
app/src/mg/dbio/mg_msg_amount_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_msg_amount_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_msg_amount_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_MSG_AMOUNT_DBIO_H
|
||||
#define MG_MSG_AMOUNT_DBIO_H
|
||||
|
||||
/* 당일 전문 금액 합계. */
|
||||
long mgdb_msg_amount_sum(const char *bizdate);
|
||||
|
||||
#endif /* MG_MSG_AMOUNT_DBIO_H */
|
||||
20
app/src/mg/dbio/mg_msg_amount_dbio.pgc
Normal file
20
app/src/mg/dbio/mg_msg_amount_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* mg_msg_amount_dbio.pgc - mg 모듈 DB 접근 함수 (mg_msg_amount_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 당일 전문 금액 합계.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_msg_amount_dbio.h"
|
||||
|
||||
long mgdb_msg_amount_sum(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(sum(amount),0) INTO :h_v FROM mg_msg_log WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { userlog("mgdb_msg_amount_sum FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_pan_like_dbio.h
Normal file
12
app/src/mg/dbio/mg_pan_like_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_pan_like_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_pan_like_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_PAN_LIKE_DBIO_H
|
||||
#define MG_PAN_LIKE_DBIO_H
|
||||
|
||||
/* PAN 접두 패턴 전문 건수. */
|
||||
long mgdb_msg_pan_like(const char *pat);
|
||||
|
||||
#endif /* MG_PAN_LIKE_DBIO_H */
|
||||
20
app/src/mg/dbio/mg_pan_like_dbio.pgc
Normal file
20
app/src/mg/dbio/mg_pan_like_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* mg_pan_like_dbio.pgc - mg 모듈 DB 접근 함수 (mg_pan_like_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* PAN 접두 패턴 전문 건수.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_pan_like_dbio.h"
|
||||
|
||||
long mgdb_msg_pan_like(const char *pat)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_pat[64];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_pat, pat, sizeof(h_pat)-1); h_pat[sizeof(h_pat)-1] = 0;
|
||||
EXEC SQL SELECT count(*) INTO :h_v FROM mg_msg_log WHERE pan LIKE :h_pat;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_peak_count_dbio.h
Normal file
12
app/src/mg/dbio/mg_peak_count_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_peak_count_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_peak_count_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_PEAK_COUNT_DBIO_H
|
||||
#define MG_PEAK_COUNT_DBIO_H
|
||||
|
||||
/* 최고 금액 전문 건수. */
|
||||
long mgdb_msg_peak_count(const char *bizdate);
|
||||
|
||||
#endif /* MG_PEAK_COUNT_DBIO_H */
|
||||
23
app/src/mg/dbio/mg_peak_count_dbio.pgc
Normal file
23
app/src/mg/dbio/mg_peak_count_dbio.pgc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* mg_peak_count_dbio.pgc - mg 모듈 DB 접근 함수 (mg_peak_count_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 최고 금액 전문 건수.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_peak_count_dbio.h"
|
||||
|
||||
long mgdb_msg_peak_count(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_peak = 0, h_cnt = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(max(amount),0) INTO :h_peak FROM mg_msg_log WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
EXEC SQL SELECT count(*) INTO :h_cnt FROM mg_msg_log
|
||||
WHERE biz_date = :h_bizdate AND amount = :h_peak;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_cnt;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_pos_count_dbio.h
Normal file
12
app/src/mg/dbio/mg_pos_count_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_pos_count_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_pos_count_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_POS_COUNT_DBIO_H
|
||||
#define MG_POS_COUNT_DBIO_H
|
||||
|
||||
/* 금액>0 전문 건수(커서). */
|
||||
long mgdb_msg_positive_count(const char *bizdate);
|
||||
|
||||
#endif /* MG_POS_COUNT_DBIO_H */
|
||||
29
app/src/mg/dbio/mg_pos_count_dbio.pgc
Normal file
29
app/src/mg/dbio/mg_pos_count_dbio.pgc
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* mg_pos_count_dbio.pgc - mg 모듈 DB 접근 함수 (mg_pos_count_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 금액>0 전문 건수(커서).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_pos_count_dbio.h"
|
||||
|
||||
long mgdb_msg_positive_count(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_x = 0, k = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL DECLARE qc CURSOR FOR
|
||||
SELECT amount FROM mg_msg_log WHERE biz_date = :h_bizdate;
|
||||
EXEC SQL OPEN qc;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
for (;;) {
|
||||
EXEC SQL FETCH qc INTO :h_x;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE qc; return -1; }
|
||||
if (h_x > 0) k++;
|
||||
}
|
||||
EXEC SQL CLOSE qc;
|
||||
return k;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_queue_backlog_dbio.h
Normal file
12
app/src/mg/dbio/mg_queue_backlog_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_queue_backlog_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_queue_backlog_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_QUEUE_BACKLOG_DBIO_H
|
||||
#define MG_QUEUE_BACKLOG_DBIO_H
|
||||
|
||||
/* 상태별 큐 적체 건수. */
|
||||
long mgdb_queue_backlog(const char *status);
|
||||
|
||||
#endif /* MG_QUEUE_BACKLOG_DBIO_H */
|
||||
20
app/src/mg/dbio/mg_queue_backlog_dbio.pgc
Normal file
20
app/src/mg/dbio/mg_queue_backlog_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* mg_queue_backlog_dbio.pgc - mg 모듈 DB 접근 함수 (mg_queue_backlog_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 상태별 큐 적체 건수.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_queue_backlog_dbio.h"
|
||||
|
||||
long mgdb_queue_backlog(const char *status)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_st[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_st, status, sizeof(h_st)-1); h_st[sizeof(h_st)-1] = 0;
|
||||
EXEC SQL SELECT count(*) INTO :h_v FROM mg_queue WHERE status = :h_st;
|
||||
if (sqlca.sqlcode < 0) { userlog("mgdb_queue_backlog FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_queue_load_dbio.h
Normal file
12
app/src/mg/dbio/mg_queue_load_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_queue_load_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_queue_load_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_QUEUE_LOAD_DBIO_H
|
||||
#define MG_QUEUE_LOAD_DBIO_H
|
||||
|
||||
/* 큐 STAN+재시도 합산 부하지표. */
|
||||
long mgdb_queue_load(const char *bizdate);
|
||||
|
||||
#endif /* MG_QUEUE_LOAD_DBIO_H */
|
||||
21
app/src/mg/dbio/mg_queue_load_dbio.pgc
Normal file
21
app/src/mg/dbio/mg_queue_load_dbio.pgc
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* mg_queue_load_dbio.pgc - mg 모듈 DB 접근 함수 (mg_queue_load_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 큐 STAN+재시도 합산 부하지표.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_queue_load_dbio.h"
|
||||
|
||||
long mgdb_queue_load(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(sum(stan),0) + coalesce(sum(retry_cnt),0) INTO :h_v
|
||||
FROM mg_queue WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_queue_payload_dbio.h
Normal file
12
app/src/mg/dbio/mg_queue_payload_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_queue_payload_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_queue_payload_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_QUEUE_PAYLOAD_DBIO_H
|
||||
#define MG_QUEUE_PAYLOAD_DBIO_H
|
||||
|
||||
/* 큐 ID 페이로드 조회. */
|
||||
int mgdb_queue_payload(long id, char *out);
|
||||
|
||||
#endif /* MG_QUEUE_PAYLOAD_DBIO_H */
|
||||
21
app/src/mg/dbio/mg_queue_payload_dbio.pgc
Normal file
21
app/src/mg/dbio/mg_queue_payload_dbio.pgc
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* mg_queue_payload_dbio.pgc - mg 모듈 DB 접근 함수 (mg_queue_payload_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 큐 ID 페이로드 조회.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_queue_payload_dbio.h"
|
||||
|
||||
int mgdb_queue_payload(long id, char *out)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_id = id;
|
||||
char h_s[64];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT payload INTO :h_s FROM mg_queue WHERE queue_id = :h_id;
|
||||
if (sqlca.sqlcode == 100) { out[0] = 0; return -1; }
|
||||
if (sqlca.sqlcode < 0) { userlog("mgdb_queue_payload FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
strncpy(out, h_s, 63); out[63] = 0;
|
||||
return 0;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_queue_purge_dbio.h
Normal file
12
app/src/mg/dbio/mg_queue_purge_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_queue_purge_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_queue_purge_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_QUEUE_PURGE_DBIO_H
|
||||
#define MG_QUEUE_PURGE_DBIO_H
|
||||
|
||||
/* 송신완료(S) 큐 정리 삭제. */
|
||||
long mgdb_queue_purge_sent(const char *bizdate);
|
||||
|
||||
#endif /* MG_QUEUE_PURGE_DBIO_H */
|
||||
19
app/src/mg/dbio/mg_queue_purge_dbio.pgc
Normal file
19
app/src/mg/dbio/mg_queue_purge_dbio.pgc
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* mg_queue_purge_dbio.pgc - mg 모듈 DB 접근 함수 (mg_queue_purge_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 송신완료(S) 큐 정리 삭제.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_queue_purge_dbio.h"
|
||||
|
||||
long mgdb_queue_purge_sent(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL DELETE FROM mg_queue WHERE biz_date = :h_bizdate AND status = 'S';
|
||||
if (sqlca.sqlcode < 0) { userlog("mgdb_queue_purge_sent FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return sqlca.sqlerrd[2];
|
||||
}
|
||||
12
app/src/mg/dbio/mg_queue_stale_dbio.h
Normal file
12
app/src/mg/dbio/mg_queue_stale_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_queue_stale_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_queue_stale_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_QUEUE_STALE_DBIO_H
|
||||
#define MG_QUEUE_STALE_DBIO_H
|
||||
|
||||
/* 대기(Q) 오래된 큐 실패(F) 전이. */
|
||||
long mgdb_queue_mark_stale(const char *bizdate);
|
||||
|
||||
#endif /* MG_QUEUE_STALE_DBIO_H */
|
||||
20
app/src/mg/dbio/mg_queue_stale_dbio.pgc
Normal file
20
app/src/mg/dbio/mg_queue_stale_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* mg_queue_stale_dbio.pgc - mg 모듈 DB 접근 함수 (mg_queue_stale_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 대기(Q) 오래된 큐 실패(F) 전이.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_queue_stale_dbio.h"
|
||||
|
||||
long mgdb_queue_mark_stale(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL UPDATE mg_queue SET status = 'F', updated_at = now()
|
||||
WHERE biz_date = :h_bizdate AND status = 'Q';
|
||||
if (sqlca.sqlcode < 0) { userlog("mgdb_queue_mark_stale FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return sqlca.sqlerrd[2];
|
||||
}
|
||||
12
app/src/mg/dbio/mg_queue_weight_dbio.h
Normal file
12
app/src/mg/dbio/mg_queue_weight_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_queue_weight_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_queue_weight_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_QUEUE_WEIGHT_DBIO_H
|
||||
#define MG_QUEUE_WEIGHT_DBIO_H
|
||||
|
||||
/* STAN x 재시도수 가중 합. */
|
||||
long mgdb_queue_weighted(const char *bizdate);
|
||||
|
||||
#endif /* MG_QUEUE_WEIGHT_DBIO_H */
|
||||
29
app/src/mg/dbio/mg_queue_weight_dbio.pgc
Normal file
29
app/src/mg/dbio/mg_queue_weight_dbio.pgc
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* mg_queue_weight_dbio.pgc - mg 모듈 DB 접근 함수 (mg_queue_weight_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* STAN x 재시도수 가중 합.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_queue_weight_dbio.h"
|
||||
|
||||
long mgdb_queue_weighted(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_a = 0, h_b = 0, acc = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL DECLARE qc CURSOR FOR
|
||||
SELECT stan, retry_cnt FROM mg_queue WHERE biz_date = :h_bizdate;
|
||||
EXEC SQL OPEN qc;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
for (;;) {
|
||||
EXEC SQL FETCH qc INTO :h_a, :h_b;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE qc; return -1; }
|
||||
acc += h_a * h_b;
|
||||
}
|
||||
EXEC SQL CLOSE qc;
|
||||
return acc;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_route_exists_dbio.h
Normal file
12
app/src/mg/dbio/mg_route_exists_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_route_exists_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_route_exists_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_ROUTE_EXISTS_DBIO_H
|
||||
#define MG_ROUTE_EXISTS_DBIO_H
|
||||
|
||||
/* 채널 라우팅 존재 여부. */
|
||||
int mgdb_route_channel_exists(const char *key);
|
||||
|
||||
#endif /* MG_ROUTE_EXISTS_DBIO_H */
|
||||
20
app/src/mg/dbio/mg_route_exists_dbio.pgc
Normal file
20
app/src/mg/dbio/mg_route_exists_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* mg_route_exists_dbio.pgc - mg 모듈 DB 접근 함수 (mg_route_exists_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 채널 라우팅 존재 여부.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_route_exists_dbio.h"
|
||||
|
||||
int mgdb_route_channel_exists(const char *key)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_key[64];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_key, key, sizeof(h_key)-1); h_key[sizeof(h_key)-1] = 0;
|
||||
EXEC SQL SELECT count(*) INTO :h_v FROM mg_route WHERE channel = :h_key;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v > 0 ? 1 : 0;
|
||||
}
|
||||
12
app/src/mg/dbio/mg_routed_amt_dbio.h
Normal file
12
app/src/mg/dbio/mg_routed_amt_dbio.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* mg_routed_amt_dbio.h - mg 모듈 DB 접근 계층 copybook (mg_routed_amt_dbio, part of libmgdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef MG_ROUTED_AMT_DBIO_H
|
||||
#define MG_ROUTED_AMT_DBIO_H
|
||||
|
||||
/* 라우팅 매칭 전문 금액(조인). */
|
||||
long mgdb_msg_routed_amount(const char *bizdate);
|
||||
|
||||
#endif /* MG_ROUTED_AMT_DBIO_H */
|
||||
22
app/src/mg/dbio/mg_routed_amt_dbio.pgc
Normal file
22
app/src/mg/dbio/mg_routed_amt_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* mg_routed_amt_dbio.pgc - mg 모듈 DB 접근 함수 (mg_routed_amt_dbio), archived into libmgdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 라우팅 매칭 전문 금액(조인).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "mg_routed_amt_dbio.h"
|
||||
|
||||
long mgdb_msg_routed_amount(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(sum(a.amount),0) INTO :h_v
|
||||
FROM mg_msg_log a JOIN mg_route b ON a.channel = b.channel
|
||||
WHERE a.biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue