diff --git a/app/batch/cm_bt_0015.c b/app/batch/cm_bt_0015.c index e02d22d..4088450 100644 --- a/app/batch/cm_bt_0015.c +++ b/app/batch/cm_bt_0015.c @@ -100,9 +100,32 @@ struct sqlca_t *ECPGget_sqlca(void); static int run_cm_bt_0015(const char *biz_date) { + /* exec sql begin declare section */ + + + + + +#line 26 "app/batch/cm_bt_0015.pgc" + char h_biz_date [ 9 ] ; + +#line 27 "app/batch/cm_bt_0015.pgc" + char h_merch_id [ 16 ] ; + +#line 28 "app/batch/cm_bt_0015.pgc" + long h_merch_cnt ; + +#line 29 "app/batch/cm_bt_0015.pgc" + long h_merch_sum ; +/* exec sql end declare section */ +#line 30 "app/batch/cm_bt_0015.pgc" + + long n_recv, n_done, n_fail, n_settled, total; long sum_amt = 0; + long merch_lines = 0; char won[32]; + char merch_won[32]; int rc; n_recv = cm_rec_count(biz_date, CM_ST_RECV); @@ -139,6 +162,57 @@ static int run_cm_bt_0015(const char *biz_date) printf(" 거래총액 : %s\n", won); if (total > 0) printf(" 완료율 : %ld%%\n", (n_done * 100) / total); + + /* + * 가맹점별 상세 브레이크다운: cm_ledger 를 가맹점번호로 그룹집계하는 + * 커서를 순회하며 건수 내림차순으로 상위 가맹점을 리포트한다. + */ + 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_cm_bt_0015 cursor for select merch_id , count ( * ) , coalesce ( sum ( amount ) , 0 ) from cm_ledger where biz_date = $1 group by merch_id order by count ( * ) desc , merch_id */ +#line 86 "app/batch/cm_bt_0015.pgc" + +#line 86 "app/batch/cm_bt_0015.pgc" + + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_cm_bt_0015 cursor for select merch_id , count ( * ) , coalesce ( sum ( amount ) , 0 ) from cm_ledger where biz_date = $1 group by merch_id order by count ( * ) desc , merch_id", + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 88 "app/batch/cm_bt_0015.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_bt_0015 OPEN cur"); + } else { + printf(" ----- 가맹점별 상세 -----\n"); + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_cm_bt_0015", ECPGt_EOIT, + ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_merch_cnt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_merch_sum),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 95 "app/batch/cm_bt_0015.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_bt_0015 FETCH cur"); + break; + } + merch_lines++; + amount_format_won(h_merch_sum, merch_won, sizeof(merch_won)); + printf(" %-12s 건수=%-6ld 금액=%s\n", + h_merch_id, h_merch_cnt, merch_won); + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_cm_bt_0015", ECPGt_EOIT, ECPGt_EORT);} +#line 108 "app/batch/cm_bt_0015.pgc" + + } + printf(" 가맹점 수 : %ld\n", merch_lines); printf("=============================================\n"); return TX_OK; diff --git a/app/batch/cm_bt_0015.pgc b/app/batch/cm_bt_0015.pgc index b1baa91..5d3b79b 100644 --- a/app/batch/cm_bt_0015.pgc +++ b/app/batch/cm_bt_0015.pgc @@ -22,9 +22,18 @@ EXEC SQL INCLUDE sqlca; static int run_cm_bt_0015(const char *biz_date) { + EXEC SQL BEGIN DECLARE SECTION; + char h_biz_date[9]; + char h_merch_id[16]; + long h_merch_cnt; + long h_merch_sum; + EXEC SQL END DECLARE SECTION; + long n_recv, n_done, n_fail, n_settled, total; long sum_amt = 0; + long merch_lines = 0; char won[32]; + char merch_won[32]; int rc; n_recv = cm_rec_count(biz_date, CM_ST_RECV); @@ -61,6 +70,44 @@ static int run_cm_bt_0015(const char *biz_date) printf(" 거래총액 : %s\n", won); if (total > 0) printf(" 완료율 : %ld%%\n", (n_done * 100) / total); + + /* + * 가맹점별 상세 브레이크다운: cm_ledger 를 가맹점번호로 그룹집계하는 + * 커서를 순회하며 건수 내림차순으로 상위 가맹점을 리포트한다. + */ + strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); + h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + + EXEC SQL DECLARE cur_cm_bt_0015 CURSOR FOR + SELECT merch_id, count(*), coalesce(sum(amount), 0) + FROM cm_ledger + WHERE biz_date = :h_biz_date + GROUP BY merch_id + ORDER BY count(*) DESC, merch_id; + + EXEC SQL OPEN cur_cm_bt_0015; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_bt_0015 OPEN cur"); + } else { + printf(" ----- 가맹점별 상세 -----\n"); + for (;;) { + EXEC SQL FETCH cur_cm_bt_0015 + INTO :h_merch_id, :h_merch_cnt, :h_merch_sum; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_bt_0015 FETCH cur"); + break; + } + merch_lines++; + amount_format_won(h_merch_sum, merch_won, sizeof(merch_won)); + printf(" %-12s 건수=%-6ld 금액=%s\n", + h_merch_id, h_merch_cnt, merch_won); + } + EXEC SQL CLOSE cur_cm_bt_0015; + } + printf(" 가맹점 수 : %ld\n", merch_lines); printf("=============================================\n"); return TX_OK; diff --git a/app/batch/mg_bt_0005.c b/app/batch/mg_bt_0005.c index 741b979..0d926cd 100644 --- a/app/batch/mg_bt_0005.c +++ b/app/batch/mg_bt_0005.c @@ -107,12 +107,37 @@ static long mg_pct_x10(long part, long whole) static int run_mg_bt_0005(const char *biz_date) { + /* exec sql begin declare section */ + + + + + +#line 33 "app/batch/mg_bt_0005.pgc" + char h_bd [ 9 ] ; + +#line 34 "app/batch/mg_bt_0005.pgc" + char h_merch [ 16 ] ; + +#line 35 "app/batch/mg_bt_0005.pgc" + long h_mcnt ; + +#line 36 "app/batch/mg_bt_0005.pgc" + long h_msum ; +/* exec sql end declare section */ +#line 37 "app/batch/mg_bt_0005.pgc" + + long c_recv, c_done, c_fail, c_settled, total; long sum_amt = 0; long rate; int rc; + int shown; char amtbuf[32]; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + c_recv = mg_rec_count(biz_date, MG_ST_RECV); c_done = mg_rec_count(biz_date, MG_ST_DONE); c_fail = mg_rec_count(biz_date, MG_ST_FAIL); @@ -149,6 +174,55 @@ static int run_mg_bt_0005(const char *biz_date) printf(" 처리율 : %ld.%ld%%\n", rate / 10, rate % 10); printf("=============================================\n"); + /* 가맹점별 거래 상위 내역을 커서로 순회하여 부가 리포트 출력 */ + ECPGset_var( 0, ( h_bd ), __LINE__);\ + /* declare cur_mg_bt_0005 cursor for select merch_id , count ( * ) , coalesce ( SUM ( amount ) , 0 ) from mg_ledger where biz_date = $1 group by merch_id order by 3 desc */ +#line 91 "app/batch/mg_bt_0005.pgc" + +#line 91 "app/batch/mg_bt_0005.pgc" + + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_mg_bt_0005 cursor for select merch_id , count ( * ) , coalesce ( SUM ( amount ) , 0 ) from mg_ledger where biz_date = $1 group by merch_id order by 3 desc", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 93 "app/batch/mg_bt_0005.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("OPEN cur_mg_bt_0005"); + return TX_OK; /* 부가 리포트 실패는 배치 성공에 영향 없음 */ + } + + printf("---------- 가맹점별 거래 상위 (mg_bt_0005) ----------\n"); + shown = 0; + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_mg_bt_0005", ECPGt_EOIT, + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_mcnt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_msum),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 102 "app/batch/mg_bt_0005.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("FETCH cur_mg_bt_0005"); + break; + } + if (shown < 10) { + amount_format_won(h_msum, amtbuf, sizeof(amtbuf)); + printf(" %-14s 건수=%-6ld 금액=%s\n", h_merch, h_mcnt, amtbuf); + } + shown++; + } + printf(" (가맹점 수: %d)\n", shown); + printf("=============================================\n"); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_bt_0005", ECPGt_EOIT, ECPGt_EORT);} +#line 118 "app/batch/mg_bt_0005.pgc" + + return TX_OK; } diff --git a/app/batch/mg_bt_0005.pgc b/app/batch/mg_bt_0005.pgc index 00d2fd6..063f312 100644 --- a/app/batch/mg_bt_0005.pgc +++ b/app/batch/mg_bt_0005.pgc @@ -29,12 +29,23 @@ static long mg_pct_x10(long part, long whole) static int run_mg_bt_0005(const char *biz_date) { + EXEC SQL BEGIN DECLARE SECTION; + char h_bd[9]; + char h_merch[16]; + long h_mcnt; + long h_msum; + EXEC SQL END DECLARE SECTION; + long c_recv, c_done, c_fail, c_settled, total; long sum_amt = 0; long rate; int rc; + int shown; char amtbuf[32]; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + c_recv = mg_rec_count(biz_date, MG_ST_RECV); c_done = mg_rec_count(biz_date, MG_ST_DONE); c_fail = mg_rec_count(biz_date, MG_ST_FAIL); @@ -71,6 +82,41 @@ static int run_mg_bt_0005(const char *biz_date) printf(" 처리율 : %ld.%ld%%\n", rate / 10, rate % 10); printf("=============================================\n"); + /* 가맹점별 거래 상위 내역을 커서로 순회하여 부가 리포트 출력 */ + EXEC SQL DECLARE cur_mg_bt_0005 CURSOR FOR + SELECT merch_id, COUNT(*), COALESCE(SUM(amount), 0) + FROM mg_ledger + WHERE biz_date = :h_bd + GROUP BY merch_id + ORDER BY 3 DESC; + + EXEC SQL OPEN cur_mg_bt_0005; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("OPEN cur_mg_bt_0005"); + return TX_OK; /* 부가 리포트 실패는 배치 성공에 영향 없음 */ + } + + printf("---------- 가맹점별 거래 상위 (mg_bt_0005) ----------\n"); + shown = 0; + for (;;) { + EXEC SQL FETCH cur_mg_bt_0005 INTO :h_merch, :h_mcnt, :h_msum; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("FETCH cur_mg_bt_0005"); + break; + } + if (shown < 10) { + amount_format_won(h_msum, amtbuf, sizeof(amtbuf)); + printf(" %-14s 건수=%-6ld 금액=%s\n", h_merch, h_mcnt, amtbuf); + } + shown++; + } + printf(" (가맹점 수: %d)\n", shown); + printf("=============================================\n"); + + EXEC SQL CLOSE cur_mg_bt_0005; + return TX_OK; } diff --git a/app/batch/rc_bt_0006.c b/app/batch/rc_bt_0006.c index c93405b..e2d8be2 100644 --- a/app/batch/rc_bt_0006.c +++ b/app/batch/rc_bt_0006.c @@ -101,11 +101,35 @@ struct sqlca_t *ECPGget_sqlca(void); static int run_rc_bt_0006(const char *biz_date) { + /* exec sql begin declare section */ + + + + + +#line 27 "app/batch/rc_bt_0006.pgc" + char h_bd [ 9 ] ; + +#line 28 "app/batch/rc_bt_0006.pgc" + long h_db_total ; + +#line 29 "app/batch/rc_bt_0006.pgc" + long h_db_unmatch ; + +#line 30 "app/batch/rc_bt_0006.pgc" + long h_db_sum ; +/* exec sql end declare section */ +#line 31 "app/batch/rc_bt_0006.pgc" + + long cntR, cntM, cntU, cntS; long total, processed; long proc_rate, settle_rate, fail_rate; int mismatch; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + /* 상태별 건수 조회 (읽기전용) */ cntR = rc_rec_count(biz_date, RC_ST_RECV); cntM = rc_rec_count(biz_date, RC_ST_DONE); @@ -166,6 +190,47 @@ static int run_rc_bt_0006(const char *biz_date) printf(" 미처리 여부 : %s\n", mismatch ? "미처리(접수 잔량)" : "완료"); printf("===============================================\n"); + /* 원장에서 직접 총건수/불일치건수/총금액을 임베디드 SQL 로 교차집계 */ + h_db_total = 0; + h_db_unmatch = 0; + h_db_sum = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) , coalesce ( SUM ( amount ) , 0 ) from rc_ledger where biz_date = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_db_total),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_db_sum),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 109 "app/batch/rc_bt_0006.pgc" + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger dbtotal (rc_bt_0006)"); + return TX_EDB; + } + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from rc_ledger where biz_date = $1 and status = 'U'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_db_unmatch),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 119 "app/batch/rc_bt_0006.pgc" + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger unmatch (rc_bt_0006)"); + return TX_EDB; + } + + printf("------- 원장 직접 교차집계 (rc_bt_0006) -------\n"); + printf(" DB 총건수 : %ld\n", h_db_total); + printf(" DB 불일치건수 : %ld\n", h_db_unmatch); + printf(" DB 총금액 : %ld\n", h_db_sum); + if (h_db_total != total) + tx_log(TX_LOG_WARN, + "[rc_bt_0006] 집계 교차검증 상이 count=%ld db=%ld", + total, h_db_total); + printf("===============================================\n"); + return TX_OK; } diff --git a/app/batch/rc_bt_0006.pgc b/app/batch/rc_bt_0006.pgc index 21a4e98..207aa5e 100644 --- a/app/batch/rc_bt_0006.pgc +++ b/app/batch/rc_bt_0006.pgc @@ -23,11 +23,21 @@ EXEC SQL INCLUDE sqlca; static int run_rc_bt_0006(const char *biz_date) { + EXEC SQL BEGIN DECLARE SECTION; + char h_bd[9]; + long h_db_total; + long h_db_unmatch; + long h_db_sum; + EXEC SQL END DECLARE SECTION; + long cntR, cntM, cntU, cntS; long total, processed; long proc_rate, settle_rate, fail_rate; int mismatch; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + /* 상태별 건수 조회 (읽기전용) */ cntR = rc_rec_count(biz_date, RC_ST_RECV); cntM = rc_rec_count(biz_date, RC_ST_DONE); @@ -88,6 +98,40 @@ static int run_rc_bt_0006(const char *biz_date) printf(" 미처리 여부 : %s\n", mismatch ? "미처리(접수 잔량)" : "완료"); printf("===============================================\n"); + /* 원장에서 직접 총건수/불일치건수/총금액을 임베디드 SQL 로 교차집계 */ + h_db_total = 0; + h_db_unmatch = 0; + h_db_sum = 0; + + EXEC SQL SELECT COUNT(*), COALESCE(SUM(amount), 0) + INTO :h_db_total, :h_db_sum + FROM rc_ledger + WHERE biz_date = :h_bd; + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger dbtotal (rc_bt_0006)"); + return TX_EDB; + } + + EXEC SQL SELECT COUNT(*) + INTO :h_db_unmatch + FROM rc_ledger + WHERE biz_date = :h_bd + AND status = 'U'; + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger unmatch (rc_bt_0006)"); + return TX_EDB; + } + + printf("------- 원장 직접 교차집계 (rc_bt_0006) -------\n"); + printf(" DB 총건수 : %ld\n", h_db_total); + printf(" DB 불일치건수 : %ld\n", h_db_unmatch); + printf(" DB 총금액 : %ld\n", h_db_sum); + if (h_db_total != total) + tx_log(TX_LOG_WARN, + "[rc_bt_0006] 집계 교차검증 상이 count=%ld db=%ld", + total, h_db_total); + printf("===============================================\n"); + return TX_OK; } diff --git a/app/common/ac_cu_0001.c b/app/common/ac_cu_0001.c index 6aa8373..25c81ff 100644 --- a/app/common/ac_cu_0001.c +++ b/app/common/ac_cu_0001.c @@ -6,32 +6,49 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* CRC-8(다항식 0x07) 계산: 고정길이 필드 무결성 */ +static unsigned ac_cu_0001_crc8(const char *s, int n) +{ + unsigned crc = 0; + int i, b; + for (i = 0; i < n; i++) { + crc ^= (unsigned char)s[i]; + for (b = 0; b < 8; b++) + crc = (crc & 0x80) ? ((crc << 1) ^ 0x07) & 0xFF : (crc << 1) & 0xFF; + } + return crc & 0xFF; +} + +/* 수수료: 금액을 12자리 고정필드로 pack 후 CRC 가산 */ long ac_cu_0001_fee(long amount, int rate_bp) { - long fee; + char buf[16]; + long v = amount < 0 ? 0 : amount; + int i; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + for (i = 11; i >= 0; i--) { buf[i] = (char)('0' + (int)(v % 10)); v /= 10; } + buf[12] = '\0'; + return (amount * (long)rate_bp) / 10000L + (long)ac_cu_0001_crc8(buf, 12); } -/* 절사(내림) 단위 정규화 */ +/* 최근접 배수 반올림(round-half-away-from-zero) */ long ac_cu_0001_round_unit(long amount, long unit) { + long r, h; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + h = (unit + 1) / 2; + if (r < 0) + return (-r >= h) ? amount - (unit + r) : amount - r; + return (r >= h) ? amount + (unit - r) : amount - r; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 부호·홀짝 조합 4가지 */ int ac_cu_0001_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int s = amount < 0 ? 2 : 0; + int p = (amount % 2 != 0) ? 1 : 0; + return s + p; } diff --git a/app/common/ac_cu_0002.c b/app/common/ac_cu_0002.c index fc53531..a655911 100644 --- a/app/common/ac_cu_0002.c +++ b/app/common/ac_cu_0002.c @@ -6,32 +6,39 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 12개월 균등분할 잔액에 대한 단리 이자 합 */ long ac_cu_0002_fee(long amount, int rate_bp) { - long fee; + long total = 0, principal; + int m; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + principal = amount / 12; + for (m = 1; m <= 12; m++) { + long bal = amount - principal * (m - 1); + total += bal * (long)rate_bp / 120000L; + } + return total; } -/* 절사(내림) 단위 정규화 */ +/* 잔돈 재분배 반올림: 잔여의 2배가 unit 이상이면 올림 */ long ac_cu_0002_round_unit(long amount, long unit) { + long base, rem; if (unit <= 0) return amount; - return (amount / unit) * unit; + base = (amount / unit) * unit; + rem = amount - base; + return (rem * 2 >= unit) ? base + unit : base; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 최상위(선두) 숫자 1~9 */ int ac_cu_0002_classify(long amount) { - if (amount < 10000L) + long v = amount < 0 ? -amount : amount; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; - return 2; + while (v >= 10) + v /= 10; + return (int)v; } diff --git a/app/common/ac_cu_0003.c b/app/common/ac_cu_0003.c index 1149da6..2773c23 100644 --- a/app/common/ac_cu_0003.c +++ b/app/common/ac_cu_0003.c @@ -6,32 +6,33 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 소수 2자리 스케일로 확대 후 요율 적용, 원 단위 복귀 */ long ac_cu_0003_fee(long amount, int rate_bp) { - long fee; + long scaled, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + scaled = amount * 100L; + fee = scaled * (long)rate_bp / 10000L; + return fee / 100L; } -/* 절사(내림) 단위 정규화 */ +/* 단위가 2의 거듭제곱이면 비트마스크 정렬, 아니면 일반 절사 */ long ac_cu_0003_round_unit(long amount, long unit) { if (unit <= 0) return amount; + if ((unit & (unit - 1)) == 0) + return amount & ~(unit - 1); return (amount / unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 금액 구간 비트맵 플래그(bit0=만,bit1=십만,bit2=백만) */ int ac_cu_0003_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int f = 0; + if (amount >= 10000L) f |= 1; + if (amount >= 100000L) f |= 2; + if (amount >= 1000000L) f |= 4; + return f; } diff --git a/app/common/ac_cu_0004.c b/app/common/ac_cu_0004.c index 42c12a8..9ae0e07 100644 --- a/app/common/ac_cu_0004.c +++ b/app/common/ac_cu_0004.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 금액 구간별 요율을 선형보간하여 적용 */ long ac_cu_0004_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + static const long x[4] = {0L, 100000L, 1000000L, 10000000L}; + static const long y[4] = {30L, 20L, 10L, 5L}; + long r = rate_bp; + int i; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + for (i = 0; i < 3; i++) { + if (amount <= x[i + 1]) { + long span = x[i + 1] - x[i]; + r = y[i] + (y[i + 1] - y[i]) * (amount - x[i]) / span; + break; + } + } + return amount * r / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 5사6입: 잔여가 unit 의 60% 이상일 때만 올림 */ long ac_cu_0004_round_unit(long amount, long unit) { + long r; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + return (r * 10 >= unit * 6) ? amount + (unit - r) : amount - r; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 이진탐색으로 경계 버킷 결정 */ int ac_cu_0004_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long b[7] = {5000L, 20000L, 50000L, 200000L, + 500000L, 2000000L, 5000000L}; + int lo = 0, hi = 7, mid; + while (lo < hi) { + mid = (lo + hi) / 2; + if (amount < b[mid]) hi = mid; else lo = mid + 1; + } + return lo; } diff --git a/app/common/ac_cu_0005.c b/app/common/ac_cu_0005.c index c02a852..b476705 100644 --- a/app/common/ac_cu_0005.c +++ b/app/common/ac_cu_0005.c @@ -6,19 +6,35 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ -long ac_cu_0005_fee(long amount, int rate_bp) +/* 그레고리력 → 율리우스일수 근사 변환 */ +static long ac_cu_0005_jdn(int y, int m, int d) { - long fee; - if (amount <= 0 || rate_bp < 0) - return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + long a = (14 - m) / 12; + long yy = y + 4800 - a; + long mm = m + 12 * a - 3; + return d + (153 * mm + 2) / 5 + 365 * yy + yy / 4 - yy / 100 + yy / 400 - 32045; } -/* 절사(내림) 단위 정규화 */ +/* 수수료: amount=YYYYMMDD 에 rate_bp 영업일 더한 율리우스일 반환 */ +long ac_cu_0005_fee(long amount, int rate_bp) +{ + int y, m, d, added = 0; + long jd; + if (amount <= 0) + return 0; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + jd = ac_cu_0005_jdn(y, m, d); + while (added < rate_bp) { + jd++; + if (jd % 7 != 5 && jd % 7 != 6) + added++; + } + return jd; +} + +/* 0 방향 대칭 절사(truncate toward zero) */ long ac_cu_0005_round_unit(long amount, long unit) { if (unit <= 0) @@ -26,12 +42,15 @@ long ac_cu_0005_round_unit(long amount, long unit) return (amount / unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: FNV-1a 해시의 하위 3비트 */ int ac_cu_0005_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + unsigned long h = 2166136261UL; + long v = amount < 0 ? -amount : amount; + do { + h ^= (unsigned long)(v % 10); + h *= 16777619UL; + v /= 10; + } while (v > 0); + return (int)(h & 0x7UL); } diff --git a/app/common/ac_cu_0006.c b/app/common/ac_cu_0006.c index 2b46145..0e80a10 100644 --- a/app/common/ac_cu_0006.c +++ b/app/common/ac_cu_0006.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 디지털 루트(각 자리 합 반복) 계산 */ +static int ac_cu_0006_droot(long v) +{ + if (v < 0) v = -v; + while (v >= 10) { + long s = 0; + while (v > 0) { s += v % 10; v /= 10; } + v = s; + } + return (int)v; +} + +/* 수수료: 정률 계산 후 상한(cap) 적용 */ long ac_cu_0006_fee(long amount, int rate_bp) { - long fee; + long fee, cap = 50000L; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + fee = amount * (long)rate_bp / 10000L; + if (fee > cap) + fee = cap; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 이중 절사: 1차 절사 후 잔여 2/3 이상이면 한 단위 보정 */ long ac_cu_0006_round_unit(long amount, long unit) { + long f1; if (unit <= 0) return amount; - return (amount / unit) * unit; + f1 = (amount / unit) * unit; + if ((amount - f1) * 3 >= unit * 2) + f1 += unit; + return f1; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 디지털 루트(1~9, 0) */ int ac_cu_0006_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + return ac_cu_0006_droot(amount); } diff --git a/app/common/ac_cu_0007.c b/app/common/ac_cu_0007.c index 182f5b1..88b0d8e 100644 --- a/app/common/ac_cu_0007.c +++ b/app/common/ac_cu_0007.c @@ -6,32 +6,49 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 슬랩(구간별 고정액) 수수료 테이블 조회 */ +static long ac_cu_0007_slab(long a) +{ + static const long lim[4] = {10000L, 100000L, 1000000L, 10000000L}; + static const long fixed[5] = {100L, 500L, 2000L, 8000L, 30000L}; + int i; + for (i = 0; i < 4; i++) + if (a < lim[i]) + return fixed[i]; + return fixed[4]; +} + +/* 수수료: 슬랩 고정액 + 미세 요율 가산 */ long ac_cu_0007_fee(long amount, int rate_bp) { - long fee; + long f; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + f = ac_cu_0007_slab(amount); + f += amount * (long)rate_bp / 100000L; + return f; } -/* 절사(내림) 단위 정규화 */ +/* 가장 가까운 배수(반올림, 동점은 올림) */ long ac_cu_0007_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount % unit; + if (r * 2 >= unit) + q++; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 통과한 임계 개수(0~5) */ int ac_cu_0007_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long g[5] = {1000L, 10000L, 100000L, 1000000L, 10000000L}; + int i, c = 0; + for (i = 0; i < 5; i++) + if (amount >= g[i]) + c++; + return c; } diff --git a/app/common/ac_cu_0008.c b/app/common/ac_cu_0008.c index b5fe649..7ef1166 100644 --- a/app/common/ac_cu_0008.c +++ b/app/common/ac_cu_0008.c @@ -6,32 +6,52 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* Luhn(mod-10) 체크섬 계산: 우대카드 판별용 */ +static int ac_cu_0008_luhn(long v) +{ + int sum = 0, alt = 0; + if (v < 0) v = -v; + while (v > 0) { + int d = (int)(v % 10); + if (alt) { d *= 2; if (d > 9) d -= 9; } + sum += d; + alt = !alt; + v /= 10; + } + return sum % 10; +} + +/* 수수료: Luhn 체크섬이 0(정상 카드)이면 면제, 그 외 정률 */ long ac_cu_0008_fee(long amount, int rate_bp) { - long fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + if (ac_cu_0008_luhn(amount) == 0) + return 0; + return (amount * (long)rate_bp) / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(round-half-up) 단위 정규화 */ long ac_cu_0008_round_unit(long amount, long unit) { + long r, half; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + half = unit / 2; + amount -= r; + if (r >= half) + amount += unit; + return amount; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 10진 자릿수 개수 반환 */ int ac_cu_0008_classify(long amount) { - if (amount < 10000L) + int digits = 0; + long v = amount < 0 ? -amount : amount; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; - return 2; + while (v > 0) { digits++; v /= 10; } + return digits; } diff --git a/app/common/ac_cu_0009.c b/app/common/ac_cu_0009.c index f461662..06cad9c 100644 --- a/app/common/ac_cu_0009.c +++ b/app/common/ac_cu_0009.c @@ -6,32 +6,54 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* BIN 범위 조회: 카드 앞 6자리 → 등급 */ +static int ac_cu_0009_bin_grade(long n) +{ + static const long lo[3] = {400000L, 510000L, 600000L}; + static const long hi[3] = {499999L, 559999L, 699999L}; + long bin = n < 0 ? -n : n; + int i; + while (bin >= 1000000L) + bin /= 10; + for (i = 0; i < 3; i++) + if (bin >= lo[i] && bin <= hi[i]) + return i + 1; + return 0; +} + +/* 수수료: 카드 등급별 가산 bp 적용 */ long ac_cu_0009_fee(long amount, int rate_bp) { - long fee; + int g; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + g = ac_cu_0009_bin_grade(amount); + rate_bp += g * 5; + return (amount * (long)rate_bp) / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 올림(ceil) 단위 정규화 */ long ac_cu_0009_round_unit(long amount, long unit) { + long r; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + if (r == 0) + return amount; + if (r < 0) + return amount - r; + return amount + (unit - r); } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 퍼센타일 경계 버킷(0~9) */ int ac_cu_0009_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long b[9] = {1000L, 5000L, 10000L, 50000L, 100000L, + 500000L, 1000000L, 5000000L, 10000000L}; + int i; + for (i = 0; i < 9; i++) + if (amount < b[i]) + return i; + return 9; } diff --git a/app/common/ac_cu_0010.c b/app/common/ac_cu_0010.c index 4b8e33d..0ab2361 100644 --- a/app/common/ac_cu_0010.c +++ b/app/common/ac_cu_0010.c @@ -6,32 +6,53 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* Zeller 합동식으로 요일 계산: 0=토,1=일,...,6=금 */ +static int ac_cu_0010_dow(int y, int m, int d) +{ + int k, j; + if (m < 3) { m += 12; y--; } + k = y % 100; + j = y / 100; + return (d + 13 * (m + 1) / 5 + k + k / 4 + j / 4 + 5 * j) % 7; +} + +/* 수수료: amount=YYYYMMDD, 주말이면 할증 rate 반환 */ long ac_cu_0010_fee(long amount, int rate_bp) { - long fee; + int y, m, d, w; + long base; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + w = ac_cu_0010_dow(y, m, d); + base = rate_bp; + if (w == 0 || w == 1) + base += (long)rate_bp / 10; + return base; } -/* 절사(내림) 단위 정규화 */ +/* 내림(floor) 단위 정규화: 음수 방향 보정 */ long ac_cu_0010_round_unit(long amount, long unit) { + long q; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + if (amount % unit != 0 && amount < 0) + q--; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: YYYYMMDD 의 요일(0~6), 오류 -1 */ int ac_cu_0010_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int y, m, d; + if (amount <= 0) + return -1; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + return ac_cu_0010_dow(y, m, d); } diff --git a/app/common/ac_cu_0011.c b/app/common/ac_cu_0011.c index fbf5dd7..9b46d48 100644 --- a/app/common/ac_cu_0011.c +++ b/app/common/ac_cu_0011.c @@ -6,32 +6,45 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 뱅커스 반올림(사사오입): num/den 을 최근접 정수로, 동점은 짝수 */ +static long ac_cu_0011_bankers(long num, long den) +{ + long q = num / den; + long r = num % den; + long twice = 2 * (r < 0 ? -r : r); + long ad = den < 0 ? -den : den; + if (twice > ad) + q += (num < 0 ? -1 : 1); + else if (twice == ad && (q % 2 != 0)) + q += (num < 0 ? -1 : 1); + return q; +} + +/* 수수료: 초과분에만 요율 적용하는 누진 구간 */ long ac_cu_0011_fee(long amount, int rate_bp) { - long fee; + long fee = 0, a = amount; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + if (a > 1000000L) { fee += (a - 1000000L) * (long)rate_bp / 10000L; a = 1000000L; } + if (a > 100000L) { fee += (a - 100000L) * (long)(rate_bp + 10) / 10000L; a = 100000L; } + fee += a * (long)(rate_bp + 20) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 뱅커스 반올림 단위 정규화 */ long ac_cu_0011_round_unit(long amount, long unit) { if (unit <= 0) return amount; - return (amount / unit) * unit; + return ac_cu_0011_bankers(amount, unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 10의 거듭제곱 지수(로그10 정수부) */ int ac_cu_0011_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int e = 0; + long v = amount < 0 ? -amount : amount; + while (v >= 10) { v /= 10; e++; } + return e; } diff --git a/app/common/au_cu_0001.c b/app/common/au_cu_0001.c index 0af58bb..6ffd44f 100644 --- a/app/common/au_cu_0001.c +++ b/app/common/au_cu_0001.c @@ -6,32 +6,53 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* Zeller 합동식으로 요일 계산: 0=토,1=일,...,6=금 */ +static int au_cu_0001_dow(int y, int m, int d) +{ + int k, j; + if (m < 3) { m += 12; y--; } + k = y % 100; + j = y / 100; + return (d + 13 * (m + 1) / 5 + k + k / 4 + j / 4 + 5 * j) % 7; +} + +/* 수수료: amount=YYYYMMDD, 주말이면 할증 rate 반환 */ long au_cu_0001_fee(long amount, int rate_bp) { - long fee; + int y, m, d, w; + long base; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + w = au_cu_0001_dow(y, m, d); + base = rate_bp; + if (w == 0 || w == 1) + base += (long)rate_bp / 10; + return base; } -/* 절사(내림) 단위 정규화 */ +/* 내림(floor) 단위 정규화: 음수 방향 보정 */ long au_cu_0001_round_unit(long amount, long unit) { + long q; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + if (amount % unit != 0 && amount < 0) + q--; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: YYYYMMDD 의 요일(0~6), 오류 -1 */ int au_cu_0001_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int y, m, d; + if (amount <= 0) + return -1; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + return au_cu_0001_dow(y, m, d); } diff --git a/app/common/au_cu_0002.c b/app/common/au_cu_0002.c index d642844..e3ef882 100644 --- a/app/common/au_cu_0002.c +++ b/app/common/au_cu_0002.c @@ -6,32 +6,45 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 뱅커스 반올림(사사오입): num/den 을 최근접 정수로, 동점은 짝수 */ +static long au_cu_0002_bankers(long num, long den) +{ + long q = num / den; + long r = num % den; + long twice = 2 * (r < 0 ? -r : r); + long ad = den < 0 ? -den : den; + if (twice > ad) + q += (num < 0 ? -1 : 1); + else if (twice == ad && (q % 2 != 0)) + q += (num < 0 ? -1 : 1); + return q; +} + +/* 수수료: 초과분에만 요율 적용하는 누진 구간 */ long au_cu_0002_fee(long amount, int rate_bp) { - long fee; + long fee = 0, a = amount; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + if (a > 1000000L) { fee += (a - 1000000L) * (long)rate_bp / 10000L; a = 1000000L; } + if (a > 100000L) { fee += (a - 100000L) * (long)(rate_bp + 10) / 10000L; a = 100000L; } + fee += a * (long)(rate_bp + 20) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 뱅커스 반올림 단위 정규화 */ long au_cu_0002_round_unit(long amount, long unit) { if (unit <= 0) return amount; - return (amount / unit) * unit; + return au_cu_0002_bankers(amount, unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 10의 거듭제곱 지수(로그10 정수부) */ int au_cu_0002_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int e = 0; + long v = amount < 0 ? -amount : amount; + while (v >= 10) { v /= 10; e++; } + return e; } diff --git a/app/common/au_cu_0003.c b/app/common/au_cu_0003.c index 0ffecae..3e15434 100644 --- a/app/common/au_cu_0003.c +++ b/app/common/au_cu_0003.c @@ -6,32 +6,49 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* CRC-8(다항식 0x07) 계산: 고정길이 필드 무결성 */ +static unsigned au_cu_0003_crc8(const char *s, int n) +{ + unsigned crc = 0; + int i, b; + for (i = 0; i < n; i++) { + crc ^= (unsigned char)s[i]; + for (b = 0; b < 8; b++) + crc = (crc & 0x80) ? ((crc << 1) ^ 0x07) & 0xFF : (crc << 1) & 0xFF; + } + return crc & 0xFF; +} + +/* 수수료: 금액을 12자리 고정필드로 pack 후 CRC 가산 */ long au_cu_0003_fee(long amount, int rate_bp) { - long fee; + char buf[16]; + long v = amount < 0 ? 0 : amount; + int i; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + for (i = 11; i >= 0; i--) { buf[i] = (char)('0' + (int)(v % 10)); v /= 10; } + buf[12] = '\0'; + return (amount * (long)rate_bp) / 10000L + (long)au_cu_0003_crc8(buf, 12); } -/* 절사(내림) 단위 정규화 */ +/* 최근접 배수 반올림(round-half-away-from-zero) */ long au_cu_0003_round_unit(long amount, long unit) { + long r, h; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + h = (unit + 1) / 2; + if (r < 0) + return (-r >= h) ? amount - (unit + r) : amount - r; + return (r >= h) ? amount + (unit - r) : amount - r; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 부호·홀짝 조합 4가지 */ int au_cu_0003_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int s = amount < 0 ? 2 : 0; + int p = (amount % 2 != 0) ? 1 : 0; + return s + p; } diff --git a/app/common/au_cu_0004.c b/app/common/au_cu_0004.c index a9cb353..5122968 100644 --- a/app/common/au_cu_0004.c +++ b/app/common/au_cu_0004.c @@ -6,32 +6,39 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 12개월 균등분할 잔액에 대한 단리 이자 합 */ long au_cu_0004_fee(long amount, int rate_bp) { - long fee; + long total = 0, principal; + int m; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + principal = amount / 12; + for (m = 1; m <= 12; m++) { + long bal = amount - principal * (m - 1); + total += bal * (long)rate_bp / 120000L; + } + return total; } -/* 절사(내림) 단위 정규화 */ +/* 잔돈 재분배 반올림: 잔여의 2배가 unit 이상이면 올림 */ long au_cu_0004_round_unit(long amount, long unit) { + long base, rem; if (unit <= 0) return amount; - return (amount / unit) * unit; + base = (amount / unit) * unit; + rem = amount - base; + return (rem * 2 >= unit) ? base + unit : base; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 최상위(선두) 숫자 1~9 */ int au_cu_0004_classify(long amount) { - if (amount < 10000L) + long v = amount < 0 ? -amount : amount; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; - return 2; + while (v >= 10) + v /= 10; + return (int)v; } diff --git a/app/common/au_cu_0005.c b/app/common/au_cu_0005.c index 30ac353..40305bb 100644 --- a/app/common/au_cu_0005.c +++ b/app/common/au_cu_0005.c @@ -6,32 +6,33 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 소수 2자리 스케일로 확대 후 요율 적용, 원 단위 복귀 */ long au_cu_0005_fee(long amount, int rate_bp) { - long fee; + long scaled, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + scaled = amount * 100L; + fee = scaled * (long)rate_bp / 10000L; + return fee / 100L; } -/* 절사(내림) 단위 정규화 */ +/* 단위가 2의 거듭제곱이면 비트마스크 정렬, 아니면 일반 절사 */ long au_cu_0005_round_unit(long amount, long unit) { if (unit <= 0) return amount; + if ((unit & (unit - 1)) == 0) + return amount & ~(unit - 1); return (amount / unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 금액 구간 비트맵 플래그(bit0=만,bit1=십만,bit2=백만) */ int au_cu_0005_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int f = 0; + if (amount >= 10000L) f |= 1; + if (amount >= 100000L) f |= 2; + if (amount >= 1000000L) f |= 4; + return f; } diff --git a/app/common/au_cu_0006.c b/app/common/au_cu_0006.c index b068c18..0ba5228 100644 --- a/app/common/au_cu_0006.c +++ b/app/common/au_cu_0006.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 금액 구간별 요율을 선형보간하여 적용 */ long au_cu_0006_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + static const long x[4] = {0L, 100000L, 1000000L, 10000000L}; + static const long y[4] = {30L, 20L, 10L, 5L}; + long r = rate_bp; + int i; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + for (i = 0; i < 3; i++) { + if (amount <= x[i + 1]) { + long span = x[i + 1] - x[i]; + r = y[i] + (y[i + 1] - y[i]) * (amount - x[i]) / span; + break; + } + } + return amount * r / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 5사6입: 잔여가 unit 의 60% 이상일 때만 올림 */ long au_cu_0006_round_unit(long amount, long unit) { + long r; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + return (r * 10 >= unit * 6) ? amount + (unit - r) : amount - r; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 이진탐색으로 경계 버킷 결정 */ int au_cu_0006_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long b[7] = {5000L, 20000L, 50000L, 200000L, + 500000L, 2000000L, 5000000L}; + int lo = 0, hi = 7, mid; + while (lo < hi) { + mid = (lo + hi) / 2; + if (amount < b[mid]) hi = mid; else lo = mid + 1; + } + return lo; } diff --git a/app/common/au_cu_0007.c b/app/common/au_cu_0007.c index 1845093..31b6c7a 100644 --- a/app/common/au_cu_0007.c +++ b/app/common/au_cu_0007.c @@ -6,19 +6,35 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ -long au_cu_0007_fee(long amount, int rate_bp) +/* 그레고리력 → 율리우스일수 근사 변환 */ +static long au_cu_0007_jdn(int y, int m, int d) { - long fee; - if (amount <= 0 || rate_bp < 0) - return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + long a = (14 - m) / 12; + long yy = y + 4800 - a; + long mm = m + 12 * a - 3; + return d + (153 * mm + 2) / 5 + 365 * yy + yy / 4 - yy / 100 + yy / 400 - 32045; } -/* 절사(내림) 단위 정규화 */ +/* 수수료: amount=YYYYMMDD 에 rate_bp 영업일 더한 율리우스일 반환 */ +long au_cu_0007_fee(long amount, int rate_bp) +{ + int y, m, d, added = 0; + long jd; + if (amount <= 0) + return 0; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + jd = au_cu_0007_jdn(y, m, d); + while (added < rate_bp) { + jd++; + if (jd % 7 != 5 && jd % 7 != 6) + added++; + } + return jd; +} + +/* 0 방향 대칭 절사(truncate toward zero) */ long au_cu_0007_round_unit(long amount, long unit) { if (unit <= 0) @@ -26,12 +42,15 @@ long au_cu_0007_round_unit(long amount, long unit) return (amount / unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: FNV-1a 해시의 하위 3비트 */ int au_cu_0007_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + unsigned long h = 2166136261UL; + long v = amount < 0 ? -amount : amount; + do { + h ^= (unsigned long)(v % 10); + h *= 16777619UL; + v /= 10; + } while (v > 0); + return (int)(h & 0x7UL); } diff --git a/app/common/au_cu_0008.c b/app/common/au_cu_0008.c index 1e9d751..b8a1232 100644 --- a/app/common/au_cu_0008.c +++ b/app/common/au_cu_0008.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 디지털 루트(각 자리 합 반복) 계산 */ +static int au_cu_0008_droot(long v) +{ + if (v < 0) v = -v; + while (v >= 10) { + long s = 0; + while (v > 0) { s += v % 10; v /= 10; } + v = s; + } + return (int)v; +} + +/* 수수료: 정률 계산 후 상한(cap) 적용 */ long au_cu_0008_fee(long amount, int rate_bp) { - long fee; + long fee, cap = 50000L; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + fee = amount * (long)rate_bp / 10000L; + if (fee > cap) + fee = cap; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 이중 절사: 1차 절사 후 잔여 2/3 이상이면 한 단위 보정 */ long au_cu_0008_round_unit(long amount, long unit) { + long f1; if (unit <= 0) return amount; - return (amount / unit) * unit; + f1 = (amount / unit) * unit; + if ((amount - f1) * 3 >= unit * 2) + f1 += unit; + return f1; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 디지털 루트(1~9, 0) */ int au_cu_0008_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + return au_cu_0008_droot(amount); } diff --git a/app/common/au_cu_0009.c b/app/common/au_cu_0009.c index e235568..2b03e23 100644 --- a/app/common/au_cu_0009.c +++ b/app/common/au_cu_0009.c @@ -6,32 +6,49 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 슬랩(구간별 고정액) 수수료 테이블 조회 */ +static long au_cu_0009_slab(long a) +{ + static const long lim[4] = {10000L, 100000L, 1000000L, 10000000L}; + static const long fixed[5] = {100L, 500L, 2000L, 8000L, 30000L}; + int i; + for (i = 0; i < 4; i++) + if (a < lim[i]) + return fixed[i]; + return fixed[4]; +} + +/* 수수료: 슬랩 고정액 + 미세 요율 가산 */ long au_cu_0009_fee(long amount, int rate_bp) { - long fee; + long f; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + f = au_cu_0009_slab(amount); + f += amount * (long)rate_bp / 100000L; + return f; } -/* 절사(내림) 단위 정규화 */ +/* 가장 가까운 배수(반올림, 동점은 올림) */ long au_cu_0009_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount % unit; + if (r * 2 >= unit) + q++; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 통과한 임계 개수(0~5) */ int au_cu_0009_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long g[5] = {1000L, 10000L, 100000L, 1000000L, 10000000L}; + int i, c = 0; + for (i = 0; i < 5; i++) + if (amount >= g[i]) + c++; + return c; } diff --git a/app/common/au_cu_0010.c b/app/common/au_cu_0010.c index 06279b1..cc4db26 100644 --- a/app/common/au_cu_0010.c +++ b/app/common/au_cu_0010.c @@ -6,32 +6,52 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* Luhn(mod-10) 체크섬 계산: 우대카드 판별용 */ +static int au_cu_0010_luhn(long v) +{ + int sum = 0, alt = 0; + if (v < 0) v = -v; + while (v > 0) { + int d = (int)(v % 10); + if (alt) { d *= 2; if (d > 9) d -= 9; } + sum += d; + alt = !alt; + v /= 10; + } + return sum % 10; +} + +/* 수수료: Luhn 체크섬이 0(정상 카드)이면 면제, 그 외 정률 */ long au_cu_0010_fee(long amount, int rate_bp) { - long fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + if (au_cu_0010_luhn(amount) == 0) + return 0; + return (amount * (long)rate_bp) / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(round-half-up) 단위 정규화 */ long au_cu_0010_round_unit(long amount, long unit) { + long r, half; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + half = unit / 2; + amount -= r; + if (r >= half) + amount += unit; + return amount; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 10진 자릿수 개수 반환 */ int au_cu_0010_classify(long amount) { - if (amount < 10000L) + int digits = 0; + long v = amount < 0 ? -amount : amount; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; - return 2; + while (v > 0) { digits++; v /= 10; } + return digits; } diff --git a/app/common/au_cu_0011.c b/app/common/au_cu_0011.c index c9a5e3c..c300083 100644 --- a/app/common/au_cu_0011.c +++ b/app/common/au_cu_0011.c @@ -6,32 +6,54 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* BIN 범위 조회: 카드 앞 6자리 → 등급 */ +static int au_cu_0011_bin_grade(long n) +{ + static const long lo[3] = {400000L, 510000L, 600000L}; + static const long hi[3] = {499999L, 559999L, 699999L}; + long bin = n < 0 ? -n : n; + int i; + while (bin >= 1000000L) + bin /= 10; + for (i = 0; i < 3; i++) + if (bin >= lo[i] && bin <= hi[i]) + return i + 1; + return 0; +} + +/* 수수료: 카드 등급별 가산 bp 적용 */ long au_cu_0011_fee(long amount, int rate_bp) { - long fee; + int g; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + g = au_cu_0011_bin_grade(amount); + rate_bp += g * 5; + return (amount * (long)rate_bp) / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 올림(ceil) 단위 정규화 */ long au_cu_0011_round_unit(long amount, long unit) { + long r; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + if (r == 0) + return amount; + if (r < 0) + return amount - r; + return amount + (unit - r); } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 퍼센타일 경계 버킷(0~9) */ int au_cu_0011_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long b[9] = {1000L, 5000L, 10000L, 50000L, 100000L, + 500000L, 1000000L, 5000000L, 10000000L}; + int i; + for (i = 0; i < 9; i++) + if (amount < b[i]) + return i; + return 9; } diff --git a/app/common/cl_cu_0001.c b/app/common/cl_cu_0001.c index 6977118..4f6844a 100644 --- a/app/common/cl_cu_0001.c +++ b/app/common/cl_cu_0001.c @@ -6,32 +6,55 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 누진 구간 수수료: 금액 구간별 한계요율을 누적 적용한다 */ long cl_cu_0001_fee(long amount, int rate_bp) { - long fee; + static const long band[] = { 100000L, 1000000L, 10000000L }; + static const int mul[] = { 1, 2, 3, 5 }; + long remain = amount; + long fee = 0; + long prev = 0; + int i; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + for (i = 0; i < 3; i++) { + long span = band[i] - prev; + long part = remain < span ? remain : span; + if (part <= 0) + break; + fee += (part * (long)rate_bp * mul[i]) / 10000L; + remain -= part; + prev = band[i]; + } + if (remain > 0) + fee += (remain * (long)rate_bp * mul[3]) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 은행가 반올림(사사오입, 짝수 반올림)으로 unit 배수 정규화 */ long cl_cu_0001_round_unit(long amount, long unit) { + long q, r, half; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + half = unit / 2; + if (r > half || (r == half && (q & 1L))) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 자릿수(log10) 규모로 5단계 분류 */ int cl_cu_0001_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + long v = amount < 0 ? -amount : amount; + int digits = 0; + while (v > 0) { digits++; v /= 10; } + if (digits <= 3) return 0; + if (digits <= 5) return 1; + if (digits <= 7) return 2; + if (digits <= 9) return 3; + return 4; } diff --git a/app/common/cl_cu_0002.c b/app/common/cl_cu_0002.c index f450728..5d6441a 100644 --- a/app/common/cl_cu_0002.c +++ b/app/common/cl_cu_0002.c @@ -6,32 +6,48 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 원리금 이자액: rate_bp 연이율을 월할(1/12) 적용 */ long cl_cu_0002_fee(long amount, int rate_bp) { - long fee; + long annual_bp; + long interest; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + annual_bp = (long)rate_bp; + interest = (amount * annual_bp) / (10000L * 12L); + if (interest < 0) + interest = 0; + return interest; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(오사오입, 0.5 이상 올림)으로 unit 정규화 */ long cl_cu_0002_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + if (r * 2 >= unit) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* Luhn 체크섬 유효성으로 분류: 유효=2, 무효 소액=0, 무효 고액=1 */ int cl_cu_0002_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + long v = amount < 0 ? -amount : amount; + int sum = 0, alt = 0, d; + long t = v; + while (t > 0) { + d = (int)(t % 10); + if (alt) { d *= 2; if (d > 9) d -= 9; } + sum += d; + alt = !alt; + t /= 10; + } + if (sum % 10 == 0) + return 2; + return v < 1000000L ? 0 : 1; } diff --git a/app/common/cl_cu_0003.c b/app/common/cl_cu_0003.c index 89e861f..a645ce2 100644 --- a/app/common/cl_cu_0003.c +++ b/app/common/cl_cu_0003.c @@ -6,32 +6,45 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 일할 정산: rate_bp 를 경과일(1..10000) 비율로 안분한다 */ long cl_cu_0003_fee(long amount, int rate_bp) { - long fee; + long days, prorated; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + days = (long)rate_bp; + if (days > 10000L) + days = 10000L; + prorated = (amount * days) / 10000L; + return prorated; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(절대값 0.5 기준 올림, 부호 보존)으로 unit 정규화 */ long cl_cu_0003_round_unit(long amount, long unit) { + long a, q, r, res; + int neg; if (unit <= 0) return amount; - return (amount / unit) * unit; + neg = amount < 0; + a = neg ? -amount : amount; + q = a / unit; + r = a - q * unit; + if (r * 2 >= unit) + q += 1; + res = q * unit; + return neg ? -res : res; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 디지털 루트(반복 자릿수합)로 분류 */ int cl_cu_0003_classify(long amount) { - if (amount < 10000L) + long v = amount < 0 ? -amount : amount; + int root; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; + root = (int)(1 + (v - 1) % 9); + if (root <= 3) return 0; + if (root <= 6) return 1; return 2; } diff --git a/app/common/cl_cu_0004.c b/app/common/cl_cu_0004.c index 392aed4..5a8cec8 100644 --- a/app/common/cl_cu_0004.c +++ b/app/common/cl_cu_0004.c @@ -6,32 +6,51 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* FNV 해시로 결정적 가산분을 산출하는 보조 함수 */ +static unsigned long cl_cu_0004_mix(long x) +{ + unsigned long h = 1469598103934665603UL; + int i; + for (i = 0; i < 8; i++) { + h ^= (unsigned long)((x >> (i * 8)) & 0xFF); + h *= 1099511628211UL; + } + return h; +} + +/* 해시 기반 가산 수수료: 기본 수수료에 결정적 잔돈을 더한다 */ long cl_cu_0004_fee(long amount, int rate_bp) { - long fee; + long base, extra; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + base = (amount * (long)rate_bp) / 10000L; + extra = (long)(cl_cu_0004_mix(amount) % 100UL); + return base + extra; } -/* 절사(내림) 단위 정규화 */ +/* 올림(상향)으로 unit 배수 정규화 */ long cl_cu_0004_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r > 0) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* BIN 범위표로 분류: 상위 6자리를 카드 BIN 처럼 구간 판정 */ int cl_cu_0004_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + long v = amount < 0 ? -amount : amount; + long bin = v; + while (bin >= 1000000L) + bin /= 10; + if (bin >= 400000L && bin <= 499999L) return 1; + if (bin >= 510000L && bin <= 559999L) return 2; + if (bin >= 340000L && bin <= 379999L) return 3; + return 0; } diff --git a/app/common/cl_cu_0005.c b/app/common/cl_cu_0005.c index dbeb28e..8b7c808 100644 --- a/app/common/cl_cu_0005.c +++ b/app/common/cl_cu_0005.c @@ -6,32 +6,39 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 통화 스케일 환산 수수료: minor unit 로 확장 후 요율 적용, major 복귀 */ long cl_cu_0005_fee(long amount, int rate_bp) { - long fee; + long scaled, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + scaled = amount * 100L; + fee = (scaled * (long)rate_bp) / 10000L; + fee = fee / 100L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 내림(음의 무한대 방향)으로 unit 정규화 */ long cl_cu_0005_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) + q -= 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 임계값 테이블 이분 탐색으로 백분위 버킷 분류 */ int cl_cu_0005_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long th[] = { 5000L, 50000L, 500000L, 5000000L, 50000000L }; + int lo = 0, hi = 5, mid; + while (lo < hi) { + mid = (lo + hi) / 2; + if (amount < th[mid]) hi = mid; else lo = mid + 1; + } + return lo; } diff --git a/app/common/cl_cu_0006.c b/app/common/cl_cu_0006.c index 7d6d576..360feb3 100644 --- a/app/common/cl_cu_0006.c +++ b/app/common/cl_cu_0006.c @@ -6,32 +6,38 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 상계(netting) 수수료: 기준 30bp 에서 rate_bp 크레딧을 차감한 순수수료 */ long cl_cu_0006_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + long gross, credit, net; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + gross = (amount * 30L) / 10000L; + credit = (amount * (long)(rate_bp < 0 ? 0 : rate_bp)) / 10000L; + net = gross - credit; + if (net < 0) + net = 0; + return net; } -/* 절사(내림) 단위 정규화 */ +/* 절사(0 방향)으로 unit 정규화 */ long cl_cu_0006_round_unit(long amount, long unit) { + long q; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 비트맵 플래그 합성 분류: 특성 비트를 OR 로 조합 */ int cl_cu_0006_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int flags = 0; + long v = amount < 0 ? -amount : amount; + if (amount < 0) flags |= 0x1; + if (v % 2 == 0) flags |= 0x2; + if (v >= 1000000L) flags |= 0x4; + if (v % 1000L == 0) flags |= 0x8; + return flags; } diff --git a/app/common/cl_cu_0007.c b/app/common/cl_cu_0007.c index 74953c1..2cb7aee 100644 --- a/app/common/cl_cu_0007.c +++ b/app/common/cl_cu_0007.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 할부 분할 수수료: rate_bp 를 할부개월(1..60)로 보고 회차수수료 산정 */ long cl_cu_0007_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + long n, per; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + n = rate_bp <= 0 ? 1 : (rate_bp > 60 ? 60 : rate_bp); + per = amount / n; + if (amount % n != 0) + per += 1; + return per; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(0.5 초과에서만 올림, 정확히 0.5는 내림)으로 unit 정규화 */ long cl_cu_0007_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + if (r * 2 > unit) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 날짜 산술: amount 를 YYYYMMDD 로 보고 Zeller 공식으로 요일 분류(0=일..6=토) */ int cl_cu_0007_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int y = (int)(amount / 10000L); + int m = (int)((amount / 100L) % 100L); + int d = (int)(amount % 100L); + int k, j, h; + if (m < 1 || m > 12 || d < 1 || d > 31) + return -1; + if (m < 3) { m += 12; y -= 1; } + k = y % 100; j = y / 100; + h = (d + (13 * (m + 1)) / 5 + k + k / 4 + j / 4 + 5 * j) % 7; + return (h + 6) % 7; } diff --git a/app/common/cl_cu_0008.c b/app/common/cl_cu_0008.c index 24fe69b..792587f 100644 --- a/app/common/cl_cu_0008.c +++ b/app/common/cl_cu_0008.c @@ -6,32 +6,57 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 상·하한 적용 정률 수수료 */ long cl_cu_0008_fee(long amount, int rate_bp) { long fee; + const long floor_fee = 100L; + const long cap_fee = 500000L; if (amount <= 0 || rate_bp < 0) return 0; fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + if (fee < floor_fee) + fee = floor_fee; + if (fee > cap_fee) + fee = cap_fee; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 최근접 배수 선택: 아래/위 배수 중 더 가까운 쪽으로 정규화 */ long cl_cu_0008_round_unit(long amount, long unit) { + long down, up, dd, du; if (unit <= 0) return amount; - return (amount / unit) * unit; + if (amount % unit == 0) + return amount; + down = (amount / unit) * unit; + if (amount > 0) + up = down + unit; + else + up = down - unit; + dd = amount - down; if (dd < 0) dd = -dd; + du = up - amount; if (du < 0) du = -du; + return dd <= du ? down : up; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* amount 를 YYYYMMDD 로 보고 월말/윤년 유효성 분류: 0=무효 1=정상 2=월말 */ int cl_cu_0008_classify(long amount) { - if (amount < 10000L) + int y = (int)(amount / 10000L); + int m = (int)((amount / 100L) % 100L); + int d = (int)(amount % 100L); + int dim[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + int leap, last; + if (m < 1 || m > 12 || d < 1) return 0; - if (amount < 1000000L) - return 1; - return 2; + leap = (y % 4 == 0 && y % 100 != 0) || (y % 400 == 0); + last = dim[m - 1]; + if (m == 2 && leap) + last = 29; + if (d > last) + return 0; + if (d == last) + return 2; + return 1; } diff --git a/app/common/cl_cu_0009.c b/app/common/cl_cu_0009.c index 1876cac..bcd4532 100644 --- a/app/common/cl_cu_0009.c +++ b/app/common/cl_cu_0009.c @@ -6,32 +6,43 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 복리형 단계 수수료: 기본 수수료에 2차(수수료에 대한) 수수료를 가산 */ long cl_cu_0009_fee(long amount, int rate_bp) { - long fee; + long f1, f2; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + f1 = (amount * (long)rate_bp) / 10000L; + f2 = (f1 * (long)rate_bp) / 10000L; + return f1 + f2; } -/* 절사(내림) 단위 정규화 */ +/* 최대공약수 계산 보조 함수 */ +static long cl_cu_0009_gcd(long a, long b) +{ + a = a < 0 ? -a : a; + b = b < 0 ? -b : b; + while (b) { long t = a % b; a = b; b = t; } + return a; +} + +/* GCD 기반 유효 배수로 절사 정규화 */ long cl_cu_0009_round_unit(long amount, long unit) { + long g, step; if (unit <= 0) return amount; - return (amount / unit) * unit; + g = cl_cu_0009_gcd(amount, unit); + step = g > 0 ? g : unit; + return (amount / step) * step; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 나머지 패턴(mod 7)으로 분류 */ int cl_cu_0009_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; + long v = amount < 0 ? -amount : amount; + int r = (int)(v % 7L); + if (r == 0) return 0; + if (r <= 3) return 1; return 2; } diff --git a/app/common/cl_cu_0010.c b/app/common/cl_cu_0010.c index a2d7255..3a2e19f 100644 --- a/app/common/cl_cu_0010.c +++ b/app/common/cl_cu_0010.c @@ -6,32 +6,35 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 마스킹 후 수수료: 하위 2자리를 마스킹한 금액에 요율 적용 */ long cl_cu_0010_fee(long amount, int rate_bp) { - long fee; + long masked, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + masked = (amount / 100L) * 100L; + fee = (masked * (long)rate_bp) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 고정소수점 스케일(x2) 반올림으로 unit 정규화 */ long cl_cu_0010_round_unit(long amount, long unit) { + long scaled, q; if (unit <= 0) return amount; - return (amount / unit) * unit; + scaled = amount * 2L + (amount >= 0 ? unit : -unit); + q = scaled / (unit * 2L); + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 비트 개수(popcount)로 분류 */ int cl_cu_0010_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; + unsigned long v = (unsigned long)(amount < 0 ? -amount : amount); + int bits = 0; + while (v) { bits += (int)(v & 1UL); v >>= 1; } + if (bits <= 4) return 0; + if (bits <= 8) return 1; return 2; } diff --git a/app/common/cm_cu_0001.c b/app/common/cm_cu_0001.c index cdd8797..0343b48 100644 --- a/app/common/cm_cu_0001.c +++ b/app/common/cm_cu_0001.c @@ -6,32 +6,55 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 누진 구간 수수료: 금액 구간별 한계요율을 누적 적용한다 */ long cm_cu_0001_fee(long amount, int rate_bp) { - long fee; + static const long band[] = { 100000L, 1000000L, 10000000L }; + static const int mul[] = { 1, 2, 3, 5 }; + long remain = amount; + long fee = 0; + long prev = 0; + int i; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + for (i = 0; i < 3; i++) { + long span = band[i] - prev; + long part = remain < span ? remain : span; + if (part <= 0) + break; + fee += (part * (long)rate_bp * mul[i]) / 10000L; + remain -= part; + prev = band[i]; + } + if (remain > 0) + fee += (remain * (long)rate_bp * mul[3]) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 은행가 반올림(사사오입, 짝수 반올림)으로 unit 배수 정규화 */ long cm_cu_0001_round_unit(long amount, long unit) { + long q, r, half; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + half = unit / 2; + if (r > half || (r == half && (q & 1L))) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 자릿수(log10) 규모로 5단계 분류 */ int cm_cu_0001_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + long v = amount < 0 ? -amount : amount; + int digits = 0; + while (v > 0) { digits++; v /= 10; } + if (digits <= 3) return 0; + if (digits <= 5) return 1; + if (digits <= 7) return 2; + if (digits <= 9) return 3; + return 4; } diff --git a/app/common/cm_cu_0002.c b/app/common/cm_cu_0002.c index bb9aedf..3e998ca 100644 --- a/app/common/cm_cu_0002.c +++ b/app/common/cm_cu_0002.c @@ -6,32 +6,48 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 원리금 이자액: rate_bp 연이율을 월할(1/12) 적용 */ long cm_cu_0002_fee(long amount, int rate_bp) { - long fee; + long annual_bp; + long interest; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + annual_bp = (long)rate_bp; + interest = (amount * annual_bp) / (10000L * 12L); + if (interest < 0) + interest = 0; + return interest; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(오사오입, 0.5 이상 올림)으로 unit 정규화 */ long cm_cu_0002_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + if (r * 2 >= unit) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* Luhn 체크섬 유효성으로 분류: 유효=2, 무효 소액=0, 무효 고액=1 */ int cm_cu_0002_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + long v = amount < 0 ? -amount : amount; + int sum = 0, alt = 0, d; + long t = v; + while (t > 0) { + d = (int)(t % 10); + if (alt) { d *= 2; if (d > 9) d -= 9; } + sum += d; + alt = !alt; + t /= 10; + } + if (sum % 10 == 0) + return 2; + return v < 1000000L ? 0 : 1; } diff --git a/app/common/cm_cu_0003.c b/app/common/cm_cu_0003.c index d666a07..3e504d0 100644 --- a/app/common/cm_cu_0003.c +++ b/app/common/cm_cu_0003.c @@ -6,32 +6,45 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 일할 정산: rate_bp 를 경과일(1..10000) 비율로 안분한다 */ long cm_cu_0003_fee(long amount, int rate_bp) { - long fee; + long days, prorated; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + days = (long)rate_bp; + if (days > 10000L) + days = 10000L; + prorated = (amount * days) / 10000L; + return prorated; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(절대값 0.5 기준 올림, 부호 보존)으로 unit 정규화 */ long cm_cu_0003_round_unit(long amount, long unit) { + long a, q, r, res; + int neg; if (unit <= 0) return amount; - return (amount / unit) * unit; + neg = amount < 0; + a = neg ? -amount : amount; + q = a / unit; + r = a - q * unit; + if (r * 2 >= unit) + q += 1; + res = q * unit; + return neg ? -res : res; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 디지털 루트(반복 자릿수합)로 분류 */ int cm_cu_0003_classify(long amount) { - if (amount < 10000L) + long v = amount < 0 ? -amount : amount; + int root; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; + root = (int)(1 + (v - 1) % 9); + if (root <= 3) return 0; + if (root <= 6) return 1; return 2; } diff --git a/app/common/cm_cu_0004.c b/app/common/cm_cu_0004.c index 13568b4..b3b9975 100644 --- a/app/common/cm_cu_0004.c +++ b/app/common/cm_cu_0004.c @@ -6,32 +6,51 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* FNV 해시로 결정적 가산분을 산출하는 보조 함수 */ +static unsigned long cm_cu_0004_mix(long x) +{ + unsigned long h = 1469598103934665603UL; + int i; + for (i = 0; i < 8; i++) { + h ^= (unsigned long)((x >> (i * 8)) & 0xFF); + h *= 1099511628211UL; + } + return h; +} + +/* 해시 기반 가산 수수료: 기본 수수료에 결정적 잔돈을 더한다 */ long cm_cu_0004_fee(long amount, int rate_bp) { - long fee; + long base, extra; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + base = (amount * (long)rate_bp) / 10000L; + extra = (long)(cm_cu_0004_mix(amount) % 100UL); + return base + extra; } -/* 절사(내림) 단위 정규화 */ +/* 올림(상향)으로 unit 배수 정규화 */ long cm_cu_0004_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r > 0) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* BIN 범위표로 분류: 상위 6자리를 카드 BIN 처럼 구간 판정 */ int cm_cu_0004_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + long v = amount < 0 ? -amount : amount; + long bin = v; + while (bin >= 1000000L) + bin /= 10; + if (bin >= 400000L && bin <= 499999L) return 1; + if (bin >= 510000L && bin <= 559999L) return 2; + if (bin >= 340000L && bin <= 379999L) return 3; + return 0; } diff --git a/app/common/cm_cu_0005.c b/app/common/cm_cu_0005.c index a9d0c52..23c886d 100644 --- a/app/common/cm_cu_0005.c +++ b/app/common/cm_cu_0005.c @@ -6,32 +6,39 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 통화 스케일 환산 수수료: minor unit 로 확장 후 요율 적용, major 복귀 */ long cm_cu_0005_fee(long amount, int rate_bp) { - long fee; + long scaled, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + scaled = amount * 100L; + fee = (scaled * (long)rate_bp) / 10000L; + fee = fee / 100L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 내림(음의 무한대 방향)으로 unit 정규화 */ long cm_cu_0005_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) + q -= 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 임계값 테이블 이분 탐색으로 백분위 버킷 분류 */ int cm_cu_0005_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long th[] = { 5000L, 50000L, 500000L, 5000000L, 50000000L }; + int lo = 0, hi = 5, mid; + while (lo < hi) { + mid = (lo + hi) / 2; + if (amount < th[mid]) hi = mid; else lo = mid + 1; + } + return lo; } diff --git a/app/common/cm_cu_0006.c b/app/common/cm_cu_0006.c index 4e71891..72f0569 100644 --- a/app/common/cm_cu_0006.c +++ b/app/common/cm_cu_0006.c @@ -6,32 +6,38 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 상계(netting) 수수료: 기준 30bp 에서 rate_bp 크레딧을 차감한 순수수료 */ long cm_cu_0006_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + long gross, credit, net; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + gross = (amount * 30L) / 10000L; + credit = (amount * (long)(rate_bp < 0 ? 0 : rate_bp)) / 10000L; + net = gross - credit; + if (net < 0) + net = 0; + return net; } -/* 절사(내림) 단위 정규화 */ +/* 절사(0 방향)으로 unit 정규화 */ long cm_cu_0006_round_unit(long amount, long unit) { + long q; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 비트맵 플래그 합성 분류: 특성 비트를 OR 로 조합 */ int cm_cu_0006_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int flags = 0; + long v = amount < 0 ? -amount : amount; + if (amount < 0) flags |= 0x1; + if (v % 2 == 0) flags |= 0x2; + if (v >= 1000000L) flags |= 0x4; + if (v % 1000L == 0) flags |= 0x8; + return flags; } diff --git a/app/common/cm_cu_0007.c b/app/common/cm_cu_0007.c index e605683..81267b8 100644 --- a/app/common/cm_cu_0007.c +++ b/app/common/cm_cu_0007.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 할부 분할 수수료: rate_bp 를 할부개월(1..60)로 보고 회차수수료 산정 */ long cm_cu_0007_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + long n, per; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + n = rate_bp <= 0 ? 1 : (rate_bp > 60 ? 60 : rate_bp); + per = amount / n; + if (amount % n != 0) + per += 1; + return per; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(0.5 초과에서만 올림, 정확히 0.5는 내림)으로 unit 정규화 */ long cm_cu_0007_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + if (r * 2 > unit) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 날짜 산술: amount 를 YYYYMMDD 로 보고 Zeller 공식으로 요일 분류(0=일..6=토) */ int cm_cu_0007_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int y = (int)(amount / 10000L); + int m = (int)((amount / 100L) % 100L); + int d = (int)(amount % 100L); + int k, j, h; + if (m < 1 || m > 12 || d < 1 || d > 31) + return -1; + if (m < 3) { m += 12; y -= 1; } + k = y % 100; j = y / 100; + h = (d + (13 * (m + 1)) / 5 + k + k / 4 + j / 4 + 5 * j) % 7; + return (h + 6) % 7; } diff --git a/app/common/cm_cu_0008.c b/app/common/cm_cu_0008.c index f1b6716..c17a6c7 100644 --- a/app/common/cm_cu_0008.c +++ b/app/common/cm_cu_0008.c @@ -6,32 +6,57 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 상·하한 적용 정률 수수료 */ long cm_cu_0008_fee(long amount, int rate_bp) { long fee; + const long floor_fee = 100L; + const long cap_fee = 500000L; if (amount <= 0 || rate_bp < 0) return 0; fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + if (fee < floor_fee) + fee = floor_fee; + if (fee > cap_fee) + fee = cap_fee; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 최근접 배수 선택: 아래/위 배수 중 더 가까운 쪽으로 정규화 */ long cm_cu_0008_round_unit(long amount, long unit) { + long down, up, dd, du; if (unit <= 0) return amount; - return (amount / unit) * unit; + if (amount % unit == 0) + return amount; + down = (amount / unit) * unit; + if (amount > 0) + up = down + unit; + else + up = down - unit; + dd = amount - down; if (dd < 0) dd = -dd; + du = up - amount; if (du < 0) du = -du; + return dd <= du ? down : up; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* amount 를 YYYYMMDD 로 보고 월말/윤년 유효성 분류: 0=무효 1=정상 2=월말 */ int cm_cu_0008_classify(long amount) { - if (amount < 10000L) + int y = (int)(amount / 10000L); + int m = (int)((amount / 100L) % 100L); + int d = (int)(amount % 100L); + int dim[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + int leap, last; + if (m < 1 || m > 12 || d < 1) return 0; - if (amount < 1000000L) - return 1; - return 2; + leap = (y % 4 == 0 && y % 100 != 0) || (y % 400 == 0); + last = dim[m - 1]; + if (m == 2 && leap) + last = 29; + if (d > last) + return 0; + if (d == last) + return 2; + return 1; } diff --git a/app/common/cm_cu_0009.c b/app/common/cm_cu_0009.c index 47051d8..c752657 100644 --- a/app/common/cm_cu_0009.c +++ b/app/common/cm_cu_0009.c @@ -6,32 +6,43 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 복리형 단계 수수료: 기본 수수료에 2차(수수료에 대한) 수수료를 가산 */ long cm_cu_0009_fee(long amount, int rate_bp) { - long fee; + long f1, f2; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + f1 = (amount * (long)rate_bp) / 10000L; + f2 = (f1 * (long)rate_bp) / 10000L; + return f1 + f2; } -/* 절사(내림) 단위 정규화 */ +/* 최대공약수 계산 보조 함수 */ +static long cm_cu_0009_gcd(long a, long b) +{ + a = a < 0 ? -a : a; + b = b < 0 ? -b : b; + while (b) { long t = a % b; a = b; b = t; } + return a; +} + +/* GCD 기반 유효 배수로 절사 정규화 */ long cm_cu_0009_round_unit(long amount, long unit) { + long g, step; if (unit <= 0) return amount; - return (amount / unit) * unit; + g = cm_cu_0009_gcd(amount, unit); + step = g > 0 ? g : unit; + return (amount / step) * step; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 나머지 패턴(mod 7)으로 분류 */ int cm_cu_0009_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; + long v = amount < 0 ? -amount : amount; + int r = (int)(v % 7L); + if (r == 0) return 0; + if (r <= 3) return 1; return 2; } diff --git a/app/common/cm_cu_0010.c b/app/common/cm_cu_0010.c index 57529c8..e3c5ffa 100644 --- a/app/common/cm_cu_0010.c +++ b/app/common/cm_cu_0010.c @@ -6,32 +6,35 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 마스킹 후 수수료: 하위 2자리를 마스킹한 금액에 요율 적용 */ long cm_cu_0010_fee(long amount, int rate_bp) { - long fee; + long masked, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + masked = (amount / 100L) * 100L; + fee = (masked * (long)rate_bp) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 고정소수점 스케일(x2) 반올림으로 unit 정규화 */ long cm_cu_0010_round_unit(long amount, long unit) { + long scaled, q; if (unit <= 0) return amount; - return (amount / unit) * unit; + scaled = amount * 2L + (amount >= 0 ? unit : -unit); + q = scaled / (unit * 2L); + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 비트 개수(popcount)로 분류 */ int cm_cu_0010_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; + unsigned long v = (unsigned long)(amount < 0 ? -amount : amount); + int bits = 0; + while (v) { bits += (int)(v & 1UL); v >>= 1; } + if (bits <= 4) return 0; + if (bits <= 8) return 1; return 2; } diff --git a/app/common/cm_cu_0011.c b/app/common/cm_cu_0011.c index b64fc25..d94f363 100644 --- a/app/common/cm_cu_0011.c +++ b/app/common/cm_cu_0011.c @@ -6,32 +6,59 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* CRC16(CCITT) 계산 보조 함수 */ +static unsigned int cm_cu_0011_crc16(long x) +{ + unsigned int crc = 0xFFFF; + unsigned char buf[8]; + int i, b; + for (i = 0; i < 8; i++) + buf[i] = (unsigned char)((x >> (i * 8)) & 0xFF); + for (i = 0; i < 8; i++) { + crc ^= (unsigned int)buf[i] << 8; + for (b = 0; b < 8; b++) + crc = (crc & 0x8000) ? (unsigned int)((crc << 1) ^ 0x1021) + : (unsigned int)(crc << 1); + } + return crc & 0xFFFF; +} + +/* CRC16 혼합 가산 수수료: 기본 수수료에 결정적 소액 가산분을 더한다 */ long cm_cu_0011_fee(long amount, int rate_bp) { - long fee; + long base; + unsigned int c; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + base = (amount * (long)rate_bp) / 10000L; + c = cm_cu_0011_crc16(amount); + return base + (long)(c % 50U); } -/* 절사(내림) 단위 정규화 */ +/* 상향 임계 반올림((unit+1)/2 기준)으로 unit 정규화 */ long cm_cu_0011_round_unit(long amount, long unit) { + long q, r, threshold; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + threshold = (unit + 1) / 2; + if (r >= threshold) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 누적분포(CDF) 근사 스캔으로 백분위 분류 */ int cm_cu_0011_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long cum[] = { 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L }; + long v = amount < 0 ? -amount : amount; + int i; + for (i = 0; i < 6; i++) { + if (v < cum[i]) + return i; + } + return 6; } diff --git a/app/common/lg_cu_0001.c b/app/common/lg_cu_0001.c index eafa439..1106769 100644 --- a/app/common/lg_cu_0001.c +++ b/app/common/lg_cu_0001.c @@ -6,32 +6,55 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 누진 구간 수수료: 금액 구간별 한계요율을 누적 적용한다 */ long lg_cu_0001_fee(long amount, int rate_bp) { - long fee; + static const long band[] = { 100000L, 1000000L, 10000000L }; + static const int mul[] = { 1, 2, 3, 5 }; + long remain = amount; + long fee = 0; + long prev = 0; + int i; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + for (i = 0; i < 3; i++) { + long span = band[i] - prev; + long part = remain < span ? remain : span; + if (part <= 0) + break; + fee += (part * (long)rate_bp * mul[i]) / 10000L; + remain -= part; + prev = band[i]; + } + if (remain > 0) + fee += (remain * (long)rate_bp * mul[3]) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 은행가 반올림(사사오입, 짝수 반올림)으로 unit 배수 정규화 */ long lg_cu_0001_round_unit(long amount, long unit) { + long q, r, half; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + half = unit / 2; + if (r > half || (r == half && (q & 1L))) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 자릿수(log10) 규모로 5단계 분류 */ int lg_cu_0001_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + long v = amount < 0 ? -amount : amount; + int digits = 0; + while (v > 0) { digits++; v /= 10; } + if (digits <= 3) return 0; + if (digits <= 5) return 1; + if (digits <= 7) return 2; + if (digits <= 9) return 3; + return 4; } diff --git a/app/common/lg_cu_0002.c b/app/common/lg_cu_0002.c index d4d69dd..5c58bd1 100644 --- a/app/common/lg_cu_0002.c +++ b/app/common/lg_cu_0002.c @@ -6,32 +6,48 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 원리금 이자액: rate_bp 연이율을 월할(1/12) 적용 */ long lg_cu_0002_fee(long amount, int rate_bp) { - long fee; + long annual_bp; + long interest; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + annual_bp = (long)rate_bp; + interest = (amount * annual_bp) / (10000L * 12L); + if (interest < 0) + interest = 0; + return interest; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(오사오입, 0.5 이상 올림)으로 unit 정규화 */ long lg_cu_0002_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + if (r * 2 >= unit) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* Luhn 체크섬 유효성으로 분류: 유효=2, 무효 소액=0, 무효 고액=1 */ int lg_cu_0002_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + long v = amount < 0 ? -amount : amount; + int sum = 0, alt = 0, d; + long t = v; + while (t > 0) { + d = (int)(t % 10); + if (alt) { d *= 2; if (d > 9) d -= 9; } + sum += d; + alt = !alt; + t /= 10; + } + if (sum % 10 == 0) + return 2; + return v < 1000000L ? 0 : 1; } diff --git a/app/common/lg_cu_0003.c b/app/common/lg_cu_0003.c index 5ac4f92..36d5775 100644 --- a/app/common/lg_cu_0003.c +++ b/app/common/lg_cu_0003.c @@ -6,32 +6,45 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 일할 정산: rate_bp 를 경과일(1..10000) 비율로 안분한다 */ long lg_cu_0003_fee(long amount, int rate_bp) { - long fee; + long days, prorated; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + days = (long)rate_bp; + if (days > 10000L) + days = 10000L; + prorated = (amount * days) / 10000L; + return prorated; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(절대값 0.5 기준 올림, 부호 보존)으로 unit 정규화 */ long lg_cu_0003_round_unit(long amount, long unit) { + long a, q, r, res; + int neg; if (unit <= 0) return amount; - return (amount / unit) * unit; + neg = amount < 0; + a = neg ? -amount : amount; + q = a / unit; + r = a - q * unit; + if (r * 2 >= unit) + q += 1; + res = q * unit; + return neg ? -res : res; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 디지털 루트(반복 자릿수합)로 분류 */ int lg_cu_0003_classify(long amount) { - if (amount < 10000L) + long v = amount < 0 ? -amount : amount; + int root; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; + root = (int)(1 + (v - 1) % 9); + if (root <= 3) return 0; + if (root <= 6) return 1; return 2; } diff --git a/app/common/lg_cu_0004.c b/app/common/lg_cu_0004.c index 4461c04..b0cd473 100644 --- a/app/common/lg_cu_0004.c +++ b/app/common/lg_cu_0004.c @@ -6,32 +6,51 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* FNV 해시로 결정적 가산분을 산출하는 보조 함수 */ +static unsigned long lg_cu_0004_mix(long x) +{ + unsigned long h = 1469598103934665603UL; + int i; + for (i = 0; i < 8; i++) { + h ^= (unsigned long)((x >> (i * 8)) & 0xFF); + h *= 1099511628211UL; + } + return h; +} + +/* 해시 기반 가산 수수료: 기본 수수료에 결정적 잔돈을 더한다 */ long lg_cu_0004_fee(long amount, int rate_bp) { - long fee; + long base, extra; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + base = (amount * (long)rate_bp) / 10000L; + extra = (long)(lg_cu_0004_mix(amount) % 100UL); + return base + extra; } -/* 절사(내림) 단위 정규화 */ +/* 올림(상향)으로 unit 배수 정규화 */ long lg_cu_0004_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r > 0) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* BIN 범위표로 분류: 상위 6자리를 카드 BIN 처럼 구간 판정 */ int lg_cu_0004_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + long v = amount < 0 ? -amount : amount; + long bin = v; + while (bin >= 1000000L) + bin /= 10; + if (bin >= 400000L && bin <= 499999L) return 1; + if (bin >= 510000L && bin <= 559999L) return 2; + if (bin >= 340000L && bin <= 379999L) return 3; + return 0; } diff --git a/app/common/lg_cu_0005.c b/app/common/lg_cu_0005.c index 210b568..4ba2037 100644 --- a/app/common/lg_cu_0005.c +++ b/app/common/lg_cu_0005.c @@ -6,32 +6,39 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 통화 스케일 환산 수수료: minor unit 로 확장 후 요율 적용, major 복귀 */ long lg_cu_0005_fee(long amount, int rate_bp) { - long fee; + long scaled, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + scaled = amount * 100L; + fee = (scaled * (long)rate_bp) / 10000L; + fee = fee / 100L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 내림(음의 무한대 방향)으로 unit 정규화 */ long lg_cu_0005_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) + q -= 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 임계값 테이블 이분 탐색으로 백분위 버킷 분류 */ int lg_cu_0005_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long th[] = { 5000L, 50000L, 500000L, 5000000L, 50000000L }; + int lo = 0, hi = 5, mid; + while (lo < hi) { + mid = (lo + hi) / 2; + if (amount < th[mid]) hi = mid; else lo = mid + 1; + } + return lo; } diff --git a/app/common/lg_cu_0006.c b/app/common/lg_cu_0006.c index 2196cbd..cbe3382 100644 --- a/app/common/lg_cu_0006.c +++ b/app/common/lg_cu_0006.c @@ -6,32 +6,38 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 상계(netting) 수수료: 기준 30bp 에서 rate_bp 크레딧을 차감한 순수수료 */ long lg_cu_0006_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + long gross, credit, net; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + gross = (amount * 30L) / 10000L; + credit = (amount * (long)(rate_bp < 0 ? 0 : rate_bp)) / 10000L; + net = gross - credit; + if (net < 0) + net = 0; + return net; } -/* 절사(내림) 단위 정규화 */ +/* 절사(0 방향)으로 unit 정규화 */ long lg_cu_0006_round_unit(long amount, long unit) { + long q; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 비트맵 플래그 합성 분류: 특성 비트를 OR 로 조합 */ int lg_cu_0006_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int flags = 0; + long v = amount < 0 ? -amount : amount; + if (amount < 0) flags |= 0x1; + if (v % 2 == 0) flags |= 0x2; + if (v >= 1000000L) flags |= 0x4; + if (v % 1000L == 0) flags |= 0x8; + return flags; } diff --git a/app/common/lg_cu_0007.c b/app/common/lg_cu_0007.c index 0a025ee..4c5ffe1 100644 --- a/app/common/lg_cu_0007.c +++ b/app/common/lg_cu_0007.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 할부 분할 수수료: rate_bp 를 할부개월(1..60)로 보고 회차수수료 산정 */ long lg_cu_0007_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + long n, per; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + n = rate_bp <= 0 ? 1 : (rate_bp > 60 ? 60 : rate_bp); + per = amount / n; + if (amount % n != 0) + per += 1; + return per; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(0.5 초과에서만 올림, 정확히 0.5는 내림)으로 unit 정규화 */ long lg_cu_0007_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + if (r * 2 > unit) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 날짜 산술: amount 를 YYYYMMDD 로 보고 Zeller 공식으로 요일 분류(0=일..6=토) */ int lg_cu_0007_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int y = (int)(amount / 10000L); + int m = (int)((amount / 100L) % 100L); + int d = (int)(amount % 100L); + int k, j, h; + if (m < 1 || m > 12 || d < 1 || d > 31) + return -1; + if (m < 3) { m += 12; y -= 1; } + k = y % 100; j = y / 100; + h = (d + (13 * (m + 1)) / 5 + k + k / 4 + j / 4 + 5 * j) % 7; + return (h + 6) % 7; } diff --git a/app/common/lg_cu_0008.c b/app/common/lg_cu_0008.c index ccde9f7..6ca55f4 100644 --- a/app/common/lg_cu_0008.c +++ b/app/common/lg_cu_0008.c @@ -6,32 +6,57 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 상·하한 적용 정률 수수료 */ long lg_cu_0008_fee(long amount, int rate_bp) { long fee; + const long floor_fee = 100L; + const long cap_fee = 500000L; if (amount <= 0 || rate_bp < 0) return 0; fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + if (fee < floor_fee) + fee = floor_fee; + if (fee > cap_fee) + fee = cap_fee; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 최근접 배수 선택: 아래/위 배수 중 더 가까운 쪽으로 정규화 */ long lg_cu_0008_round_unit(long amount, long unit) { + long down, up, dd, du; if (unit <= 0) return amount; - return (amount / unit) * unit; + if (amount % unit == 0) + return amount; + down = (amount / unit) * unit; + if (amount > 0) + up = down + unit; + else + up = down - unit; + dd = amount - down; if (dd < 0) dd = -dd; + du = up - amount; if (du < 0) du = -du; + return dd <= du ? down : up; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* amount 를 YYYYMMDD 로 보고 월말/윤년 유효성 분류: 0=무효 1=정상 2=월말 */ int lg_cu_0008_classify(long amount) { - if (amount < 10000L) + int y = (int)(amount / 10000L); + int m = (int)((amount / 100L) % 100L); + int d = (int)(amount % 100L); + int dim[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + int leap, last; + if (m < 1 || m > 12 || d < 1) return 0; - if (amount < 1000000L) - return 1; - return 2; + leap = (y % 4 == 0 && y % 100 != 0) || (y % 400 == 0); + last = dim[m - 1]; + if (m == 2 && leap) + last = 29; + if (d > last) + return 0; + if (d == last) + return 2; + return 1; } diff --git a/app/common/lg_cu_0009.c b/app/common/lg_cu_0009.c index 6b5e32d..a566d06 100644 --- a/app/common/lg_cu_0009.c +++ b/app/common/lg_cu_0009.c @@ -6,32 +6,43 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 복리형 단계 수수료: 기본 수수료에 2차(수수료에 대한) 수수료를 가산 */ long lg_cu_0009_fee(long amount, int rate_bp) { - long fee; + long f1, f2; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + f1 = (amount * (long)rate_bp) / 10000L; + f2 = (f1 * (long)rate_bp) / 10000L; + return f1 + f2; } -/* 절사(내림) 단위 정규화 */ +/* 최대공약수 계산 보조 함수 */ +static long lg_cu_0009_gcd(long a, long b) +{ + a = a < 0 ? -a : a; + b = b < 0 ? -b : b; + while (b) { long t = a % b; a = b; b = t; } + return a; +} + +/* GCD 기반 유효 배수로 절사 정규화 */ long lg_cu_0009_round_unit(long amount, long unit) { + long g, step; if (unit <= 0) return amount; - return (amount / unit) * unit; + g = lg_cu_0009_gcd(amount, unit); + step = g > 0 ? g : unit; + return (amount / step) * step; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 나머지 패턴(mod 7)으로 분류 */ int lg_cu_0009_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; + long v = amount < 0 ? -amount : amount; + int r = (int)(v % 7L); + if (r == 0) return 0; + if (r <= 3) return 1; return 2; } diff --git a/app/common/lg_cu_0010.c b/app/common/lg_cu_0010.c index a6cebbe..674f406 100644 --- a/app/common/lg_cu_0010.c +++ b/app/common/lg_cu_0010.c @@ -6,32 +6,35 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 마스킹 후 수수료: 하위 2자리를 마스킹한 금액에 요율 적용 */ long lg_cu_0010_fee(long amount, int rate_bp) { - long fee; + long masked, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + masked = (amount / 100L) * 100L; + fee = (masked * (long)rate_bp) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 고정소수점 스케일(x2) 반올림으로 unit 정규화 */ long lg_cu_0010_round_unit(long amount, long unit) { + long scaled, q; if (unit <= 0) return amount; - return (amount / unit) * unit; + scaled = amount * 2L + (amount >= 0 ? unit : -unit); + q = scaled / (unit * 2L); + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 비트 개수(popcount)로 분류 */ int lg_cu_0010_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; + unsigned long v = (unsigned long)(amount < 0 ? -amount : amount); + int bits = 0; + while (v) { bits += (int)(v & 1UL); v >>= 1; } + if (bits <= 4) return 0; + if (bits <= 8) return 1; return 2; } diff --git a/app/common/lg_cu_0011.c b/app/common/lg_cu_0011.c index 8088565..24bdf0e 100644 --- a/app/common/lg_cu_0011.c +++ b/app/common/lg_cu_0011.c @@ -6,32 +6,59 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* CRC16(CCITT) 계산 보조 함수 */ +static unsigned int lg_cu_0011_crc16(long x) +{ + unsigned int crc = 0xFFFF; + unsigned char buf[8]; + int i, b; + for (i = 0; i < 8; i++) + buf[i] = (unsigned char)((x >> (i * 8)) & 0xFF); + for (i = 0; i < 8; i++) { + crc ^= (unsigned int)buf[i] << 8; + for (b = 0; b < 8; b++) + crc = (crc & 0x8000) ? (unsigned int)((crc << 1) ^ 0x1021) + : (unsigned int)(crc << 1); + } + return crc & 0xFFFF; +} + +/* CRC16 혼합 가산 수수료: 기본 수수료에 결정적 소액 가산분을 더한다 */ long lg_cu_0011_fee(long amount, int rate_bp) { - long fee; + long base; + unsigned int c; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + base = (amount * (long)rate_bp) / 10000L; + c = lg_cu_0011_crc16(amount); + return base + (long)(c % 50U); } -/* 절사(내림) 단위 정규화 */ +/* 상향 임계 반올림((unit+1)/2 기준)으로 unit 정규화 */ long lg_cu_0011_round_unit(long amount, long unit) { + long q, r, threshold; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + threshold = (unit + 1) / 2; + if (r >= threshold) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 누적분포(CDF) 근사 스캔으로 백분위 분류 */ int lg_cu_0011_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long cum[] = { 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L }; + long v = amount < 0 ? -amount : amount; + int i; + for (i = 0; i < 6; i++) { + if (v < cum[i]) + return i; + } + return 6; } diff --git a/app/common/mg_cu_0001.c b/app/common/mg_cu_0001.c index 2cfe9c2..21df021 100644 --- a/app/common/mg_cu_0001.c +++ b/app/common/mg_cu_0001.c @@ -6,32 +6,52 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* Luhn(mod-10) 체크섬 계산: 우대카드 판별용 */ +static int mg_cu_0001_luhn(long v) +{ + int sum = 0, alt = 0; + if (v < 0) v = -v; + while (v > 0) { + int d = (int)(v % 10); + if (alt) { d *= 2; if (d > 9) d -= 9; } + sum += d; + alt = !alt; + v /= 10; + } + return sum % 10; +} + +/* 수수료: Luhn 체크섬이 0(정상 카드)이면 면제, 그 외 정률 */ long mg_cu_0001_fee(long amount, int rate_bp) { - long fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + if (mg_cu_0001_luhn(amount) == 0) + return 0; + return (amount * (long)rate_bp) / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(round-half-up) 단위 정규화 */ long mg_cu_0001_round_unit(long amount, long unit) { + long r, half; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + half = unit / 2; + amount -= r; + if (r >= half) + amount += unit; + return amount; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 10진 자릿수 개수 반환 */ int mg_cu_0001_classify(long amount) { - if (amount < 10000L) + int digits = 0; + long v = amount < 0 ? -amount : amount; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; - return 2; + while (v > 0) { digits++; v /= 10; } + return digits; } diff --git a/app/common/mg_cu_0002.c b/app/common/mg_cu_0002.c index 6b1d90e..d75dc8f 100644 --- a/app/common/mg_cu_0002.c +++ b/app/common/mg_cu_0002.c @@ -6,32 +6,54 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* BIN 범위 조회: 카드 앞 6자리 → 등급 */ +static int mg_cu_0002_bin_grade(long n) +{ + static const long lo[3] = {400000L, 510000L, 600000L}; + static const long hi[3] = {499999L, 559999L, 699999L}; + long bin = n < 0 ? -n : n; + int i; + while (bin >= 1000000L) + bin /= 10; + for (i = 0; i < 3; i++) + if (bin >= lo[i] && bin <= hi[i]) + return i + 1; + return 0; +} + +/* 수수료: 카드 등급별 가산 bp 적용 */ long mg_cu_0002_fee(long amount, int rate_bp) { - long fee; + int g; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + g = mg_cu_0002_bin_grade(amount); + rate_bp += g * 5; + return (amount * (long)rate_bp) / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 올림(ceil) 단위 정규화 */ long mg_cu_0002_round_unit(long amount, long unit) { + long r; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + if (r == 0) + return amount; + if (r < 0) + return amount - r; + return amount + (unit - r); } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 퍼센타일 경계 버킷(0~9) */ int mg_cu_0002_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long b[9] = {1000L, 5000L, 10000L, 50000L, 100000L, + 500000L, 1000000L, 5000000L, 10000000L}; + int i; + for (i = 0; i < 9; i++) + if (amount < b[i]) + return i; + return 9; } diff --git a/app/common/mg_cu_0003.c b/app/common/mg_cu_0003.c index 055fc79..dbb3b24 100644 --- a/app/common/mg_cu_0003.c +++ b/app/common/mg_cu_0003.c @@ -6,32 +6,53 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* Zeller 합동식으로 요일 계산: 0=토,1=일,...,6=금 */ +static int mg_cu_0003_dow(int y, int m, int d) +{ + int k, j; + if (m < 3) { m += 12; y--; } + k = y % 100; + j = y / 100; + return (d + 13 * (m + 1) / 5 + k + k / 4 + j / 4 + 5 * j) % 7; +} + +/* 수수료: amount=YYYYMMDD, 주말이면 할증 rate 반환 */ long mg_cu_0003_fee(long amount, int rate_bp) { - long fee; + int y, m, d, w; + long base; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + w = mg_cu_0003_dow(y, m, d); + base = rate_bp; + if (w == 0 || w == 1) + base += (long)rate_bp / 10; + return base; } -/* 절사(내림) 단위 정규화 */ +/* 내림(floor) 단위 정규화: 음수 방향 보정 */ long mg_cu_0003_round_unit(long amount, long unit) { + long q; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + if (amount % unit != 0 && amount < 0) + q--; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: YYYYMMDD 의 요일(0~6), 오류 -1 */ int mg_cu_0003_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int y, m, d; + if (amount <= 0) + return -1; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + return mg_cu_0003_dow(y, m, d); } diff --git a/app/common/mg_cu_0004.c b/app/common/mg_cu_0004.c index 702ae53..91ee19c 100644 --- a/app/common/mg_cu_0004.c +++ b/app/common/mg_cu_0004.c @@ -6,32 +6,45 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 뱅커스 반올림(사사오입): num/den 을 최근접 정수로, 동점은 짝수 */ +static long mg_cu_0004_bankers(long num, long den) +{ + long q = num / den; + long r = num % den; + long twice = 2 * (r < 0 ? -r : r); + long ad = den < 0 ? -den : den; + if (twice > ad) + q += (num < 0 ? -1 : 1); + else if (twice == ad && (q % 2 != 0)) + q += (num < 0 ? -1 : 1); + return q; +} + +/* 수수료: 초과분에만 요율 적용하는 누진 구간 */ long mg_cu_0004_fee(long amount, int rate_bp) { - long fee; + long fee = 0, a = amount; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + if (a > 1000000L) { fee += (a - 1000000L) * (long)rate_bp / 10000L; a = 1000000L; } + if (a > 100000L) { fee += (a - 100000L) * (long)(rate_bp + 10) / 10000L; a = 100000L; } + fee += a * (long)(rate_bp + 20) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 뱅커스 반올림 단위 정규화 */ long mg_cu_0004_round_unit(long amount, long unit) { if (unit <= 0) return amount; - return (amount / unit) * unit; + return mg_cu_0004_bankers(amount, unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 10의 거듭제곱 지수(로그10 정수부) */ int mg_cu_0004_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int e = 0; + long v = amount < 0 ? -amount : amount; + while (v >= 10) { v /= 10; e++; } + return e; } diff --git a/app/common/mg_cu_0005.c b/app/common/mg_cu_0005.c index 19e2a1c..ea7bd17 100644 --- a/app/common/mg_cu_0005.c +++ b/app/common/mg_cu_0005.c @@ -6,32 +6,49 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* CRC-8(다항식 0x07) 계산: 고정길이 필드 무결성 */ +static unsigned mg_cu_0005_crc8(const char *s, int n) +{ + unsigned crc = 0; + int i, b; + for (i = 0; i < n; i++) { + crc ^= (unsigned char)s[i]; + for (b = 0; b < 8; b++) + crc = (crc & 0x80) ? ((crc << 1) ^ 0x07) & 0xFF : (crc << 1) & 0xFF; + } + return crc & 0xFF; +} + +/* 수수료: 금액을 12자리 고정필드로 pack 후 CRC 가산 */ long mg_cu_0005_fee(long amount, int rate_bp) { - long fee; + char buf[16]; + long v = amount < 0 ? 0 : amount; + int i; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + for (i = 11; i >= 0; i--) { buf[i] = (char)('0' + (int)(v % 10)); v /= 10; } + buf[12] = '\0'; + return (amount * (long)rate_bp) / 10000L + (long)mg_cu_0005_crc8(buf, 12); } -/* 절사(내림) 단위 정규화 */ +/* 최근접 배수 반올림(round-half-away-from-zero) */ long mg_cu_0005_round_unit(long amount, long unit) { + long r, h; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + h = (unit + 1) / 2; + if (r < 0) + return (-r >= h) ? amount - (unit + r) : amount - r; + return (r >= h) ? amount + (unit - r) : amount - r; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 부호·홀짝 조합 4가지 */ int mg_cu_0005_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int s = amount < 0 ? 2 : 0; + int p = (amount % 2 != 0) ? 1 : 0; + return s + p; } diff --git a/app/common/mg_cu_0006.c b/app/common/mg_cu_0006.c index acc533f..f17f852 100644 --- a/app/common/mg_cu_0006.c +++ b/app/common/mg_cu_0006.c @@ -6,32 +6,39 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 12개월 균등분할 잔액에 대한 단리 이자 합 */ long mg_cu_0006_fee(long amount, int rate_bp) { - long fee; + long total = 0, principal; + int m; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + principal = amount / 12; + for (m = 1; m <= 12; m++) { + long bal = amount - principal * (m - 1); + total += bal * (long)rate_bp / 120000L; + } + return total; } -/* 절사(내림) 단위 정규화 */ +/* 잔돈 재분배 반올림: 잔여의 2배가 unit 이상이면 올림 */ long mg_cu_0006_round_unit(long amount, long unit) { + long base, rem; if (unit <= 0) return amount; - return (amount / unit) * unit; + base = (amount / unit) * unit; + rem = amount - base; + return (rem * 2 >= unit) ? base + unit : base; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 최상위(선두) 숫자 1~9 */ int mg_cu_0006_classify(long amount) { - if (amount < 10000L) + long v = amount < 0 ? -amount : amount; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; - return 2; + while (v >= 10) + v /= 10; + return (int)v; } diff --git a/app/common/mg_cu_0007.c b/app/common/mg_cu_0007.c index 8cc35b8..37f0722 100644 --- a/app/common/mg_cu_0007.c +++ b/app/common/mg_cu_0007.c @@ -6,32 +6,33 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 소수 2자리 스케일로 확대 후 요율 적용, 원 단위 복귀 */ long mg_cu_0007_fee(long amount, int rate_bp) { - long fee; + long scaled, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + scaled = amount * 100L; + fee = scaled * (long)rate_bp / 10000L; + return fee / 100L; } -/* 절사(내림) 단위 정규화 */ +/* 단위가 2의 거듭제곱이면 비트마스크 정렬, 아니면 일반 절사 */ long mg_cu_0007_round_unit(long amount, long unit) { if (unit <= 0) return amount; + if ((unit & (unit - 1)) == 0) + return amount & ~(unit - 1); return (amount / unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 금액 구간 비트맵 플래그(bit0=만,bit1=십만,bit2=백만) */ int mg_cu_0007_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int f = 0; + if (amount >= 10000L) f |= 1; + if (amount >= 100000L) f |= 2; + if (amount >= 1000000L) f |= 4; + return f; } diff --git a/app/common/mg_cu_0008.c b/app/common/mg_cu_0008.c index dca2650..ec63a60 100644 --- a/app/common/mg_cu_0008.c +++ b/app/common/mg_cu_0008.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 금액 구간별 요율을 선형보간하여 적용 */ long mg_cu_0008_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + static const long x[4] = {0L, 100000L, 1000000L, 10000000L}; + static const long y[4] = {30L, 20L, 10L, 5L}; + long r = rate_bp; + int i; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + for (i = 0; i < 3; i++) { + if (amount <= x[i + 1]) { + long span = x[i + 1] - x[i]; + r = y[i] + (y[i + 1] - y[i]) * (amount - x[i]) / span; + break; + } + } + return amount * r / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 5사6입: 잔여가 unit 의 60% 이상일 때만 올림 */ long mg_cu_0008_round_unit(long amount, long unit) { + long r; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + return (r * 10 >= unit * 6) ? amount + (unit - r) : amount - r; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 이진탐색으로 경계 버킷 결정 */ int mg_cu_0008_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long b[7] = {5000L, 20000L, 50000L, 200000L, + 500000L, 2000000L, 5000000L}; + int lo = 0, hi = 7, mid; + while (lo < hi) { + mid = (lo + hi) / 2; + if (amount < b[mid]) hi = mid; else lo = mid + 1; + } + return lo; } diff --git a/app/common/mg_cu_0009.c b/app/common/mg_cu_0009.c index fbb5722..9756d1d 100644 --- a/app/common/mg_cu_0009.c +++ b/app/common/mg_cu_0009.c @@ -6,19 +6,35 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ -long mg_cu_0009_fee(long amount, int rate_bp) +/* 그레고리력 → 율리우스일수 근사 변환 */ +static long mg_cu_0009_jdn(int y, int m, int d) { - long fee; - if (amount <= 0 || rate_bp < 0) - return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + long a = (14 - m) / 12; + long yy = y + 4800 - a; + long mm = m + 12 * a - 3; + return d + (153 * mm + 2) / 5 + 365 * yy + yy / 4 - yy / 100 + yy / 400 - 32045; } -/* 절사(내림) 단위 정규화 */ +/* 수수료: amount=YYYYMMDD 에 rate_bp 영업일 더한 율리우스일 반환 */ +long mg_cu_0009_fee(long amount, int rate_bp) +{ + int y, m, d, added = 0; + long jd; + if (amount <= 0) + return 0; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + jd = mg_cu_0009_jdn(y, m, d); + while (added < rate_bp) { + jd++; + if (jd % 7 != 5 && jd % 7 != 6) + added++; + } + return jd; +} + +/* 0 방향 대칭 절사(truncate toward zero) */ long mg_cu_0009_round_unit(long amount, long unit) { if (unit <= 0) @@ -26,12 +42,15 @@ long mg_cu_0009_round_unit(long amount, long unit) return (amount / unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: FNV-1a 해시의 하위 3비트 */ int mg_cu_0009_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + unsigned long h = 2166136261UL; + long v = amount < 0 ? -amount : amount; + do { + h ^= (unsigned long)(v % 10); + h *= 16777619UL; + v /= 10; + } while (v > 0); + return (int)(h & 0x7UL); } diff --git a/app/common/mg_cu_0010.c b/app/common/mg_cu_0010.c index bb18532..e934ffa 100644 --- a/app/common/mg_cu_0010.c +++ b/app/common/mg_cu_0010.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 디지털 루트(각 자리 합 반복) 계산 */ +static int mg_cu_0010_droot(long v) +{ + if (v < 0) v = -v; + while (v >= 10) { + long s = 0; + while (v > 0) { s += v % 10; v /= 10; } + v = s; + } + return (int)v; +} + +/* 수수료: 정률 계산 후 상한(cap) 적용 */ long mg_cu_0010_fee(long amount, int rate_bp) { - long fee; + long fee, cap = 50000L; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + fee = amount * (long)rate_bp / 10000L; + if (fee > cap) + fee = cap; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 이중 절사: 1차 절사 후 잔여 2/3 이상이면 한 단위 보정 */ long mg_cu_0010_round_unit(long amount, long unit) { + long f1; if (unit <= 0) return amount; - return (amount / unit) * unit; + f1 = (amount / unit) * unit; + if ((amount - f1) * 3 >= unit * 2) + f1 += unit; + return f1; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 디지털 루트(1~9, 0) */ int mg_cu_0010_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + return mg_cu_0010_droot(amount); } diff --git a/app/common/mg_cu_0011.c b/app/common/mg_cu_0011.c index ed30b51..36b91dd 100644 --- a/app/common/mg_cu_0011.c +++ b/app/common/mg_cu_0011.c @@ -6,32 +6,49 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 슬랩(구간별 고정액) 수수료 테이블 조회 */ +static long mg_cu_0011_slab(long a) +{ + static const long lim[4] = {10000L, 100000L, 1000000L, 10000000L}; + static const long fixed[5] = {100L, 500L, 2000L, 8000L, 30000L}; + int i; + for (i = 0; i < 4; i++) + if (a < lim[i]) + return fixed[i]; + return fixed[4]; +} + +/* 수수료: 슬랩 고정액 + 미세 요율 가산 */ long mg_cu_0011_fee(long amount, int rate_bp) { - long fee; + long f; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + f = mg_cu_0011_slab(amount); + f += amount * (long)rate_bp / 100000L; + return f; } -/* 절사(내림) 단위 정규화 */ +/* 가장 가까운 배수(반올림, 동점은 올림) */ long mg_cu_0011_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount % unit; + if (r * 2 >= unit) + q++; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 통과한 임계 개수(0~5) */ int mg_cu_0011_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long g[5] = {1000L, 10000L, 100000L, 1000000L, 10000000L}; + int i, c = 0; + for (i = 0; i < 5; i++) + if (amount >= g[i]) + c++; + return c; } diff --git a/app/common/mm_cu_0001.c b/app/common/mm_cu_0001.c index a0eb25b..173a68e 100644 --- a/app/common/mm_cu_0001.c +++ b/app/common/mm_cu_0001.c @@ -6,32 +6,55 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 누진 구간 수수료: 금액 구간별 한계요율을 누적 적용한다 */ long mm_cu_0001_fee(long amount, int rate_bp) { - long fee; + static const long band[] = { 100000L, 1000000L, 10000000L }; + static const int mul[] = { 1, 2, 3, 5 }; + long remain = amount; + long fee = 0; + long prev = 0; + int i; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + for (i = 0; i < 3; i++) { + long span = band[i] - prev; + long part = remain < span ? remain : span; + if (part <= 0) + break; + fee += (part * (long)rate_bp * mul[i]) / 10000L; + remain -= part; + prev = band[i]; + } + if (remain > 0) + fee += (remain * (long)rate_bp * mul[3]) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 은행가 반올림(사사오입, 짝수 반올림)으로 unit 배수 정규화 */ long mm_cu_0001_round_unit(long amount, long unit) { + long q, r, half; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + half = unit / 2; + if (r > half || (r == half && (q & 1L))) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 자릿수(log10) 규모로 5단계 분류 */ int mm_cu_0001_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + long v = amount < 0 ? -amount : amount; + int digits = 0; + while (v > 0) { digits++; v /= 10; } + if (digits <= 3) return 0; + if (digits <= 5) return 1; + if (digits <= 7) return 2; + if (digits <= 9) return 3; + return 4; } diff --git a/app/common/mm_cu_0002.c b/app/common/mm_cu_0002.c index fceca39..2b45611 100644 --- a/app/common/mm_cu_0002.c +++ b/app/common/mm_cu_0002.c @@ -6,32 +6,48 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 원리금 이자액: rate_bp 연이율을 월할(1/12) 적용 */ long mm_cu_0002_fee(long amount, int rate_bp) { - long fee; + long annual_bp; + long interest; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + annual_bp = (long)rate_bp; + interest = (amount * annual_bp) / (10000L * 12L); + if (interest < 0) + interest = 0; + return interest; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(오사오입, 0.5 이상 올림)으로 unit 정규화 */ long mm_cu_0002_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + if (r * 2 >= unit) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* Luhn 체크섬 유효성으로 분류: 유효=2, 무효 소액=0, 무효 고액=1 */ int mm_cu_0002_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + long v = amount < 0 ? -amount : amount; + int sum = 0, alt = 0, d; + long t = v; + while (t > 0) { + d = (int)(t % 10); + if (alt) { d *= 2; if (d > 9) d -= 9; } + sum += d; + alt = !alt; + t /= 10; + } + if (sum % 10 == 0) + return 2; + return v < 1000000L ? 0 : 1; } diff --git a/app/common/mm_cu_0003.c b/app/common/mm_cu_0003.c index 1c5d967..174cad7 100644 --- a/app/common/mm_cu_0003.c +++ b/app/common/mm_cu_0003.c @@ -6,32 +6,45 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 일할 정산: rate_bp 를 경과일(1..10000) 비율로 안분한다 */ long mm_cu_0003_fee(long amount, int rate_bp) { - long fee; + long days, prorated; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + days = (long)rate_bp; + if (days > 10000L) + days = 10000L; + prorated = (amount * days) / 10000L; + return prorated; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(절대값 0.5 기준 올림, 부호 보존)으로 unit 정규화 */ long mm_cu_0003_round_unit(long amount, long unit) { + long a, q, r, res; + int neg; if (unit <= 0) return amount; - return (amount / unit) * unit; + neg = amount < 0; + a = neg ? -amount : amount; + q = a / unit; + r = a - q * unit; + if (r * 2 >= unit) + q += 1; + res = q * unit; + return neg ? -res : res; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 디지털 루트(반복 자릿수합)로 분류 */ int mm_cu_0003_classify(long amount) { - if (amount < 10000L) + long v = amount < 0 ? -amount : amount; + int root; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; + root = (int)(1 + (v - 1) % 9); + if (root <= 3) return 0; + if (root <= 6) return 1; return 2; } diff --git a/app/common/mm_cu_0004.c b/app/common/mm_cu_0004.c index 74fed38..e468d71 100644 --- a/app/common/mm_cu_0004.c +++ b/app/common/mm_cu_0004.c @@ -6,32 +6,51 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* FNV 해시로 결정적 가산분을 산출하는 보조 함수 */ +static unsigned long mm_cu_0004_mix(long x) +{ + unsigned long h = 1469598103934665603UL; + int i; + for (i = 0; i < 8; i++) { + h ^= (unsigned long)((x >> (i * 8)) & 0xFF); + h *= 1099511628211UL; + } + return h; +} + +/* 해시 기반 가산 수수료: 기본 수수료에 결정적 잔돈을 더한다 */ long mm_cu_0004_fee(long amount, int rate_bp) { - long fee; + long base, extra; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + base = (amount * (long)rate_bp) / 10000L; + extra = (long)(mm_cu_0004_mix(amount) % 100UL); + return base + extra; } -/* 절사(내림) 단위 정규화 */ +/* 올림(상향)으로 unit 배수 정규화 */ long mm_cu_0004_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r > 0) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* BIN 범위표로 분류: 상위 6자리를 카드 BIN 처럼 구간 판정 */ int mm_cu_0004_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + long v = amount < 0 ? -amount : amount; + long bin = v; + while (bin >= 1000000L) + bin /= 10; + if (bin >= 400000L && bin <= 499999L) return 1; + if (bin >= 510000L && bin <= 559999L) return 2; + if (bin >= 340000L && bin <= 379999L) return 3; + return 0; } diff --git a/app/common/mm_cu_0005.c b/app/common/mm_cu_0005.c index cb065bb..5a81aff 100644 --- a/app/common/mm_cu_0005.c +++ b/app/common/mm_cu_0005.c @@ -6,32 +6,39 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 통화 스케일 환산 수수료: minor unit 로 확장 후 요율 적용, major 복귀 */ long mm_cu_0005_fee(long amount, int rate_bp) { - long fee; + long scaled, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + scaled = amount * 100L; + fee = (scaled * (long)rate_bp) / 10000L; + fee = fee / 100L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 내림(음의 무한대 방향)으로 unit 정규화 */ long mm_cu_0005_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) + q -= 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 임계값 테이블 이분 탐색으로 백분위 버킷 분류 */ int mm_cu_0005_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long th[] = { 5000L, 50000L, 500000L, 5000000L, 50000000L }; + int lo = 0, hi = 5, mid; + while (lo < hi) { + mid = (lo + hi) / 2; + if (amount < th[mid]) hi = mid; else lo = mid + 1; + } + return lo; } diff --git a/app/common/mm_cu_0006.c b/app/common/mm_cu_0006.c index afc470c..671663b 100644 --- a/app/common/mm_cu_0006.c +++ b/app/common/mm_cu_0006.c @@ -6,32 +6,38 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 상계(netting) 수수료: 기준 30bp 에서 rate_bp 크레딧을 차감한 순수수료 */ long mm_cu_0006_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + long gross, credit, net; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + gross = (amount * 30L) / 10000L; + credit = (amount * (long)(rate_bp < 0 ? 0 : rate_bp)) / 10000L; + net = gross - credit; + if (net < 0) + net = 0; + return net; } -/* 절사(내림) 단위 정규화 */ +/* 절사(0 방향)으로 unit 정규화 */ long mm_cu_0006_round_unit(long amount, long unit) { + long q; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 비트맵 플래그 합성 분류: 특성 비트를 OR 로 조합 */ int mm_cu_0006_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int flags = 0; + long v = amount < 0 ? -amount : amount; + if (amount < 0) flags |= 0x1; + if (v % 2 == 0) flags |= 0x2; + if (v >= 1000000L) flags |= 0x4; + if (v % 1000L == 0) flags |= 0x8; + return flags; } diff --git a/app/common/mm_cu_0007.c b/app/common/mm_cu_0007.c index 9549878..46e841c 100644 --- a/app/common/mm_cu_0007.c +++ b/app/common/mm_cu_0007.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 할부 분할 수수료: rate_bp 를 할부개월(1..60)로 보고 회차수수료 산정 */ long mm_cu_0007_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + long n, per; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + n = rate_bp <= 0 ? 1 : (rate_bp > 60 ? 60 : rate_bp); + per = amount / n; + if (amount % n != 0) + per += 1; + return per; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(0.5 초과에서만 올림, 정확히 0.5는 내림)으로 unit 정규화 */ long mm_cu_0007_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + if (r * 2 > unit) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 날짜 산술: amount 를 YYYYMMDD 로 보고 Zeller 공식으로 요일 분류(0=일..6=토) */ int mm_cu_0007_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int y = (int)(amount / 10000L); + int m = (int)((amount / 100L) % 100L); + int d = (int)(amount % 100L); + int k, j, h; + if (m < 1 || m > 12 || d < 1 || d > 31) + return -1; + if (m < 3) { m += 12; y -= 1; } + k = y % 100; j = y / 100; + h = (d + (13 * (m + 1)) / 5 + k + k / 4 + j / 4 + 5 * j) % 7; + return (h + 6) % 7; } diff --git a/app/common/mm_cu_0008.c b/app/common/mm_cu_0008.c index 999b007..da50498 100644 --- a/app/common/mm_cu_0008.c +++ b/app/common/mm_cu_0008.c @@ -6,32 +6,57 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 상·하한 적용 정률 수수료 */ long mm_cu_0008_fee(long amount, int rate_bp) { long fee; + const long floor_fee = 100L; + const long cap_fee = 500000L; if (amount <= 0 || rate_bp < 0) return 0; fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + if (fee < floor_fee) + fee = floor_fee; + if (fee > cap_fee) + fee = cap_fee; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 최근접 배수 선택: 아래/위 배수 중 더 가까운 쪽으로 정규화 */ long mm_cu_0008_round_unit(long amount, long unit) { + long down, up, dd, du; if (unit <= 0) return amount; - return (amount / unit) * unit; + if (amount % unit == 0) + return amount; + down = (amount / unit) * unit; + if (amount > 0) + up = down + unit; + else + up = down - unit; + dd = amount - down; if (dd < 0) dd = -dd; + du = up - amount; if (du < 0) du = -du; + return dd <= du ? down : up; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* amount 를 YYYYMMDD 로 보고 월말/윤년 유효성 분류: 0=무효 1=정상 2=월말 */ int mm_cu_0008_classify(long amount) { - if (amount < 10000L) + int y = (int)(amount / 10000L); + int m = (int)((amount / 100L) % 100L); + int d = (int)(amount % 100L); + int dim[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + int leap, last; + if (m < 1 || m > 12 || d < 1) return 0; - if (amount < 1000000L) - return 1; - return 2; + leap = (y % 4 == 0 && y % 100 != 0) || (y % 400 == 0); + last = dim[m - 1]; + if (m == 2 && leap) + last = 29; + if (d > last) + return 0; + if (d == last) + return 2; + return 1; } diff --git a/app/common/mm_cu_0009.c b/app/common/mm_cu_0009.c index 37dfb2a..72b0416 100644 --- a/app/common/mm_cu_0009.c +++ b/app/common/mm_cu_0009.c @@ -6,32 +6,43 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 복리형 단계 수수료: 기본 수수료에 2차(수수료에 대한) 수수료를 가산 */ long mm_cu_0009_fee(long amount, int rate_bp) { - long fee; + long f1, f2; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + f1 = (amount * (long)rate_bp) / 10000L; + f2 = (f1 * (long)rate_bp) / 10000L; + return f1 + f2; } -/* 절사(내림) 단위 정규화 */ +/* 최대공약수 계산 보조 함수 */ +static long mm_cu_0009_gcd(long a, long b) +{ + a = a < 0 ? -a : a; + b = b < 0 ? -b : b; + while (b) { long t = a % b; a = b; b = t; } + return a; +} + +/* GCD 기반 유효 배수로 절사 정규화 */ long mm_cu_0009_round_unit(long amount, long unit) { + long g, step; if (unit <= 0) return amount; - return (amount / unit) * unit; + g = mm_cu_0009_gcd(amount, unit); + step = g > 0 ? g : unit; + return (amount / step) * step; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 나머지 패턴(mod 7)으로 분류 */ int mm_cu_0009_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; + long v = amount < 0 ? -amount : amount; + int r = (int)(v % 7L); + if (r == 0) return 0; + if (r <= 3) return 1; return 2; } diff --git a/app/common/mm_cu_0010.c b/app/common/mm_cu_0010.c index 618542b..6c13883 100644 --- a/app/common/mm_cu_0010.c +++ b/app/common/mm_cu_0010.c @@ -6,32 +6,35 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 마스킹 후 수수료: 하위 2자리를 마스킹한 금액에 요율 적용 */ long mm_cu_0010_fee(long amount, int rate_bp) { - long fee; + long masked, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + masked = (amount / 100L) * 100L; + fee = (masked * (long)rate_bp) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 고정소수점 스케일(x2) 반올림으로 unit 정규화 */ long mm_cu_0010_round_unit(long amount, long unit) { + long scaled, q; if (unit <= 0) return amount; - return (amount / unit) * unit; + scaled = amount * 2L + (amount >= 0 ? unit : -unit); + q = scaled / (unit * 2L); + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 비트 개수(popcount)로 분류 */ int mm_cu_0010_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; + unsigned long v = (unsigned long)(amount < 0 ? -amount : amount); + int bits = 0; + while (v) { bits += (int)(v & 1UL); v >>= 1; } + if (bits <= 4) return 0; + if (bits <= 8) return 1; return 2; } diff --git a/app/common/mm_cu_0011.c b/app/common/mm_cu_0011.c index e180aab..7efd3bf 100644 --- a/app/common/mm_cu_0011.c +++ b/app/common/mm_cu_0011.c @@ -6,32 +6,59 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* CRC16(CCITT) 계산 보조 함수 */ +static unsigned int mm_cu_0011_crc16(long x) +{ + unsigned int crc = 0xFFFF; + unsigned char buf[8]; + int i, b; + for (i = 0; i < 8; i++) + buf[i] = (unsigned char)((x >> (i * 8)) & 0xFF); + for (i = 0; i < 8; i++) { + crc ^= (unsigned int)buf[i] << 8; + for (b = 0; b < 8; b++) + crc = (crc & 0x8000) ? (unsigned int)((crc << 1) ^ 0x1021) + : (unsigned int)(crc << 1); + } + return crc & 0xFFFF; +} + +/* CRC16 혼합 가산 수수료: 기본 수수료에 결정적 소액 가산분을 더한다 */ long mm_cu_0011_fee(long amount, int rate_bp) { - long fee; + long base; + unsigned int c; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + base = (amount * (long)rate_bp) / 10000L; + c = mm_cu_0011_crc16(amount); + return base + (long)(c % 50U); } -/* 절사(내림) 단위 정규화 */ +/* 상향 임계 반올림((unit+1)/2 기준)으로 unit 정규화 */ long mm_cu_0011_round_unit(long amount, long unit) { + long q, r, threshold; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + threshold = (unit + 1) / 2; + if (r >= threshold) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 누적분포(CDF) 근사 스캔으로 백분위 분류 */ int mm_cu_0011_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long cum[] = { 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L }; + long v = amount < 0 ? -amount : amount; + int i; + for (i = 0; i < 6; i++) { + if (v < cum[i]) + return i; + } + return 6; } diff --git a/app/common/py_cu_0001.c b/app/common/py_cu_0001.c index 66bd298..1441adc 100644 --- a/app/common/py_cu_0001.c +++ b/app/common/py_cu_0001.c @@ -6,32 +6,55 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 누진 구간 수수료: 금액 구간별 한계요율을 누적 적용한다 */ long py_cu_0001_fee(long amount, int rate_bp) { - long fee; + static const long band[] = { 100000L, 1000000L, 10000000L }; + static const int mul[] = { 1, 2, 3, 5 }; + long remain = amount; + long fee = 0; + long prev = 0; + int i; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + for (i = 0; i < 3; i++) { + long span = band[i] - prev; + long part = remain < span ? remain : span; + if (part <= 0) + break; + fee += (part * (long)rate_bp * mul[i]) / 10000L; + remain -= part; + prev = band[i]; + } + if (remain > 0) + fee += (remain * (long)rate_bp * mul[3]) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 은행가 반올림(사사오입, 짝수 반올림)으로 unit 배수 정규화 */ long py_cu_0001_round_unit(long amount, long unit) { + long q, r, half; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + half = unit / 2; + if (r > half || (r == half && (q & 1L))) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 자릿수(log10) 규모로 5단계 분류 */ int py_cu_0001_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + long v = amount < 0 ? -amount : amount; + int digits = 0; + while (v > 0) { digits++; v /= 10; } + if (digits <= 3) return 0; + if (digits <= 5) return 1; + if (digits <= 7) return 2; + if (digits <= 9) return 3; + return 4; } diff --git a/app/common/py_cu_0002.c b/app/common/py_cu_0002.c index cd5a874..2884803 100644 --- a/app/common/py_cu_0002.c +++ b/app/common/py_cu_0002.c @@ -6,32 +6,48 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 원리금 이자액: rate_bp 연이율을 월할(1/12) 적용 */ long py_cu_0002_fee(long amount, int rate_bp) { - long fee; + long annual_bp; + long interest; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + annual_bp = (long)rate_bp; + interest = (amount * annual_bp) / (10000L * 12L); + if (interest < 0) + interest = 0; + return interest; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(오사오입, 0.5 이상 올림)으로 unit 정규화 */ long py_cu_0002_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + if (r * 2 >= unit) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* Luhn 체크섬 유효성으로 분류: 유효=2, 무효 소액=0, 무효 고액=1 */ int py_cu_0002_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + long v = amount < 0 ? -amount : amount; + int sum = 0, alt = 0, d; + long t = v; + while (t > 0) { + d = (int)(t % 10); + if (alt) { d *= 2; if (d > 9) d -= 9; } + sum += d; + alt = !alt; + t /= 10; + } + if (sum % 10 == 0) + return 2; + return v < 1000000L ? 0 : 1; } diff --git a/app/common/py_cu_0003.c b/app/common/py_cu_0003.c index 2f432c0..1af08ad 100644 --- a/app/common/py_cu_0003.c +++ b/app/common/py_cu_0003.c @@ -6,32 +6,45 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 일할 정산: rate_bp 를 경과일(1..10000) 비율로 안분한다 */ long py_cu_0003_fee(long amount, int rate_bp) { - long fee; + long days, prorated; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + days = (long)rate_bp; + if (days > 10000L) + days = 10000L; + prorated = (amount * days) / 10000L; + return prorated; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(절대값 0.5 기준 올림, 부호 보존)으로 unit 정규화 */ long py_cu_0003_round_unit(long amount, long unit) { + long a, q, r, res; + int neg; if (unit <= 0) return amount; - return (amount / unit) * unit; + neg = amount < 0; + a = neg ? -amount : amount; + q = a / unit; + r = a - q * unit; + if (r * 2 >= unit) + q += 1; + res = q * unit; + return neg ? -res : res; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 디지털 루트(반복 자릿수합)로 분류 */ int py_cu_0003_classify(long amount) { - if (amount < 10000L) + long v = amount < 0 ? -amount : amount; + int root; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; + root = (int)(1 + (v - 1) % 9); + if (root <= 3) return 0; + if (root <= 6) return 1; return 2; } diff --git a/app/common/py_cu_0004.c b/app/common/py_cu_0004.c index be7afd0..55109f8 100644 --- a/app/common/py_cu_0004.c +++ b/app/common/py_cu_0004.c @@ -6,32 +6,51 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* FNV 해시로 결정적 가산분을 산출하는 보조 함수 */ +static unsigned long py_cu_0004_mix(long x) +{ + unsigned long h = 1469598103934665603UL; + int i; + for (i = 0; i < 8; i++) { + h ^= (unsigned long)((x >> (i * 8)) & 0xFF); + h *= 1099511628211UL; + } + return h; +} + +/* 해시 기반 가산 수수료: 기본 수수료에 결정적 잔돈을 더한다 */ long py_cu_0004_fee(long amount, int rate_bp) { - long fee; + long base, extra; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + base = (amount * (long)rate_bp) / 10000L; + extra = (long)(py_cu_0004_mix(amount) % 100UL); + return base + extra; } -/* 절사(내림) 단위 정규화 */ +/* 올림(상향)으로 unit 배수 정규화 */ long py_cu_0004_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r > 0) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* BIN 범위표로 분류: 상위 6자리를 카드 BIN 처럼 구간 판정 */ int py_cu_0004_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + long v = amount < 0 ? -amount : amount; + long bin = v; + while (bin >= 1000000L) + bin /= 10; + if (bin >= 400000L && bin <= 499999L) return 1; + if (bin >= 510000L && bin <= 559999L) return 2; + if (bin >= 340000L && bin <= 379999L) return 3; + return 0; } diff --git a/app/common/py_cu_0005.c b/app/common/py_cu_0005.c index 593e51e..9307708 100644 --- a/app/common/py_cu_0005.c +++ b/app/common/py_cu_0005.c @@ -6,32 +6,39 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 통화 스케일 환산 수수료: minor unit 로 확장 후 요율 적용, major 복귀 */ long py_cu_0005_fee(long amount, int rate_bp) { - long fee; + long scaled, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + scaled = amount * 100L; + fee = (scaled * (long)rate_bp) / 10000L; + fee = fee / 100L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 내림(음의 무한대 방향)으로 unit 정규화 */ long py_cu_0005_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) + q -= 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 임계값 테이블 이분 탐색으로 백분위 버킷 분류 */ int py_cu_0005_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long th[] = { 5000L, 50000L, 500000L, 5000000L, 50000000L }; + int lo = 0, hi = 5, mid; + while (lo < hi) { + mid = (lo + hi) / 2; + if (amount < th[mid]) hi = mid; else lo = mid + 1; + } + return lo; } diff --git a/app/common/py_cu_0006.c b/app/common/py_cu_0006.c index 7bc56ca..50acdab 100644 --- a/app/common/py_cu_0006.c +++ b/app/common/py_cu_0006.c @@ -6,32 +6,38 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 상계(netting) 수수료: 기준 30bp 에서 rate_bp 크레딧을 차감한 순수수료 */ long py_cu_0006_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + long gross, credit, net; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + gross = (amount * 30L) / 10000L; + credit = (amount * (long)(rate_bp < 0 ? 0 : rate_bp)) / 10000L; + net = gross - credit; + if (net < 0) + net = 0; + return net; } -/* 절사(내림) 단위 정규화 */ +/* 절사(0 방향)으로 unit 정규화 */ long py_cu_0006_round_unit(long amount, long unit) { + long q; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 비트맵 플래그 합성 분류: 특성 비트를 OR 로 조합 */ int py_cu_0006_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int flags = 0; + long v = amount < 0 ? -amount : amount; + if (amount < 0) flags |= 0x1; + if (v % 2 == 0) flags |= 0x2; + if (v >= 1000000L) flags |= 0x4; + if (v % 1000L == 0) flags |= 0x8; + return flags; } diff --git a/app/common/py_cu_0007.c b/app/common/py_cu_0007.c index 15b7af6..13c26c1 100644 --- a/app/common/py_cu_0007.c +++ b/app/common/py_cu_0007.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 할부 분할 수수료: rate_bp 를 할부개월(1..60)로 보고 회차수수료 산정 */ long py_cu_0007_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + long n, per; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + n = rate_bp <= 0 ? 1 : (rate_bp > 60 ? 60 : rate_bp); + per = amount / n; + if (amount % n != 0) + per += 1; + return per; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(0.5 초과에서만 올림, 정확히 0.5는 내림)으로 unit 정규화 */ long py_cu_0007_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + if (r * 2 > unit) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 날짜 산술: amount 를 YYYYMMDD 로 보고 Zeller 공식으로 요일 분류(0=일..6=토) */ int py_cu_0007_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int y = (int)(amount / 10000L); + int m = (int)((amount / 100L) % 100L); + int d = (int)(amount % 100L); + int k, j, h; + if (m < 1 || m > 12 || d < 1 || d > 31) + return -1; + if (m < 3) { m += 12; y -= 1; } + k = y % 100; j = y / 100; + h = (d + (13 * (m + 1)) / 5 + k + k / 4 + j / 4 + 5 * j) % 7; + return (h + 6) % 7; } diff --git a/app/common/py_cu_0008.c b/app/common/py_cu_0008.c index 895b503..d2154ec 100644 --- a/app/common/py_cu_0008.c +++ b/app/common/py_cu_0008.c @@ -6,32 +6,57 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 상·하한 적용 정률 수수료 */ long py_cu_0008_fee(long amount, int rate_bp) { long fee; + const long floor_fee = 100L; + const long cap_fee = 500000L; if (amount <= 0 || rate_bp < 0) return 0; fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + if (fee < floor_fee) + fee = floor_fee; + if (fee > cap_fee) + fee = cap_fee; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 최근접 배수 선택: 아래/위 배수 중 더 가까운 쪽으로 정규화 */ long py_cu_0008_round_unit(long amount, long unit) { + long down, up, dd, du; if (unit <= 0) return amount; - return (amount / unit) * unit; + if (amount % unit == 0) + return amount; + down = (amount / unit) * unit; + if (amount > 0) + up = down + unit; + else + up = down - unit; + dd = amount - down; if (dd < 0) dd = -dd; + du = up - amount; if (du < 0) du = -du; + return dd <= du ? down : up; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* amount 를 YYYYMMDD 로 보고 월말/윤년 유효성 분류: 0=무효 1=정상 2=월말 */ int py_cu_0008_classify(long amount) { - if (amount < 10000L) + int y = (int)(amount / 10000L); + int m = (int)((amount / 100L) % 100L); + int d = (int)(amount % 100L); + int dim[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + int leap, last; + if (m < 1 || m > 12 || d < 1) return 0; - if (amount < 1000000L) - return 1; - return 2; + leap = (y % 4 == 0 && y % 100 != 0) || (y % 400 == 0); + last = dim[m - 1]; + if (m == 2 && leap) + last = 29; + if (d > last) + return 0; + if (d == last) + return 2; + return 1; } diff --git a/app/common/py_cu_0009.c b/app/common/py_cu_0009.c index f305015..606ad69 100644 --- a/app/common/py_cu_0009.c +++ b/app/common/py_cu_0009.c @@ -6,32 +6,43 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 복리형 단계 수수료: 기본 수수료에 2차(수수료에 대한) 수수료를 가산 */ long py_cu_0009_fee(long amount, int rate_bp) { - long fee; + long f1, f2; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + f1 = (amount * (long)rate_bp) / 10000L; + f2 = (f1 * (long)rate_bp) / 10000L; + return f1 + f2; } -/* 절사(내림) 단위 정규화 */ +/* 최대공약수 계산 보조 함수 */ +static long py_cu_0009_gcd(long a, long b) +{ + a = a < 0 ? -a : a; + b = b < 0 ? -b : b; + while (b) { long t = a % b; a = b; b = t; } + return a; +} + +/* GCD 기반 유효 배수로 절사 정규화 */ long py_cu_0009_round_unit(long amount, long unit) { + long g, step; if (unit <= 0) return amount; - return (amount / unit) * unit; + g = py_cu_0009_gcd(amount, unit); + step = g > 0 ? g : unit; + return (amount / step) * step; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 나머지 패턴(mod 7)으로 분류 */ int py_cu_0009_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; + long v = amount < 0 ? -amount : amount; + int r = (int)(v % 7L); + if (r == 0) return 0; + if (r <= 3) return 1; return 2; } diff --git a/app/common/py_cu_0010.c b/app/common/py_cu_0010.c index 4fd2a6b..f158062 100644 --- a/app/common/py_cu_0010.c +++ b/app/common/py_cu_0010.c @@ -6,32 +6,35 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 마스킹 후 수수료: 하위 2자리를 마스킹한 금액에 요율 적용 */ long py_cu_0010_fee(long amount, int rate_bp) { - long fee; + long masked, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + masked = (amount / 100L) * 100L; + fee = (masked * (long)rate_bp) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 고정소수점 스케일(x2) 반올림으로 unit 정규화 */ long py_cu_0010_round_unit(long amount, long unit) { + long scaled, q; if (unit <= 0) return amount; - return (amount / unit) * unit; + scaled = amount * 2L + (amount >= 0 ? unit : -unit); + q = scaled / (unit * 2L); + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 비트 개수(popcount)로 분류 */ int py_cu_0010_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; + unsigned long v = (unsigned long)(amount < 0 ? -amount : amount); + int bits = 0; + while (v) { bits += (int)(v & 1UL); v >>= 1; } + if (bits <= 4) return 0; + if (bits <= 8) return 1; return 2; } diff --git a/app/common/py_cu_0011.c b/app/common/py_cu_0011.c index ba36d0c..0112c20 100644 --- a/app/common/py_cu_0011.c +++ b/app/common/py_cu_0011.c @@ -6,32 +6,59 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* CRC16(CCITT) 계산 보조 함수 */ +static unsigned int py_cu_0011_crc16(long x) +{ + unsigned int crc = 0xFFFF; + unsigned char buf[8]; + int i, b; + for (i = 0; i < 8; i++) + buf[i] = (unsigned char)((x >> (i * 8)) & 0xFF); + for (i = 0; i < 8; i++) { + crc ^= (unsigned int)buf[i] << 8; + for (b = 0; b < 8; b++) + crc = (crc & 0x8000) ? (unsigned int)((crc << 1) ^ 0x1021) + : (unsigned int)(crc << 1); + } + return crc & 0xFFFF; +} + +/* CRC16 혼합 가산 수수료: 기본 수수료에 결정적 소액 가산분을 더한다 */ long py_cu_0011_fee(long amount, int rate_bp) { - long fee; + long base; + unsigned int c; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + base = (amount * (long)rate_bp) / 10000L; + c = py_cu_0011_crc16(amount); + return base + (long)(c % 50U); } -/* 절사(내림) 단위 정규화 */ +/* 상향 임계 반올림((unit+1)/2 기준)으로 unit 정규화 */ long py_cu_0011_round_unit(long amount, long unit) { + long q, r, threshold; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount - q * unit; + if (r < 0) { r += unit; q -= 1; } + threshold = (unit + 1) / 2; + if (r >= threshold) + q += 1; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 누적분포(CDF) 근사 스캔으로 백분위 분류 */ int py_cu_0011_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long cum[] = { 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L }; + long v = amount < 0 ? -amount : amount; + int i; + for (i = 0; i < 6; i++) { + if (v < cum[i]) + return i; + } + return 6; } diff --git a/app/common/rc_cu_0001.c b/app/common/rc_cu_0001.c index f5dd0cb..de22de5 100644 --- a/app/common/rc_cu_0001.c +++ b/app/common/rc_cu_0001.c @@ -6,32 +6,33 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 소수 2자리 스케일로 확대 후 요율 적용, 원 단위 복귀 */ long rc_cu_0001_fee(long amount, int rate_bp) { - long fee; + long scaled, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + scaled = amount * 100L; + fee = scaled * (long)rate_bp / 10000L; + return fee / 100L; } -/* 절사(내림) 단위 정규화 */ +/* 단위가 2의 거듭제곱이면 비트마스크 정렬, 아니면 일반 절사 */ long rc_cu_0001_round_unit(long amount, long unit) { if (unit <= 0) return amount; + if ((unit & (unit - 1)) == 0) + return amount & ~(unit - 1); return (amount / unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 금액 구간 비트맵 플래그(bit0=만,bit1=십만,bit2=백만) */ int rc_cu_0001_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int f = 0; + if (amount >= 10000L) f |= 1; + if (amount >= 100000L) f |= 2; + if (amount >= 1000000L) f |= 4; + return f; } diff --git a/app/common/rc_cu_0002.c b/app/common/rc_cu_0002.c index 5d2a4a5..8009eb6 100644 --- a/app/common/rc_cu_0002.c +++ b/app/common/rc_cu_0002.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 금액 구간별 요율을 선형보간하여 적용 */ long rc_cu_0002_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + static const long x[4] = {0L, 100000L, 1000000L, 10000000L}; + static const long y[4] = {30L, 20L, 10L, 5L}; + long r = rate_bp; + int i; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + for (i = 0; i < 3; i++) { + if (amount <= x[i + 1]) { + long span = x[i + 1] - x[i]; + r = y[i] + (y[i + 1] - y[i]) * (amount - x[i]) / span; + break; + } + } + return amount * r / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 5사6입: 잔여가 unit 의 60% 이상일 때만 올림 */ long rc_cu_0002_round_unit(long amount, long unit) { + long r; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + return (r * 10 >= unit * 6) ? amount + (unit - r) : amount - r; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 이진탐색으로 경계 버킷 결정 */ int rc_cu_0002_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long b[7] = {5000L, 20000L, 50000L, 200000L, + 500000L, 2000000L, 5000000L}; + int lo = 0, hi = 7, mid; + while (lo < hi) { + mid = (lo + hi) / 2; + if (amount < b[mid]) hi = mid; else lo = mid + 1; + } + return lo; } diff --git a/app/common/rc_cu_0003.c b/app/common/rc_cu_0003.c index 58705aa..078590a 100644 --- a/app/common/rc_cu_0003.c +++ b/app/common/rc_cu_0003.c @@ -6,19 +6,35 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ -long rc_cu_0003_fee(long amount, int rate_bp) +/* 그레고리력 → 율리우스일수 근사 변환 */ +static long rc_cu_0003_jdn(int y, int m, int d) { - long fee; - if (amount <= 0 || rate_bp < 0) - return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + long a = (14 - m) / 12; + long yy = y + 4800 - a; + long mm = m + 12 * a - 3; + return d + (153 * mm + 2) / 5 + 365 * yy + yy / 4 - yy / 100 + yy / 400 - 32045; } -/* 절사(내림) 단위 정규화 */ +/* 수수료: amount=YYYYMMDD 에 rate_bp 영업일 더한 율리우스일 반환 */ +long rc_cu_0003_fee(long amount, int rate_bp) +{ + int y, m, d, added = 0; + long jd; + if (amount <= 0) + return 0; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + jd = rc_cu_0003_jdn(y, m, d); + while (added < rate_bp) { + jd++; + if (jd % 7 != 5 && jd % 7 != 6) + added++; + } + return jd; +} + +/* 0 방향 대칭 절사(truncate toward zero) */ long rc_cu_0003_round_unit(long amount, long unit) { if (unit <= 0) @@ -26,12 +42,15 @@ long rc_cu_0003_round_unit(long amount, long unit) return (amount / unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: FNV-1a 해시의 하위 3비트 */ int rc_cu_0003_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + unsigned long h = 2166136261UL; + long v = amount < 0 ? -amount : amount; + do { + h ^= (unsigned long)(v % 10); + h *= 16777619UL; + v /= 10; + } while (v > 0); + return (int)(h & 0x7UL); } diff --git a/app/common/rc_cu_0004.c b/app/common/rc_cu_0004.c index 3c00a42..4b437ca 100644 --- a/app/common/rc_cu_0004.c +++ b/app/common/rc_cu_0004.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 디지털 루트(각 자리 합 반복) 계산 */ +static int rc_cu_0004_droot(long v) +{ + if (v < 0) v = -v; + while (v >= 10) { + long s = 0; + while (v > 0) { s += v % 10; v /= 10; } + v = s; + } + return (int)v; +} + +/* 수수료: 정률 계산 후 상한(cap) 적용 */ long rc_cu_0004_fee(long amount, int rate_bp) { - long fee; + long fee, cap = 50000L; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + fee = amount * (long)rate_bp / 10000L; + if (fee > cap) + fee = cap; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 이중 절사: 1차 절사 후 잔여 2/3 이상이면 한 단위 보정 */ long rc_cu_0004_round_unit(long amount, long unit) { + long f1; if (unit <= 0) return amount; - return (amount / unit) * unit; + f1 = (amount / unit) * unit; + if ((amount - f1) * 3 >= unit * 2) + f1 += unit; + return f1; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 디지털 루트(1~9, 0) */ int rc_cu_0004_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + return rc_cu_0004_droot(amount); } diff --git a/app/common/rc_cu_0005.c b/app/common/rc_cu_0005.c index a5ea3e8..5d5b83e 100644 --- a/app/common/rc_cu_0005.c +++ b/app/common/rc_cu_0005.c @@ -6,32 +6,49 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 슬랩(구간별 고정액) 수수료 테이블 조회 */ +static long rc_cu_0005_slab(long a) +{ + static const long lim[4] = {10000L, 100000L, 1000000L, 10000000L}; + static const long fixed[5] = {100L, 500L, 2000L, 8000L, 30000L}; + int i; + for (i = 0; i < 4; i++) + if (a < lim[i]) + return fixed[i]; + return fixed[4]; +} + +/* 수수료: 슬랩 고정액 + 미세 요율 가산 */ long rc_cu_0005_fee(long amount, int rate_bp) { - long fee; + long f; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + f = rc_cu_0005_slab(amount); + f += amount * (long)rate_bp / 100000L; + return f; } -/* 절사(내림) 단위 정규화 */ +/* 가장 가까운 배수(반올림, 동점은 올림) */ long rc_cu_0005_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount % unit; + if (r * 2 >= unit) + q++; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 통과한 임계 개수(0~5) */ int rc_cu_0005_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long g[5] = {1000L, 10000L, 100000L, 1000000L, 10000000L}; + int i, c = 0; + for (i = 0; i < 5; i++) + if (amount >= g[i]) + c++; + return c; } diff --git a/app/common/rc_cu_0006.c b/app/common/rc_cu_0006.c index a395ab6..5334822 100644 --- a/app/common/rc_cu_0006.c +++ b/app/common/rc_cu_0006.c @@ -6,32 +6,52 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* Luhn(mod-10) 체크섬 계산: 우대카드 판별용 */ +static int rc_cu_0006_luhn(long v) +{ + int sum = 0, alt = 0; + if (v < 0) v = -v; + while (v > 0) { + int d = (int)(v % 10); + if (alt) { d *= 2; if (d > 9) d -= 9; } + sum += d; + alt = !alt; + v /= 10; + } + return sum % 10; +} + +/* 수수료: Luhn 체크섬이 0(정상 카드)이면 면제, 그 외 정률 */ long rc_cu_0006_fee(long amount, int rate_bp) { - long fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + if (rc_cu_0006_luhn(amount) == 0) + return 0; + return (amount * (long)rate_bp) / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(round-half-up) 단위 정규화 */ long rc_cu_0006_round_unit(long amount, long unit) { + long r, half; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + half = unit / 2; + amount -= r; + if (r >= half) + amount += unit; + return amount; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 10진 자릿수 개수 반환 */ int rc_cu_0006_classify(long amount) { - if (amount < 10000L) + int digits = 0; + long v = amount < 0 ? -amount : amount; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; - return 2; + while (v > 0) { digits++; v /= 10; } + return digits; } diff --git a/app/common/rc_cu_0007.c b/app/common/rc_cu_0007.c index 20bf5f7..7dd4fcb 100644 --- a/app/common/rc_cu_0007.c +++ b/app/common/rc_cu_0007.c @@ -6,32 +6,54 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* BIN 범위 조회: 카드 앞 6자리 → 등급 */ +static int rc_cu_0007_bin_grade(long n) +{ + static const long lo[3] = {400000L, 510000L, 600000L}; + static const long hi[3] = {499999L, 559999L, 699999L}; + long bin = n < 0 ? -n : n; + int i; + while (bin >= 1000000L) + bin /= 10; + for (i = 0; i < 3; i++) + if (bin >= lo[i] && bin <= hi[i]) + return i + 1; + return 0; +} + +/* 수수료: 카드 등급별 가산 bp 적용 */ long rc_cu_0007_fee(long amount, int rate_bp) { - long fee; + int g; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + g = rc_cu_0007_bin_grade(amount); + rate_bp += g * 5; + return (amount * (long)rate_bp) / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 올림(ceil) 단위 정규화 */ long rc_cu_0007_round_unit(long amount, long unit) { + long r; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + if (r == 0) + return amount; + if (r < 0) + return amount - r; + return amount + (unit - r); } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 퍼센타일 경계 버킷(0~9) */ int rc_cu_0007_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long b[9] = {1000L, 5000L, 10000L, 50000L, 100000L, + 500000L, 1000000L, 5000000L, 10000000L}; + int i; + for (i = 0; i < 9; i++) + if (amount < b[i]) + return i; + return 9; } diff --git a/app/common/rc_cu_0008.c b/app/common/rc_cu_0008.c index 485946d..f28aa55 100644 --- a/app/common/rc_cu_0008.c +++ b/app/common/rc_cu_0008.c @@ -6,32 +6,53 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* Zeller 합동식으로 요일 계산: 0=토,1=일,...,6=금 */ +static int rc_cu_0008_dow(int y, int m, int d) +{ + int k, j; + if (m < 3) { m += 12; y--; } + k = y % 100; + j = y / 100; + return (d + 13 * (m + 1) / 5 + k + k / 4 + j / 4 + 5 * j) % 7; +} + +/* 수수료: amount=YYYYMMDD, 주말이면 할증 rate 반환 */ long rc_cu_0008_fee(long amount, int rate_bp) { - long fee; + int y, m, d, w; + long base; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + w = rc_cu_0008_dow(y, m, d); + base = rate_bp; + if (w == 0 || w == 1) + base += (long)rate_bp / 10; + return base; } -/* 절사(내림) 단위 정규화 */ +/* 내림(floor) 단위 정규화: 음수 방향 보정 */ long rc_cu_0008_round_unit(long amount, long unit) { + long q; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + if (amount % unit != 0 && amount < 0) + q--; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: YYYYMMDD 의 요일(0~6), 오류 -1 */ int rc_cu_0008_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int y, m, d; + if (amount <= 0) + return -1; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + return rc_cu_0008_dow(y, m, d); } diff --git a/app/common/rc_cu_0009.c b/app/common/rc_cu_0009.c index 376c087..9be6c6d 100644 --- a/app/common/rc_cu_0009.c +++ b/app/common/rc_cu_0009.c @@ -6,32 +6,45 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 뱅커스 반올림(사사오입): num/den 을 최근접 정수로, 동점은 짝수 */ +static long rc_cu_0009_bankers(long num, long den) +{ + long q = num / den; + long r = num % den; + long twice = 2 * (r < 0 ? -r : r); + long ad = den < 0 ? -den : den; + if (twice > ad) + q += (num < 0 ? -1 : 1); + else if (twice == ad && (q % 2 != 0)) + q += (num < 0 ? -1 : 1); + return q; +} + +/* 수수료: 초과분에만 요율 적용하는 누진 구간 */ long rc_cu_0009_fee(long amount, int rate_bp) { - long fee; + long fee = 0, a = amount; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + if (a > 1000000L) { fee += (a - 1000000L) * (long)rate_bp / 10000L; a = 1000000L; } + if (a > 100000L) { fee += (a - 100000L) * (long)(rate_bp + 10) / 10000L; a = 100000L; } + fee += a * (long)(rate_bp + 20) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 뱅커스 반올림 단위 정규화 */ long rc_cu_0009_round_unit(long amount, long unit) { if (unit <= 0) return amount; - return (amount / unit) * unit; + return rc_cu_0009_bankers(amount, unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 10의 거듭제곱 지수(로그10 정수부) */ int rc_cu_0009_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int e = 0; + long v = amount < 0 ? -amount : amount; + while (v >= 10) { v /= 10; e++; } + return e; } diff --git a/app/common/rc_cu_0010.c b/app/common/rc_cu_0010.c index 8ee9f12..4ab1ace 100644 --- a/app/common/rc_cu_0010.c +++ b/app/common/rc_cu_0010.c @@ -6,32 +6,49 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* CRC-8(다항식 0x07) 계산: 고정길이 필드 무결성 */ +static unsigned rc_cu_0010_crc8(const char *s, int n) +{ + unsigned crc = 0; + int i, b; + for (i = 0; i < n; i++) { + crc ^= (unsigned char)s[i]; + for (b = 0; b < 8; b++) + crc = (crc & 0x80) ? ((crc << 1) ^ 0x07) & 0xFF : (crc << 1) & 0xFF; + } + return crc & 0xFF; +} + +/* 수수료: 금액을 12자리 고정필드로 pack 후 CRC 가산 */ long rc_cu_0010_fee(long amount, int rate_bp) { - long fee; + char buf[16]; + long v = amount < 0 ? 0 : amount; + int i; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + for (i = 11; i >= 0; i--) { buf[i] = (char)('0' + (int)(v % 10)); v /= 10; } + buf[12] = '\0'; + return (amount * (long)rate_bp) / 10000L + (long)rc_cu_0010_crc8(buf, 12); } -/* 절사(내림) 단위 정규화 */ +/* 최근접 배수 반올림(round-half-away-from-zero) */ long rc_cu_0010_round_unit(long amount, long unit) { + long r, h; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + h = (unit + 1) / 2; + if (r < 0) + return (-r >= h) ? amount - (unit + r) : amount - r; + return (r >= h) ? amount + (unit - r) : amount - r; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 부호·홀짝 조합 4가지 */ int rc_cu_0010_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int s = amount < 0 ? 2 : 0; + int p = (amount % 2 != 0) ? 1 : 0; + return s + p; } diff --git a/app/common/rc_cu_0011.c b/app/common/rc_cu_0011.c index 298ec2d..66429a1 100644 --- a/app/common/rc_cu_0011.c +++ b/app/common/rc_cu_0011.c @@ -6,32 +6,39 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 12개월 균등분할 잔액에 대한 단리 이자 합 */ long rc_cu_0011_fee(long amount, int rate_bp) { - long fee; + long total = 0, principal; + int m; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + principal = amount / 12; + for (m = 1; m <= 12; m++) { + long bal = amount - principal * (m - 1); + total += bal * (long)rate_bp / 120000L; + } + return total; } -/* 절사(내림) 단위 정규화 */ +/* 잔돈 재분배 반올림: 잔여의 2배가 unit 이상이면 올림 */ long rc_cu_0011_round_unit(long amount, long unit) { + long base, rem; if (unit <= 0) return amount; - return (amount / unit) * unit; + base = (amount / unit) * unit; + rem = amount - base; + return (rem * 2 >= unit) ? base + unit : base; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 최상위(선두) 숫자 1~9 */ int rc_cu_0011_classify(long amount) { - if (amount < 10000L) + long v = amount < 0 ? -amount : amount; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; - return 2; + while (v >= 10) + v /= 10; + return (int)v; } diff --git a/app/common/st_cu_0001.c b/app/common/st_cu_0001.c index 0aae7c1..f3fa786 100644 --- a/app/common/st_cu_0001.c +++ b/app/common/st_cu_0001.c @@ -6,32 +6,49 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 슬랩(구간별 고정액) 수수료 테이블 조회 */ +static long st_cu_0001_slab(long a) +{ + static const long lim[4] = {10000L, 100000L, 1000000L, 10000000L}; + static const long fixed[5] = {100L, 500L, 2000L, 8000L, 30000L}; + int i; + for (i = 0; i < 4; i++) + if (a < lim[i]) + return fixed[i]; + return fixed[4]; +} + +/* 수수료: 슬랩 고정액 + 미세 요율 가산 */ long st_cu_0001_fee(long amount, int rate_bp) { - long fee; + long f; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + f = st_cu_0001_slab(amount); + f += amount * (long)rate_bp / 100000L; + return f; } -/* 절사(내림) 단위 정규화 */ +/* 가장 가까운 배수(반올림, 동점은 올림) */ long st_cu_0001_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount % unit; + if (r * 2 >= unit) + q++; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 통과한 임계 개수(0~5) */ int st_cu_0001_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long g[5] = {1000L, 10000L, 100000L, 1000000L, 10000000L}; + int i, c = 0; + for (i = 0; i < 5; i++) + if (amount >= g[i]) + c++; + return c; } diff --git a/app/common/st_cu_0002.c b/app/common/st_cu_0002.c index a68ffeb..ad5f015 100644 --- a/app/common/st_cu_0002.c +++ b/app/common/st_cu_0002.c @@ -6,32 +6,52 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* Luhn(mod-10) 체크섬 계산: 우대카드 판별용 */ +static int st_cu_0002_luhn(long v) +{ + int sum = 0, alt = 0; + if (v < 0) v = -v; + while (v > 0) { + int d = (int)(v % 10); + if (alt) { d *= 2; if (d > 9) d -= 9; } + sum += d; + alt = !alt; + v /= 10; + } + return sum % 10; +} + +/* 수수료: Luhn 체크섬이 0(정상 카드)이면 면제, 그 외 정률 */ long st_cu_0002_fee(long amount, int rate_bp) { - long fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + if (st_cu_0002_luhn(amount) == 0) + return 0; + return (amount * (long)rate_bp) / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(round-half-up) 단위 정규화 */ long st_cu_0002_round_unit(long amount, long unit) { + long r, half; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + half = unit / 2; + amount -= r; + if (r >= half) + amount += unit; + return amount; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 10진 자릿수 개수 반환 */ int st_cu_0002_classify(long amount) { - if (amount < 10000L) + int digits = 0; + long v = amount < 0 ? -amount : amount; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; - return 2; + while (v > 0) { digits++; v /= 10; } + return digits; } diff --git a/app/common/st_cu_0003.c b/app/common/st_cu_0003.c index 13d7cab..62e885c 100644 --- a/app/common/st_cu_0003.c +++ b/app/common/st_cu_0003.c @@ -6,32 +6,54 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* BIN 범위 조회: 카드 앞 6자리 → 등급 */ +static int st_cu_0003_bin_grade(long n) +{ + static const long lo[3] = {400000L, 510000L, 600000L}; + static const long hi[3] = {499999L, 559999L, 699999L}; + long bin = n < 0 ? -n : n; + int i; + while (bin >= 1000000L) + bin /= 10; + for (i = 0; i < 3; i++) + if (bin >= lo[i] && bin <= hi[i]) + return i + 1; + return 0; +} + +/* 수수료: 카드 등급별 가산 bp 적용 */ long st_cu_0003_fee(long amount, int rate_bp) { - long fee; + int g; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + g = st_cu_0003_bin_grade(amount); + rate_bp += g * 5; + return (amount * (long)rate_bp) / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 올림(ceil) 단위 정규화 */ long st_cu_0003_round_unit(long amount, long unit) { + long r; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + if (r == 0) + return amount; + if (r < 0) + return amount - r; + return amount + (unit - r); } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 퍼센타일 경계 버킷(0~9) */ int st_cu_0003_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long b[9] = {1000L, 5000L, 10000L, 50000L, 100000L, + 500000L, 1000000L, 5000000L, 10000000L}; + int i; + for (i = 0; i < 9; i++) + if (amount < b[i]) + return i; + return 9; } diff --git a/app/common/st_cu_0004.c b/app/common/st_cu_0004.c index 252e765..8d81fa2 100644 --- a/app/common/st_cu_0004.c +++ b/app/common/st_cu_0004.c @@ -6,32 +6,53 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* Zeller 합동식으로 요일 계산: 0=토,1=일,...,6=금 */ +static int st_cu_0004_dow(int y, int m, int d) +{ + int k, j; + if (m < 3) { m += 12; y--; } + k = y % 100; + j = y / 100; + return (d + 13 * (m + 1) / 5 + k + k / 4 + j / 4 + 5 * j) % 7; +} + +/* 수수료: amount=YYYYMMDD, 주말이면 할증 rate 반환 */ long st_cu_0004_fee(long amount, int rate_bp) { - long fee; + int y, m, d, w; + long base; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + w = st_cu_0004_dow(y, m, d); + base = rate_bp; + if (w == 0 || w == 1) + base += (long)rate_bp / 10; + return base; } -/* 절사(내림) 단위 정규화 */ +/* 내림(floor) 단위 정규화: 음수 방향 보정 */ long st_cu_0004_round_unit(long amount, long unit) { + long q; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + if (amount % unit != 0 && amount < 0) + q--; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: YYYYMMDD 의 요일(0~6), 오류 -1 */ int st_cu_0004_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int y, m, d; + if (amount <= 0) + return -1; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + return st_cu_0004_dow(y, m, d); } diff --git a/app/common/st_cu_0005.c b/app/common/st_cu_0005.c index 6536e80..49e2208 100644 --- a/app/common/st_cu_0005.c +++ b/app/common/st_cu_0005.c @@ -6,32 +6,45 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 뱅커스 반올림(사사오입): num/den 을 최근접 정수로, 동점은 짝수 */ +static long st_cu_0005_bankers(long num, long den) +{ + long q = num / den; + long r = num % den; + long twice = 2 * (r < 0 ? -r : r); + long ad = den < 0 ? -den : den; + if (twice > ad) + q += (num < 0 ? -1 : 1); + else if (twice == ad && (q % 2 != 0)) + q += (num < 0 ? -1 : 1); + return q; +} + +/* 수수료: 초과분에만 요율 적용하는 누진 구간 */ long st_cu_0005_fee(long amount, int rate_bp) { - long fee; + long fee = 0, a = amount; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + if (a > 1000000L) { fee += (a - 1000000L) * (long)rate_bp / 10000L; a = 1000000L; } + if (a > 100000L) { fee += (a - 100000L) * (long)(rate_bp + 10) / 10000L; a = 100000L; } + fee += a * (long)(rate_bp + 20) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 뱅커스 반올림 단위 정규화 */ long st_cu_0005_round_unit(long amount, long unit) { if (unit <= 0) return amount; - return (amount / unit) * unit; + return st_cu_0005_bankers(amount, unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 10의 거듭제곱 지수(로그10 정수부) */ int st_cu_0005_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int e = 0; + long v = amount < 0 ? -amount : amount; + while (v >= 10) { v /= 10; e++; } + return e; } diff --git a/app/common/st_cu_0006.c b/app/common/st_cu_0006.c index 1f32b00..ec2c95b 100644 --- a/app/common/st_cu_0006.c +++ b/app/common/st_cu_0006.c @@ -6,32 +6,49 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* CRC-8(다항식 0x07) 계산: 고정길이 필드 무결성 */ +static unsigned st_cu_0006_crc8(const char *s, int n) +{ + unsigned crc = 0; + int i, b; + for (i = 0; i < n; i++) { + crc ^= (unsigned char)s[i]; + for (b = 0; b < 8; b++) + crc = (crc & 0x80) ? ((crc << 1) ^ 0x07) & 0xFF : (crc << 1) & 0xFF; + } + return crc & 0xFF; +} + +/* 수수료: 금액을 12자리 고정필드로 pack 후 CRC 가산 */ long st_cu_0006_fee(long amount, int rate_bp) { - long fee; + char buf[16]; + long v = amount < 0 ? 0 : amount; + int i; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + for (i = 11; i >= 0; i--) { buf[i] = (char)('0' + (int)(v % 10)); v /= 10; } + buf[12] = '\0'; + return (amount * (long)rate_bp) / 10000L + (long)st_cu_0006_crc8(buf, 12); } -/* 절사(내림) 단위 정규화 */ +/* 최근접 배수 반올림(round-half-away-from-zero) */ long st_cu_0006_round_unit(long amount, long unit) { + long r, h; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + h = (unit + 1) / 2; + if (r < 0) + return (-r >= h) ? amount - (unit + r) : amount - r; + return (r >= h) ? amount + (unit - r) : amount - r; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 부호·홀짝 조합 4가지 */ int st_cu_0006_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int s = amount < 0 ? 2 : 0; + int p = (amount % 2 != 0) ? 1 : 0; + return s + p; } diff --git a/app/common/st_cu_0007.c b/app/common/st_cu_0007.c index 102a37f..a573296 100644 --- a/app/common/st_cu_0007.c +++ b/app/common/st_cu_0007.c @@ -6,32 +6,39 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 12개월 균등분할 잔액에 대한 단리 이자 합 */ long st_cu_0007_fee(long amount, int rate_bp) { - long fee; + long total = 0, principal; + int m; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + principal = amount / 12; + for (m = 1; m <= 12; m++) { + long bal = amount - principal * (m - 1); + total += bal * (long)rate_bp / 120000L; + } + return total; } -/* 절사(내림) 단위 정규화 */ +/* 잔돈 재분배 반올림: 잔여의 2배가 unit 이상이면 올림 */ long st_cu_0007_round_unit(long amount, long unit) { + long base, rem; if (unit <= 0) return amount; - return (amount / unit) * unit; + base = (amount / unit) * unit; + rem = amount - base; + return (rem * 2 >= unit) ? base + unit : base; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 최상위(선두) 숫자 1~9 */ int st_cu_0007_classify(long amount) { - if (amount < 10000L) + long v = amount < 0 ? -amount : amount; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; - return 2; + while (v >= 10) + v /= 10; + return (int)v; } diff --git a/app/common/st_cu_0008.c b/app/common/st_cu_0008.c index 3883b8c..8ad5094 100644 --- a/app/common/st_cu_0008.c +++ b/app/common/st_cu_0008.c @@ -6,32 +6,33 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 소수 2자리 스케일로 확대 후 요율 적용, 원 단위 복귀 */ long st_cu_0008_fee(long amount, int rate_bp) { - long fee; + long scaled, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + scaled = amount * 100L; + fee = scaled * (long)rate_bp / 10000L; + return fee / 100L; } -/* 절사(내림) 단위 정규화 */ +/* 단위가 2의 거듭제곱이면 비트마스크 정렬, 아니면 일반 절사 */ long st_cu_0008_round_unit(long amount, long unit) { if (unit <= 0) return amount; + if ((unit & (unit - 1)) == 0) + return amount & ~(unit - 1); return (amount / unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 금액 구간 비트맵 플래그(bit0=만,bit1=십만,bit2=백만) */ int st_cu_0008_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int f = 0; + if (amount >= 10000L) f |= 1; + if (amount >= 100000L) f |= 2; + if (amount >= 1000000L) f |= 4; + return f; } diff --git a/app/common/st_cu_0009.c b/app/common/st_cu_0009.c index fe7706b..0ad372d 100644 --- a/app/common/st_cu_0009.c +++ b/app/common/st_cu_0009.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 금액 구간별 요율을 선형보간하여 적용 */ long st_cu_0009_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + static const long x[4] = {0L, 100000L, 1000000L, 10000000L}; + static const long y[4] = {30L, 20L, 10L, 5L}; + long r = rate_bp; + int i; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + for (i = 0; i < 3; i++) { + if (amount <= x[i + 1]) { + long span = x[i + 1] - x[i]; + r = y[i] + (y[i + 1] - y[i]) * (amount - x[i]) / span; + break; + } + } + return amount * r / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 5사6입: 잔여가 unit 의 60% 이상일 때만 올림 */ long st_cu_0009_round_unit(long amount, long unit) { + long r; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + return (r * 10 >= unit * 6) ? amount + (unit - r) : amount - r; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 이진탐색으로 경계 버킷 결정 */ int st_cu_0009_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long b[7] = {5000L, 20000L, 50000L, 200000L, + 500000L, 2000000L, 5000000L}; + int lo = 0, hi = 7, mid; + while (lo < hi) { + mid = (lo + hi) / 2; + if (amount < b[mid]) hi = mid; else lo = mid + 1; + } + return lo; } diff --git a/app/common/st_cu_0010.c b/app/common/st_cu_0010.c index 5be27e7..416f9c6 100644 --- a/app/common/st_cu_0010.c +++ b/app/common/st_cu_0010.c @@ -6,19 +6,35 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ -long st_cu_0010_fee(long amount, int rate_bp) +/* 그레고리력 → 율리우스일수 근사 변환 */ +static long st_cu_0010_jdn(int y, int m, int d) { - long fee; - if (amount <= 0 || rate_bp < 0) - return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + long a = (14 - m) / 12; + long yy = y + 4800 - a; + long mm = m + 12 * a - 3; + return d + (153 * mm + 2) / 5 + 365 * yy + yy / 4 - yy / 100 + yy / 400 - 32045; } -/* 절사(내림) 단위 정규화 */ +/* 수수료: amount=YYYYMMDD 에 rate_bp 영업일 더한 율리우스일 반환 */ +long st_cu_0010_fee(long amount, int rate_bp) +{ + int y, m, d, added = 0; + long jd; + if (amount <= 0) + return 0; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + jd = st_cu_0010_jdn(y, m, d); + while (added < rate_bp) { + jd++; + if (jd % 7 != 5 && jd % 7 != 6) + added++; + } + return jd; +} + +/* 0 방향 대칭 절사(truncate toward zero) */ long st_cu_0010_round_unit(long amount, long unit) { if (unit <= 0) @@ -26,12 +42,15 @@ long st_cu_0010_round_unit(long amount, long unit) return (amount / unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: FNV-1a 해시의 하위 3비트 */ int st_cu_0010_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + unsigned long h = 2166136261UL; + long v = amount < 0 ? -amount : amount; + do { + h ^= (unsigned long)(v % 10); + h *= 16777619UL; + v /= 10; + } while (v > 0); + return (int)(h & 0x7UL); } diff --git a/app/common/st_cu_0011.c b/app/common/st_cu_0011.c index 192a97c..63f6944 100644 --- a/app/common/st_cu_0011.c +++ b/app/common/st_cu_0011.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 디지털 루트(각 자리 합 반복) 계산 */ +static int st_cu_0011_droot(long v) +{ + if (v < 0) v = -v; + while (v >= 10) { + long s = 0; + while (v > 0) { s += v % 10; v /= 10; } + v = s; + } + return (int)v; +} + +/* 수수료: 정률 계산 후 상한(cap) 적용 */ long st_cu_0011_fee(long amount, int rate_bp) { - long fee; + long fee, cap = 50000L; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + fee = amount * (long)rate_bp / 10000L; + if (fee > cap) + fee = cap; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 이중 절사: 1차 절사 후 잔여 2/3 이상이면 한 단위 보정 */ long st_cu_0011_round_unit(long amount, long unit) { + long f1; if (unit <= 0) return amount; - return (amount / unit) * unit; + f1 = (amount / unit) * unit; + if ((amount - f1) * 3 >= unit * 2) + f1 += unit; + return f1; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 디지털 루트(1~9, 0) */ int st_cu_0011_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + return st_cu_0011_droot(amount); } diff --git a/app/common/vl_cu_0001.c b/app/common/vl_cu_0001.c index 95215b2..509e199 100644 --- a/app/common/vl_cu_0001.c +++ b/app/common/vl_cu_0001.c @@ -6,19 +6,35 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ -long vl_cu_0001_fee(long amount, int rate_bp) +/* 그레고리력 → 율리우스일수 근사 변환 */ +static long vl_cu_0001_jdn(int y, int m, int d) { - long fee; - if (amount <= 0 || rate_bp < 0) - return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + long a = (14 - m) / 12; + long yy = y + 4800 - a; + long mm = m + 12 * a - 3; + return d + (153 * mm + 2) / 5 + 365 * yy + yy / 4 - yy / 100 + yy / 400 - 32045; } -/* 절사(내림) 단위 정규화 */ +/* 수수료: amount=YYYYMMDD 에 rate_bp 영업일 더한 율리우스일 반환 */ +long vl_cu_0001_fee(long amount, int rate_bp) +{ + int y, m, d, added = 0; + long jd; + if (amount <= 0) + return 0; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + jd = vl_cu_0001_jdn(y, m, d); + while (added < rate_bp) { + jd++; + if (jd % 7 != 5 && jd % 7 != 6) + added++; + } + return jd; +} + +/* 0 방향 대칭 절사(truncate toward zero) */ long vl_cu_0001_round_unit(long amount, long unit) { if (unit <= 0) @@ -26,12 +42,15 @@ long vl_cu_0001_round_unit(long amount, long unit) return (amount / unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: FNV-1a 해시의 하위 3비트 */ int vl_cu_0001_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + unsigned long h = 2166136261UL; + long v = amount < 0 ? -amount : amount; + do { + h ^= (unsigned long)(v % 10); + h *= 16777619UL; + v /= 10; + } while (v > 0); + return (int)(h & 0x7UL); } diff --git a/app/common/vl_cu_0002.c b/app/common/vl_cu_0002.c index 2acf65d..88c094f 100644 --- a/app/common/vl_cu_0002.c +++ b/app/common/vl_cu_0002.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 디지털 루트(각 자리 합 반복) 계산 */ +static int vl_cu_0002_droot(long v) +{ + if (v < 0) v = -v; + while (v >= 10) { + long s = 0; + while (v > 0) { s += v % 10; v /= 10; } + v = s; + } + return (int)v; +} + +/* 수수료: 정률 계산 후 상한(cap) 적용 */ long vl_cu_0002_fee(long amount, int rate_bp) { - long fee; + long fee, cap = 50000L; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + fee = amount * (long)rate_bp / 10000L; + if (fee > cap) + fee = cap; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 이중 절사: 1차 절사 후 잔여 2/3 이상이면 한 단위 보정 */ long vl_cu_0002_round_unit(long amount, long unit) { + long f1; if (unit <= 0) return amount; - return (amount / unit) * unit; + f1 = (amount / unit) * unit; + if ((amount - f1) * 3 >= unit * 2) + f1 += unit; + return f1; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 디지털 루트(1~9, 0) */ int vl_cu_0002_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + return vl_cu_0002_droot(amount); } diff --git a/app/common/vl_cu_0003.c b/app/common/vl_cu_0003.c index fb956c6..8d7583d 100644 --- a/app/common/vl_cu_0003.c +++ b/app/common/vl_cu_0003.c @@ -6,32 +6,49 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 슬랩(구간별 고정액) 수수료 테이블 조회 */ +static long vl_cu_0003_slab(long a) +{ + static const long lim[4] = {10000L, 100000L, 1000000L, 10000000L}; + static const long fixed[5] = {100L, 500L, 2000L, 8000L, 30000L}; + int i; + for (i = 0; i < 4; i++) + if (a < lim[i]) + return fixed[i]; + return fixed[4]; +} + +/* 수수료: 슬랩 고정액 + 미세 요율 가산 */ long vl_cu_0003_fee(long amount, int rate_bp) { - long fee; + long f; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + f = vl_cu_0003_slab(amount); + f += amount * (long)rate_bp / 100000L; + return f; } -/* 절사(내림) 단위 정규화 */ +/* 가장 가까운 배수(반올림, 동점은 올림) */ long vl_cu_0003_round_unit(long amount, long unit) { + long q, r; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + r = amount % unit; + if (r * 2 >= unit) + q++; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 통과한 임계 개수(0~5) */ int vl_cu_0003_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long g[5] = {1000L, 10000L, 100000L, 1000000L, 10000000L}; + int i, c = 0; + for (i = 0; i < 5; i++) + if (amount >= g[i]) + c++; + return c; } diff --git a/app/common/vl_cu_0004.c b/app/common/vl_cu_0004.c index 1478bfc..9e9fcbd 100644 --- a/app/common/vl_cu_0004.c +++ b/app/common/vl_cu_0004.c @@ -6,32 +6,52 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* Luhn(mod-10) 체크섬 계산: 우대카드 판별용 */ +static int vl_cu_0004_luhn(long v) +{ + int sum = 0, alt = 0; + if (v < 0) v = -v; + while (v > 0) { + int d = (int)(v % 10); + if (alt) { d *= 2; if (d > 9) d -= 9; } + sum += d; + alt = !alt; + v /= 10; + } + return sum % 10; +} + +/* 수수료: Luhn 체크섬이 0(정상 카드)이면 면제, 그 외 정률 */ long vl_cu_0004_fee(long amount, int rate_bp) { - long fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + if (vl_cu_0004_luhn(amount) == 0) + return 0; + return (amount * (long)rate_bp) / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 반올림(round-half-up) 단위 정규화 */ long vl_cu_0004_round_unit(long amount, long unit) { + long r, half; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + half = unit / 2; + amount -= r; + if (r >= half) + amount += unit; + return amount; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 10진 자릿수 개수 반환 */ int vl_cu_0004_classify(long amount) { - if (amount < 10000L) + int digits = 0; + long v = amount < 0 ? -amount : amount; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; - return 2; + while (v > 0) { digits++; v /= 10; } + return digits; } diff --git a/app/common/vl_cu_0005.c b/app/common/vl_cu_0005.c index a129df5..e5fc021 100644 --- a/app/common/vl_cu_0005.c +++ b/app/common/vl_cu_0005.c @@ -6,32 +6,54 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* BIN 범위 조회: 카드 앞 6자리 → 등급 */ +static int vl_cu_0005_bin_grade(long n) +{ + static const long lo[3] = {400000L, 510000L, 600000L}; + static const long hi[3] = {499999L, 559999L, 699999L}; + long bin = n < 0 ? -n : n; + int i; + while (bin >= 1000000L) + bin /= 10; + for (i = 0; i < 3; i++) + if (bin >= lo[i] && bin <= hi[i]) + return i + 1; + return 0; +} + +/* 수수료: 카드 등급별 가산 bp 적용 */ long vl_cu_0005_fee(long amount, int rate_bp) { - long fee; + int g; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + g = vl_cu_0005_bin_grade(amount); + rate_bp += g * 5; + return (amount * (long)rate_bp) / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 올림(ceil) 단위 정규화 */ long vl_cu_0005_round_unit(long amount, long unit) { + long r; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + if (r == 0) + return amount; + if (r < 0) + return amount - r; + return amount + (unit - r); } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 퍼센타일 경계 버킷(0~9) */ int vl_cu_0005_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long b[9] = {1000L, 5000L, 10000L, 50000L, 100000L, + 500000L, 1000000L, 5000000L, 10000000L}; + int i; + for (i = 0; i < 9; i++) + if (amount < b[i]) + return i; + return 9; } diff --git a/app/common/vl_cu_0006.c b/app/common/vl_cu_0006.c index b29fc2e..274f1c3 100644 --- a/app/common/vl_cu_0006.c +++ b/app/common/vl_cu_0006.c @@ -6,32 +6,53 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* Zeller 합동식으로 요일 계산: 0=토,1=일,...,6=금 */ +static int vl_cu_0006_dow(int y, int m, int d) +{ + int k, j; + if (m < 3) { m += 12; y--; } + k = y % 100; + j = y / 100; + return (d + 13 * (m + 1) / 5 + k + k / 4 + j / 4 + 5 * j) % 7; +} + +/* 수수료: amount=YYYYMMDD, 주말이면 할증 rate 반환 */ long vl_cu_0006_fee(long amount, int rate_bp) { - long fee; + int y, m, d, w; + long base; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + w = vl_cu_0006_dow(y, m, d); + base = rate_bp; + if (w == 0 || w == 1) + base += (long)rate_bp / 10; + return base; } -/* 절사(내림) 단위 정규화 */ +/* 내림(floor) 단위 정규화: 음수 방향 보정 */ long vl_cu_0006_round_unit(long amount, long unit) { + long q; if (unit <= 0) return amount; - return (amount / unit) * unit; + q = amount / unit; + if (amount % unit != 0 && amount < 0) + q--; + return q * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: YYYYMMDD 의 요일(0~6), 오류 -1 */ int vl_cu_0006_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int y, m, d; + if (amount <= 0) + return -1; + y = (int)(amount / 10000L); + m = (int)((amount / 100L) % 100L); + d = (int)(amount % 100L); + return vl_cu_0006_dow(y, m, d); } diff --git a/app/common/vl_cu_0007.c b/app/common/vl_cu_0007.c index 329c9c7..2e378ec 100644 --- a/app/common/vl_cu_0007.c +++ b/app/common/vl_cu_0007.c @@ -6,32 +6,45 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 뱅커스 반올림(사사오입): num/den 을 최근접 정수로, 동점은 짝수 */ +static long vl_cu_0007_bankers(long num, long den) +{ + long q = num / den; + long r = num % den; + long twice = 2 * (r < 0 ? -r : r); + long ad = den < 0 ? -den : den; + if (twice > ad) + q += (num < 0 ? -1 : 1); + else if (twice == ad && (q % 2 != 0)) + q += (num < 0 ? -1 : 1); + return q; +} + +/* 수수료: 초과분에만 요율 적용하는 누진 구간 */ long vl_cu_0007_fee(long amount, int rate_bp) { - long fee; + long fee = 0, a = amount; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; + if (a > 1000000L) { fee += (a - 1000000L) * (long)rate_bp / 10000L; a = 1000000L; } + if (a > 100000L) { fee += (a - 100000L) * (long)(rate_bp + 10) / 10000L; a = 100000L; } + fee += a * (long)(rate_bp + 20) / 10000L; return fee; } -/* 절사(내림) 단위 정규화 */ +/* 뱅커스 반올림 단위 정규화 */ long vl_cu_0007_round_unit(long amount, long unit) { if (unit <= 0) return amount; - return (amount / unit) * unit; + return vl_cu_0007_bankers(amount, unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 10의 거듭제곱 지수(로그10 정수부) */ int vl_cu_0007_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int e = 0; + long v = amount < 0 ? -amount : amount; + while (v >= 10) { v /= 10; e++; } + return e; } diff --git a/app/common/vl_cu_0008.c b/app/common/vl_cu_0008.c index 4b2b6c8..5c4f760 100644 --- a/app/common/vl_cu_0008.c +++ b/app/common/vl_cu_0008.c @@ -6,32 +6,49 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* CRC-8(다항식 0x07) 계산: 고정길이 필드 무결성 */ +static unsigned vl_cu_0008_crc8(const char *s, int n) +{ + unsigned crc = 0; + int i, b; + for (i = 0; i < n; i++) { + crc ^= (unsigned char)s[i]; + for (b = 0; b < 8; b++) + crc = (crc & 0x80) ? ((crc << 1) ^ 0x07) & 0xFF : (crc << 1) & 0xFF; + } + return crc & 0xFF; +} + +/* 수수료: 금액을 12자리 고정필드로 pack 후 CRC 가산 */ long vl_cu_0008_fee(long amount, int rate_bp) { - long fee; + char buf[16]; + long v = amount < 0 ? 0 : amount; + int i; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + for (i = 11; i >= 0; i--) { buf[i] = (char)('0' + (int)(v % 10)); v /= 10; } + buf[12] = '\0'; + return (amount * (long)rate_bp) / 10000L + (long)vl_cu_0008_crc8(buf, 12); } -/* 절사(내림) 단위 정규화 */ +/* 최근접 배수 반올림(round-half-away-from-zero) */ long vl_cu_0008_round_unit(long amount, long unit) { + long r, h; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + h = (unit + 1) / 2; + if (r < 0) + return (-r >= h) ? amount - (unit + r) : amount - r; + return (r >= h) ? amount + (unit - r) : amount - r; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 부호·홀짝 조합 4가지 */ int vl_cu_0008_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int s = amount < 0 ? 2 : 0; + int p = (amount % 2 != 0) ? 1 : 0; + return s + p; } diff --git a/app/common/vl_cu_0009.c b/app/common/vl_cu_0009.c index 6288f0c..6b32bd5 100644 --- a/app/common/vl_cu_0009.c +++ b/app/common/vl_cu_0009.c @@ -6,32 +6,39 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 12개월 균등분할 잔액에 대한 단리 이자 합 */ long vl_cu_0009_fee(long amount, int rate_bp) { - long fee; + long total = 0, principal; + int m; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + principal = amount / 12; + for (m = 1; m <= 12; m++) { + long bal = amount - principal * (m - 1); + total += bal * (long)rate_bp / 120000L; + } + return total; } -/* 절사(내림) 단위 정규화 */ +/* 잔돈 재분배 반올림: 잔여의 2배가 unit 이상이면 올림 */ long vl_cu_0009_round_unit(long amount, long unit) { + long base, rem; if (unit <= 0) return amount; - return (amount / unit) * unit; + base = (amount / unit) * unit; + rem = amount - base; + return (rem * 2 >= unit) ? base + unit : base; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 최상위(선두) 숫자 1~9 */ int vl_cu_0009_classify(long amount) { - if (amount < 10000L) + long v = amount < 0 ? -amount : amount; + if (v == 0) return 0; - if (amount < 1000000L) - return 1; - return 2; + while (v >= 10) + v /= 10; + return (int)v; } diff --git a/app/common/vl_cu_0010.c b/app/common/vl_cu_0010.c index 78d91ab..82b90be 100644 --- a/app/common/vl_cu_0010.c +++ b/app/common/vl_cu_0010.c @@ -6,32 +6,33 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 소수 2자리 스케일로 확대 후 요율 적용, 원 단위 복귀 */ long vl_cu_0010_fee(long amount, int rate_bp) { - long fee; + long scaled, fee; if (amount <= 0 || rate_bp < 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + scaled = amount * 100L; + fee = scaled * (long)rate_bp / 10000L; + return fee / 100L; } -/* 절사(내림) 단위 정규화 */ +/* 단위가 2의 거듭제곱이면 비트마스크 정렬, 아니면 일반 절사 */ long vl_cu_0010_round_unit(long amount, long unit) { if (unit <= 0) return amount; + if ((unit & (unit - 1)) == 0) + return amount & ~(unit - 1); return (amount / unit) * unit; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 금액 구간 비트맵 플래그(bit0=만,bit1=십만,bit2=백만) */ int vl_cu_0010_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + int f = 0; + if (amount >= 10000L) f |= 1; + if (amount >= 100000L) f |= 2; + if (amount >= 1000000L) f |= 4; + return f; } diff --git a/app/common/vl_cu_0011.c b/app/common/vl_cu_0011.c index 985db9b..8f7e5aa 100644 --- a/app/common/vl_cu_0011.c +++ b/app/common/vl_cu_0011.c @@ -6,32 +6,44 @@ #include -/* 수수료 계산: rate_bp 는 basis point(1bp=0.01%) */ +/* 수수료: 금액 구간별 요율을 선형보간하여 적용 */ long vl_cu_0011_fee(long amount, int rate_bp) { - long fee; - if (amount <= 0 || rate_bp < 0) + static const long x[4] = {0L, 100000L, 1000000L, 10000000L}; + static const long y[4] = {30L, 20L, 10L, 5L}; + long r = rate_bp; + int i; + if (amount <= 0) return 0; - fee = (amount * (long)rate_bp) / 10000L; - if (fee < 0) - fee = 0; - return fee; + for (i = 0; i < 3; i++) { + if (amount <= x[i + 1]) { + long span = x[i + 1] - x[i]; + r = y[i] + (y[i + 1] - y[i]) * (amount - x[i]) / span; + break; + } + } + return amount * r / 10000L; } -/* 절사(내림) 단위 정규화 */ +/* 5사6입: 잔여가 unit 의 60% 이상일 때만 올림 */ long vl_cu_0011_round_unit(long amount, long unit) { + long r; if (unit <= 0) return amount; - return (amount / unit) * unit; + r = amount % unit; + return (r * 10 >= unit * 6) ? amount + (unit - r) : amount - r; } -/* 금액 구간 분류: 0=소액 1=일반 2=고액 */ +/* 분류: 이진탐색으로 경계 버킷 결정 */ int vl_cu_0011_classify(long amount) { - if (amount < 10000L) - return 0; - if (amount < 1000000L) - return 1; - return 2; + static const long b[7] = {5000L, 20000L, 50000L, 200000L, + 500000L, 2000000L, 5000000L}; + int lo = 0, hi = 7, mid; + while (lo < hi) { + mid = (lo + hi) / 2; + if (amount < b[mid]) hi = mid; else lo = mid + 1; + } + return lo; } diff --git a/app/dbio/ac_io_0001.c b/app/dbio/ac_io_0001.c index 85e0ebb..7a8bfe9 100644 --- a/app/dbio/ac_io_0001.c +++ b/app/dbio/ac_io_0001.c @@ -110,7 +110,7 @@ int ac_io_0001_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0001_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt from ac_io_0001_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), @@ -150,7 +150,7 @@ int ac_io_0001_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0001_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0001_t set appr_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), @@ -188,7 +188,7 @@ long ac_io_0001_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0001_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( appr_amt ) , 0 ) from ac_io_0001_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), @@ -202,3 +202,4 @@ long ac_io_0001_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0001.pgc b/app/dbio/ac_io_0001.pgc index 0b97266..54c8f43 100644 --- a/app/dbio/ac_io_0001.pgc +++ b/app/dbio/ac_io_0001.pgc @@ -24,10 +24,10 @@ int ac_io_0001_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT appr_amt INTO :h_amount FROM ac_io_0001_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +54,8 @@ int ac_io_0001_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE ac_io_0001_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET appr_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0001_touch"); @@ -79,7 +79,7 @@ long ac_io_0001_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(appr_amt), 0) INTO :h_sum FROM ac_io_0001_t WHERE biz_date = :h_biz_date; @@ -90,3 +90,4 @@ long ac_io_0001_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0002.c b/app/dbio/ac_io_0002.c index a4f09c3..0bf301f 100644 --- a/app/dbio/ac_io_0002.c +++ b/app/dbio/ac_io_0002.c @@ -94,14 +94,22 @@ int ac_io_0002_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + + #line 17 "app/dbio/ac_io_0002.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/ac_io_0002.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_appr ; + #line 19 "app/dbio/ac_io_0002.pgc" + long h_fee ; + +#line 20 "app/dbio/ac_io_0002.pgc" + long h_vat ; +/* exec sql end declare section */ +#line 21 "app/dbio/ac_io_0002.pgc" if (!key || !out_amount) @@ -110,12 +118,16 @@ int ac_io_0002_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0002_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt , fee_amt , vat_amt from ac_io_0002_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_appr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_vat),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0002.pgc" +#line 32 "app/dbio/ac_io_0002.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +136,7 @@ int ac_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -134,13 +146,13 @@ int ac_io_0002_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0002.pgc" +#line 47 "app/dbio/ac_io_0002.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0002.pgc" +#line 48 "app/dbio/ac_io_0002.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0002.pgc" +#line 49 "app/dbio/ac_io_0002.pgc" if (!key) @@ -150,12 +162,12 @@ int ac_io_0002_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0002_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0002_t set net_amt = $1 , upd_ts = now ( ) where mcht_no = $2 and status_cd = '00' and appr_amt > 0", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0002.pgc" +#line 60 "app/dbio/ac_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +185,13 @@ long ac_io_0002_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0002.pgc" +#line 74 "app/dbio/ac_io_0002.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0002.pgc" - long h_sum ; +#line 75 "app/dbio/ac_io_0002.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0002.pgc" +#line 76 "app/dbio/ac_io_0002.pgc" if (!biz_date) @@ -188,17 +200,18 @@ long ac_io_0002_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0002_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from ac_io_0002_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0002.pgc" +#line 87 "app/dbio/ac_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/ac_io_0002.pgc b/app/dbio/ac_io_0002.pgc index ea27348..fb4a493 100644 --- a/app/dbio/ac_io_0002.pgc +++ b/app/dbio/ac_io_0002.pgc @@ -15,7 +15,9 @@ int ac_io_0002_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; - long h_amount; + long h_appr; + long h_fee; + long h_vat; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +26,10 @@ int ac_io_0002_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM ac_io_0002_t - WHERE key = :h_key; + EXEC SQL SELECT appr_amt, fee_amt, vat_amt + INTO :h_appr, :h_fee, :h_vat + FROM ac_io_0002_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,7 +37,7 @@ int ac_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -54,8 +56,8 @@ int ac_io_0002_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE ac_io_0002_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET net_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key AND status_cd = '00' AND appr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0002_touch"); @@ -70,7 +72,7 @@ long ac_io_0002_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,8 +81,8 @@ long ac_io_0002_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_cnt FROM ac_io_0002_t WHERE biz_date = :h_biz_date; @@ -88,5 +90,6 @@ long ac_io_0002_total(const char *biz_date) TX_DBIO_LOG_ERR("ac_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/ac_io_0003.c b/app/dbio/ac_io_0003.c index 519ba28..c843eac 100644 --- a/app/dbio/ac_io_0003.c +++ b/app/dbio/ac_io_0003.c @@ -110,12 +110,12 @@ int ac_io_0003_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0003_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select h . net_amt from ac_io_0003_t h join ac_io_0003_map_t m on m . mcht_no = h . mcht_no where h . mcht_no = $1 and m . use_yn = 'Y'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0003.pgc" +#line 31 "app/dbio/ac_io_0003.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int ac_io_0003_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0003.pgc" +#line 46 "app/dbio/ac_io_0003.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0003.pgc" +#line 47 "app/dbio/ac_io_0003.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0003.pgc" +#line 48 "app/dbio/ac_io_0003.pgc" if (!key) @@ -150,10 +150,10 @@ int ac_io_0003_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0003_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into ac_io_0003_log_t ( mcht_no , appr_amt , reg_ts ) values ( $1 , $2 , now ( ) )", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} #line 58 "app/dbio/ac_io_0003.pgc" @@ -162,8 +162,6 @@ int ac_io_0003_touch(const char *key, long amount) TX_DBIO_LOG_ERR("ac_io_0003_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -172,14 +170,18 @@ long ac_io_0003_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/ac_io_0003.pgc" +#line 70 "app/dbio/ac_io_0003.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0003.pgc" - long h_sum ; +#line 71 "app/dbio/ac_io_0003.pgc" + long h_avg ; + +#line 72 "app/dbio/ac_io_0003.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0003.pgc" +#line 73 "app/dbio/ac_io_0003.pgc" if (!biz_date) @@ -188,17 +190,20 @@ long ac_io_0003_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0003_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select avg ( appr_amt ) from ac_io_0003_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0003.pgc" + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 84 "app/dbio/ac_io_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0003_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/ac_io_0003.pgc b/app/dbio/ac_io_0003.pgc index 1b50125..d6a75b6 100644 --- a/app/dbio/ac_io_0003.pgc +++ b/app/dbio/ac_io_0003.pgc @@ -24,10 +24,11 @@ int ac_io_0003_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT h.net_amt INTO :h_amount - FROM ac_io_0003_t - WHERE key = :h_key; + FROM ac_io_0003_t h + JOIN ac_io_0003_map_t m ON m.mcht_no = h.mcht_no + WHERE h.mcht_no = :h_key AND m.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,16 +54,13 @@ int ac_io_0003_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE ac_io_0003_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL INSERT INTO ac_io_0003_log_t (mcht_no, appr_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0003_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -70,7 +68,8 @@ long ac_io_0003_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_avg; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +78,17 @@ long ac_io_0003_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM ac_io_0003_t + EXEC SQL SELECT avg(appr_amt) + INTO :h_avg :h_ind + FROM ac_io_0003_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0003_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/ac_io_0004.c b/app/dbio/ac_io_0004.c index 115b48e..36b8779 100644 --- a/app/dbio/ac_io_0004.c +++ b/app/dbio/ac_io_0004.c @@ -94,14 +94,18 @@ int ac_io_0004_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/ac_io_0004.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/ac_io_0004.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/ac_io_0004.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/ac_io_0004.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int ac_io_0004_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0004_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select bal_amt from ac_io_0004_bal_t where acct_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0004.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/ac_io_0004.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int ac_io_0004_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0004_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int ac_io_0004_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0004.pgc" +#line 48 "app/dbio/ac_io_0004.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0004.pgc" +#line 49 "app/dbio/ac_io_0004.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0004.pgc" +#line 50 "app/dbio/ac_io_0004.pgc" if (!key) @@ -150,20 +156,31 @@ int ac_io_0004_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0004_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0004_bal_t set bal_amt = $1 , upd_ts = now ( ) where acct_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0004.pgc" +#line 61 "app/dbio/ac_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into ac_io_0004_bal_t ( acct_no , bal_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 69 "app/dbio/ac_io_0004.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0004_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -173,13 +190,13 @@ long ac_io_0004_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0004.pgc" +#line 81 "app/dbio/ac_io_0004.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0004.pgc" +#line 82 "app/dbio/ac_io_0004.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0004.pgc" +#line 83 "app/dbio/ac_io_0004.pgc" if (!biz_date) @@ -188,17 +205,20 @@ long ac_io_0004_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0004_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( net_amt ) , 0 ) from ac_io_0004_t where biz_date = $1 group by biz_date having sum ( net_amt ) > 0 limit 1", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0004.pgc" +#line 97 "app/dbio/ac_io_0004.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0004_total"); return -1; } return h_sum; } + diff --git a/app/dbio/ac_io_0004.pgc b/app/dbio/ac_io_0004.pgc index 68e6dde..cd0a3af 100644 --- a/app/dbio/ac_io_0004.pgc +++ b/app/dbio/ac_io_0004.pgc @@ -16,6 +16,7 @@ int ac_io_0004_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int ac_io_0004_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM ac_io_0004_t - WHERE key = :h_key; + EXEC SQL SELECT bal_amt + INTO :h_amount :h_ind + FROM ac_io_0004_bal_t + WHERE acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int ac_io_0004_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0004_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -53,16 +56,22 @@ int ac_io_0004_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE ac_io_0004_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE ac_io_0004_bal_t + SET bal_amt = :h_amount, upd_ts = now() + WHERE acct_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + EXEC SQL INSERT INTO ac_io_0004_bal_t (acct_no, bal_amt, upd_ts) + VALUES (:h_key, :h_amount, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0004_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -79,14 +88,20 @@ long ac_io_0004_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(net_amt), 0) INTO :h_sum FROM ac_io_0004_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + GROUP BY biz_date + HAVING sum(net_amt) > 0 + LIMIT 1; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0004_total"); return -1; } return h_sum; } + diff --git a/app/dbio/ac_io_0005.c b/app/dbio/ac_io_0005.c index 05de785..21dc1dc 100644 --- a/app/dbio/ac_io_0005.c +++ b/app/dbio/ac_io_0005.c @@ -110,12 +110,12 @@ int ac_io_0005_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0005_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select req_amt from ac_io_0005_t where mcht_no = $1 and status_cd = '00' and cancel_yn = 'N'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0005.pgc" +#line 31 "app/dbio/ac_io_0005.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int ac_io_0005_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0005.pgc" +#line 46 "app/dbio/ac_io_0005.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0005.pgc" +#line 47 "app/dbio/ac_io_0005.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0005.pgc" +#line 48 "app/dbio/ac_io_0005.pgc" if (!key) @@ -150,9 +150,7 @@ int ac_io_0005_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0005_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from ac_io_0005_tmp_t where ref_key = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/ac_io_0005.pgc" @@ -172,14 +170,18 @@ long ac_io_0005_total(const char *biz_date) /* exec sql begin declare section */ + #line 72 "app/dbio/ac_io_0005.pgc" char h_biz_date [ 9 ] ; #line 73 "app/dbio/ac_io_0005.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_row ; + #line 74 "app/dbio/ac_io_0005.pgc" + long acc = 0 ; +/* exec sql end declare section */ +#line 75 "app/dbio/ac_io_0005.pgc" if (!biz_date) @@ -188,17 +190,42 @@ long ac_io_0005_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0005_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0005.pgc" + ECPGset_var( 0, ( h_biz_date ), __LINE__);\ + /* declare cur_ac_io_0005_t cursor for select net_amt from ac_io_0005_sum_t where biz_date = $1 */ +#line 84 "app/dbio/ac_io_0005.pgc" +#line 84 "app/dbio/ac_io_0005.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_io_0005_t cursor for select net_amt from ac_io_0005_sum_t where biz_date = $1 ", + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 85 "app/dbio/ac_io_0005.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0005_total"); return -1; } - return h_sum; + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_io_0005_t", ECPGt_EOIT, + ECPGt_long,&(h_row),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 91 "app/dbio/ac_io_0005.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0005_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_io_0005_t", ECPGt_EOIT, ECPGt_EORT);} +#line 96 "app/dbio/ac_io_0005.pgc" + + return -1; + } + acc += h_row; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_io_0005_t", ECPGt_EOIT, ECPGt_EORT);} +#line 101 "app/dbio/ac_io_0005.pgc" + + + return acc; } + diff --git a/app/dbio/ac_io_0005.pgc b/app/dbio/ac_io_0005.pgc index d2dce16..e1f01fb 100644 --- a/app/dbio/ac_io_0005.pgc +++ b/app/dbio/ac_io_0005.pgc @@ -24,10 +24,11 @@ int ac_io_0005_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT req_amt INTO :h_amount FROM ac_io_0005_t - WHERE key = :h_key; + WHERE mcht_no = :h_key AND status_cd = '00' + AND cancel_yn = 'N'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,8 @@ int ac_io_0005_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE ac_io_0005_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM ac_io_0005_tmp_t + WHERE ref_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0005_touch"); @@ -70,7 +70,8 @@ long ac_io_0005_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_row; + long acc = 0; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +80,26 @@ long ac_io_0005_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM ac_io_0005_t - WHERE biz_date = :h_biz_date; - + EXEC SQL DECLARE cur_ac_io_0005_t CURSOR FOR + SELECT net_amt FROM ac_io_0005_sum_t WHERE biz_date = :h_biz_date; + EXEC SQL OPEN cur_ac_io_0005_t; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0005_total"); return -1; } - return h_sum; + for (;;) { + EXEC SQL FETCH cur_ac_io_0005_t INTO :h_row; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0005_total"); + EXEC SQL CLOSE cur_ac_io_0005_t; + return -1; + } + acc += h_row; + } + EXEC SQL CLOSE cur_ac_io_0005_t; + + return acc; } + diff --git a/app/dbio/ac_io_0006.c b/app/dbio/ac_io_0006.c index 05535a2..54beb4b 100644 --- a/app/dbio/ac_io_0006.c +++ b/app/dbio/ac_io_0006.c @@ -94,14 +94,18 @@ int ac_io_0006_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/ac_io_0006.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/ac_io_0006.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/ac_io_0006.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/ac_io_0006.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int ac_io_0006_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0006_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( appr_amt ) from ac_io_0006_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0006.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/ac_io_0006.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int ac_io_0006_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0006_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int ac_io_0006_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0006.pgc" +#line 48 "app/dbio/ac_io_0006.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0006.pgc" +#line 49 "app/dbio/ac_io_0006.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0006.pgc" +#line 50 "app/dbio/ac_io_0006.pgc" if (!key) @@ -150,12 +156,14 @@ int ac_io_0006_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0006_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0006_t set fee_amt = $1 , vat_amt = $2 / 10 , upd_ts = now ( ) where mcht_no = $3 ", + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + 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_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0006.pgc" +#line 61 "app/dbio/ac_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -172,14 +180,18 @@ long ac_io_0006_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/ac_io_0006.pgc" +#line 75 "app/dbio/ac_io_0006.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0006.pgc" - long h_sum ; +#line 76 "app/dbio/ac_io_0006.pgc" + long h_max ; + +#line 77 "app/dbio/ac_io_0006.pgc" + long h_min ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0006.pgc" +#line 78 "app/dbio/ac_io_0006.pgc" if (!biz_date) @@ -188,17 +200,20 @@ long ac_io_0006_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0006_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( max ( appr_amt ) , 0 ) , coalesce ( min ( appr_amt ) , 0 ) from ac_io_0006_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0006.pgc" +#line 89 "app/dbio/ac_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0006_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/ac_io_0006.pgc b/app/dbio/ac_io_0006.pgc index ad4a976..e7c9190 100644 --- a/app/dbio/ac_io_0006.pgc +++ b/app/dbio/ac_io_0006.pgc @@ -16,6 +16,7 @@ int ac_io_0006_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int ac_io_0006_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM ac_io_0006_t - WHERE key = :h_key; + EXEC SQL SELECT max(appr_amt) + INTO :h_amount :h_ind + FROM ac_io_0006_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int ac_io_0006_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0006_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -54,8 +57,8 @@ int ac_io_0006_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE ac_io_0006_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET fee_amt = :h_amount, vat_amt = :h_amount / 10, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0006_touch"); @@ -70,7 +73,8 @@ long ac_io_0006_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_max; + long h_min; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +83,15 @@ long ac_io_0006_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM ac_io_0006_t + EXEC SQL SELECT coalesce(max(appr_amt), 0), coalesce(min(appr_amt), 0) + INTO :h_max, :h_min + FROM ac_io_0006_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0006_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/ac_io_0007.c b/app/dbio/ac_io_0007.c index 9af094c..b1247d0 100644 --- a/app/dbio/ac_io_0007.c +++ b/app/dbio/ac_io_0007.c @@ -110,12 +110,12 @@ int ac_io_0007_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0007_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select net_amt from ac_io_0007_t where mcht_no in ( select mcht_no from ac_io_0007_map_t where grp_key = $1 )", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0007.pgc" +#line 31 "app/dbio/ac_io_0007.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int ac_io_0007_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0007.pgc" +#line 46 "app/dbio/ac_io_0007.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0007.pgc" +#line 47 "app/dbio/ac_io_0007.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0007.pgc" +#line 48 "app/dbio/ac_io_0007.pgc" if (!key) @@ -150,12 +150,12 @@ int ac_io_0007_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0007_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0007_t set status_cd = case when $1 > 0 then '00' else '99' end , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0007.pgc" +#line 60 "app/dbio/ac_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long ac_io_0007_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0007.pgc" +#line 74 "app/dbio/ac_io_0007.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0007.pgc" +#line 75 "app/dbio/ac_io_0007.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0007.pgc" +#line 76 "app/dbio/ac_io_0007.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long ac_io_0007_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0007_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . appr_amt ) , 0 ) from ac_io_0007_dtl_t d join ac_io_0007_t h on h . mcht_no = d . mcht_no where d . biz_date = $1 and h . status_cd = '00'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0007.pgc" +#line 88 "app/dbio/ac_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long ac_io_0007_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0007.pgc b/app/dbio/ac_io_0007.pgc index d780264..30621b0 100644 --- a/app/dbio/ac_io_0007.pgc +++ b/app/dbio/ac_io_0007.pgc @@ -24,10 +24,11 @@ int ac_io_0007_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT net_amt INTO :h_amount FROM ac_io_0007_t - WHERE key = :h_key; + WHERE mcht_no IN + (SELECT mcht_no FROM ac_io_0007_map_t WHERE grp_key = :h_key); if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,9 @@ int ac_io_0007_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE ac_io_0007_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET status_cd = CASE WHEN :h_amount > 0 THEN '00' ELSE '99' END, + upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0007_touch"); @@ -79,10 +81,11 @@ long ac_io_0007_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.appr_amt), 0) INTO :h_sum - FROM ac_io_0007_t - WHERE biz_date = :h_biz_date; + FROM ac_io_0007_dtl_t d + JOIN ac_io_0007_t h ON h.mcht_no = d.mcht_no + WHERE d.biz_date = :h_biz_date AND h.status_cd = '00'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0007_total"); @@ -90,3 +93,4 @@ long ac_io_0007_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0008.c b/app/dbio/ac_io_0008.c index 5905015..229bb9d 100644 --- a/app/dbio/ac_io_0008.c +++ b/app/dbio/ac_io_0008.c @@ -110,20 +110,43 @@ int ac_io_0008_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0008_t where key = $1 ", + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cur_ac_io_0008_f cursor for select appr_amt from ac_io_0008_dtl_t where mcht_no = $1 order by seq desc */ +#line 29 "app/dbio/ac_io_0008.pgc" + +#line 29 "app/dbio/ac_io_0008.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_io_0008_f cursor for select appr_amt from ac_io_0008_dtl_t where mcht_no = $1 order by seq desc", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 30 "app/dbio/ac_io_0008.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0008_fetch"); return TX_EDB; } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_io_0008_f", ECPGt_EOIT, + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 35 "app/dbio/ac_io_0008.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_io_0008_f", ECPGt_EOIT, ECPGt_EORT);} +#line 37 "app/dbio/ac_io_0008.pgc" + + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0008_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_io_0008_f", ECPGt_EOIT, ECPGt_EORT);} +#line 42 "app/dbio/ac_io_0008.pgc" + + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_io_0008_f", ECPGt_EOIT, ECPGt_EORT);} +#line 45 "app/dbio/ac_io_0008.pgc" + + *out_amount = h_amount; return TX_OK; } @@ -134,13 +157,13 @@ int ac_io_0008_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0008.pgc" +#line 54 "app/dbio/ac_io_0008.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0008.pgc" +#line 55 "app/dbio/ac_io_0008.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0008.pgc" +#line 56 "app/dbio/ac_io_0008.pgc" if (!key) @@ -150,12 +173,12 @@ int ac_io_0008_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0008_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0008_acc_t set accum_amt = accum_amt + $1 , cnt = cnt + 1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0008.pgc" +#line 67 "app/dbio/ac_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +196,13 @@ long ac_io_0008_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0008.pgc" +#line 81 "app/dbio/ac_io_0008.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0008.pgc" - long h_sum ; +#line 82 "app/dbio/ac_io_0008.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0008.pgc" +#line 83 "app/dbio/ac_io_0008.pgc" if (!biz_date) @@ -188,17 +211,18 @@ long ac_io_0008_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0008_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct mcht_no ) from ac_io_0008_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0008.pgc" +#line 94 "app/dbio/ac_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0008_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/ac_io_0008.pgc b/app/dbio/ac_io_0008.pgc index 3b752aa..030e747 100644 --- a/app/dbio/ac_io_0008.pgc +++ b/app/dbio/ac_io_0008.pgc @@ -24,17 +24,26 @@ int ac_io_0008_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM ac_io_0008_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL DECLARE cur_ac_io_0008_f CURSOR FOR + SELECT appr_amt FROM ac_io_0008_dtl_t + WHERE mcht_no = :h_key ORDER BY seq DESC; + EXEC SQL OPEN cur_ac_io_0008_f; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0008_fetch"); return TX_EDB; } + EXEC SQL FETCH cur_ac_io_0008_f INTO :h_amount; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE cur_ac_io_0008_f; + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0008_fetch"); + EXEC SQL CLOSE cur_ac_io_0008_f; + return TX_EDB; + } + EXEC SQL CLOSE cur_ac_io_0008_f; + *out_amount = h_amount; return TX_OK; } @@ -53,9 +62,9 @@ int ac_io_0008_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE ac_io_0008_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE ac_io_0008_acc_t + SET accum_amt = accum_amt + :h_amount, cnt = cnt + 1, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0008_touch"); @@ -70,7 +79,7 @@ long ac_io_0008_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +88,15 @@ long ac_io_0008_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM ac_io_0008_t + EXEC SQL SELECT count(DISTINCT mcht_no) + INTO :h_cnt + FROM ac_io_0008_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0008_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/ac_io_0009.c b/app/dbio/ac_io_0009.c index 8ae6ff0..bc67910 100644 --- a/app/dbio/ac_io_0009.c +++ b/app/dbio/ac_io_0009.c @@ -110,12 +110,12 @@ int ac_io_0009_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0009_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when status_cd = '00' then appr_amt else 0 end from ac_io_0009_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0009.pgc" +#line 31 "app/dbio/ac_io_0009.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int ac_io_0009_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0009.pgc" +#line 46 "app/dbio/ac_io_0009.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0009.pgc" +#line 47 "app/dbio/ac_io_0009.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0009.pgc" +#line 48 "app/dbio/ac_io_0009.pgc" if (!key) @@ -150,10 +150,10 @@ int ac_io_0009_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0009_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from ac_io_0009_bal_t where acct_no = $1 and bal_amt <= $2 ", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} #line 58 "app/dbio/ac_io_0009.pgc" @@ -188,12 +188,12 @@ long ac_io_0009_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0009_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( cancel_amt ) , 0 ) from ac_io_0009_t where biz_date = $1 and status_cd = '90' and cancel_yn = 'Y'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0009.pgc" +#line 86 "app/dbio/ac_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long ac_io_0009_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0009.pgc b/app/dbio/ac_io_0009.pgc index 7618652..8293406 100644 --- a/app/dbio/ac_io_0009.pgc +++ b/app/dbio/ac_io_0009.pgc @@ -24,10 +24,11 @@ int ac_io_0009_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT + CASE WHEN status_cd = '00' THEN appr_amt ELSE 0 END INTO :h_amount FROM ac_io_0009_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,8 @@ int ac_io_0009_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE ac_io_0009_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM ac_io_0009_bal_t + WHERE acct_no = :h_key AND bal_amt <= :h_amount; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0009_touch"); @@ -79,10 +79,11 @@ long ac_io_0009_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(cancel_amt), 0) INTO :h_sum FROM ac_io_0009_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + AND status_cd = '90' AND cancel_yn = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0009_total"); @@ -90,3 +91,4 @@ long ac_io_0009_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0010.c b/app/dbio/ac_io_0010.c index fde25ba..a1ca794 100644 --- a/app/dbio/ac_io_0010.c +++ b/app/dbio/ac_io_0010.c @@ -110,7 +110,7 @@ int ac_io_0010_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0010_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt from ac_io_0010_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), @@ -150,20 +150,29 @@ int ac_io_0010_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0010_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0010_t set req_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/ac_io_0010.pgc" + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0010_touch"); + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into ac_io_0010_hist_t ( mcht_no , req_amt , reg_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 64 "app/dbio/ac_io_0010.pgc" + if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0010_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,13 +182,13 @@ long ac_io_0010_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0010.pgc" +#line 76 "app/dbio/ac_io_0010.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0010.pgc" +#line 77 "app/dbio/ac_io_0010.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0010.pgc" +#line 78 "app/dbio/ac_io_0010.pgc" if (!biz_date) @@ -188,12 +197,12 @@ long ac_io_0010_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0010_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( recon_amt ) , 0 ) from ac_io_0010_sum_t where biz_date in ( select biz_date from ac_io_0010_map_t where biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0010.pgc" +#line 90 "app/dbio/ac_io_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +211,4 @@ long ac_io_0010_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0010.pgc b/app/dbio/ac_io_0010.pgc index 3dd1a7a..d80566f 100644 --- a/app/dbio/ac_io_0010.pgc +++ b/app/dbio/ac_io_0010.pgc @@ -24,10 +24,10 @@ int ac_io_0010_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT appr_amt INTO :h_amount FROM ac_io_0010_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,15 +54,19 @@ int ac_io_0010_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE ac_io_0010_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET req_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0010_touch"); + return TX_EDB; + } + EXEC SQL INSERT INTO ac_io_0010_hist_t (mcht_no, req_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0010_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -79,10 +83,11 @@ long ac_io_0010_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(recon_amt), 0) INTO :h_sum - FROM ac_io_0010_t - WHERE biz_date = :h_biz_date; + FROM ac_io_0010_sum_t + WHERE biz_date IN + (SELECT biz_date FROM ac_io_0010_map_t WHERE biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0010_total"); @@ -90,3 +95,4 @@ long ac_io_0010_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0011.c b/app/dbio/ac_io_0011.c index dd26b0a..1d56979 100644 --- a/app/dbio/ac_io_0011.c +++ b/app/dbio/ac_io_0011.c @@ -94,14 +94,22 @@ int ac_io_0011_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + + #line 17 "app/dbio/ac_io_0011.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/ac_io_0011.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_appr ; + #line 19 "app/dbio/ac_io_0011.pgc" + long h_fee ; + +#line 20 "app/dbio/ac_io_0011.pgc" + long h_vat ; +/* exec sql end declare section */ +#line 21 "app/dbio/ac_io_0011.pgc" if (!key || !out_amount) @@ -110,12 +118,16 @@ int ac_io_0011_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0011_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt , fee_amt , vat_amt from ac_io_0011_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_appr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_vat),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0011.pgc" +#line 32 "app/dbio/ac_io_0011.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +136,7 @@ int ac_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -134,13 +146,13 @@ int ac_io_0011_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0011.pgc" +#line 47 "app/dbio/ac_io_0011.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0011.pgc" +#line 48 "app/dbio/ac_io_0011.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0011.pgc" +#line 49 "app/dbio/ac_io_0011.pgc" if (!key) @@ -150,12 +162,12 @@ int ac_io_0011_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0011_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0011_t set appr_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0011.pgc" +#line 60 "app/dbio/ac_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +185,13 @@ long ac_io_0011_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0011.pgc" +#line 74 "app/dbio/ac_io_0011.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0011.pgc" - long h_sum ; +#line 75 "app/dbio/ac_io_0011.pgc" + long h_flag ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0011.pgc" +#line 76 "app/dbio/ac_io_0011.pgc" if (!biz_date) @@ -188,17 +200,18 @@ long ac_io_0011_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0011_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from ac_io_0011_t where exists ( select 1 from ac_io_0011_dtl_t d where d . biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0011.pgc" +#line 89 "app/dbio/ac_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0011_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/ac_io_0011.pgc b/app/dbio/ac_io_0011.pgc index 8a5e6fa..4f4ef00 100644 --- a/app/dbio/ac_io_0011.pgc +++ b/app/dbio/ac_io_0011.pgc @@ -15,7 +15,9 @@ int ac_io_0011_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; - long h_amount; + long h_appr; + long h_fee; + long h_vat; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +26,10 @@ int ac_io_0011_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM ac_io_0011_t - WHERE key = :h_key; + EXEC SQL SELECT appr_amt, fee_amt, vat_amt + INTO :h_appr, :h_fee, :h_vat + FROM ac_io_0011_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,7 +37,7 @@ int ac_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -54,8 +56,8 @@ int ac_io_0011_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE ac_io_0011_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET appr_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0011_touch"); @@ -70,7 +72,7 @@ long ac_io_0011_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_flag; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +81,17 @@ long ac_io_0011_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_flag FROM ac_io_0011_t - WHERE biz_date = :h_biz_date; + WHERE EXISTS + (SELECT 1 FROM ac_io_0011_dtl_t d + WHERE d.biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0011_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/ac_io_0012.c b/app/dbio/ac_io_0012.c index 20c6b9a..4d1e22b 100644 --- a/app/dbio/ac_io_0012.c +++ b/app/dbio/ac_io_0012.c @@ -110,12 +110,12 @@ int ac_io_0012_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0012_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select h . net_amt from ac_io_0012_t h join ac_io_0012_map_t m on m . mcht_no = h . mcht_no where h . mcht_no = $1 and m . use_yn = 'Y'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0012.pgc" +#line 31 "app/dbio/ac_io_0012.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int ac_io_0012_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0012.pgc" +#line 46 "app/dbio/ac_io_0012.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0012.pgc" +#line 47 "app/dbio/ac_io_0012.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0012.pgc" +#line 48 "app/dbio/ac_io_0012.pgc" if (!key) @@ -150,12 +150,12 @@ int ac_io_0012_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0012_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0012_t set net_amt = $1 , upd_ts = now ( ) where mcht_no = $2 and status_cd = '00' and appr_amt > 0", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0012.pgc" +#line 59 "app/dbio/ac_io_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long ac_io_0012_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0012.pgc" +#line 73 "app/dbio/ac_io_0012.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0012.pgc" +#line 74 "app/dbio/ac_io_0012.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0012.pgc" +#line 75 "app/dbio/ac_io_0012.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long ac_io_0012_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0012_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( appr_amt ) , 0 ) from ac_io_0012_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0012.pgc" +#line 86 "app/dbio/ac_io_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long ac_io_0012_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0012.pgc b/app/dbio/ac_io_0012.pgc index a82bbe0..cae2d4e 100644 --- a/app/dbio/ac_io_0012.pgc +++ b/app/dbio/ac_io_0012.pgc @@ -24,10 +24,11 @@ int ac_io_0012_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT h.net_amt INTO :h_amount - FROM ac_io_0012_t - WHERE key = :h_key; + FROM ac_io_0012_t h + JOIN ac_io_0012_map_t m ON m.mcht_no = h.mcht_no + WHERE h.mcht_no = :h_key AND m.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,8 @@ int ac_io_0012_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE ac_io_0012_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET net_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key AND status_cd = '00' AND appr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0012_touch"); @@ -79,7 +80,7 @@ long ac_io_0012_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(appr_amt), 0) INTO :h_sum FROM ac_io_0012_t WHERE biz_date = :h_biz_date; @@ -90,3 +91,4 @@ long ac_io_0012_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0013.c b/app/dbio/ac_io_0013.c index 8c77fc5..01a84bf 100644 --- a/app/dbio/ac_io_0013.c +++ b/app/dbio/ac_io_0013.c @@ -94,14 +94,18 @@ int ac_io_0013_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/ac_io_0013.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/ac_io_0013.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/ac_io_0013.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/ac_io_0013.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int ac_io_0013_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0013_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select bal_amt from ac_io_0013_bal_t where acct_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0013.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/ac_io_0013.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int ac_io_0013_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0013_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int ac_io_0013_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0013.pgc" +#line 48 "app/dbio/ac_io_0013.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0013.pgc" +#line 49 "app/dbio/ac_io_0013.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0013.pgc" +#line 50 "app/dbio/ac_io_0013.pgc" if (!key) @@ -150,20 +156,18 @@ int ac_io_0013_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0013_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into ac_io_0013_log_t ( mcht_no , appr_amt , reg_ts ) values ( $1 , $2 , now ( ) )", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0013.pgc" +#line 60 "app/dbio/ac_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -177,7 +181,7 @@ long ac_io_0013_total(const char *biz_date) char h_biz_date [ 9 ] ; #line 73 "app/dbio/ac_io_0013.pgc" - long h_sum ; + long h_cnt ; /* exec sql end declare section */ #line 74 "app/dbio/ac_io_0013.pgc" @@ -188,10 +192,10 @@ long ac_io_0013_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0013_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from ac_io_0013_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 85 "app/dbio/ac_io_0013.pgc" @@ -200,5 +204,6 @@ long ac_io_0013_total(const char *biz_date) TX_DBIO_LOG_ERR("ac_io_0013_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/ac_io_0013.pgc b/app/dbio/ac_io_0013.pgc index 5a588aa..bb5feb3 100644 --- a/app/dbio/ac_io_0013.pgc +++ b/app/dbio/ac_io_0013.pgc @@ -16,6 +16,7 @@ int ac_io_0013_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int ac_io_0013_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM ac_io_0013_t - WHERE key = :h_key; + EXEC SQL SELECT bal_amt + INTO :h_amount :h_ind + FROM ac_io_0013_bal_t + WHERE acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int ac_io_0013_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0013_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -53,16 +56,13 @@ int ac_io_0013_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE ac_io_0013_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL INSERT INTO ac_io_0013_log_t (mcht_no, appr_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -70,7 +70,7 @@ long ac_io_0013_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,8 +79,8 @@ long ac_io_0013_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_cnt FROM ac_io_0013_t WHERE biz_date = :h_biz_date; @@ -88,5 +88,6 @@ long ac_io_0013_total(const char *biz_date) TX_DBIO_LOG_ERR("ac_io_0013_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/ac_io_0014.c b/app/dbio/ac_io_0014.c index 8e83017..060a1e4 100644 --- a/app/dbio/ac_io_0014.c +++ b/app/dbio/ac_io_0014.c @@ -110,12 +110,12 @@ int ac_io_0014_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0014_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select req_amt from ac_io_0014_t where mcht_no = $1 and status_cd = '00' and cancel_yn = 'N'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0014.pgc" +#line 31 "app/dbio/ac_io_0014.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int ac_io_0014_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0014.pgc" +#line 46 "app/dbio/ac_io_0014.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0014.pgc" +#line 47 "app/dbio/ac_io_0014.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0014.pgc" +#line 48 "app/dbio/ac_io_0014.pgc" if (!key) @@ -150,20 +150,31 @@ int ac_io_0014_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0014_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0014_bal_t set bal_amt = $1 , upd_ts = now ( ) where acct_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0014.pgc" +#line 59 "app/dbio/ac_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0014_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into ac_io_0014_bal_t ( acct_no , bal_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 67 "app/dbio/ac_io_0014.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0014_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -172,14 +183,18 @@ long ac_io_0014_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/ac_io_0014.pgc" +#line 79 "app/dbio/ac_io_0014.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0014.pgc" - long h_sum ; +#line 80 "app/dbio/ac_io_0014.pgc" + long h_avg ; + +#line 81 "app/dbio/ac_io_0014.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0014.pgc" +#line 82 "app/dbio/ac_io_0014.pgc" if (!biz_date) @@ -188,17 +203,20 @@ long ac_io_0014_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0014_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select avg ( appr_amt ) from ac_io_0014_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0014.pgc" + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 93 "app/dbio/ac_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0014_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/ac_io_0014.pgc b/app/dbio/ac_io_0014.pgc index 18c63c8..7bb82b3 100644 --- a/app/dbio/ac_io_0014.pgc +++ b/app/dbio/ac_io_0014.pgc @@ -24,10 +24,11 @@ int ac_io_0014_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT req_amt INTO :h_amount FROM ac_io_0014_t - WHERE key = :h_key; + WHERE mcht_no = :h_key AND status_cd = '00' + AND cancel_yn = 'N'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,16 +54,22 @@ int ac_io_0014_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE ac_io_0014_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE ac_io_0014_bal_t + SET bal_amt = :h_amount, upd_ts = now() + WHERE acct_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0014_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + EXEC SQL INSERT INTO ac_io_0014_bal_t (acct_no, bal_amt, upd_ts) + VALUES (:h_key, :h_amount, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0014_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -70,7 +77,8 @@ long ac_io_0014_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_avg; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +87,17 @@ long ac_io_0014_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM ac_io_0014_t + EXEC SQL SELECT avg(appr_amt) + INTO :h_avg :h_ind + FROM ac_io_0014_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0014_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/ac_io_0015.c b/app/dbio/ac_io_0015.c index cad461a..51cf68a 100644 --- a/app/dbio/ac_io_0015.c +++ b/app/dbio/ac_io_0015.c @@ -94,14 +94,18 @@ int ac_io_0015_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/ac_io_0015.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/ac_io_0015.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/ac_io_0015.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/ac_io_0015.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int ac_io_0015_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0015_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( appr_amt ) from ac_io_0015_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0015.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/ac_io_0015.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int ac_io_0015_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0015_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int ac_io_0015_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0015.pgc" +#line 48 "app/dbio/ac_io_0015.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0015.pgc" +#line 49 "app/dbio/ac_io_0015.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0015.pgc" +#line 50 "app/dbio/ac_io_0015.pgc" if (!key) @@ -150,12 +156,10 @@ int ac_io_0015_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0015_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from ac_io_0015_tmp_t where ref_key = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0015.pgc" +#line 60 "app/dbio/ac_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +177,13 @@ long ac_io_0015_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0015.pgc" +#line 74 "app/dbio/ac_io_0015.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0015.pgc" +#line 75 "app/dbio/ac_io_0015.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0015.pgc" +#line 76 "app/dbio/ac_io_0015.pgc" if (!biz_date) @@ -188,17 +192,20 @@ long ac_io_0015_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0015_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( net_amt ) , 0 ) from ac_io_0015_t where biz_date = $1 group by biz_date having sum ( net_amt ) > 0 limit 1", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0015.pgc" +#line 90 "app/dbio/ac_io_0015.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0015_total"); return -1; } return h_sum; } + diff --git a/app/dbio/ac_io_0015.pgc b/app/dbio/ac_io_0015.pgc index 7cfa478..78ac1ff 100644 --- a/app/dbio/ac_io_0015.pgc +++ b/app/dbio/ac_io_0015.pgc @@ -16,6 +16,7 @@ int ac_io_0015_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int ac_io_0015_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM ac_io_0015_t - WHERE key = :h_key; + EXEC SQL SELECT max(appr_amt) + INTO :h_amount :h_ind + FROM ac_io_0015_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int ac_io_0015_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0015_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -53,9 +56,8 @@ int ac_io_0015_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE ac_io_0015_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM ac_io_0015_tmp_t + WHERE ref_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0015_touch"); @@ -79,14 +81,20 @@ long ac_io_0015_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(net_amt), 0) INTO :h_sum FROM ac_io_0015_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + GROUP BY biz_date + HAVING sum(net_amt) > 0 + LIMIT 1; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0015_total"); return -1; } return h_sum; } + diff --git a/app/dbio/ac_io_0016.c b/app/dbio/ac_io_0016.c index a6b34dc..ed675e5 100644 --- a/app/dbio/ac_io_0016.c +++ b/app/dbio/ac_io_0016.c @@ -110,12 +110,12 @@ int ac_io_0016_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0016_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select net_amt from ac_io_0016_t where mcht_no in ( select mcht_no from ac_io_0016_map_t where grp_key = $1 )", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0016.pgc" +#line 31 "app/dbio/ac_io_0016.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int ac_io_0016_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0016.pgc" +#line 46 "app/dbio/ac_io_0016.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0016.pgc" +#line 47 "app/dbio/ac_io_0016.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0016.pgc" +#line 48 "app/dbio/ac_io_0016.pgc" if (!key) @@ -150,12 +150,14 @@ int ac_io_0016_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0016_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0016_t set fee_amt = $1 , vat_amt = $2 / 10 , upd_ts = now ( ) where mcht_no = $3 ", + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + 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_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0016.pgc" +#line 59 "app/dbio/ac_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -172,14 +174,18 @@ long ac_io_0016_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/ac_io_0016.pgc" +#line 73 "app/dbio/ac_io_0016.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0016.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/ac_io_0016.pgc" + long h_row ; + +#line 75 "app/dbio/ac_io_0016.pgc" + long acc = 0 ; +/* exec sql end declare section */ +#line 76 "app/dbio/ac_io_0016.pgc" if (!biz_date) @@ -188,17 +194,42 @@ long ac_io_0016_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0016_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGset_var( 0, ( h_biz_date ), __LINE__);\ + /* declare cur_ac_io_0016_t cursor for select net_amt from ac_io_0016_sum_t where biz_date = $1 */ #line 85 "app/dbio/ac_io_0016.pgc" +#line 85 "app/dbio/ac_io_0016.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_io_0016_t cursor for select net_amt from ac_io_0016_sum_t where biz_date = $1 ", + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 86 "app/dbio/ac_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0016_total"); return -1; } - return h_sum; + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_io_0016_t", ECPGt_EOIT, + ECPGt_long,&(h_row),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 92 "app/dbio/ac_io_0016.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0016_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_io_0016_t", ECPGt_EOIT, ECPGt_EORT);} +#line 97 "app/dbio/ac_io_0016.pgc" + + return -1; + } + acc += h_row; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_io_0016_t", ECPGt_EOIT, ECPGt_EORT);} +#line 102 "app/dbio/ac_io_0016.pgc" + + + return acc; } + diff --git a/app/dbio/ac_io_0016.pgc b/app/dbio/ac_io_0016.pgc index f582e57..7bc2993 100644 --- a/app/dbio/ac_io_0016.pgc +++ b/app/dbio/ac_io_0016.pgc @@ -24,10 +24,11 @@ int ac_io_0016_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT net_amt INTO :h_amount FROM ac_io_0016_t - WHERE key = :h_key; + WHERE mcht_no IN + (SELECT mcht_no FROM ac_io_0016_map_t WHERE grp_key = :h_key); if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,8 @@ int ac_io_0016_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE ac_io_0016_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET fee_amt = :h_amount, vat_amt = :h_amount / 10, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0016_touch"); @@ -70,7 +71,8 @@ long ac_io_0016_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_row; + long acc = 0; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +81,26 @@ long ac_io_0016_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM ac_io_0016_t - WHERE biz_date = :h_biz_date; - + EXEC SQL DECLARE cur_ac_io_0016_t CURSOR FOR + SELECT net_amt FROM ac_io_0016_sum_t WHERE biz_date = :h_biz_date; + EXEC SQL OPEN cur_ac_io_0016_t; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0016_total"); return -1; } - return h_sum; + for (;;) { + EXEC SQL FETCH cur_ac_io_0016_t INTO :h_row; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0016_total"); + EXEC SQL CLOSE cur_ac_io_0016_t; + return -1; + } + acc += h_row; + } + EXEC SQL CLOSE cur_ac_io_0016_t; + + return acc; } + diff --git a/app/dbio/ac_io_0017.c b/app/dbio/ac_io_0017.c index bef6607..c4e1960 100644 --- a/app/dbio/ac_io_0017.c +++ b/app/dbio/ac_io_0017.c @@ -110,20 +110,43 @@ int ac_io_0017_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0017_t where key = $1 ", + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cur_ac_io_0017_f cursor for select appr_amt from ac_io_0017_dtl_t where mcht_no = $1 order by seq desc */ +#line 29 "app/dbio/ac_io_0017.pgc" + +#line 29 "app/dbio/ac_io_0017.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_io_0017_f cursor for select appr_amt from ac_io_0017_dtl_t where mcht_no = $1 order by seq desc", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 30 "app/dbio/ac_io_0017.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0017_fetch"); return TX_EDB; } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_io_0017_f", ECPGt_EOIT, + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 35 "app/dbio/ac_io_0017.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_io_0017_f", ECPGt_EOIT, ECPGt_EORT);} +#line 37 "app/dbio/ac_io_0017.pgc" + + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0017_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_io_0017_f", ECPGt_EOIT, ECPGt_EORT);} +#line 42 "app/dbio/ac_io_0017.pgc" + + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_io_0017_f", ECPGt_EOIT, ECPGt_EORT);} +#line 45 "app/dbio/ac_io_0017.pgc" + + *out_amount = h_amount; return TX_OK; } @@ -134,13 +157,13 @@ int ac_io_0017_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0017.pgc" +#line 54 "app/dbio/ac_io_0017.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0017.pgc" +#line 55 "app/dbio/ac_io_0017.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0017.pgc" +#line 56 "app/dbio/ac_io_0017.pgc" if (!key) @@ -150,12 +173,12 @@ int ac_io_0017_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0017_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0017_t set status_cd = case when $1 > 0 then '00' else '99' end , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0017.pgc" +#line 68 "app/dbio/ac_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -172,14 +195,18 @@ long ac_io_0017_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/ac_io_0017.pgc" +#line 82 "app/dbio/ac_io_0017.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0017.pgc" - long h_sum ; +#line 83 "app/dbio/ac_io_0017.pgc" + long h_max ; + +#line 84 "app/dbio/ac_io_0017.pgc" + long h_min ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0017.pgc" +#line 85 "app/dbio/ac_io_0017.pgc" if (!biz_date) @@ -188,17 +215,20 @@ long ac_io_0017_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0017_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( max ( appr_amt ) , 0 ) , coalesce ( min ( appr_amt ) , 0 ) from ac_io_0017_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0017.pgc" +#line 96 "app/dbio/ac_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0017_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/ac_io_0017.pgc b/app/dbio/ac_io_0017.pgc index bb4bb09..9f6f762 100644 --- a/app/dbio/ac_io_0017.pgc +++ b/app/dbio/ac_io_0017.pgc @@ -24,17 +24,26 @@ int ac_io_0017_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM ac_io_0017_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL DECLARE cur_ac_io_0017_f CURSOR FOR + SELECT appr_amt FROM ac_io_0017_dtl_t + WHERE mcht_no = :h_key ORDER BY seq DESC; + EXEC SQL OPEN cur_ac_io_0017_f; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0017_fetch"); return TX_EDB; } + EXEC SQL FETCH cur_ac_io_0017_f INTO :h_amount; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE cur_ac_io_0017_f; + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0017_fetch"); + EXEC SQL CLOSE cur_ac_io_0017_f; + return TX_EDB; + } + EXEC SQL CLOSE cur_ac_io_0017_f; + *out_amount = h_amount; return TX_OK; } @@ -54,8 +63,9 @@ int ac_io_0017_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE ac_io_0017_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET status_cd = CASE WHEN :h_amount > 0 THEN '00' ELSE '99' END, + upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0017_touch"); @@ -70,7 +80,8 @@ long ac_io_0017_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_max; + long h_min; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +90,15 @@ long ac_io_0017_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM ac_io_0017_t + EXEC SQL SELECT coalesce(max(appr_amt), 0), coalesce(min(appr_amt), 0) + INTO :h_max, :h_min + FROM ac_io_0017_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0017_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/ac_io_0018.c b/app/dbio/ac_io_0018.c index f152a75..96d5675 100644 --- a/app/dbio/ac_io_0018.c +++ b/app/dbio/ac_io_0018.c @@ -110,12 +110,12 @@ int ac_io_0018_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0018_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when status_cd = '00' then appr_amt else 0 end from ac_io_0018_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0018.pgc" +#line 31 "app/dbio/ac_io_0018.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int ac_io_0018_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0018.pgc" +#line 46 "app/dbio/ac_io_0018.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0018.pgc" +#line 47 "app/dbio/ac_io_0018.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0018.pgc" +#line 48 "app/dbio/ac_io_0018.pgc" if (!key) @@ -150,12 +150,12 @@ int ac_io_0018_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0018_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0018_acc_t set accum_amt = accum_amt + $1 , cnt = cnt + 1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0018.pgc" +#line 59 "app/dbio/ac_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long ac_io_0018_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0018.pgc" +#line 73 "app/dbio/ac_io_0018.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0018.pgc" +#line 74 "app/dbio/ac_io_0018.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0018.pgc" +#line 75 "app/dbio/ac_io_0018.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long ac_io_0018_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0018_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . appr_amt ) , 0 ) from ac_io_0018_dtl_t d join ac_io_0018_t h on h . mcht_no = d . mcht_no where d . biz_date = $1 and h . status_cd = '00'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0018.pgc" +#line 87 "app/dbio/ac_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long ac_io_0018_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0018.pgc b/app/dbio/ac_io_0018.pgc index 9e0acf2..7316c1a 100644 --- a/app/dbio/ac_io_0018.pgc +++ b/app/dbio/ac_io_0018.pgc @@ -24,10 +24,11 @@ int ac_io_0018_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT + CASE WHEN status_cd = '00' THEN appr_amt ELSE 0 END INTO :h_amount FROM ac_io_0018_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,9 @@ int ac_io_0018_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE ac_io_0018_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE ac_io_0018_acc_t + SET accum_amt = accum_amt + :h_amount, cnt = cnt + 1, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0018_touch"); @@ -79,10 +80,11 @@ long ac_io_0018_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.appr_amt), 0) INTO :h_sum - FROM ac_io_0018_t - WHERE biz_date = :h_biz_date; + FROM ac_io_0018_dtl_t d + JOIN ac_io_0018_t h ON h.mcht_no = d.mcht_no + WHERE d.biz_date = :h_biz_date AND h.status_cd = '00'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0018_total"); @@ -90,3 +92,4 @@ long ac_io_0018_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0019.c b/app/dbio/ac_io_0019.c index b874c10..645a883 100644 --- a/app/dbio/ac_io_0019.c +++ b/app/dbio/ac_io_0019.c @@ -110,7 +110,7 @@ int ac_io_0019_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0019_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt from ac_io_0019_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), @@ -150,12 +150,12 @@ int ac_io_0019_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0019_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from ac_io_0019_bal_t where acct_no = $1 and bal_amt <= $2 ", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0019.pgc" +#line 57 "app/dbio/ac_io_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long ac_io_0019_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0019.pgc" +#line 71 "app/dbio/ac_io_0019.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0019.pgc" - long h_sum ; +#line 72 "app/dbio/ac_io_0019.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0019.pgc" +#line 73 "app/dbio/ac_io_0019.pgc" if (!biz_date) @@ -188,17 +188,18 @@ long ac_io_0019_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0019_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct mcht_no ) from ac_io_0019_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0019.pgc" +#line 84 "app/dbio/ac_io_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0019_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/ac_io_0019.pgc b/app/dbio/ac_io_0019.pgc index 9472dfc..dfaffa6 100644 --- a/app/dbio/ac_io_0019.pgc +++ b/app/dbio/ac_io_0019.pgc @@ -24,10 +24,10 @@ int ac_io_0019_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT appr_amt INTO :h_amount FROM ac_io_0019_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +53,8 @@ int ac_io_0019_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE ac_io_0019_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM ac_io_0019_bal_t + WHERE acct_no = :h_key AND bal_amt <= :h_amount; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0019_touch"); @@ -70,7 +69,7 @@ long ac_io_0019_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +78,15 @@ long ac_io_0019_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM ac_io_0019_t + EXEC SQL SELECT count(DISTINCT mcht_no) + INTO :h_cnt + FROM ac_io_0019_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0019_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/ac_io_0020.c b/app/dbio/ac_io_0020.c index 9e0a240..3909bb6 100644 --- a/app/dbio/ac_io_0020.c +++ b/app/dbio/ac_io_0020.c @@ -94,14 +94,22 @@ int ac_io_0020_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + + #line 17 "app/dbio/ac_io_0020.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/ac_io_0020.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_appr ; + #line 19 "app/dbio/ac_io_0020.pgc" + long h_fee ; + +#line 20 "app/dbio/ac_io_0020.pgc" + long h_vat ; +/* exec sql end declare section */ +#line 21 "app/dbio/ac_io_0020.pgc" if (!key || !out_amount) @@ -110,12 +118,16 @@ int ac_io_0020_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0020_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt , fee_amt , vat_amt from ac_io_0020_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_appr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_vat),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0020.pgc" +#line 32 "app/dbio/ac_io_0020.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +136,7 @@ int ac_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -134,13 +146,13 @@ int ac_io_0020_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0020.pgc" +#line 47 "app/dbio/ac_io_0020.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0020.pgc" +#line 48 "app/dbio/ac_io_0020.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0020.pgc" +#line 49 "app/dbio/ac_io_0020.pgc" if (!key) @@ -150,20 +162,29 @@ int ac_io_0020_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0020_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0020_t set req_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0020.pgc" +#line 60 "app/dbio/ac_io_0020.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0020_touch"); + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into ac_io_0020_hist_t ( mcht_no , req_amt , reg_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 66 "app/dbio/ac_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,13 +194,13 @@ long ac_io_0020_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0020.pgc" +#line 78 "app/dbio/ac_io_0020.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0020.pgc" +#line 79 "app/dbio/ac_io_0020.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0020.pgc" +#line 80 "app/dbio/ac_io_0020.pgc" if (!biz_date) @@ -188,12 +209,12 @@ long ac_io_0020_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0020_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( cancel_amt ) , 0 ) from ac_io_0020_t where biz_date = $1 and status_cd = '90' and cancel_yn = 'Y'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0020.pgc" +#line 92 "app/dbio/ac_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +223,4 @@ long ac_io_0020_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0020.pgc b/app/dbio/ac_io_0020.pgc index 89aa12f..6899fcd 100644 --- a/app/dbio/ac_io_0020.pgc +++ b/app/dbio/ac_io_0020.pgc @@ -15,7 +15,9 @@ int ac_io_0020_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; - long h_amount; + long h_appr; + long h_fee; + long h_vat; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +26,10 @@ int ac_io_0020_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM ac_io_0020_t - WHERE key = :h_key; + EXEC SQL SELECT appr_amt, fee_amt, vat_amt + INTO :h_appr, :h_fee, :h_vat + FROM ac_io_0020_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,7 +37,7 @@ int ac_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -54,15 +56,19 @@ int ac_io_0020_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE ac_io_0020_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET req_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0020_touch"); + return TX_EDB; + } + EXEC SQL INSERT INTO ac_io_0020_hist_t (mcht_no, req_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -79,10 +85,11 @@ long ac_io_0020_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(cancel_amt), 0) INTO :h_sum FROM ac_io_0020_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + AND status_cd = '90' AND cancel_yn = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0020_total"); @@ -90,3 +97,4 @@ long ac_io_0020_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0021.c b/app/dbio/ac_io_0021.c index 0aa903d..840b6a8 100644 --- a/app/dbio/ac_io_0021.c +++ b/app/dbio/ac_io_0021.c @@ -110,12 +110,12 @@ int ac_io_0021_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0021_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select h . net_amt from ac_io_0021_t h join ac_io_0021_map_t m on m . mcht_no = h . mcht_no where h . mcht_no = $1 and m . use_yn = 'Y'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0021.pgc" +#line 31 "app/dbio/ac_io_0021.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int ac_io_0021_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0021.pgc" +#line 46 "app/dbio/ac_io_0021.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0021.pgc" +#line 47 "app/dbio/ac_io_0021.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0021.pgc" +#line 48 "app/dbio/ac_io_0021.pgc" if (!key) @@ -150,12 +150,12 @@ int ac_io_0021_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0021_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0021_t set appr_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0021.pgc" +#line 59 "app/dbio/ac_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long ac_io_0021_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0021.pgc" +#line 73 "app/dbio/ac_io_0021.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0021.pgc" +#line 74 "app/dbio/ac_io_0021.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0021.pgc" +#line 75 "app/dbio/ac_io_0021.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long ac_io_0021_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0021_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( recon_amt ) , 0 ) from ac_io_0021_sum_t where biz_date in ( select biz_date from ac_io_0021_map_t where biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0021.pgc" +#line 87 "app/dbio/ac_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long ac_io_0021_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0021.pgc b/app/dbio/ac_io_0021.pgc index 383f515..b15ddc9 100644 --- a/app/dbio/ac_io_0021.pgc +++ b/app/dbio/ac_io_0021.pgc @@ -24,10 +24,11 @@ int ac_io_0021_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT h.net_amt INTO :h_amount - FROM ac_io_0021_t - WHERE key = :h_key; + FROM ac_io_0021_t h + JOIN ac_io_0021_map_t m ON m.mcht_no = h.mcht_no + WHERE h.mcht_no = :h_key AND m.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,8 @@ int ac_io_0021_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE ac_io_0021_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET appr_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0021_touch"); @@ -79,10 +80,11 @@ long ac_io_0021_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(recon_amt), 0) INTO :h_sum - FROM ac_io_0021_t - WHERE biz_date = :h_biz_date; + FROM ac_io_0021_sum_t + WHERE biz_date IN + (SELECT biz_date FROM ac_io_0021_map_t WHERE biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0021_total"); @@ -90,3 +92,4 @@ long ac_io_0021_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0022.c b/app/dbio/ac_io_0022.c index 20930cb..b6f82fb 100644 --- a/app/dbio/ac_io_0022.c +++ b/app/dbio/ac_io_0022.c @@ -94,14 +94,18 @@ int ac_io_0022_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/ac_io_0022.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/ac_io_0022.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/ac_io_0022.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/ac_io_0022.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int ac_io_0022_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0022_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select bal_amt from ac_io_0022_bal_t where acct_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0022.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/ac_io_0022.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int ac_io_0022_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0022_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int ac_io_0022_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0022.pgc" +#line 48 "app/dbio/ac_io_0022.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0022.pgc" +#line 49 "app/dbio/ac_io_0022.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0022.pgc" +#line 50 "app/dbio/ac_io_0022.pgc" if (!key) @@ -150,12 +156,12 @@ int ac_io_0022_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0022_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0022_t set net_amt = $1 , upd_ts = now ( ) where mcht_no = $2 and status_cd = '00' and appr_amt > 0", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0022.pgc" +#line 61 "app/dbio/ac_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +179,13 @@ long ac_io_0022_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0022.pgc" +#line 75 "app/dbio/ac_io_0022.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0022.pgc" - long h_sum ; +#line 76 "app/dbio/ac_io_0022.pgc" + long h_flag ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0022.pgc" +#line 77 "app/dbio/ac_io_0022.pgc" if (!biz_date) @@ -188,17 +194,18 @@ long ac_io_0022_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0022_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from ac_io_0022_t where exists ( select 1 from ac_io_0022_dtl_t d where d . biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0022.pgc" +#line 90 "app/dbio/ac_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0022_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/ac_io_0022.pgc b/app/dbio/ac_io_0022.pgc index efd9b9f..bbdf670 100644 --- a/app/dbio/ac_io_0022.pgc +++ b/app/dbio/ac_io_0022.pgc @@ -16,6 +16,7 @@ int ac_io_0022_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int ac_io_0022_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM ac_io_0022_t - WHERE key = :h_key; + EXEC SQL SELECT bal_amt + INTO :h_amount :h_ind + FROM ac_io_0022_bal_t + WHERE acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int ac_io_0022_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0022_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -54,8 +57,8 @@ int ac_io_0022_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE ac_io_0022_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET net_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key AND status_cd = '00' AND appr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0022_touch"); @@ -70,7 +73,7 @@ long ac_io_0022_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_flag; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +82,17 @@ long ac_io_0022_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_flag FROM ac_io_0022_t - WHERE biz_date = :h_biz_date; + WHERE EXISTS + (SELECT 1 FROM ac_io_0022_dtl_t d + WHERE d.biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0022_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/ac_io_0023.c b/app/dbio/ac_io_0023.c index f83080d..b2b4591 100644 --- a/app/dbio/ac_io_0023.c +++ b/app/dbio/ac_io_0023.c @@ -110,12 +110,12 @@ int ac_io_0023_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0023_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select req_amt from ac_io_0023_t where mcht_no = $1 and status_cd = '00' and cancel_yn = 'N'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0023.pgc" +#line 31 "app/dbio/ac_io_0023.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int ac_io_0023_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0023.pgc" +#line 46 "app/dbio/ac_io_0023.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0023.pgc" +#line 47 "app/dbio/ac_io_0023.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0023.pgc" +#line 48 "app/dbio/ac_io_0023.pgc" if (!key) @@ -150,10 +150,10 @@ int ac_io_0023_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0023_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into ac_io_0023_log_t ( mcht_no , appr_amt , reg_ts ) values ( $1 , $2 , now ( ) )", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} #line 58 "app/dbio/ac_io_0023.pgc" @@ -162,8 +162,6 @@ int ac_io_0023_touch(const char *key, long amount) TX_DBIO_LOG_ERR("ac_io_0023_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,13 +171,13 @@ long ac_io_0023_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0023.pgc" +#line 70 "app/dbio/ac_io_0023.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0023.pgc" +#line 71 "app/dbio/ac_io_0023.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0023.pgc" +#line 72 "app/dbio/ac_io_0023.pgc" if (!biz_date) @@ -188,12 +186,12 @@ long ac_io_0023_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0023_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( appr_amt ) , 0 ) from ac_io_0023_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0023.pgc" +#line 83 "app/dbio/ac_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +200,4 @@ long ac_io_0023_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0023.pgc b/app/dbio/ac_io_0023.pgc index c8498d9..a970ecf 100644 --- a/app/dbio/ac_io_0023.pgc +++ b/app/dbio/ac_io_0023.pgc @@ -24,10 +24,11 @@ int ac_io_0023_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT req_amt INTO :h_amount FROM ac_io_0023_t - WHERE key = :h_key; + WHERE mcht_no = :h_key AND status_cd = '00' + AND cancel_yn = 'N'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,16 +54,13 @@ int ac_io_0023_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE ac_io_0023_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL INSERT INTO ac_io_0023_log_t (mcht_no, appr_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0023_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -79,7 +77,7 @@ long ac_io_0023_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(appr_amt), 0) INTO :h_sum FROM ac_io_0023_t WHERE biz_date = :h_biz_date; @@ -90,3 +88,4 @@ long ac_io_0023_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/ac_io_0024.c b/app/dbio/ac_io_0024.c index cf8658a..0cf7e36 100644 --- a/app/dbio/ac_io_0024.c +++ b/app/dbio/ac_io_0024.c @@ -94,14 +94,18 @@ int ac_io_0024_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/ac_io_0024.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/ac_io_0024.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/ac_io_0024.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/ac_io_0024.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int ac_io_0024_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0024_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( appr_amt ) from ac_io_0024_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0024.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/ac_io_0024.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int ac_io_0024_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0024_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int ac_io_0024_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0024.pgc" +#line 48 "app/dbio/ac_io_0024.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0024.pgc" +#line 49 "app/dbio/ac_io_0024.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0024.pgc" +#line 50 "app/dbio/ac_io_0024.pgc" if (!key) @@ -150,20 +156,31 @@ int ac_io_0024_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0024_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0024_bal_t set bal_amt = $1 , upd_ts = now ( ) where acct_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0024.pgc" +#line 61 "app/dbio/ac_io_0024.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0024_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into ac_io_0024_bal_t ( acct_no , bal_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 69 "app/dbio/ac_io_0024.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0024_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -173,13 +190,13 @@ long ac_io_0024_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0024.pgc" +#line 81 "app/dbio/ac_io_0024.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0024.pgc" - long h_sum ; +#line 82 "app/dbio/ac_io_0024.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0024.pgc" +#line 83 "app/dbio/ac_io_0024.pgc" if (!biz_date) @@ -188,17 +205,18 @@ long ac_io_0024_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0024_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from ac_io_0024_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0024.pgc" +#line 94 "app/dbio/ac_io_0024.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0024_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/ac_io_0024.pgc b/app/dbio/ac_io_0024.pgc index fa8bf03..1dc148e 100644 --- a/app/dbio/ac_io_0024.pgc +++ b/app/dbio/ac_io_0024.pgc @@ -16,6 +16,7 @@ int ac_io_0024_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int ac_io_0024_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM ac_io_0024_t - WHERE key = :h_key; + EXEC SQL SELECT max(appr_amt) + INTO :h_amount :h_ind + FROM ac_io_0024_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int ac_io_0024_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("ac_io_0024_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -53,16 +56,22 @@ int ac_io_0024_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE ac_io_0024_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE ac_io_0024_bal_t + SET bal_amt = :h_amount, upd_ts = now() + WHERE acct_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0024_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + EXEC SQL INSERT INTO ac_io_0024_bal_t (acct_no, bal_amt, upd_ts) + VALUES (:h_key, :h_amount, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0024_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -70,7 +79,7 @@ long ac_io_0024_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,8 +88,8 @@ long ac_io_0024_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_cnt FROM ac_io_0024_t WHERE biz_date = :h_biz_date; @@ -88,5 +97,6 @@ long ac_io_0024_total(const char *biz_date) TX_DBIO_LOG_ERR("ac_io_0024_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/ac_io_0025.c b/app/dbio/ac_io_0025.c index eaab8f6..3d89ab6 100644 --- a/app/dbio/ac_io_0025.c +++ b/app/dbio/ac_io_0025.c @@ -110,12 +110,12 @@ int ac_io_0025_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0025_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select net_amt from ac_io_0025_t where mcht_no in ( select mcht_no from ac_io_0025_map_t where grp_key = $1 )", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0025.pgc" +#line 31 "app/dbio/ac_io_0025.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int ac_io_0025_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0025.pgc" +#line 46 "app/dbio/ac_io_0025.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0025.pgc" +#line 47 "app/dbio/ac_io_0025.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0025.pgc" +#line 48 "app/dbio/ac_io_0025.pgc" if (!key) @@ -150,9 +150,7 @@ int ac_io_0025_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0025_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from ac_io_0025_tmp_t where ref_key = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/ac_io_0025.pgc" @@ -172,14 +170,18 @@ long ac_io_0025_total(const char *biz_date) /* exec sql begin declare section */ + #line 72 "app/dbio/ac_io_0025.pgc" char h_biz_date [ 9 ] ; #line 73 "app/dbio/ac_io_0025.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_avg ; + #line 74 "app/dbio/ac_io_0025.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 75 "app/dbio/ac_io_0025.pgc" if (!biz_date) @@ -188,17 +190,20 @@ long ac_io_0025_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0025_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select avg ( appr_amt ) from ac_io_0025_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0025.pgc" + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 86 "app/dbio/ac_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0025_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/ac_io_0025.pgc b/app/dbio/ac_io_0025.pgc index f950c9f..6b9b3e0 100644 --- a/app/dbio/ac_io_0025.pgc +++ b/app/dbio/ac_io_0025.pgc @@ -24,10 +24,11 @@ int ac_io_0025_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT net_amt INTO :h_amount FROM ac_io_0025_t - WHERE key = :h_key; + WHERE mcht_no IN + (SELECT mcht_no FROM ac_io_0025_map_t WHERE grp_key = :h_key); if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,8 @@ int ac_io_0025_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE ac_io_0025_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM ac_io_0025_tmp_t + WHERE ref_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0025_touch"); @@ -70,7 +70,8 @@ long ac_io_0025_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_avg; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +80,17 @@ long ac_io_0025_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM ac_io_0025_t + EXEC SQL SELECT avg(appr_amt) + INTO :h_avg :h_ind + FROM ac_io_0025_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0025_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/ac_io_0026.c b/app/dbio/ac_io_0026.c index 8ec5418..d7c3741 100644 --- a/app/dbio/ac_io_0026.c +++ b/app/dbio/ac_io_0026.c @@ -110,20 +110,43 @@ int ac_io_0026_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0026_t where key = $1 ", + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cur_ac_io_0026_f cursor for select appr_amt from ac_io_0026_dtl_t where mcht_no = $1 order by seq desc */ +#line 29 "app/dbio/ac_io_0026.pgc" + +#line 29 "app/dbio/ac_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_io_0026_f cursor for select appr_amt from ac_io_0026_dtl_t where mcht_no = $1 order by seq desc", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 30 "app/dbio/ac_io_0026.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0026_fetch"); return TX_EDB; } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_io_0026_f", ECPGt_EOIT, + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 35 "app/dbio/ac_io_0026.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_io_0026_f", ECPGt_EOIT, ECPGt_EORT);} +#line 37 "app/dbio/ac_io_0026.pgc" + + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0026_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_io_0026_f", ECPGt_EOIT, ECPGt_EORT);} +#line 42 "app/dbio/ac_io_0026.pgc" + + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_io_0026_f", ECPGt_EOIT, ECPGt_EORT);} +#line 45 "app/dbio/ac_io_0026.pgc" + + *out_amount = h_amount; return TX_OK; } @@ -134,13 +157,13 @@ int ac_io_0026_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0026.pgc" +#line 54 "app/dbio/ac_io_0026.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0026.pgc" +#line 55 "app/dbio/ac_io_0026.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0026.pgc" +#line 56 "app/dbio/ac_io_0026.pgc" if (!key) @@ -150,12 +173,14 @@ int ac_io_0026_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0026_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0026_t set fee_amt = $1 , vat_amt = $2 / 10 , upd_ts = now ( ) where mcht_no = $3 ", + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + 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_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0026.pgc" +#line 67 "app/dbio/ac_io_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +198,13 @@ long ac_io_0026_total(const char *biz_date) -#line 72 "app/dbio/ac_io_0026.pgc" +#line 81 "app/dbio/ac_io_0026.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0026.pgc" +#line 82 "app/dbio/ac_io_0026.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0026.pgc" +#line 83 "app/dbio/ac_io_0026.pgc" if (!biz_date) @@ -188,17 +213,20 @@ long ac_io_0026_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0026_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( net_amt ) , 0 ) from ac_io_0026_t where biz_date = $1 group by biz_date having sum ( net_amt ) > 0 limit 1", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0026.pgc" +#line 97 "app/dbio/ac_io_0026.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0026_total"); return -1; } return h_sum; } + diff --git a/app/dbio/ac_io_0026.pgc b/app/dbio/ac_io_0026.pgc index 9c8532f..9526359 100644 --- a/app/dbio/ac_io_0026.pgc +++ b/app/dbio/ac_io_0026.pgc @@ -24,17 +24,26 @@ int ac_io_0026_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM ac_io_0026_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL DECLARE cur_ac_io_0026_f CURSOR FOR + SELECT appr_amt FROM ac_io_0026_dtl_t + WHERE mcht_no = :h_key ORDER BY seq DESC; + EXEC SQL OPEN cur_ac_io_0026_f; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0026_fetch"); return TX_EDB; } + EXEC SQL FETCH cur_ac_io_0026_f INTO :h_amount; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE cur_ac_io_0026_f; + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0026_fetch"); + EXEC SQL CLOSE cur_ac_io_0026_f; + return TX_EDB; + } + EXEC SQL CLOSE cur_ac_io_0026_f; + *out_amount = h_amount; return TX_OK; } @@ -54,8 +63,8 @@ int ac_io_0026_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE ac_io_0026_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET fee_amt = :h_amount, vat_amt = :h_amount / 10, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0026_touch"); @@ -79,14 +88,20 @@ long ac_io_0026_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(net_amt), 0) INTO :h_sum FROM ac_io_0026_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + GROUP BY biz_date + HAVING sum(net_amt) > 0 + LIMIT 1; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0026_total"); return -1; } return h_sum; } + diff --git a/app/dbio/ac_io_0027.c b/app/dbio/ac_io_0027.c index 9839666..81808c4 100644 --- a/app/dbio/ac_io_0027.c +++ b/app/dbio/ac_io_0027.c @@ -110,12 +110,12 @@ int ac_io_0027_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from ac_io_0027_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when status_cd = '00' then appr_amt else 0 end from ac_io_0027_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/ac_io_0027.pgc" +#line 31 "app/dbio/ac_io_0027.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int ac_io_0027_touch(const char *key, long amount) -#line 45 "app/dbio/ac_io_0027.pgc" +#line 46 "app/dbio/ac_io_0027.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/ac_io_0027.pgc" +#line 47 "app/dbio/ac_io_0027.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/ac_io_0027.pgc" +#line 48 "app/dbio/ac_io_0027.pgc" if (!key) @@ -150,12 +150,12 @@ int ac_io_0027_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0027_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update ac_io_0027_t set status_cd = case when $1 > 0 then '00' else '99' end , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/ac_io_0027.pgc" +#line 60 "app/dbio/ac_io_0027.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -172,14 +172,18 @@ long ac_io_0027_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/ac_io_0027.pgc" +#line 74 "app/dbio/ac_io_0027.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/ac_io_0027.pgc" - long h_sum ; +#line 75 "app/dbio/ac_io_0027.pgc" + long h_row ; + +#line 76 "app/dbio/ac_io_0027.pgc" + long acc = 0 ; /* exec sql end declare section */ -#line 74 "app/dbio/ac_io_0027.pgc" +#line 77 "app/dbio/ac_io_0027.pgc" if (!biz_date) @@ -188,17 +192,42 @@ long ac_io_0027_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from ac_io_0027_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/ac_io_0027.pgc" + ECPGset_var( 0, ( h_biz_date ), __LINE__);\ + /* declare cur_ac_io_0027_t cursor for select net_amt from ac_io_0027_sum_t where biz_date = $1 */ +#line 86 "app/dbio/ac_io_0027.pgc" +#line 86 "app/dbio/ac_io_0027.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_ac_io_0027_t cursor for select net_amt from ac_io_0027_sum_t where biz_date = $1 ", + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 87 "app/dbio/ac_io_0027.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0027_total"); return -1; } - return h_sum; + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_ac_io_0027_t", ECPGt_EOIT, + ECPGt_long,&(h_row),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 93 "app/dbio/ac_io_0027.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0027_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_io_0027_t", ECPGt_EOIT, ECPGt_EORT);} +#line 98 "app/dbio/ac_io_0027.pgc" + + return -1; + } + acc += h_row; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_ac_io_0027_t", ECPGt_EOIT, ECPGt_EORT);} +#line 103 "app/dbio/ac_io_0027.pgc" + + + return acc; } + diff --git a/app/dbio/ac_io_0027.pgc b/app/dbio/ac_io_0027.pgc index 9596abe..9e9496e 100644 --- a/app/dbio/ac_io_0027.pgc +++ b/app/dbio/ac_io_0027.pgc @@ -24,10 +24,11 @@ int ac_io_0027_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT + CASE WHEN status_cd = '00' THEN appr_amt ELSE 0 END INTO :h_amount FROM ac_io_0027_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,9 @@ int ac_io_0027_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE ac_io_0027_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET status_cd = CASE WHEN :h_amount > 0 THEN '00' ELSE '99' END, + upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0027_touch"); @@ -70,7 +72,8 @@ long ac_io_0027_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_row; + long acc = 0; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +82,26 @@ long ac_io_0027_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM ac_io_0027_t - WHERE biz_date = :h_biz_date; - + EXEC SQL DECLARE cur_ac_io_0027_t CURSOR FOR + SELECT net_amt FROM ac_io_0027_sum_t WHERE biz_date = :h_biz_date; + EXEC SQL OPEN cur_ac_io_0027_t; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("ac_io_0027_total"); return -1; } - return h_sum; + for (;;) { + EXEC SQL FETCH cur_ac_io_0027_t INTO :h_row; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("ac_io_0027_total"); + EXEC SQL CLOSE cur_ac_io_0027_t; + return -1; + } + acc += h_row; + } + EXEC SQL CLOSE cur_ac_io_0027_t; + + return acc; } + diff --git a/app/dbio/au_io_0001.c b/app/dbio/au_io_0001.c index 2f4fa81..2e4b594 100644 --- a/app/dbio/au_io_0001.c +++ b/app/dbio/au_io_0001.c @@ -110,7 +110,7 @@ int au_io_0001_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0001_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt from au_io_0001_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), @@ -150,7 +150,7 @@ int au_io_0001_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0001_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0001_t set appr_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), @@ -188,7 +188,7 @@ long au_io_0001_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0001_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( appr_amt ) , 0 ) from au_io_0001_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), @@ -202,3 +202,4 @@ long au_io_0001_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0001.pgc b/app/dbio/au_io_0001.pgc index c234fcd..d10bd58 100644 --- a/app/dbio/au_io_0001.pgc +++ b/app/dbio/au_io_0001.pgc @@ -24,10 +24,10 @@ int au_io_0001_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT appr_amt INTO :h_amount FROM au_io_0001_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +54,8 @@ int au_io_0001_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE au_io_0001_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET appr_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0001_touch"); @@ -79,7 +79,7 @@ long au_io_0001_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(appr_amt), 0) INTO :h_sum FROM au_io_0001_t WHERE biz_date = :h_biz_date; @@ -90,3 +90,4 @@ long au_io_0001_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0002.c b/app/dbio/au_io_0002.c index e781017..fc1e006 100644 --- a/app/dbio/au_io_0002.c +++ b/app/dbio/au_io_0002.c @@ -94,14 +94,22 @@ int au_io_0002_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + + #line 17 "app/dbio/au_io_0002.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/au_io_0002.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_appr ; + #line 19 "app/dbio/au_io_0002.pgc" + long h_fee ; + +#line 20 "app/dbio/au_io_0002.pgc" + long h_vat ; +/* exec sql end declare section */ +#line 21 "app/dbio/au_io_0002.pgc" if (!key || !out_amount) @@ -110,12 +118,16 @@ int au_io_0002_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0002_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt , fee_amt , vat_amt from au_io_0002_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_appr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_vat),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0002.pgc" +#line 32 "app/dbio/au_io_0002.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +136,7 @@ int au_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -134,13 +146,13 @@ int au_io_0002_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0002.pgc" +#line 47 "app/dbio/au_io_0002.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0002.pgc" +#line 48 "app/dbio/au_io_0002.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0002.pgc" +#line 49 "app/dbio/au_io_0002.pgc" if (!key) @@ -150,12 +162,12 @@ int au_io_0002_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0002_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0002_t set net_amt = $1 , upd_ts = now ( ) where mcht_no = $2 and status_cd = '00' and appr_amt > 0", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0002.pgc" +#line 60 "app/dbio/au_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +185,13 @@ long au_io_0002_total(const char *biz_date) -#line 72 "app/dbio/au_io_0002.pgc" +#line 74 "app/dbio/au_io_0002.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0002.pgc" - long h_sum ; +#line 75 "app/dbio/au_io_0002.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0002.pgc" +#line 76 "app/dbio/au_io_0002.pgc" if (!biz_date) @@ -188,17 +200,18 @@ long au_io_0002_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0002_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from au_io_0002_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0002.pgc" +#line 87 "app/dbio/au_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/au_io_0002.pgc b/app/dbio/au_io_0002.pgc index 04cd5b6..b73652d 100644 --- a/app/dbio/au_io_0002.pgc +++ b/app/dbio/au_io_0002.pgc @@ -15,7 +15,9 @@ int au_io_0002_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; - long h_amount; + long h_appr; + long h_fee; + long h_vat; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +26,10 @@ int au_io_0002_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM au_io_0002_t - WHERE key = :h_key; + EXEC SQL SELECT appr_amt, fee_amt, vat_amt + INTO :h_appr, :h_fee, :h_vat + FROM au_io_0002_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,7 +37,7 @@ int au_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -54,8 +56,8 @@ int au_io_0002_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE au_io_0002_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET net_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key AND status_cd = '00' AND appr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0002_touch"); @@ -70,7 +72,7 @@ long au_io_0002_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,8 +81,8 @@ long au_io_0002_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_cnt FROM au_io_0002_t WHERE biz_date = :h_biz_date; @@ -88,5 +90,6 @@ long au_io_0002_total(const char *biz_date) TX_DBIO_LOG_ERR("au_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/au_io_0003.c b/app/dbio/au_io_0003.c index 2a2ce00..41c57e1 100644 --- a/app/dbio/au_io_0003.c +++ b/app/dbio/au_io_0003.c @@ -110,12 +110,12 @@ int au_io_0003_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0003_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select h . net_amt from au_io_0003_t h join au_io_0003_map_t m on m . mcht_no = h . mcht_no where h . mcht_no = $1 and m . use_yn = 'Y'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0003.pgc" +#line 31 "app/dbio/au_io_0003.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int au_io_0003_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0003.pgc" +#line 46 "app/dbio/au_io_0003.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0003.pgc" +#line 47 "app/dbio/au_io_0003.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0003.pgc" +#line 48 "app/dbio/au_io_0003.pgc" if (!key) @@ -150,10 +150,10 @@ int au_io_0003_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0003_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into au_io_0003_log_t ( mcht_no , appr_amt , reg_ts ) values ( $1 , $2 , now ( ) )", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} #line 58 "app/dbio/au_io_0003.pgc" @@ -162,8 +162,6 @@ int au_io_0003_touch(const char *key, long amount) TX_DBIO_LOG_ERR("au_io_0003_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -172,14 +170,18 @@ long au_io_0003_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/au_io_0003.pgc" +#line 70 "app/dbio/au_io_0003.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0003.pgc" - long h_sum ; +#line 71 "app/dbio/au_io_0003.pgc" + long h_avg ; + +#line 72 "app/dbio/au_io_0003.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0003.pgc" +#line 73 "app/dbio/au_io_0003.pgc" if (!biz_date) @@ -188,17 +190,20 @@ long au_io_0003_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0003_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select avg ( appr_amt ) from au_io_0003_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0003.pgc" + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 84 "app/dbio/au_io_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0003_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/au_io_0003.pgc b/app/dbio/au_io_0003.pgc index a549d3f..c05d90a 100644 --- a/app/dbio/au_io_0003.pgc +++ b/app/dbio/au_io_0003.pgc @@ -24,10 +24,11 @@ int au_io_0003_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT h.net_amt INTO :h_amount - FROM au_io_0003_t - WHERE key = :h_key; + FROM au_io_0003_t h + JOIN au_io_0003_map_t m ON m.mcht_no = h.mcht_no + WHERE h.mcht_no = :h_key AND m.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,16 +54,13 @@ int au_io_0003_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE au_io_0003_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL INSERT INTO au_io_0003_log_t (mcht_no, appr_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0003_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -70,7 +68,8 @@ long au_io_0003_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_avg; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +78,17 @@ long au_io_0003_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM au_io_0003_t + EXEC SQL SELECT avg(appr_amt) + INTO :h_avg :h_ind + FROM au_io_0003_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0003_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/au_io_0004.c b/app/dbio/au_io_0004.c index 65e7146..8b374bc 100644 --- a/app/dbio/au_io_0004.c +++ b/app/dbio/au_io_0004.c @@ -94,14 +94,18 @@ int au_io_0004_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/au_io_0004.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/au_io_0004.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/au_io_0004.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/au_io_0004.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int au_io_0004_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0004_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select bal_amt from au_io_0004_bal_t where acct_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0004.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/au_io_0004.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int au_io_0004_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0004_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int au_io_0004_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0004.pgc" +#line 48 "app/dbio/au_io_0004.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0004.pgc" +#line 49 "app/dbio/au_io_0004.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0004.pgc" +#line 50 "app/dbio/au_io_0004.pgc" if (!key) @@ -150,20 +156,31 @@ int au_io_0004_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0004_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0004_bal_t set bal_amt = $1 , upd_ts = now ( ) where acct_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0004.pgc" +#line 61 "app/dbio/au_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into au_io_0004_bal_t ( acct_no , bal_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 69 "app/dbio/au_io_0004.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0004_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -173,13 +190,13 @@ long au_io_0004_total(const char *biz_date) -#line 72 "app/dbio/au_io_0004.pgc" +#line 81 "app/dbio/au_io_0004.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0004.pgc" +#line 82 "app/dbio/au_io_0004.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0004.pgc" +#line 83 "app/dbio/au_io_0004.pgc" if (!biz_date) @@ -188,17 +205,20 @@ long au_io_0004_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0004_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( net_amt ) , 0 ) from au_io_0004_t where biz_date = $1 group by biz_date having sum ( net_amt ) > 0 limit 1", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0004.pgc" +#line 97 "app/dbio/au_io_0004.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0004_total"); return -1; } return h_sum; } + diff --git a/app/dbio/au_io_0004.pgc b/app/dbio/au_io_0004.pgc index ffcb6ac..720a7a1 100644 --- a/app/dbio/au_io_0004.pgc +++ b/app/dbio/au_io_0004.pgc @@ -16,6 +16,7 @@ int au_io_0004_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int au_io_0004_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM au_io_0004_t - WHERE key = :h_key; + EXEC SQL SELECT bal_amt + INTO :h_amount :h_ind + FROM au_io_0004_bal_t + WHERE acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int au_io_0004_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0004_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -53,16 +56,22 @@ int au_io_0004_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE au_io_0004_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE au_io_0004_bal_t + SET bal_amt = :h_amount, upd_ts = now() + WHERE acct_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + EXEC SQL INSERT INTO au_io_0004_bal_t (acct_no, bal_amt, upd_ts) + VALUES (:h_key, :h_amount, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0004_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -79,14 +88,20 @@ long au_io_0004_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(net_amt), 0) INTO :h_sum FROM au_io_0004_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + GROUP BY biz_date + HAVING sum(net_amt) > 0 + LIMIT 1; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0004_total"); return -1; } return h_sum; } + diff --git a/app/dbio/au_io_0005.c b/app/dbio/au_io_0005.c index 4450ccd..1681c08 100644 --- a/app/dbio/au_io_0005.c +++ b/app/dbio/au_io_0005.c @@ -110,12 +110,12 @@ int au_io_0005_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0005_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select req_amt from au_io_0005_t where mcht_no = $1 and status_cd = '00' and cancel_yn = 'N'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0005.pgc" +#line 31 "app/dbio/au_io_0005.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int au_io_0005_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0005.pgc" +#line 46 "app/dbio/au_io_0005.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0005.pgc" +#line 47 "app/dbio/au_io_0005.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0005.pgc" +#line 48 "app/dbio/au_io_0005.pgc" if (!key) @@ -150,9 +150,7 @@ int au_io_0005_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0005_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from au_io_0005_tmp_t where ref_key = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/au_io_0005.pgc" @@ -172,14 +170,18 @@ long au_io_0005_total(const char *biz_date) /* exec sql begin declare section */ + #line 72 "app/dbio/au_io_0005.pgc" char h_biz_date [ 9 ] ; #line 73 "app/dbio/au_io_0005.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_row ; + #line 74 "app/dbio/au_io_0005.pgc" + long acc = 0 ; +/* exec sql end declare section */ +#line 75 "app/dbio/au_io_0005.pgc" if (!biz_date) @@ -188,17 +190,42 @@ long au_io_0005_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0005_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0005.pgc" + ECPGset_var( 0, ( h_biz_date ), __LINE__);\ + /* declare cur_au_io_0005_t cursor for select net_amt from au_io_0005_sum_t where biz_date = $1 */ +#line 84 "app/dbio/au_io_0005.pgc" +#line 84 "app/dbio/au_io_0005.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_io_0005_t cursor for select net_amt from au_io_0005_sum_t where biz_date = $1 ", + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 85 "app/dbio/au_io_0005.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0005_total"); return -1; } - return h_sum; + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_io_0005_t", ECPGt_EOIT, + ECPGt_long,&(h_row),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 91 "app/dbio/au_io_0005.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0005_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_io_0005_t", ECPGt_EOIT, ECPGt_EORT);} +#line 96 "app/dbio/au_io_0005.pgc" + + return -1; + } + acc += h_row; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_io_0005_t", ECPGt_EOIT, ECPGt_EORT);} +#line 101 "app/dbio/au_io_0005.pgc" + + + return acc; } + diff --git a/app/dbio/au_io_0005.pgc b/app/dbio/au_io_0005.pgc index 32019d6..664a4b5 100644 --- a/app/dbio/au_io_0005.pgc +++ b/app/dbio/au_io_0005.pgc @@ -24,10 +24,11 @@ int au_io_0005_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT req_amt INTO :h_amount FROM au_io_0005_t - WHERE key = :h_key; + WHERE mcht_no = :h_key AND status_cd = '00' + AND cancel_yn = 'N'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,8 @@ int au_io_0005_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE au_io_0005_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM au_io_0005_tmp_t + WHERE ref_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0005_touch"); @@ -70,7 +70,8 @@ long au_io_0005_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_row; + long acc = 0; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +80,26 @@ long au_io_0005_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM au_io_0005_t - WHERE biz_date = :h_biz_date; - + EXEC SQL DECLARE cur_au_io_0005_t CURSOR FOR + SELECT net_amt FROM au_io_0005_sum_t WHERE biz_date = :h_biz_date; + EXEC SQL OPEN cur_au_io_0005_t; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0005_total"); return -1; } - return h_sum; + for (;;) { + EXEC SQL FETCH cur_au_io_0005_t INTO :h_row; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0005_total"); + EXEC SQL CLOSE cur_au_io_0005_t; + return -1; + } + acc += h_row; + } + EXEC SQL CLOSE cur_au_io_0005_t; + + return acc; } + diff --git a/app/dbio/au_io_0006.c b/app/dbio/au_io_0006.c index 6caf83a..7f5fb21 100644 --- a/app/dbio/au_io_0006.c +++ b/app/dbio/au_io_0006.c @@ -94,14 +94,18 @@ int au_io_0006_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/au_io_0006.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/au_io_0006.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/au_io_0006.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/au_io_0006.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int au_io_0006_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0006_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( appr_amt ) from au_io_0006_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0006.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/au_io_0006.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int au_io_0006_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0006_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int au_io_0006_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0006.pgc" +#line 48 "app/dbio/au_io_0006.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0006.pgc" +#line 49 "app/dbio/au_io_0006.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0006.pgc" +#line 50 "app/dbio/au_io_0006.pgc" if (!key) @@ -150,12 +156,14 @@ int au_io_0006_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0006_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0006_t set fee_amt = $1 , vat_amt = $2 / 10 , upd_ts = now ( ) where mcht_no = $3 ", + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + 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_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0006.pgc" +#line 61 "app/dbio/au_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -172,14 +180,18 @@ long au_io_0006_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/au_io_0006.pgc" +#line 75 "app/dbio/au_io_0006.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0006.pgc" - long h_sum ; +#line 76 "app/dbio/au_io_0006.pgc" + long h_max ; + +#line 77 "app/dbio/au_io_0006.pgc" + long h_min ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0006.pgc" +#line 78 "app/dbio/au_io_0006.pgc" if (!biz_date) @@ -188,17 +200,20 @@ long au_io_0006_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0006_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( max ( appr_amt ) , 0 ) , coalesce ( min ( appr_amt ) , 0 ) from au_io_0006_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0006.pgc" +#line 89 "app/dbio/au_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0006_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/au_io_0006.pgc b/app/dbio/au_io_0006.pgc index 3aa3f7b..e5b55f0 100644 --- a/app/dbio/au_io_0006.pgc +++ b/app/dbio/au_io_0006.pgc @@ -16,6 +16,7 @@ int au_io_0006_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int au_io_0006_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM au_io_0006_t - WHERE key = :h_key; + EXEC SQL SELECT max(appr_amt) + INTO :h_amount :h_ind + FROM au_io_0006_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int au_io_0006_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0006_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -54,8 +57,8 @@ int au_io_0006_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE au_io_0006_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET fee_amt = :h_amount, vat_amt = :h_amount / 10, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0006_touch"); @@ -70,7 +73,8 @@ long au_io_0006_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_max; + long h_min; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +83,15 @@ long au_io_0006_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM au_io_0006_t + EXEC SQL SELECT coalesce(max(appr_amt), 0), coalesce(min(appr_amt), 0) + INTO :h_max, :h_min + FROM au_io_0006_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0006_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/au_io_0007.c b/app/dbio/au_io_0007.c index 6881149..aa79b3a 100644 --- a/app/dbio/au_io_0007.c +++ b/app/dbio/au_io_0007.c @@ -110,12 +110,12 @@ int au_io_0007_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0007_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select net_amt from au_io_0007_t where mcht_no in ( select mcht_no from au_io_0007_map_t where grp_key = $1 )", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0007.pgc" +#line 31 "app/dbio/au_io_0007.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int au_io_0007_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0007.pgc" +#line 46 "app/dbio/au_io_0007.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0007.pgc" +#line 47 "app/dbio/au_io_0007.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0007.pgc" +#line 48 "app/dbio/au_io_0007.pgc" if (!key) @@ -150,12 +150,12 @@ int au_io_0007_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0007_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0007_t set status_cd = case when $1 > 0 then '00' else '99' end , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0007.pgc" +#line 60 "app/dbio/au_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long au_io_0007_total(const char *biz_date) -#line 72 "app/dbio/au_io_0007.pgc" +#line 74 "app/dbio/au_io_0007.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0007.pgc" +#line 75 "app/dbio/au_io_0007.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0007.pgc" +#line 76 "app/dbio/au_io_0007.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long au_io_0007_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0007_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . appr_amt ) , 0 ) from au_io_0007_dtl_t d join au_io_0007_t h on h . mcht_no = d . mcht_no where d . biz_date = $1 and h . status_cd = '00'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0007.pgc" +#line 88 "app/dbio/au_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long au_io_0007_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0007.pgc b/app/dbio/au_io_0007.pgc index 3445134..80d9953 100644 --- a/app/dbio/au_io_0007.pgc +++ b/app/dbio/au_io_0007.pgc @@ -24,10 +24,11 @@ int au_io_0007_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT net_amt INTO :h_amount FROM au_io_0007_t - WHERE key = :h_key; + WHERE mcht_no IN + (SELECT mcht_no FROM au_io_0007_map_t WHERE grp_key = :h_key); if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,9 @@ int au_io_0007_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE au_io_0007_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET status_cd = CASE WHEN :h_amount > 0 THEN '00' ELSE '99' END, + upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0007_touch"); @@ -79,10 +81,11 @@ long au_io_0007_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.appr_amt), 0) INTO :h_sum - FROM au_io_0007_t - WHERE biz_date = :h_biz_date; + FROM au_io_0007_dtl_t d + JOIN au_io_0007_t h ON h.mcht_no = d.mcht_no + WHERE d.biz_date = :h_biz_date AND h.status_cd = '00'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0007_total"); @@ -90,3 +93,4 @@ long au_io_0007_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0008.c b/app/dbio/au_io_0008.c index 5251367..30b6a7f 100644 --- a/app/dbio/au_io_0008.c +++ b/app/dbio/au_io_0008.c @@ -110,20 +110,43 @@ int au_io_0008_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0008_t where key = $1 ", + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cur_au_io_0008_f cursor for select appr_amt from au_io_0008_dtl_t where mcht_no = $1 order by seq desc */ +#line 29 "app/dbio/au_io_0008.pgc" + +#line 29 "app/dbio/au_io_0008.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_io_0008_f cursor for select appr_amt from au_io_0008_dtl_t where mcht_no = $1 order by seq desc", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 30 "app/dbio/au_io_0008.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0008_fetch"); return TX_EDB; } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_io_0008_f", ECPGt_EOIT, + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 35 "app/dbio/au_io_0008.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_io_0008_f", ECPGt_EOIT, ECPGt_EORT);} +#line 37 "app/dbio/au_io_0008.pgc" + + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0008_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_io_0008_f", ECPGt_EOIT, ECPGt_EORT);} +#line 42 "app/dbio/au_io_0008.pgc" + + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_io_0008_f", ECPGt_EOIT, ECPGt_EORT);} +#line 45 "app/dbio/au_io_0008.pgc" + + *out_amount = h_amount; return TX_OK; } @@ -134,13 +157,13 @@ int au_io_0008_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0008.pgc" +#line 54 "app/dbio/au_io_0008.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0008.pgc" +#line 55 "app/dbio/au_io_0008.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0008.pgc" +#line 56 "app/dbio/au_io_0008.pgc" if (!key) @@ -150,12 +173,12 @@ int au_io_0008_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0008_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0008_acc_t set accum_amt = accum_amt + $1 , cnt = cnt + 1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0008.pgc" +#line 67 "app/dbio/au_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +196,13 @@ long au_io_0008_total(const char *biz_date) -#line 72 "app/dbio/au_io_0008.pgc" +#line 81 "app/dbio/au_io_0008.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0008.pgc" - long h_sum ; +#line 82 "app/dbio/au_io_0008.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0008.pgc" +#line 83 "app/dbio/au_io_0008.pgc" if (!biz_date) @@ -188,17 +211,18 @@ long au_io_0008_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0008_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct mcht_no ) from au_io_0008_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0008.pgc" +#line 94 "app/dbio/au_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0008_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/au_io_0008.pgc b/app/dbio/au_io_0008.pgc index 17a2ee8..9473844 100644 --- a/app/dbio/au_io_0008.pgc +++ b/app/dbio/au_io_0008.pgc @@ -24,17 +24,26 @@ int au_io_0008_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM au_io_0008_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL DECLARE cur_au_io_0008_f CURSOR FOR + SELECT appr_amt FROM au_io_0008_dtl_t + WHERE mcht_no = :h_key ORDER BY seq DESC; + EXEC SQL OPEN cur_au_io_0008_f; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0008_fetch"); return TX_EDB; } + EXEC SQL FETCH cur_au_io_0008_f INTO :h_amount; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE cur_au_io_0008_f; + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0008_fetch"); + EXEC SQL CLOSE cur_au_io_0008_f; + return TX_EDB; + } + EXEC SQL CLOSE cur_au_io_0008_f; + *out_amount = h_amount; return TX_OK; } @@ -53,9 +62,9 @@ int au_io_0008_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE au_io_0008_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE au_io_0008_acc_t + SET accum_amt = accum_amt + :h_amount, cnt = cnt + 1, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0008_touch"); @@ -70,7 +79,7 @@ long au_io_0008_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +88,15 @@ long au_io_0008_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM au_io_0008_t + EXEC SQL SELECT count(DISTINCT mcht_no) + INTO :h_cnt + FROM au_io_0008_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0008_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/au_io_0009.c b/app/dbio/au_io_0009.c index b42e871..f274c28 100644 --- a/app/dbio/au_io_0009.c +++ b/app/dbio/au_io_0009.c @@ -110,12 +110,12 @@ int au_io_0009_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0009_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when status_cd = '00' then appr_amt else 0 end from au_io_0009_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0009.pgc" +#line 31 "app/dbio/au_io_0009.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int au_io_0009_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0009.pgc" +#line 46 "app/dbio/au_io_0009.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0009.pgc" +#line 47 "app/dbio/au_io_0009.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0009.pgc" +#line 48 "app/dbio/au_io_0009.pgc" if (!key) @@ -150,10 +150,10 @@ int au_io_0009_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0009_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from au_io_0009_bal_t where acct_no = $1 and bal_amt <= $2 ", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} #line 58 "app/dbio/au_io_0009.pgc" @@ -188,12 +188,12 @@ long au_io_0009_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0009_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( cancel_amt ) , 0 ) from au_io_0009_t where biz_date = $1 and status_cd = '90' and cancel_yn = 'Y'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0009.pgc" +#line 86 "app/dbio/au_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long au_io_0009_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0009.pgc b/app/dbio/au_io_0009.pgc index 2dfda02..cc168fd 100644 --- a/app/dbio/au_io_0009.pgc +++ b/app/dbio/au_io_0009.pgc @@ -24,10 +24,11 @@ int au_io_0009_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT + CASE WHEN status_cd = '00' THEN appr_amt ELSE 0 END INTO :h_amount FROM au_io_0009_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,8 @@ int au_io_0009_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE au_io_0009_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM au_io_0009_bal_t + WHERE acct_no = :h_key AND bal_amt <= :h_amount; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0009_touch"); @@ -79,10 +79,11 @@ long au_io_0009_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(cancel_amt), 0) INTO :h_sum FROM au_io_0009_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + AND status_cd = '90' AND cancel_yn = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0009_total"); @@ -90,3 +91,4 @@ long au_io_0009_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0010.c b/app/dbio/au_io_0010.c index 1a9e450..eaeb9f9 100644 --- a/app/dbio/au_io_0010.c +++ b/app/dbio/au_io_0010.c @@ -110,7 +110,7 @@ int au_io_0010_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0010_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt from au_io_0010_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), @@ -150,20 +150,29 @@ int au_io_0010_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0010_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0010_t set req_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/au_io_0010.pgc" + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0010_touch"); + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into au_io_0010_hist_t ( mcht_no , req_amt , reg_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 64 "app/dbio/au_io_0010.pgc" + if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0010_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,13 +182,13 @@ long au_io_0010_total(const char *biz_date) -#line 72 "app/dbio/au_io_0010.pgc" +#line 76 "app/dbio/au_io_0010.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0010.pgc" +#line 77 "app/dbio/au_io_0010.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0010.pgc" +#line 78 "app/dbio/au_io_0010.pgc" if (!biz_date) @@ -188,12 +197,12 @@ long au_io_0010_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0010_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( recon_amt ) , 0 ) from au_io_0010_sum_t where biz_date in ( select biz_date from au_io_0010_map_t where biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0010.pgc" +#line 90 "app/dbio/au_io_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +211,4 @@ long au_io_0010_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0010.pgc b/app/dbio/au_io_0010.pgc index cd5db21..c3366aa 100644 --- a/app/dbio/au_io_0010.pgc +++ b/app/dbio/au_io_0010.pgc @@ -24,10 +24,10 @@ int au_io_0010_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT appr_amt INTO :h_amount FROM au_io_0010_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,15 +54,19 @@ int au_io_0010_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE au_io_0010_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET req_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0010_touch"); + return TX_EDB; + } + EXEC SQL INSERT INTO au_io_0010_hist_t (mcht_no, req_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0010_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -79,10 +83,11 @@ long au_io_0010_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(recon_amt), 0) INTO :h_sum - FROM au_io_0010_t - WHERE biz_date = :h_biz_date; + FROM au_io_0010_sum_t + WHERE biz_date IN + (SELECT biz_date FROM au_io_0010_map_t WHERE biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0010_total"); @@ -90,3 +95,4 @@ long au_io_0010_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0011.c b/app/dbio/au_io_0011.c index fc54471..c987749 100644 --- a/app/dbio/au_io_0011.c +++ b/app/dbio/au_io_0011.c @@ -94,14 +94,22 @@ int au_io_0011_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + + #line 17 "app/dbio/au_io_0011.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/au_io_0011.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_appr ; + #line 19 "app/dbio/au_io_0011.pgc" + long h_fee ; + +#line 20 "app/dbio/au_io_0011.pgc" + long h_vat ; +/* exec sql end declare section */ +#line 21 "app/dbio/au_io_0011.pgc" if (!key || !out_amount) @@ -110,12 +118,16 @@ int au_io_0011_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0011_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt , fee_amt , vat_amt from au_io_0011_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_appr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_vat),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0011.pgc" +#line 32 "app/dbio/au_io_0011.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +136,7 @@ int au_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -134,13 +146,13 @@ int au_io_0011_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0011.pgc" +#line 47 "app/dbio/au_io_0011.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0011.pgc" +#line 48 "app/dbio/au_io_0011.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0011.pgc" +#line 49 "app/dbio/au_io_0011.pgc" if (!key) @@ -150,12 +162,12 @@ int au_io_0011_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0011_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0011_t set appr_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0011.pgc" +#line 60 "app/dbio/au_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +185,13 @@ long au_io_0011_total(const char *biz_date) -#line 72 "app/dbio/au_io_0011.pgc" +#line 74 "app/dbio/au_io_0011.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0011.pgc" - long h_sum ; +#line 75 "app/dbio/au_io_0011.pgc" + long h_flag ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0011.pgc" +#line 76 "app/dbio/au_io_0011.pgc" if (!biz_date) @@ -188,17 +200,18 @@ long au_io_0011_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0011_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from au_io_0011_t where exists ( select 1 from au_io_0011_dtl_t d where d . biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0011.pgc" +#line 89 "app/dbio/au_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0011_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/au_io_0011.pgc b/app/dbio/au_io_0011.pgc index 508273b..8404ab3 100644 --- a/app/dbio/au_io_0011.pgc +++ b/app/dbio/au_io_0011.pgc @@ -15,7 +15,9 @@ int au_io_0011_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; - long h_amount; + long h_appr; + long h_fee; + long h_vat; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +26,10 @@ int au_io_0011_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM au_io_0011_t - WHERE key = :h_key; + EXEC SQL SELECT appr_amt, fee_amt, vat_amt + INTO :h_appr, :h_fee, :h_vat + FROM au_io_0011_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,7 +37,7 @@ int au_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -54,8 +56,8 @@ int au_io_0011_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE au_io_0011_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET appr_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0011_touch"); @@ -70,7 +72,7 @@ long au_io_0011_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_flag; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +81,17 @@ long au_io_0011_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_flag FROM au_io_0011_t - WHERE biz_date = :h_biz_date; + WHERE EXISTS + (SELECT 1 FROM au_io_0011_dtl_t d + WHERE d.biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0011_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/au_io_0012.c b/app/dbio/au_io_0012.c index 5fe9af1..55b36e5 100644 --- a/app/dbio/au_io_0012.c +++ b/app/dbio/au_io_0012.c @@ -110,12 +110,12 @@ int au_io_0012_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0012_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select h . net_amt from au_io_0012_t h join au_io_0012_map_t m on m . mcht_no = h . mcht_no where h . mcht_no = $1 and m . use_yn = 'Y'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0012.pgc" +#line 31 "app/dbio/au_io_0012.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int au_io_0012_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0012.pgc" +#line 46 "app/dbio/au_io_0012.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0012.pgc" +#line 47 "app/dbio/au_io_0012.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0012.pgc" +#line 48 "app/dbio/au_io_0012.pgc" if (!key) @@ -150,12 +150,12 @@ int au_io_0012_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0012_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0012_t set net_amt = $1 , upd_ts = now ( ) where mcht_no = $2 and status_cd = '00' and appr_amt > 0", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0012.pgc" +#line 59 "app/dbio/au_io_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long au_io_0012_total(const char *biz_date) -#line 72 "app/dbio/au_io_0012.pgc" +#line 73 "app/dbio/au_io_0012.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0012.pgc" +#line 74 "app/dbio/au_io_0012.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0012.pgc" +#line 75 "app/dbio/au_io_0012.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long au_io_0012_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0012_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( appr_amt ) , 0 ) from au_io_0012_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0012.pgc" +#line 86 "app/dbio/au_io_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long au_io_0012_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0012.pgc b/app/dbio/au_io_0012.pgc index 5a465cf..f45402d 100644 --- a/app/dbio/au_io_0012.pgc +++ b/app/dbio/au_io_0012.pgc @@ -24,10 +24,11 @@ int au_io_0012_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT h.net_amt INTO :h_amount - FROM au_io_0012_t - WHERE key = :h_key; + FROM au_io_0012_t h + JOIN au_io_0012_map_t m ON m.mcht_no = h.mcht_no + WHERE h.mcht_no = :h_key AND m.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,8 @@ int au_io_0012_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE au_io_0012_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET net_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key AND status_cd = '00' AND appr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0012_touch"); @@ -79,7 +80,7 @@ long au_io_0012_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(appr_amt), 0) INTO :h_sum FROM au_io_0012_t WHERE biz_date = :h_biz_date; @@ -90,3 +91,4 @@ long au_io_0012_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0013.c b/app/dbio/au_io_0013.c index 71e5190..1f7b180 100644 --- a/app/dbio/au_io_0013.c +++ b/app/dbio/au_io_0013.c @@ -94,14 +94,18 @@ int au_io_0013_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/au_io_0013.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/au_io_0013.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/au_io_0013.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/au_io_0013.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int au_io_0013_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0013_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select bal_amt from au_io_0013_bal_t where acct_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0013.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/au_io_0013.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int au_io_0013_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0013_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int au_io_0013_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0013.pgc" +#line 48 "app/dbio/au_io_0013.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0013.pgc" +#line 49 "app/dbio/au_io_0013.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0013.pgc" +#line 50 "app/dbio/au_io_0013.pgc" if (!key) @@ -150,20 +156,18 @@ int au_io_0013_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0013_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into au_io_0013_log_t ( mcht_no , appr_amt , reg_ts ) values ( $1 , $2 , now ( ) )", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0013.pgc" +#line 60 "app/dbio/au_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -177,7 +181,7 @@ long au_io_0013_total(const char *biz_date) char h_biz_date [ 9 ] ; #line 73 "app/dbio/au_io_0013.pgc" - long h_sum ; + long h_cnt ; /* exec sql end declare section */ #line 74 "app/dbio/au_io_0013.pgc" @@ -188,10 +192,10 @@ long au_io_0013_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0013_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from au_io_0013_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 85 "app/dbio/au_io_0013.pgc" @@ -200,5 +204,6 @@ long au_io_0013_total(const char *biz_date) TX_DBIO_LOG_ERR("au_io_0013_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/au_io_0013.pgc b/app/dbio/au_io_0013.pgc index b0b0383..0b8230e 100644 --- a/app/dbio/au_io_0013.pgc +++ b/app/dbio/au_io_0013.pgc @@ -16,6 +16,7 @@ int au_io_0013_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int au_io_0013_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM au_io_0013_t - WHERE key = :h_key; + EXEC SQL SELECT bal_amt + INTO :h_amount :h_ind + FROM au_io_0013_bal_t + WHERE acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int au_io_0013_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0013_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -53,16 +56,13 @@ int au_io_0013_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE au_io_0013_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL INSERT INTO au_io_0013_log_t (mcht_no, appr_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -70,7 +70,7 @@ long au_io_0013_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,8 +79,8 @@ long au_io_0013_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_cnt FROM au_io_0013_t WHERE biz_date = :h_biz_date; @@ -88,5 +88,6 @@ long au_io_0013_total(const char *biz_date) TX_DBIO_LOG_ERR("au_io_0013_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/au_io_0014.c b/app/dbio/au_io_0014.c index 21e7395..5b92957 100644 --- a/app/dbio/au_io_0014.c +++ b/app/dbio/au_io_0014.c @@ -110,12 +110,12 @@ int au_io_0014_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0014_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select req_amt from au_io_0014_t where mcht_no = $1 and status_cd = '00' and cancel_yn = 'N'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0014.pgc" +#line 31 "app/dbio/au_io_0014.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int au_io_0014_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0014.pgc" +#line 46 "app/dbio/au_io_0014.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0014.pgc" +#line 47 "app/dbio/au_io_0014.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0014.pgc" +#line 48 "app/dbio/au_io_0014.pgc" if (!key) @@ -150,20 +150,31 @@ int au_io_0014_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0014_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0014_bal_t set bal_amt = $1 , upd_ts = now ( ) where acct_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0014.pgc" +#line 59 "app/dbio/au_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0014_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into au_io_0014_bal_t ( acct_no , bal_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 67 "app/dbio/au_io_0014.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0014_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -172,14 +183,18 @@ long au_io_0014_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/au_io_0014.pgc" +#line 79 "app/dbio/au_io_0014.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0014.pgc" - long h_sum ; +#line 80 "app/dbio/au_io_0014.pgc" + long h_avg ; + +#line 81 "app/dbio/au_io_0014.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0014.pgc" +#line 82 "app/dbio/au_io_0014.pgc" if (!biz_date) @@ -188,17 +203,20 @@ long au_io_0014_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0014_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select avg ( appr_amt ) from au_io_0014_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0014.pgc" + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 93 "app/dbio/au_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0014_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/au_io_0014.pgc b/app/dbio/au_io_0014.pgc index 07e07ec..e170700 100644 --- a/app/dbio/au_io_0014.pgc +++ b/app/dbio/au_io_0014.pgc @@ -24,10 +24,11 @@ int au_io_0014_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT req_amt INTO :h_amount FROM au_io_0014_t - WHERE key = :h_key; + WHERE mcht_no = :h_key AND status_cd = '00' + AND cancel_yn = 'N'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,16 +54,22 @@ int au_io_0014_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE au_io_0014_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE au_io_0014_bal_t + SET bal_amt = :h_amount, upd_ts = now() + WHERE acct_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0014_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + EXEC SQL INSERT INTO au_io_0014_bal_t (acct_no, bal_amt, upd_ts) + VALUES (:h_key, :h_amount, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0014_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -70,7 +77,8 @@ long au_io_0014_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_avg; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +87,17 @@ long au_io_0014_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM au_io_0014_t + EXEC SQL SELECT avg(appr_amt) + INTO :h_avg :h_ind + FROM au_io_0014_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0014_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/au_io_0015.c b/app/dbio/au_io_0015.c index 64a4deb..bc94eae 100644 --- a/app/dbio/au_io_0015.c +++ b/app/dbio/au_io_0015.c @@ -94,14 +94,18 @@ int au_io_0015_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/au_io_0015.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/au_io_0015.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/au_io_0015.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/au_io_0015.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int au_io_0015_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0015_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( appr_amt ) from au_io_0015_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0015.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/au_io_0015.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int au_io_0015_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0015_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int au_io_0015_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0015.pgc" +#line 48 "app/dbio/au_io_0015.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0015.pgc" +#line 49 "app/dbio/au_io_0015.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0015.pgc" +#line 50 "app/dbio/au_io_0015.pgc" if (!key) @@ -150,12 +156,10 @@ int au_io_0015_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0015_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from au_io_0015_tmp_t where ref_key = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0015.pgc" +#line 60 "app/dbio/au_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +177,13 @@ long au_io_0015_total(const char *biz_date) -#line 72 "app/dbio/au_io_0015.pgc" +#line 74 "app/dbio/au_io_0015.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0015.pgc" +#line 75 "app/dbio/au_io_0015.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0015.pgc" +#line 76 "app/dbio/au_io_0015.pgc" if (!biz_date) @@ -188,17 +192,20 @@ long au_io_0015_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0015_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( net_amt ) , 0 ) from au_io_0015_t where biz_date = $1 group by biz_date having sum ( net_amt ) > 0 limit 1", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0015.pgc" +#line 90 "app/dbio/au_io_0015.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0015_total"); return -1; } return h_sum; } + diff --git a/app/dbio/au_io_0015.pgc b/app/dbio/au_io_0015.pgc index 4fe4e86..b0cc396 100644 --- a/app/dbio/au_io_0015.pgc +++ b/app/dbio/au_io_0015.pgc @@ -16,6 +16,7 @@ int au_io_0015_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int au_io_0015_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM au_io_0015_t - WHERE key = :h_key; + EXEC SQL SELECT max(appr_amt) + INTO :h_amount :h_ind + FROM au_io_0015_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int au_io_0015_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0015_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -53,9 +56,8 @@ int au_io_0015_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE au_io_0015_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM au_io_0015_tmp_t + WHERE ref_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0015_touch"); @@ -79,14 +81,20 @@ long au_io_0015_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(net_amt), 0) INTO :h_sum FROM au_io_0015_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + GROUP BY biz_date + HAVING sum(net_amt) > 0 + LIMIT 1; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0015_total"); return -1; } return h_sum; } + diff --git a/app/dbio/au_io_0016.c b/app/dbio/au_io_0016.c index 5b88a8b..c4ab1a6 100644 --- a/app/dbio/au_io_0016.c +++ b/app/dbio/au_io_0016.c @@ -110,12 +110,12 @@ int au_io_0016_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0016_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select net_amt from au_io_0016_t where mcht_no in ( select mcht_no from au_io_0016_map_t where grp_key = $1 )", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0016.pgc" +#line 31 "app/dbio/au_io_0016.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int au_io_0016_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0016.pgc" +#line 46 "app/dbio/au_io_0016.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0016.pgc" +#line 47 "app/dbio/au_io_0016.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0016.pgc" +#line 48 "app/dbio/au_io_0016.pgc" if (!key) @@ -150,12 +150,14 @@ int au_io_0016_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0016_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0016_t set fee_amt = $1 , vat_amt = $2 / 10 , upd_ts = now ( ) where mcht_no = $3 ", + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + 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_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0016.pgc" +#line 59 "app/dbio/au_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -172,14 +174,18 @@ long au_io_0016_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/au_io_0016.pgc" +#line 73 "app/dbio/au_io_0016.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0016.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/au_io_0016.pgc" + long h_row ; + +#line 75 "app/dbio/au_io_0016.pgc" + long acc = 0 ; +/* exec sql end declare section */ +#line 76 "app/dbio/au_io_0016.pgc" if (!biz_date) @@ -188,17 +194,42 @@ long au_io_0016_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0016_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGset_var( 0, ( h_biz_date ), __LINE__);\ + /* declare cur_au_io_0016_t cursor for select net_amt from au_io_0016_sum_t where biz_date = $1 */ #line 85 "app/dbio/au_io_0016.pgc" +#line 85 "app/dbio/au_io_0016.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_io_0016_t cursor for select net_amt from au_io_0016_sum_t where biz_date = $1 ", + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 86 "app/dbio/au_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0016_total"); return -1; } - return h_sum; + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_io_0016_t", ECPGt_EOIT, + ECPGt_long,&(h_row),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 92 "app/dbio/au_io_0016.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0016_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_io_0016_t", ECPGt_EOIT, ECPGt_EORT);} +#line 97 "app/dbio/au_io_0016.pgc" + + return -1; + } + acc += h_row; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_io_0016_t", ECPGt_EOIT, ECPGt_EORT);} +#line 102 "app/dbio/au_io_0016.pgc" + + + return acc; } + diff --git a/app/dbio/au_io_0016.pgc b/app/dbio/au_io_0016.pgc index 2204cee..78df201 100644 --- a/app/dbio/au_io_0016.pgc +++ b/app/dbio/au_io_0016.pgc @@ -24,10 +24,11 @@ int au_io_0016_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT net_amt INTO :h_amount FROM au_io_0016_t - WHERE key = :h_key; + WHERE mcht_no IN + (SELECT mcht_no FROM au_io_0016_map_t WHERE grp_key = :h_key); if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,8 @@ int au_io_0016_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE au_io_0016_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET fee_amt = :h_amount, vat_amt = :h_amount / 10, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0016_touch"); @@ -70,7 +71,8 @@ long au_io_0016_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_row; + long acc = 0; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +81,26 @@ long au_io_0016_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM au_io_0016_t - WHERE biz_date = :h_biz_date; - + EXEC SQL DECLARE cur_au_io_0016_t CURSOR FOR + SELECT net_amt FROM au_io_0016_sum_t WHERE biz_date = :h_biz_date; + EXEC SQL OPEN cur_au_io_0016_t; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0016_total"); return -1; } - return h_sum; + for (;;) { + EXEC SQL FETCH cur_au_io_0016_t INTO :h_row; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0016_total"); + EXEC SQL CLOSE cur_au_io_0016_t; + return -1; + } + acc += h_row; + } + EXEC SQL CLOSE cur_au_io_0016_t; + + return acc; } + diff --git a/app/dbio/au_io_0017.c b/app/dbio/au_io_0017.c index 99f1561..d1191a3 100644 --- a/app/dbio/au_io_0017.c +++ b/app/dbio/au_io_0017.c @@ -110,20 +110,43 @@ int au_io_0017_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0017_t where key = $1 ", + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cur_au_io_0017_f cursor for select appr_amt from au_io_0017_dtl_t where mcht_no = $1 order by seq desc */ +#line 29 "app/dbio/au_io_0017.pgc" + +#line 29 "app/dbio/au_io_0017.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_io_0017_f cursor for select appr_amt from au_io_0017_dtl_t where mcht_no = $1 order by seq desc", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 30 "app/dbio/au_io_0017.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0017_fetch"); return TX_EDB; } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_io_0017_f", ECPGt_EOIT, + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 35 "app/dbio/au_io_0017.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_io_0017_f", ECPGt_EOIT, ECPGt_EORT);} +#line 37 "app/dbio/au_io_0017.pgc" + + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0017_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_io_0017_f", ECPGt_EOIT, ECPGt_EORT);} +#line 42 "app/dbio/au_io_0017.pgc" + + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_io_0017_f", ECPGt_EOIT, ECPGt_EORT);} +#line 45 "app/dbio/au_io_0017.pgc" + + *out_amount = h_amount; return TX_OK; } @@ -134,13 +157,13 @@ int au_io_0017_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0017.pgc" +#line 54 "app/dbio/au_io_0017.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0017.pgc" +#line 55 "app/dbio/au_io_0017.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0017.pgc" +#line 56 "app/dbio/au_io_0017.pgc" if (!key) @@ -150,12 +173,12 @@ int au_io_0017_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0017_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0017_t set status_cd = case when $1 > 0 then '00' else '99' end , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0017.pgc" +#line 68 "app/dbio/au_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -172,14 +195,18 @@ long au_io_0017_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/au_io_0017.pgc" +#line 82 "app/dbio/au_io_0017.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0017.pgc" - long h_sum ; +#line 83 "app/dbio/au_io_0017.pgc" + long h_max ; + +#line 84 "app/dbio/au_io_0017.pgc" + long h_min ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0017.pgc" +#line 85 "app/dbio/au_io_0017.pgc" if (!biz_date) @@ -188,17 +215,20 @@ long au_io_0017_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0017_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( max ( appr_amt ) , 0 ) , coalesce ( min ( appr_amt ) , 0 ) from au_io_0017_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0017.pgc" +#line 96 "app/dbio/au_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0017_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/au_io_0017.pgc b/app/dbio/au_io_0017.pgc index c4e2b33..ed31928 100644 --- a/app/dbio/au_io_0017.pgc +++ b/app/dbio/au_io_0017.pgc @@ -24,17 +24,26 @@ int au_io_0017_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM au_io_0017_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL DECLARE cur_au_io_0017_f CURSOR FOR + SELECT appr_amt FROM au_io_0017_dtl_t + WHERE mcht_no = :h_key ORDER BY seq DESC; + EXEC SQL OPEN cur_au_io_0017_f; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0017_fetch"); return TX_EDB; } + EXEC SQL FETCH cur_au_io_0017_f INTO :h_amount; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE cur_au_io_0017_f; + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0017_fetch"); + EXEC SQL CLOSE cur_au_io_0017_f; + return TX_EDB; + } + EXEC SQL CLOSE cur_au_io_0017_f; + *out_amount = h_amount; return TX_OK; } @@ -54,8 +63,9 @@ int au_io_0017_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE au_io_0017_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET status_cd = CASE WHEN :h_amount > 0 THEN '00' ELSE '99' END, + upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0017_touch"); @@ -70,7 +80,8 @@ long au_io_0017_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_max; + long h_min; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +90,15 @@ long au_io_0017_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM au_io_0017_t + EXEC SQL SELECT coalesce(max(appr_amt), 0), coalesce(min(appr_amt), 0) + INTO :h_max, :h_min + FROM au_io_0017_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0017_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/au_io_0018.c b/app/dbio/au_io_0018.c index dcea524..bf7ef29 100644 --- a/app/dbio/au_io_0018.c +++ b/app/dbio/au_io_0018.c @@ -110,12 +110,12 @@ int au_io_0018_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0018_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when status_cd = '00' then appr_amt else 0 end from au_io_0018_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0018.pgc" +#line 31 "app/dbio/au_io_0018.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int au_io_0018_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0018.pgc" +#line 46 "app/dbio/au_io_0018.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0018.pgc" +#line 47 "app/dbio/au_io_0018.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0018.pgc" +#line 48 "app/dbio/au_io_0018.pgc" if (!key) @@ -150,12 +150,12 @@ int au_io_0018_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0018_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0018_acc_t set accum_amt = accum_amt + $1 , cnt = cnt + 1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0018.pgc" +#line 59 "app/dbio/au_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long au_io_0018_total(const char *biz_date) -#line 72 "app/dbio/au_io_0018.pgc" +#line 73 "app/dbio/au_io_0018.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0018.pgc" +#line 74 "app/dbio/au_io_0018.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0018.pgc" +#line 75 "app/dbio/au_io_0018.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long au_io_0018_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0018_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . appr_amt ) , 0 ) from au_io_0018_dtl_t d join au_io_0018_t h on h . mcht_no = d . mcht_no where d . biz_date = $1 and h . status_cd = '00'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0018.pgc" +#line 87 "app/dbio/au_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long au_io_0018_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0018.pgc b/app/dbio/au_io_0018.pgc index 368fe80..51a1577 100644 --- a/app/dbio/au_io_0018.pgc +++ b/app/dbio/au_io_0018.pgc @@ -24,10 +24,11 @@ int au_io_0018_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT + CASE WHEN status_cd = '00' THEN appr_amt ELSE 0 END INTO :h_amount FROM au_io_0018_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,9 @@ int au_io_0018_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE au_io_0018_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE au_io_0018_acc_t + SET accum_amt = accum_amt + :h_amount, cnt = cnt + 1, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0018_touch"); @@ -79,10 +80,11 @@ long au_io_0018_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.appr_amt), 0) INTO :h_sum - FROM au_io_0018_t - WHERE biz_date = :h_biz_date; + FROM au_io_0018_dtl_t d + JOIN au_io_0018_t h ON h.mcht_no = d.mcht_no + WHERE d.biz_date = :h_biz_date AND h.status_cd = '00'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0018_total"); @@ -90,3 +92,4 @@ long au_io_0018_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0019.c b/app/dbio/au_io_0019.c index 2848b41..42b0f52 100644 --- a/app/dbio/au_io_0019.c +++ b/app/dbio/au_io_0019.c @@ -110,7 +110,7 @@ int au_io_0019_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0019_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt from au_io_0019_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), @@ -150,12 +150,12 @@ int au_io_0019_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0019_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from au_io_0019_bal_t where acct_no = $1 and bal_amt <= $2 ", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0019.pgc" +#line 57 "app/dbio/au_io_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long au_io_0019_total(const char *biz_date) -#line 72 "app/dbio/au_io_0019.pgc" +#line 71 "app/dbio/au_io_0019.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0019.pgc" - long h_sum ; +#line 72 "app/dbio/au_io_0019.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0019.pgc" +#line 73 "app/dbio/au_io_0019.pgc" if (!biz_date) @@ -188,17 +188,18 @@ long au_io_0019_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0019_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct mcht_no ) from au_io_0019_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0019.pgc" +#line 84 "app/dbio/au_io_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0019_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/au_io_0019.pgc b/app/dbio/au_io_0019.pgc index 02c725f..18c5116 100644 --- a/app/dbio/au_io_0019.pgc +++ b/app/dbio/au_io_0019.pgc @@ -24,10 +24,10 @@ int au_io_0019_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT appr_amt INTO :h_amount FROM au_io_0019_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +53,8 @@ int au_io_0019_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE au_io_0019_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM au_io_0019_bal_t + WHERE acct_no = :h_key AND bal_amt <= :h_amount; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0019_touch"); @@ -70,7 +69,7 @@ long au_io_0019_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +78,15 @@ long au_io_0019_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM au_io_0019_t + EXEC SQL SELECT count(DISTINCT mcht_no) + INTO :h_cnt + FROM au_io_0019_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0019_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/au_io_0020.c b/app/dbio/au_io_0020.c index 588a388..1cd5bfe 100644 --- a/app/dbio/au_io_0020.c +++ b/app/dbio/au_io_0020.c @@ -94,14 +94,22 @@ int au_io_0020_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + + #line 17 "app/dbio/au_io_0020.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/au_io_0020.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_appr ; + #line 19 "app/dbio/au_io_0020.pgc" + long h_fee ; + +#line 20 "app/dbio/au_io_0020.pgc" + long h_vat ; +/* exec sql end declare section */ +#line 21 "app/dbio/au_io_0020.pgc" if (!key || !out_amount) @@ -110,12 +118,16 @@ int au_io_0020_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0020_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt , fee_amt , vat_amt from au_io_0020_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_appr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_vat),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0020.pgc" +#line 32 "app/dbio/au_io_0020.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +136,7 @@ int au_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -134,13 +146,13 @@ int au_io_0020_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0020.pgc" +#line 47 "app/dbio/au_io_0020.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0020.pgc" +#line 48 "app/dbio/au_io_0020.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0020.pgc" +#line 49 "app/dbio/au_io_0020.pgc" if (!key) @@ -150,20 +162,29 @@ int au_io_0020_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0020_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0020_t set req_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0020.pgc" +#line 60 "app/dbio/au_io_0020.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0020_touch"); + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into au_io_0020_hist_t ( mcht_no , req_amt , reg_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 66 "app/dbio/au_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,13 +194,13 @@ long au_io_0020_total(const char *biz_date) -#line 72 "app/dbio/au_io_0020.pgc" +#line 78 "app/dbio/au_io_0020.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0020.pgc" +#line 79 "app/dbio/au_io_0020.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0020.pgc" +#line 80 "app/dbio/au_io_0020.pgc" if (!biz_date) @@ -188,12 +209,12 @@ long au_io_0020_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0020_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( cancel_amt ) , 0 ) from au_io_0020_t where biz_date = $1 and status_cd = '90' and cancel_yn = 'Y'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0020.pgc" +#line 92 "app/dbio/au_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +223,4 @@ long au_io_0020_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0020.pgc b/app/dbio/au_io_0020.pgc index 18771a0..6d19803 100644 --- a/app/dbio/au_io_0020.pgc +++ b/app/dbio/au_io_0020.pgc @@ -15,7 +15,9 @@ int au_io_0020_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; - long h_amount; + long h_appr; + long h_fee; + long h_vat; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +26,10 @@ int au_io_0020_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM au_io_0020_t - WHERE key = :h_key; + EXEC SQL SELECT appr_amt, fee_amt, vat_amt + INTO :h_appr, :h_fee, :h_vat + FROM au_io_0020_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,7 +37,7 @@ int au_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -54,15 +56,19 @@ int au_io_0020_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE au_io_0020_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET req_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0020_touch"); + return TX_EDB; + } + EXEC SQL INSERT INTO au_io_0020_hist_t (mcht_no, req_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -79,10 +85,11 @@ long au_io_0020_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(cancel_amt), 0) INTO :h_sum FROM au_io_0020_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + AND status_cd = '90' AND cancel_yn = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0020_total"); @@ -90,3 +97,4 @@ long au_io_0020_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0021.c b/app/dbio/au_io_0021.c index 9fccf30..a894faf 100644 --- a/app/dbio/au_io_0021.c +++ b/app/dbio/au_io_0021.c @@ -110,12 +110,12 @@ int au_io_0021_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0021_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select h . net_amt from au_io_0021_t h join au_io_0021_map_t m on m . mcht_no = h . mcht_no where h . mcht_no = $1 and m . use_yn = 'Y'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0021.pgc" +#line 31 "app/dbio/au_io_0021.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int au_io_0021_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0021.pgc" +#line 46 "app/dbio/au_io_0021.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0021.pgc" +#line 47 "app/dbio/au_io_0021.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0021.pgc" +#line 48 "app/dbio/au_io_0021.pgc" if (!key) @@ -150,12 +150,12 @@ int au_io_0021_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0021_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0021_t set appr_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0021.pgc" +#line 59 "app/dbio/au_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long au_io_0021_total(const char *biz_date) -#line 72 "app/dbio/au_io_0021.pgc" +#line 73 "app/dbio/au_io_0021.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0021.pgc" +#line 74 "app/dbio/au_io_0021.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0021.pgc" +#line 75 "app/dbio/au_io_0021.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long au_io_0021_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0021_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( recon_amt ) , 0 ) from au_io_0021_sum_t where biz_date in ( select biz_date from au_io_0021_map_t where biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0021.pgc" +#line 87 "app/dbio/au_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long au_io_0021_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0021.pgc b/app/dbio/au_io_0021.pgc index 2838813..15f1dcd 100644 --- a/app/dbio/au_io_0021.pgc +++ b/app/dbio/au_io_0021.pgc @@ -24,10 +24,11 @@ int au_io_0021_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT h.net_amt INTO :h_amount - FROM au_io_0021_t - WHERE key = :h_key; + FROM au_io_0021_t h + JOIN au_io_0021_map_t m ON m.mcht_no = h.mcht_no + WHERE h.mcht_no = :h_key AND m.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,8 @@ int au_io_0021_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE au_io_0021_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET appr_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0021_touch"); @@ -79,10 +80,11 @@ long au_io_0021_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(recon_amt), 0) INTO :h_sum - FROM au_io_0021_t - WHERE biz_date = :h_biz_date; + FROM au_io_0021_sum_t + WHERE biz_date IN + (SELECT biz_date FROM au_io_0021_map_t WHERE biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0021_total"); @@ -90,3 +92,4 @@ long au_io_0021_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0022.c b/app/dbio/au_io_0022.c index a9bf845..4fb0c2d 100644 --- a/app/dbio/au_io_0022.c +++ b/app/dbio/au_io_0022.c @@ -94,14 +94,18 @@ int au_io_0022_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/au_io_0022.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/au_io_0022.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/au_io_0022.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/au_io_0022.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int au_io_0022_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0022_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select bal_amt from au_io_0022_bal_t where acct_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0022.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/au_io_0022.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int au_io_0022_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0022_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int au_io_0022_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0022.pgc" +#line 48 "app/dbio/au_io_0022.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0022.pgc" +#line 49 "app/dbio/au_io_0022.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0022.pgc" +#line 50 "app/dbio/au_io_0022.pgc" if (!key) @@ -150,12 +156,12 @@ int au_io_0022_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0022_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0022_t set net_amt = $1 , upd_ts = now ( ) where mcht_no = $2 and status_cd = '00' and appr_amt > 0", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0022.pgc" +#line 61 "app/dbio/au_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +179,13 @@ long au_io_0022_total(const char *biz_date) -#line 72 "app/dbio/au_io_0022.pgc" +#line 75 "app/dbio/au_io_0022.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0022.pgc" - long h_sum ; +#line 76 "app/dbio/au_io_0022.pgc" + long h_flag ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0022.pgc" +#line 77 "app/dbio/au_io_0022.pgc" if (!biz_date) @@ -188,17 +194,18 @@ long au_io_0022_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0022_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from au_io_0022_t where exists ( select 1 from au_io_0022_dtl_t d where d . biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0022.pgc" +#line 90 "app/dbio/au_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0022_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/au_io_0022.pgc b/app/dbio/au_io_0022.pgc index bd1836c..3f1f429 100644 --- a/app/dbio/au_io_0022.pgc +++ b/app/dbio/au_io_0022.pgc @@ -16,6 +16,7 @@ int au_io_0022_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int au_io_0022_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM au_io_0022_t - WHERE key = :h_key; + EXEC SQL SELECT bal_amt + INTO :h_amount :h_ind + FROM au_io_0022_bal_t + WHERE acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int au_io_0022_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0022_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -54,8 +57,8 @@ int au_io_0022_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE au_io_0022_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET net_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key AND status_cd = '00' AND appr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0022_touch"); @@ -70,7 +73,7 @@ long au_io_0022_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_flag; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +82,17 @@ long au_io_0022_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_flag FROM au_io_0022_t - WHERE biz_date = :h_biz_date; + WHERE EXISTS + (SELECT 1 FROM au_io_0022_dtl_t d + WHERE d.biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0022_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/au_io_0023.c b/app/dbio/au_io_0023.c index f182abb..a01ef3e 100644 --- a/app/dbio/au_io_0023.c +++ b/app/dbio/au_io_0023.c @@ -110,12 +110,12 @@ int au_io_0023_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0023_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select req_amt from au_io_0023_t where mcht_no = $1 and status_cd = '00' and cancel_yn = 'N'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0023.pgc" +#line 31 "app/dbio/au_io_0023.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int au_io_0023_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0023.pgc" +#line 46 "app/dbio/au_io_0023.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0023.pgc" +#line 47 "app/dbio/au_io_0023.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0023.pgc" +#line 48 "app/dbio/au_io_0023.pgc" if (!key) @@ -150,10 +150,10 @@ int au_io_0023_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0023_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into au_io_0023_log_t ( mcht_no , appr_amt , reg_ts ) values ( $1 , $2 , now ( ) )", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} #line 58 "app/dbio/au_io_0023.pgc" @@ -162,8 +162,6 @@ int au_io_0023_touch(const char *key, long amount) TX_DBIO_LOG_ERR("au_io_0023_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,13 +171,13 @@ long au_io_0023_total(const char *biz_date) -#line 72 "app/dbio/au_io_0023.pgc" +#line 70 "app/dbio/au_io_0023.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0023.pgc" +#line 71 "app/dbio/au_io_0023.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0023.pgc" +#line 72 "app/dbio/au_io_0023.pgc" if (!biz_date) @@ -188,12 +186,12 @@ long au_io_0023_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0023_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( appr_amt ) , 0 ) from au_io_0023_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0023.pgc" +#line 83 "app/dbio/au_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +200,4 @@ long au_io_0023_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0023.pgc b/app/dbio/au_io_0023.pgc index be687ac..4ce2308 100644 --- a/app/dbio/au_io_0023.pgc +++ b/app/dbio/au_io_0023.pgc @@ -24,10 +24,11 @@ int au_io_0023_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT req_amt INTO :h_amount FROM au_io_0023_t - WHERE key = :h_key; + WHERE mcht_no = :h_key AND status_cd = '00' + AND cancel_yn = 'N'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,16 +54,13 @@ int au_io_0023_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE au_io_0023_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL INSERT INTO au_io_0023_log_t (mcht_no, appr_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0023_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -79,7 +77,7 @@ long au_io_0023_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(appr_amt), 0) INTO :h_sum FROM au_io_0023_t WHERE biz_date = :h_biz_date; @@ -90,3 +88,4 @@ long au_io_0023_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/au_io_0024.c b/app/dbio/au_io_0024.c index 4ecaee9..975f421 100644 --- a/app/dbio/au_io_0024.c +++ b/app/dbio/au_io_0024.c @@ -94,14 +94,18 @@ int au_io_0024_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/au_io_0024.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/au_io_0024.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/au_io_0024.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/au_io_0024.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int au_io_0024_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0024_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( appr_amt ) from au_io_0024_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0024.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/au_io_0024.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int au_io_0024_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0024_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int au_io_0024_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0024.pgc" +#line 48 "app/dbio/au_io_0024.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0024.pgc" +#line 49 "app/dbio/au_io_0024.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0024.pgc" +#line 50 "app/dbio/au_io_0024.pgc" if (!key) @@ -150,20 +156,31 @@ int au_io_0024_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0024_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0024_bal_t set bal_amt = $1 , upd_ts = now ( ) where acct_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0024.pgc" +#line 61 "app/dbio/au_io_0024.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0024_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into au_io_0024_bal_t ( acct_no , bal_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 69 "app/dbio/au_io_0024.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0024_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -173,13 +190,13 @@ long au_io_0024_total(const char *biz_date) -#line 72 "app/dbio/au_io_0024.pgc" +#line 81 "app/dbio/au_io_0024.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0024.pgc" - long h_sum ; +#line 82 "app/dbio/au_io_0024.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0024.pgc" +#line 83 "app/dbio/au_io_0024.pgc" if (!biz_date) @@ -188,17 +205,18 @@ long au_io_0024_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0024_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from au_io_0024_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0024.pgc" +#line 94 "app/dbio/au_io_0024.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0024_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/au_io_0024.pgc b/app/dbio/au_io_0024.pgc index d617cc9..9194fbd 100644 --- a/app/dbio/au_io_0024.pgc +++ b/app/dbio/au_io_0024.pgc @@ -16,6 +16,7 @@ int au_io_0024_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int au_io_0024_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM au_io_0024_t - WHERE key = :h_key; + EXEC SQL SELECT max(appr_amt) + INTO :h_amount :h_ind + FROM au_io_0024_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int au_io_0024_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("au_io_0024_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -53,16 +56,22 @@ int au_io_0024_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE au_io_0024_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE au_io_0024_bal_t + SET bal_amt = :h_amount, upd_ts = now() + WHERE acct_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0024_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + EXEC SQL INSERT INTO au_io_0024_bal_t (acct_no, bal_amt, upd_ts) + VALUES (:h_key, :h_amount, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0024_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -70,7 +79,7 @@ long au_io_0024_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,8 +88,8 @@ long au_io_0024_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_cnt FROM au_io_0024_t WHERE biz_date = :h_biz_date; @@ -88,5 +97,6 @@ long au_io_0024_total(const char *biz_date) TX_DBIO_LOG_ERR("au_io_0024_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/au_io_0025.c b/app/dbio/au_io_0025.c index 9a20bac..0d2377b 100644 --- a/app/dbio/au_io_0025.c +++ b/app/dbio/au_io_0025.c @@ -110,12 +110,12 @@ int au_io_0025_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0025_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select net_amt from au_io_0025_t where mcht_no in ( select mcht_no from au_io_0025_map_t where grp_key = $1 )", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0025.pgc" +#line 31 "app/dbio/au_io_0025.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int au_io_0025_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0025.pgc" +#line 46 "app/dbio/au_io_0025.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0025.pgc" +#line 47 "app/dbio/au_io_0025.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0025.pgc" +#line 48 "app/dbio/au_io_0025.pgc" if (!key) @@ -150,9 +150,7 @@ int au_io_0025_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0025_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from au_io_0025_tmp_t where ref_key = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/au_io_0025.pgc" @@ -172,14 +170,18 @@ long au_io_0025_total(const char *biz_date) /* exec sql begin declare section */ + #line 72 "app/dbio/au_io_0025.pgc" char h_biz_date [ 9 ] ; #line 73 "app/dbio/au_io_0025.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_avg ; + #line 74 "app/dbio/au_io_0025.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 75 "app/dbio/au_io_0025.pgc" if (!biz_date) @@ -188,17 +190,20 @@ long au_io_0025_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0025_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select avg ( appr_amt ) from au_io_0025_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0025.pgc" + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 86 "app/dbio/au_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0025_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/au_io_0025.pgc b/app/dbio/au_io_0025.pgc index 58337a2..69903f8 100644 --- a/app/dbio/au_io_0025.pgc +++ b/app/dbio/au_io_0025.pgc @@ -24,10 +24,11 @@ int au_io_0025_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT net_amt INTO :h_amount FROM au_io_0025_t - WHERE key = :h_key; + WHERE mcht_no IN + (SELECT mcht_no FROM au_io_0025_map_t WHERE grp_key = :h_key); if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,8 @@ int au_io_0025_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE au_io_0025_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM au_io_0025_tmp_t + WHERE ref_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0025_touch"); @@ -70,7 +70,8 @@ long au_io_0025_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_avg; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +80,17 @@ long au_io_0025_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM au_io_0025_t + EXEC SQL SELECT avg(appr_amt) + INTO :h_avg :h_ind + FROM au_io_0025_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0025_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/au_io_0026.c b/app/dbio/au_io_0026.c index 438b67b..170677a 100644 --- a/app/dbio/au_io_0026.c +++ b/app/dbio/au_io_0026.c @@ -110,20 +110,43 @@ int au_io_0026_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0026_t where key = $1 ", + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cur_au_io_0026_f cursor for select appr_amt from au_io_0026_dtl_t where mcht_no = $1 order by seq desc */ +#line 29 "app/dbio/au_io_0026.pgc" + +#line 29 "app/dbio/au_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_io_0026_f cursor for select appr_amt from au_io_0026_dtl_t where mcht_no = $1 order by seq desc", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 30 "app/dbio/au_io_0026.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0026_fetch"); return TX_EDB; } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_io_0026_f", ECPGt_EOIT, + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 35 "app/dbio/au_io_0026.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_io_0026_f", ECPGt_EOIT, ECPGt_EORT);} +#line 37 "app/dbio/au_io_0026.pgc" + + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0026_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_io_0026_f", ECPGt_EOIT, ECPGt_EORT);} +#line 42 "app/dbio/au_io_0026.pgc" + + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_io_0026_f", ECPGt_EOIT, ECPGt_EORT);} +#line 45 "app/dbio/au_io_0026.pgc" + + *out_amount = h_amount; return TX_OK; } @@ -134,13 +157,13 @@ int au_io_0026_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0026.pgc" +#line 54 "app/dbio/au_io_0026.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0026.pgc" +#line 55 "app/dbio/au_io_0026.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0026.pgc" +#line 56 "app/dbio/au_io_0026.pgc" if (!key) @@ -150,12 +173,14 @@ int au_io_0026_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0026_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0026_t set fee_amt = $1 , vat_amt = $2 / 10 , upd_ts = now ( ) where mcht_no = $3 ", + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + 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_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0026.pgc" +#line 67 "app/dbio/au_io_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +198,13 @@ long au_io_0026_total(const char *biz_date) -#line 72 "app/dbio/au_io_0026.pgc" +#line 81 "app/dbio/au_io_0026.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0026.pgc" +#line 82 "app/dbio/au_io_0026.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0026.pgc" +#line 83 "app/dbio/au_io_0026.pgc" if (!biz_date) @@ -188,17 +213,20 @@ long au_io_0026_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0026_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( net_amt ) , 0 ) from au_io_0026_t where biz_date = $1 group by biz_date having sum ( net_amt ) > 0 limit 1", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0026.pgc" +#line 97 "app/dbio/au_io_0026.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0026_total"); return -1; } return h_sum; } + diff --git a/app/dbio/au_io_0026.pgc b/app/dbio/au_io_0026.pgc index 83e3ded..250ea70 100644 --- a/app/dbio/au_io_0026.pgc +++ b/app/dbio/au_io_0026.pgc @@ -24,17 +24,26 @@ int au_io_0026_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM au_io_0026_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL DECLARE cur_au_io_0026_f CURSOR FOR + SELECT appr_amt FROM au_io_0026_dtl_t + WHERE mcht_no = :h_key ORDER BY seq DESC; + EXEC SQL OPEN cur_au_io_0026_f; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0026_fetch"); return TX_EDB; } + EXEC SQL FETCH cur_au_io_0026_f INTO :h_amount; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE cur_au_io_0026_f; + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0026_fetch"); + EXEC SQL CLOSE cur_au_io_0026_f; + return TX_EDB; + } + EXEC SQL CLOSE cur_au_io_0026_f; + *out_amount = h_amount; return TX_OK; } @@ -54,8 +63,8 @@ int au_io_0026_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE au_io_0026_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET fee_amt = :h_amount, vat_amt = :h_amount / 10, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0026_touch"); @@ -79,14 +88,20 @@ long au_io_0026_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(net_amt), 0) INTO :h_sum FROM au_io_0026_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + GROUP BY biz_date + HAVING sum(net_amt) > 0 + LIMIT 1; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0026_total"); return -1; } return h_sum; } + diff --git a/app/dbio/au_io_0027.c b/app/dbio/au_io_0027.c index 9fe8933..a91a004 100644 --- a/app/dbio/au_io_0027.c +++ b/app/dbio/au_io_0027.c @@ -110,12 +110,12 @@ int au_io_0027_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from au_io_0027_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when status_cd = '00' then appr_amt else 0 end from au_io_0027_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/au_io_0027.pgc" +#line 31 "app/dbio/au_io_0027.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int au_io_0027_touch(const char *key, long amount) -#line 45 "app/dbio/au_io_0027.pgc" +#line 46 "app/dbio/au_io_0027.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/au_io_0027.pgc" +#line 47 "app/dbio/au_io_0027.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/au_io_0027.pgc" +#line 48 "app/dbio/au_io_0027.pgc" if (!key) @@ -150,12 +150,12 @@ int au_io_0027_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0027_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_io_0027_t set status_cd = case when $1 > 0 then '00' else '99' end , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/au_io_0027.pgc" +#line 60 "app/dbio/au_io_0027.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -172,14 +172,18 @@ long au_io_0027_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/au_io_0027.pgc" +#line 74 "app/dbio/au_io_0027.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/au_io_0027.pgc" - long h_sum ; +#line 75 "app/dbio/au_io_0027.pgc" + long h_row ; + +#line 76 "app/dbio/au_io_0027.pgc" + long acc = 0 ; /* exec sql end declare section */ -#line 74 "app/dbio/au_io_0027.pgc" +#line 77 "app/dbio/au_io_0027.pgc" if (!biz_date) @@ -188,17 +192,42 @@ long au_io_0027_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from au_io_0027_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/au_io_0027.pgc" + ECPGset_var( 0, ( h_biz_date ), __LINE__);\ + /* declare cur_au_io_0027_t cursor for select net_amt from au_io_0027_sum_t where biz_date = $1 */ +#line 86 "app/dbio/au_io_0027.pgc" +#line 86 "app/dbio/au_io_0027.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_au_io_0027_t cursor for select net_amt from au_io_0027_sum_t where biz_date = $1 ", + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 87 "app/dbio/au_io_0027.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0027_total"); return -1; } - return h_sum; + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_au_io_0027_t", ECPGt_EOIT, + ECPGt_long,&(h_row),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 93 "app/dbio/au_io_0027.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0027_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_io_0027_t", ECPGt_EOIT, ECPGt_EORT);} +#line 98 "app/dbio/au_io_0027.pgc" + + return -1; + } + acc += h_row; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_au_io_0027_t", ECPGt_EOIT, ECPGt_EORT);} +#line 103 "app/dbio/au_io_0027.pgc" + + + return acc; } + diff --git a/app/dbio/au_io_0027.pgc b/app/dbio/au_io_0027.pgc index df9a08c..651e9d3 100644 --- a/app/dbio/au_io_0027.pgc +++ b/app/dbio/au_io_0027.pgc @@ -24,10 +24,11 @@ int au_io_0027_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT + CASE WHEN status_cd = '00' THEN appr_amt ELSE 0 END INTO :h_amount FROM au_io_0027_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,9 @@ int au_io_0027_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE au_io_0027_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET status_cd = CASE WHEN :h_amount > 0 THEN '00' ELSE '99' END, + upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0027_touch"); @@ -70,7 +72,8 @@ long au_io_0027_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_row; + long acc = 0; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +82,26 @@ long au_io_0027_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM au_io_0027_t - WHERE biz_date = :h_biz_date; - + EXEC SQL DECLARE cur_au_io_0027_t CURSOR FOR + SELECT net_amt FROM au_io_0027_sum_t WHERE biz_date = :h_biz_date; + EXEC SQL OPEN cur_au_io_0027_t; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("au_io_0027_total"); return -1; } - return h_sum; + for (;;) { + EXEC SQL FETCH cur_au_io_0027_t INTO :h_row; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("au_io_0027_total"); + EXEC SQL CLOSE cur_au_io_0027_t; + return -1; + } + acc += h_row; + } + EXEC SQL CLOSE cur_au_io_0027_t; + + return acc; } + diff --git a/app/dbio/cl_io_0001.c b/app/dbio/cl_io_0001.c index 722d759..f0ead27 100644 --- a/app/dbio/cl_io_0001.c +++ b/app/dbio/cl_io_0001.c @@ -96,26 +96,25 @@ int cl_io_0001_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cl_io_0001.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0001.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cl_io_0001.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0001_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . cr_amt ) , 0 ) from cls_ledger a join cls_daily_bal b on a . ledger_no = b . ledger_no where a . ledger_no = $1 and b . close_yn = 'Y'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0001.pgc" +#line 31 "app/dbio/cl_io_0001.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int cl_io_0001_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0001_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -134,29 +133,27 @@ int cl_io_0001_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0001.pgc" - char h_key [ 16 ] ; - #line 46 "app/dbio/cl_io_0001.pgc" - long h_amount ; -/* exec sql end declare section */ + char h_key [ 20 ] ; + #line 47 "app/dbio/cl_io_0001.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 48 "app/dbio/cl_io_0001.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0001_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cls_ledger set cr_amt = $1 , upd_ts = now ( ) where ledger_no = $2 and close_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0001.pgc" - +#line 59 "app/dbio/cl_io_0001.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0001_touch"); @@ -174,7 +171,7 @@ long cl_io_0001_total(const char *biz_date) #line 72 "app/dbio/cl_io_0001.pgc" - char h_biz_date [ 9 ] ; + char h_bd [ 9 ] ; #line 73 "app/dbio/cl_io_0001.pgc" long h_sum ; @@ -184,17 +181,15 @@ long cl_io_0001_total(const char *biz_date) if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0001_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( cr_amt ) , 0 ) from cls_ledger where biz_date = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0001.pgc" - +#line 84 "app/dbio/cl_io_0001.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0001_total"); diff --git a/app/dbio/cl_io_0001.pgc b/app/dbio/cl_io_0001.pgc index ba24fd6..b5722b1 100644 --- a/app/dbio/cl_io_0001.pgc +++ b/app/dbio/cl_io_0001.pgc @@ -14,20 +14,21 @@ EXEC SQL INCLUDE sqlca; int cl_io_0001_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0001_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(a.cr_amt), 0) + INTO :h_amt + FROM cls_ledger a + JOIN cls_daily_bal b ON a.ledger_no = b.ledger_no + WHERE a.ledger_no = :h_key + AND b.close_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +36,27 @@ int cl_io_0001_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0001_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cl_io_0001_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0001_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE cls_ledger + SET cr_amt = :h_amt, upd_ts = now() + WHERE ledger_no = :h_key + AND close_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0001_touch"); return TX_EDB; @@ -69,21 +69,19 @@ int cl_io_0001_touch(const char *key, long amount) long cl_io_0001_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(cr_amt), 0) INTO :h_sum - FROM cl_io_0001_t - WHERE biz_date = :h_biz_date; - + FROM cls_ledger + WHERE biz_date = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0001_total"); return -1; diff --git a/app/dbio/cl_io_0002.c b/app/dbio/cl_io_0002.c index 0188b22..ebf4a8e 100644 --- a/app/dbio/cl_io_0002.c +++ b/app/dbio/cl_io_0002.c @@ -94,37 +94,51 @@ int cl_io_0002_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cl_io_0002.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0002.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cl_io_0002.pgc" + int h_cnt ; +/* exec sql end declare section */ +#line 20 "app/dbio/cl_io_0002.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0002_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from cls_daily_bal where acct_no = $1 and dr_amt > 0", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_int,&(h_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0002.pgc" +#line 31 "app/dbio/cl_io_0002.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select dr_amt from cls_daily_bal where acct_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 42 "app/dbio/cl_io_0002.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0002_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +148,27 @@ int cl_io_0002_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0002.pgc" - char h_key [ 16 ] ; +#line 54 "app/dbio/cl_io_0002.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0002.pgc" - long h_amount ; +#line 55 "app/dbio/cl_io_0002.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0002.pgc" +#line 56 "app/dbio/cl_io_0002.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0002_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cls_daily_bal set dr_amt = $1 , upd_ts = now ( ) where acct_no = $2 and confirm_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0002.pgc" - +#line 67 "app/dbio/cl_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0002_touch"); @@ -173,32 +185,30 @@ long cl_io_0002_total(const char *biz_date) -#line 72 "app/dbio/cl_io_0002.pgc" - char h_biz_date [ 9 ] ; +#line 80 "app/dbio/cl_io_0002.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0002.pgc" - long h_sum ; +#line 81 "app/dbio/cl_io_0002.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0002.pgc" +#line 82 "app/dbio/cl_io_0002.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0002_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from cls_journal where close_dt = $1 and dr_amt <> 0", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0002.pgc" - +#line 93 "app/dbio/cl_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cl_io_0002.pgc b/app/dbio/cl_io_0002.pgc index 30dccd7..e25e3a9 100644 --- a/app/dbio/cl_io_0002.pgc +++ b/app/dbio/cl_io_0002.pgc @@ -14,49 +14,57 @@ EXEC SQL INCLUDE sqlca; int cl_io_0002_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + int h_cnt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0002_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM cls_daily_bal + WHERE acct_no = :h_key + AND dr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + EXEC SQL SELECT dr_amt + INTO :h_amt + FROM cls_daily_bal + WHERE acct_no = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0002_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } int cl_io_0002_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0002_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE cls_daily_bal + SET dr_amt = :h_amt, upd_ts = now() + WHERE acct_no = :h_key + AND confirm_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0002_touch"); return TX_EDB; @@ -69,24 +77,23 @@ int cl_io_0002_touch(const char *key, long amount) long cl_io_0002_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0002_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM cls_journal + WHERE close_dt = :h_bd + AND dr_amt <> 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cl_io_0003.c b/app/dbio/cl_io_0003.c index 4a91da2..2d87419 100644 --- a/app/dbio/cl_io_0003.c +++ b/app/dbio/cl_io_0003.c @@ -92,39 +92,45 @@ struct sqlca_t *ECPGget_sqlca(void); int cl_io_0003_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ - + + #line 17 "app/dbio/cl_io_0003.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0003.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cl_io_0003.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/cl_io_0003.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0003_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( bal_amt ) from cls_carry where journal_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/cl_io_0003.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0003_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +140,27 @@ int cl_io_0003_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0003.pgc" - char h_key [ 16 ] ; +#line 48 "app/dbio/cl_io_0003.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0003.pgc" - long h_amount ; +#line 49 "app/dbio/cl_io_0003.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0003.pgc" +#line 50 "app/dbio/cl_io_0003.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0003_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cls_summary set bal_amt = $1 , upd_ts = now ( ) where journal_no = $2 and post_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0003.pgc" - +#line 61 "app/dbio/cl_io_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0003_touch"); @@ -172,33 +176,62 @@ long cl_io_0003_total(const char *biz_date) /* exec sql begin declare section */ + + -#line 72 "app/dbio/cl_io_0003.pgc" - char h_biz_date [ 9 ] ; - -#line 73 "app/dbio/cl_io_0003.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/cl_io_0003.pgc" + char h_bd [ 9 ] ; + +#line 75 "app/dbio/cl_io_0003.pgc" + char h_grp [ 20 ] ; + +#line 76 "app/dbio/cl_io_0003.pgc" + long h_sub ; + +#line 77 "app/dbio/cl_io_0003.pgc" + long h_tot ; +/* exec sql end declare section */ +#line 78 "app/dbio/cl_io_0003.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + ECPGset_var( 0, ( h_bd ), __LINE__);\ + /* declare cl_io_0003_total_gc cursor for select cost_ctr , coalesce ( sum ( bal_amt ) , 0 ) from cls_summary where post_dt = $1 group by cost_ctr order by cost_ctr */ +#line 91 "app/dbio/cl_io_0003.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0003_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), +#line 91 "app/dbio/cl_io_0003.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cl_io_0003_total_gc cursor for select cost_ctr , coalesce ( sum ( bal_amt ) , 0 ) from cls_summary where post_dt = $1 group by cost_ctr order by cost_ctr", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 92 "app/dbio/cl_io_0003.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cl_io_0003_total_gc", ECPGt_EOIT, + ECPGt_char,(h_grp),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sub),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0003.pgc" +#line 94 "app/dbio/cl_io_0003.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0003_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0003_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 99 "app/dbio/cl_io_0003.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0003_total"); - return -1; + return -1; + } + h_tot += h_sub; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0003_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 104 "app/dbio/cl_io_0003.pgc" + + return h_tot; } diff --git a/app/dbio/cl_io_0003.pgc b/app/dbio/cl_io_0003.pgc index 5d61359..53c76d8 100644 --- a/app/dbio/cl_io_0003.pgc +++ b/app/dbio/cl_io_0003.pgc @@ -14,49 +14,51 @@ EXEC SQL INCLUDE sqlca; int cl_io_0003_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0003_t - WHERE key = :h_key; - + EXEC SQL SELECT max(bal_amt) + INTO :h_amt:h_ind + FROM cls_carry + WHERE journal_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0003_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } int cl_io_0003_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0003_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE cls_summary + SET bal_amt = :h_amt, upd_ts = now() + WHERE journal_no = :h_key + AND post_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0003_touch"); return TX_EDB; @@ -69,24 +71,36 @@ int cl_io_0003_touch(const char *key, long amount) long cl_io_0003_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + char h_grp[20]; + long h_sub; + long h_tot; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0003_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0003_total"); - return -1; + EXEC SQL DECLARE cl_io_0003_total_gc CURSOR FOR + SELECT cost_ctr, coalesce(sum(bal_amt), 0) + FROM cls_summary + WHERE post_dt = :h_bd + GROUP BY cost_ctr + ORDER BY cost_ctr; + EXEC SQL OPEN cl_io_0003_total_gc; + for (;;) { + EXEC SQL FETCH cl_io_0003_total_gc INTO :h_grp, :h_sub; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0003_total"); + EXEC SQL CLOSE cl_io_0003_total_gc; + return -1; + } + h_tot += h_sub; } - return h_sum; + EXEC SQL CLOSE cl_io_0003_total_gc; + return h_tot; } diff --git a/app/dbio/cl_io_0004.c b/app/dbio/cl_io_0004.c index 9d8c0ef..b9b6d52 100644 --- a/app/dbio/cl_io_0004.c +++ b/app/dbio/cl_io_0004.c @@ -94,37 +94,58 @@ int cl_io_0004_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cl_io_0004.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0004.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cl_io_0004.pgc" + long h_acc ; +/* exec sql end declare section */ +#line 20 "app/dbio/cl_io_0004.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0004_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cl_io_0004_fetch_cur cursor for select carry_amt from cls_month where slip_no = $1 order by biz_date */ +#line 31 "app/dbio/cl_io_0004.pgc" + +#line 31 "app/dbio/cl_io_0004.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cl_io_0004_fetch_cur cursor for select carry_amt from cls_month where slip_no = $1 order by biz_date", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 32 "app/dbio/cl_io_0004.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cl_io_0004_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0004.pgc" +#line 34 "app/dbio/cl_io_0004.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0004_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0004_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 39 "app/dbio/cl_io_0004.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0004_fetch"); - return TX_EDB; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0004_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 44 "app/dbio/cl_io_0004.pgc" + + *out_amount = h_acc; return TX_OK; } @@ -134,29 +155,27 @@ int cl_io_0004_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0004.pgc" - char h_key [ 16 ] ; +#line 52 "app/dbio/cl_io_0004.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0004.pgc" - long h_amount ; +#line 53 "app/dbio/cl_io_0004.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0004.pgc" +#line 54 "app/dbio/cl_io_0004.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0004_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cls_journal set carry_amt = $1 , upd_ts = now ( ) where slip_no = $2 and close_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0004.pgc" - +#line 65 "app/dbio/cl_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0004_touch"); @@ -173,28 +192,26 @@ long cl_io_0004_total(const char *biz_date) -#line 72 "app/dbio/cl_io_0004.pgc" - char h_biz_date [ 9 ] ; +#line 78 "app/dbio/cl_io_0004.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0004.pgc" +#line 79 "app/dbio/cl_io_0004.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0004.pgc" +#line 80 "app/dbio/cl_io_0004.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0004_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . carry_amt ) , 0 ) from cls_month d join cls_journal m on d . slip_no = m . slip_no where d . biz_date = $1 and m . close_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0004.pgc" - +#line 92 "app/dbio/cl_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0004_total"); diff --git a/app/dbio/cl_io_0004.pgc b/app/dbio/cl_io_0004.pgc index 892178b..c2d95dc 100644 --- a/app/dbio/cl_io_0004.pgc +++ b/app/dbio/cl_io_0004.pgc @@ -14,49 +14,55 @@ EXEC SQL INCLUDE sqlca; int cl_io_0004_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + long h_acc; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0004_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0004_fetch"); - return TX_EDB; + EXEC SQL DECLARE cl_io_0004_fetch_cur CURSOR FOR + SELECT carry_amt FROM cls_month + WHERE slip_no = :h_key + ORDER BY biz_date; + EXEC SQL OPEN cl_io_0004_fetch_cur; + for (;;) { + EXEC SQL FETCH cl_io_0004_fetch_cur INTO :h_amt; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0004_fetch"); + EXEC SQL CLOSE cl_io_0004_fetch_cur; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + EXEC SQL CLOSE cl_io_0004_fetch_cur; + *out_amount = h_acc; return TX_OK; } int cl_io_0004_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0004_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE cls_journal + SET carry_amt = :h_amt, upd_ts = now() + WHERE slip_no = :h_key + AND close_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0004_touch"); return TX_EDB; @@ -69,21 +75,21 @@ int cl_io_0004_touch(const char *key, long amount) long cl_io_0004_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.carry_amt), 0) INTO :h_sum - FROM cl_io_0004_t - WHERE biz_date = :h_biz_date; - + FROM cls_month d + JOIN cls_journal m ON d.slip_no = m.slip_no + WHERE d.biz_date = :h_bd + AND m.close_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0004_total"); return -1; diff --git a/app/dbio/cl_io_0005.c b/app/dbio/cl_io_0005.c index 4c62daa..663ef55 100644 --- a/app/dbio/cl_io_0005.c +++ b/app/dbio/cl_io_0005.c @@ -96,27 +96,25 @@ int cl_io_0005_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cl_io_0005.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0005.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cl_io_0005.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0005_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( m . net_amt , 0 ) - ( select coalesce ( sum ( h . net_amt ) , 0 ) from cls_account h where h . ledger_no = m . ledger_no ) from cls_carry m where m . ledger_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0005.pgc" - +#line 31 "app/dbio/cl_io_0005.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +122,7 @@ int cl_io_0005_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0005_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -135,29 +133,27 @@ int cl_io_0005_touch(const char *key, long amount) #line 45 "app/dbio/cl_io_0005.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 46 "app/dbio/cl_io_0005.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/cl_io_0005.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0005_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cls_carry set net_amt = $1 , upd_ts = now ( ) where ledger_no = $2 and confirm_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/cl_io_0005.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0005_touch"); return TX_EDB; @@ -170,35 +166,39 @@ int cl_io_0005_touch(const char *key, long amount) long cl_io_0005_total(const char *biz_date) { /* exec sql begin declare section */ - + + +#line 71 "app/dbio/cl_io_0005.pgc" + char h_bd [ 9 ] ; + #line 72 "app/dbio/cl_io_0005.pgc" - char h_biz_date [ 9 ] ; + long h_max ; #line 73 "app/dbio/cl_io_0005.pgc" - long h_sum ; + short h_ind ; /* exec sql end declare section */ #line 74 "app/dbio/cl_io_0005.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0005_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( net_amt ) from cls_month where close_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0005.pgc" - + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 84 "app/dbio/cl_io_0005.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0005_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/cl_io_0005.pgc b/app/dbio/cl_io_0005.pgc index 7f8bd1b..d3ea4d6 100644 --- a/app/dbio/cl_io_0005.pgc +++ b/app/dbio/cl_io_0005.pgc @@ -14,49 +14,48 @@ EXEC SQL INCLUDE sqlca; int cl_io_0005_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0005_t - WHERE key = :h_key; - + EXEC SQL SELECT coalesce(m.net_amt, 0) + - (SELECT coalesce(sum(h.net_amt), 0) + FROM cls_account h WHERE h.ledger_no = m.ledger_no) + INTO :h_amt + FROM cls_carry m + WHERE m.ledger_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0005_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cl_io_0005_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0005_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE cls_carry + SET net_amt = :h_amt, upd_ts = now() + WHERE ledger_no = :h_key + AND confirm_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0005_touch"); return TX_EDB; @@ -69,24 +68,25 @@ int cl_io_0005_touch(const char *key, long amount) long cl_io_0005_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0005_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT max(net_amt) + INTO :h_max:h_ind + FROM cls_month + WHERE close_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0005_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/cl_io_0006.c b/app/dbio/cl_io_0006.c index fbee7bd..7795510 100644 --- a/app/dbio/cl_io_0006.c +++ b/app/dbio/cl_io_0006.c @@ -92,31 +92,43 @@ struct sqlca_t *ECPGget_sqlca(void); int cl_io_0006_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ + + + #line 17 "app/dbio/cl_io_0006.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0006.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_min ; + #line 19 "app/dbio/cl_io_0006.pgc" + long h_max ; + +#line 20 "app/dbio/cl_io_0006.pgc" + short h_i1 ; + +#line 21 "app/dbio/cl_io_0006.pgc" + short h_i2 ; +/* exec sql end declare section */ +#line 22 "app/dbio/cl_io_0006.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0006_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( tax_amt ) , max ( tax_amt ) from cls_account where acct_no = $1 and post_yn <> 'D'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0006.pgc" - + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i1),(long)1,(long)1,sizeof(short), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i2),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 33 "app/dbio/cl_io_0006.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +136,9 @@ int cl_io_0006_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0006_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } @@ -134,29 +148,27 @@ int cl_io_0006_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0006.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/cl_io_0006.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0006.pgc" - long h_amount ; +#line 50 "app/dbio/cl_io_0006.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0006.pgc" +#line 51 "app/dbio/cl_io_0006.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0006_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cls_month set tax_amt = $1 , upd_ts = now ( ) where acct_no = $2 and post_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0006.pgc" - +#line 62 "app/dbio/cl_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0006_touch"); @@ -173,32 +185,30 @@ long cl_io_0006_total(const char *biz_date) -#line 72 "app/dbio/cl_io_0006.pgc" - char h_biz_date [ 9 ] ; +#line 75 "app/dbio/cl_io_0006.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0006.pgc" - long h_sum ; +#line 76 "app/dbio/cl_io_0006.pgc" + long h_avg ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0006.pgc" +#line 77 "app/dbio/cl_io_0006.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0006_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( avg ( tax_amt ) , 0 ) :: bigint from cls_month where post_dt = $1 and post_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0006.pgc" - +#line 88 "app/dbio/cl_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0006_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/cl_io_0006.pgc b/app/dbio/cl_io_0006.pgc index 076351c..55df13d 100644 --- a/app/dbio/cl_io_0006.pgc +++ b/app/dbio/cl_io_0006.pgc @@ -14,49 +14,52 @@ EXEC SQL INCLUDE sqlca; int cl_io_0006_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_min; + long h_max; + short h_i1; + short h_i2; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0006_t - WHERE key = :h_key; - + EXEC SQL SELECT min(tax_amt), max(tax_amt) + INTO :h_min:h_i1, :h_max:h_i2 + FROM cls_account + WHERE acct_no = :h_key + AND post_yn <> 'D'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0006_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } int cl_io_0006_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0006_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE cls_month + SET tax_amt = :h_amt, upd_ts = now() + WHERE acct_no = :h_key + AND post_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0006_touch"); return TX_EDB; @@ -69,24 +72,23 @@ int cl_io_0006_touch(const char *key, long amount) long cl_io_0006_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_avg; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0006_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT coalesce(avg(tax_amt), 0)::bigint + INTO :h_avg + FROM cls_month + WHERE post_dt = :h_bd + AND post_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0006_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/cl_io_0007.c b/app/dbio/cl_io_0007.c index 4776abc..1254ecf 100644 --- a/app/dbio/cl_io_0007.c +++ b/app/dbio/cl_io_0007.c @@ -96,26 +96,25 @@ int cl_io_0007_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cl_io_0007.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0007.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cl_io_0007.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0007_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . cr_amt ) , 0 ) from cls_account a join cls_trial b on a . journal_no = b . journal_no where a . journal_no = $1 and b . close_yn = 'Y'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0007.pgc" +#line 31 "app/dbio/cl_io_0007.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int cl_io_0007_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0007_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -134,36 +133,32 @@ int cl_io_0007_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0007.pgc" - char h_key [ 16 ] ; - #line 46 "app/dbio/cl_io_0007.pgc" - long h_amount ; -/* exec sql end declare section */ + char h_key [ 20 ] ; + #line 47 "app/dbio/cl_io_0007.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 48 "app/dbio/cl_io_0007.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0007_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cls_ledger ( journal_no , cr_amt , biz_date , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/cl_io_0007.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0007_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -172,33 +167,37 @@ long cl_io_0007_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/cl_io_0007.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/cl_io_0007.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0007.pgc" - long h_sum ; +#line 70 "app/dbio/cl_io_0007.pgc" + long h_dr ; + +#line 71 "app/dbio/cl_io_0007.pgc" + long h_cr ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0007.pgc" +#line 72 "app/dbio/cl_io_0007.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0007_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when close_yn = 'D' then cr_amt else 0 end ) , 0 ) , coalesce ( sum ( case when close_yn = 'C' then cr_amt else 0 end ) , 0 ) from cls_ledger where biz_date = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_dr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_cr),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0007.pgc" - +#line 84 "app/dbio/cl_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0007_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/cl_io_0007.pgc b/app/dbio/cl_io_0007.pgc index 155c890..e13cf08 100644 --- a/app/dbio/cl_io_0007.pgc +++ b/app/dbio/cl_io_0007.pgc @@ -14,20 +14,21 @@ EXEC SQL INCLUDE sqlca; int cl_io_0007_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0007_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(a.cr_amt), 0) + INTO :h_amt + FROM cls_account a + JOIN cls_trial b ON a.journal_no = b.journal_no + WHERE a.journal_no = :h_key + AND b.close_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,58 +36,55 @@ int cl_io_0007_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0007_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cl_io_0007_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0007_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO cls_ledger + (journal_no, cr_amt, biz_date, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0007_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long cl_io_0007_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_dr; + long h_cr; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0007_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT + coalesce(sum(CASE WHEN close_yn = 'D' THEN cr_amt ELSE 0 END), 0), + coalesce(sum(CASE WHEN close_yn = 'C' THEN cr_amt ELSE 0 END), 0) + INTO :h_dr, :h_cr + FROM cls_ledger + WHERE biz_date = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0007_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/cl_io_0008.c b/app/dbio/cl_io_0008.c index e1216da..2c296c8 100644 --- a/app/dbio/cl_io_0008.c +++ b/app/dbio/cl_io_0008.c @@ -94,37 +94,51 @@ int cl_io_0008_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cl_io_0008.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0008.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cl_io_0008.pgc" + int h_cnt ; +/* exec sql end declare section */ +#line 20 "app/dbio/cl_io_0008.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0008_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from cls_trial where slip_no = $1 and dr_amt > 0", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_int,&(h_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0008.pgc" +#line 31 "app/dbio/cl_io_0008.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0008_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select dr_amt from cls_trial where slip_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 42 "app/dbio/cl_io_0008.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0008_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } @@ -134,36 +148,32 @@ int cl_io_0008_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0008.pgc" - char h_key [ 16 ] ; +#line 54 "app/dbio/cl_io_0008.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0008.pgc" - long h_amount ; +#line 55 "app/dbio/cl_io_0008.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0008.pgc" +#line 56 "app/dbio/cl_io_0008.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0008_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cls_daily_bal ( slip_no , dr_amt , close_dt , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0008.pgc" - +#line 66 "app/dbio/cl_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0008_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,28 +183,26 @@ long cl_io_0008_total(const char *biz_date) -#line 72 "app/dbio/cl_io_0008.pgc" - char h_biz_date [ 9 ] ; +#line 77 "app/dbio/cl_io_0008.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0008.pgc" +#line 78 "app/dbio/cl_io_0008.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0008.pgc" +#line 79 "app/dbio/cl_io_0008.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0008_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( dr_amt ) , 0 ) from cls_trial where close_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0008.pgc" - +#line 89 "app/dbio/cl_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0008_total"); diff --git a/app/dbio/cl_io_0008.pgc b/app/dbio/cl_io_0008.pgc index f9d8fcd..887553a 100644 --- a/app/dbio/cl_io_0008.pgc +++ b/app/dbio/cl_io_0008.pgc @@ -14,76 +14,79 @@ EXEC SQL INCLUDE sqlca; int cl_io_0008_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + int h_cnt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0008_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM cls_trial + WHERE slip_no = :h_key + AND dr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0008_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + EXEC SQL SELECT dr_amt + INTO :h_amt + FROM cls_trial + WHERE slip_no = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0008_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } int cl_io_0008_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0008_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO cls_daily_bal + (slip_no, dr_amt, close_dt, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0008_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long cl_io_0008_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(dr_amt), 0) INTO :h_sum - FROM cl_io_0008_t - WHERE biz_date = :h_biz_date; - + FROM cls_trial + WHERE close_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0008_total"); return -1; diff --git a/app/dbio/cl_io_0009.c b/app/dbio/cl_io_0009.c index 746d91c..47fbe32 100644 --- a/app/dbio/cl_io_0009.c +++ b/app/dbio/cl_io_0009.c @@ -92,39 +92,45 @@ struct sqlca_t *ECPGget_sqlca(void); int cl_io_0009_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ - + + #line 17 "app/dbio/cl_io_0009.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0009.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cl_io_0009.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/cl_io_0009.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0009_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( bal_amt ) from cls_summary where ledger_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/cl_io_0009.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0009_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } @@ -134,36 +140,32 @@ int cl_io_0009_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0009.pgc" - char h_key [ 16 ] ; +#line 48 "app/dbio/cl_io_0009.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0009.pgc" - long h_amount ; +#line 49 "app/dbio/cl_io_0009.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0009.pgc" +#line 50 "app/dbio/cl_io_0009.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0009_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cls_summary ( ledger_no , bal_amt , post_dt , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0009.pgc" - +#line 60 "app/dbio/cl_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0009_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,32 +175,30 @@ long cl_io_0009_total(const char *biz_date) -#line 72 "app/dbio/cl_io_0009.pgc" - char h_biz_date [ 9 ] ; +#line 71 "app/dbio/cl_io_0009.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0009.pgc" - long h_sum ; +#line 72 "app/dbio/cl_io_0009.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0009.pgc" +#line 73 "app/dbio/cl_io_0009.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0009_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from cls_summary where post_dt = $1 and bal_amt <> 0", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0009.pgc" - +#line 84 "app/dbio/cl_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0009_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cl_io_0009.pgc b/app/dbio/cl_io_0009.pgc index a57cfce..afc6c18 100644 --- a/app/dbio/cl_io_0009.pgc +++ b/app/dbio/cl_io_0009.pgc @@ -14,79 +14,77 @@ EXEC SQL INCLUDE sqlca; int cl_io_0009_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0009_t - WHERE key = :h_key; - + EXEC SQL SELECT max(bal_amt) + INTO :h_amt:h_ind + FROM cls_summary + WHERE ledger_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0009_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } int cl_io_0009_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0009_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO cls_summary + (ledger_no, bal_amt, post_dt, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0009_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long cl_io_0009_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0009_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM cls_summary + WHERE post_dt = :h_bd + AND bal_amt <> 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0009_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cl_io_0010.c b/app/dbio/cl_io_0010.c index 655b337..062fbf5 100644 --- a/app/dbio/cl_io_0010.c +++ b/app/dbio/cl_io_0010.c @@ -94,37 +94,58 @@ int cl_io_0010_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cl_io_0010.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0010.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cl_io_0010.pgc" + long h_acc ; +/* exec sql end declare section */ +#line 20 "app/dbio/cl_io_0010.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0010_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cl_io_0010_fetch_cur cursor for select carry_amt from cls_journal where acct_no = $1 order by biz_date */ +#line 31 "app/dbio/cl_io_0010.pgc" + +#line 31 "app/dbio/cl_io_0010.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cl_io_0010_fetch_cur cursor for select carry_amt from cls_journal where acct_no = $1 order by biz_date", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 32 "app/dbio/cl_io_0010.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cl_io_0010_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0010.pgc" +#line 34 "app/dbio/cl_io_0010.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0010_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0010_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 39 "app/dbio/cl_io_0010.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0010_fetch"); - return TX_EDB; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0010_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 44 "app/dbio/cl_io_0010.pgc" + + *out_amount = h_acc; return TX_OK; } @@ -134,36 +155,32 @@ int cl_io_0010_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0010.pgc" - char h_key [ 16 ] ; +#line 52 "app/dbio/cl_io_0010.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0010.pgc" - long h_amount ; +#line 53 "app/dbio/cl_io_0010.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0010.pgc" +#line 54 "app/dbio/cl_io_0010.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0010_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cls_journal ( acct_no , carry_amt , biz_date , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0010.pgc" - +#line 64 "app/dbio/cl_io_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0010_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -172,33 +189,62 @@ long cl_io_0010_total(const char *biz_date) /* exec sql begin declare section */ + + -#line 72 "app/dbio/cl_io_0010.pgc" - char h_biz_date [ 9 ] ; +#line 75 "app/dbio/cl_io_0010.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0010.pgc" - long h_sum ; +#line 76 "app/dbio/cl_io_0010.pgc" + char h_grp [ 20 ] ; + +#line 77 "app/dbio/cl_io_0010.pgc" + long h_sub ; + +#line 78 "app/dbio/cl_io_0010.pgc" + long h_tot ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0010.pgc" +#line 79 "app/dbio/cl_io_0010.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + ECPGset_var( 1, ( h_bd ), __LINE__);\ + /* declare cl_io_0010_total_gc cursor for select acct_cd , coalesce ( sum ( carry_amt ) , 0 ) from cls_daily_bal where biz_date = $1 group by acct_cd order by acct_cd */ +#line 92 "app/dbio/cl_io_0010.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0010_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), +#line 92 "app/dbio/cl_io_0010.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cl_io_0010_total_gc cursor for select acct_cd , coalesce ( sum ( carry_amt ) , 0 ) from cls_daily_bal where biz_date = $1 group by acct_cd order by acct_cd", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 93 "app/dbio/cl_io_0010.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cl_io_0010_total_gc", ECPGt_EOIT, + ECPGt_char,(h_grp),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sub),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0010.pgc" +#line 95 "app/dbio/cl_io_0010.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0010_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0010_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 100 "app/dbio/cl_io_0010.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0010_total"); - return -1; + return -1; + } + h_tot += h_sub; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0010_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 105 "app/dbio/cl_io_0010.pgc" + + return h_tot; } diff --git a/app/dbio/cl_io_0010.pgc b/app/dbio/cl_io_0010.pgc index a335c0f..5b6184b 100644 --- a/app/dbio/cl_io_0010.pgc +++ b/app/dbio/cl_io_0010.pgc @@ -14,79 +14,94 @@ EXEC SQL INCLUDE sqlca; int cl_io_0010_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + long h_acc; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0010_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0010_fetch"); - return TX_EDB; + EXEC SQL DECLARE cl_io_0010_fetch_cur CURSOR FOR + SELECT carry_amt FROM cls_journal + WHERE acct_no = :h_key + ORDER BY biz_date; + EXEC SQL OPEN cl_io_0010_fetch_cur; + for (;;) { + EXEC SQL FETCH cl_io_0010_fetch_cur INTO :h_amt; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0010_fetch"); + EXEC SQL CLOSE cl_io_0010_fetch_cur; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + EXEC SQL CLOSE cl_io_0010_fetch_cur; + *out_amount = h_acc; return TX_OK; } int cl_io_0010_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0010_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO cls_journal + (acct_no, carry_amt, biz_date, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0010_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long cl_io_0010_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + char h_grp[20]; + long h_sub; + long h_tot; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0010_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0010_total"); - return -1; + EXEC SQL DECLARE cl_io_0010_total_gc CURSOR FOR + SELECT acct_cd, coalesce(sum(carry_amt), 0) + FROM cls_daily_bal + WHERE biz_date = :h_bd + GROUP BY acct_cd + ORDER BY acct_cd; + EXEC SQL OPEN cl_io_0010_total_gc; + for (;;) { + EXEC SQL FETCH cl_io_0010_total_gc INTO :h_grp, :h_sub; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0010_total"); + EXEC SQL CLOSE cl_io_0010_total_gc; + return -1; + } + h_tot += h_sub; } - return h_sum; + EXEC SQL CLOSE cl_io_0010_total_gc; + return h_tot; } diff --git a/app/dbio/cl_io_0011.c b/app/dbio/cl_io_0011.c index b42928f..edd3fde 100644 --- a/app/dbio/cl_io_0011.c +++ b/app/dbio/cl_io_0011.c @@ -96,27 +96,25 @@ int cl_io_0011_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cl_io_0011.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0011.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cl_io_0011.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0011_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( m . net_amt , 0 ) - ( select coalesce ( sum ( h . net_amt ) , 0 ) from cls_carry h where h . journal_no = m . journal_no ) from cls_summary m where m . journal_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0011.pgc" - +#line 31 "app/dbio/cl_io_0011.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +122,7 @@ int cl_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -135,35 +133,31 @@ int cl_io_0011_touch(const char *key, long amount) #line 45 "app/dbio/cl_io_0011.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 46 "app/dbio/cl_io_0011.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/cl_io_0011.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0011_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cls_carry ( journal_no , net_amt , close_dt , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0011.pgc" - +#line 57 "app/dbio/cl_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0011_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,28 +167,26 @@ long cl_io_0011_total(const char *biz_date) -#line 72 "app/dbio/cl_io_0011.pgc" - char h_biz_date [ 9 ] ; +#line 68 "app/dbio/cl_io_0011.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0011.pgc" +#line 69 "app/dbio/cl_io_0011.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0011.pgc" +#line 70 "app/dbio/cl_io_0011.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0011_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . net_amt ) , 0 ) from cls_carry d join cls_summary m on d . journal_no = m . journal_no where d . close_dt = $1 and m . confirm_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0011.pgc" - +#line 82 "app/dbio/cl_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0011_total"); diff --git a/app/dbio/cl_io_0011.pgc b/app/dbio/cl_io_0011.pgc index 1c4a635..572d096 100644 --- a/app/dbio/cl_io_0011.pgc +++ b/app/dbio/cl_io_0011.pgc @@ -14,76 +14,72 @@ EXEC SQL INCLUDE sqlca; int cl_io_0011_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0011_t - WHERE key = :h_key; - + EXEC SQL SELECT coalesce(m.net_amt, 0) + - (SELECT coalesce(sum(h.net_amt), 0) + FROM cls_carry h WHERE h.journal_no = m.journal_no) + INTO :h_amt + FROM cls_summary m + WHERE m.journal_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cl_io_0011_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0011_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO cls_carry + (journal_no, net_amt, close_dt, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0011_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long cl_io_0011_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.net_amt), 0) INTO :h_sum - FROM cl_io_0011_t - WHERE biz_date = :h_biz_date; - + FROM cls_carry d + JOIN cls_summary m ON d.journal_no = m.journal_no + WHERE d.close_dt = :h_bd + AND m.confirm_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0011_total"); return -1; diff --git a/app/dbio/cl_io_0012.c b/app/dbio/cl_io_0012.c index 1afa8e0..8cf66a9 100644 --- a/app/dbio/cl_io_0012.c +++ b/app/dbio/cl_io_0012.c @@ -92,31 +92,43 @@ struct sqlca_t *ECPGget_sqlca(void); int cl_io_0012_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ + + + #line 17 "app/dbio/cl_io_0012.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0012.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_min ; + #line 19 "app/dbio/cl_io_0012.pgc" + long h_max ; + +#line 20 "app/dbio/cl_io_0012.pgc" + short h_i1 ; + +#line 21 "app/dbio/cl_io_0012.pgc" + short h_i2 ; +/* exec sql end declare section */ +#line 22 "app/dbio/cl_io_0012.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0012_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( tax_amt ) , max ( tax_amt ) from cls_carry where slip_no = $1 and post_yn <> 'D'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0012.pgc" - + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i1),(long)1,(long)1,sizeof(short), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i2),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 33 "app/dbio/cl_io_0012.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +136,9 @@ int cl_io_0012_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0012_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } @@ -134,71 +148,71 @@ int cl_io_0012_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0012.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/cl_io_0012.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0012.pgc" - long h_amount ; +#line 50 "app/dbio/cl_io_0012.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0012.pgc" +#line 51 "app/dbio/cl_io_0012.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0012_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cls_month ( slip_no , tax_amt , post_dt , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0012.pgc" - +#line 61 "app/dbio/cl_io_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0012_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long cl_io_0012_total(const char *biz_date) { /* exec sql begin declare section */ - + + #line 72 "app/dbio/cl_io_0012.pgc" - char h_biz_date [ 9 ] ; + char h_bd [ 9 ] ; #line 73 "app/dbio/cl_io_0012.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_max ; + #line 74 "app/dbio/cl_io_0012.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 75 "app/dbio/cl_io_0012.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0012_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( tax_amt ) from cls_carry where post_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 85 "app/dbio/cl_io_0012.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0012_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/cl_io_0012.pgc b/app/dbio/cl_io_0012.pgc index 31d19ea..4c4eb16 100644 --- a/app/dbio/cl_io_0012.pgc +++ b/app/dbio/cl_io_0012.pgc @@ -14,79 +14,80 @@ EXEC SQL INCLUDE sqlca; int cl_io_0012_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_min; + long h_max; + short h_i1; + short h_i2; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0012_t - WHERE key = :h_key; - + EXEC SQL SELECT min(tax_amt), max(tax_amt) + INTO :h_min:h_i1, :h_max:h_i2 + FROM cls_carry + WHERE slip_no = :h_key + AND post_yn <> 'D'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0012_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } int cl_io_0012_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0012_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO cls_month + (slip_no, tax_amt, post_dt, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0012_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long cl_io_0012_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0012_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT max(tax_amt) + INTO :h_max:h_ind + FROM cls_carry + WHERE post_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0012_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/cl_io_0013.c b/app/dbio/cl_io_0013.c index afffbfe..4bb29dd 100644 --- a/app/dbio/cl_io_0013.c +++ b/app/dbio/cl_io_0013.c @@ -96,26 +96,25 @@ int cl_io_0013_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cl_io_0013.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0013.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cl_io_0013.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0013_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . cr_amt ) , 0 ) from cls_carry a join cls_month b on a . ledger_no = b . ledger_no where a . ledger_no = $1 and b . close_yn = 'Y'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0013.pgc" +#line 31 "app/dbio/cl_io_0013.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int cl_io_0013_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0013_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -134,29 +133,27 @@ int cl_io_0013_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0013.pgc" - char h_key [ 16 ] ; - #line 46 "app/dbio/cl_io_0013.pgc" - long h_amount ; -/* exec sql end declare section */ + char h_key [ 20 ] ; + #line 47 "app/dbio/cl_io_0013.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 48 "app/dbio/cl_io_0013.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0013_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cls_carry ( ledger_no , cr_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( ledger_no ) do update set cr_amt = cls_carry . cr_amt + EXCLUDED . cr_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0013.pgc" - +#line 60 "app/dbio/cl_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0013_touch"); @@ -173,32 +170,30 @@ long cl_io_0013_total(const char *biz_date) -#line 72 "app/dbio/cl_io_0013.pgc" - char h_biz_date [ 9 ] ; - #line 73 "app/dbio/cl_io_0013.pgc" - long h_sum ; -/* exec sql end declare section */ + char h_bd [ 9 ] ; + #line 74 "app/dbio/cl_io_0013.pgc" + long h_avg ; +/* exec sql end declare section */ +#line 75 "app/dbio/cl_io_0013.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0013_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( avg ( cr_amt ) , 0 ) :: bigint from cls_carry where biz_date = $1 and close_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0013.pgc" - +#line 86 "app/dbio/cl_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0013_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/cl_io_0013.pgc b/app/dbio/cl_io_0013.pgc index b546811..1c56814 100644 --- a/app/dbio/cl_io_0013.pgc +++ b/app/dbio/cl_io_0013.pgc @@ -14,20 +14,21 @@ EXEC SQL INCLUDE sqlca; int cl_io_0013_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0013_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(a.cr_amt), 0) + INTO :h_amt + FROM cls_carry a + JOIN cls_month b ON a.ledger_no = b.ledger_no + WHERE a.ledger_no = :h_key + AND b.close_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +36,28 @@ int cl_io_0013_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0013_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cl_io_0013_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0013_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO cls_carry (ledger_no, cr_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (ledger_no) + DO UPDATE SET cr_amt = cls_carry.cr_amt + EXCLUDED.cr_amt, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0013_touch"); return TX_EDB; @@ -69,24 +70,23 @@ int cl_io_0013_touch(const char *key, long amount) long cl_io_0013_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_avg; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0013_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT coalesce(avg(cr_amt), 0)::bigint + INTO :h_avg + FROM cls_carry + WHERE biz_date = :h_bd + AND close_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0013_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/cl_io_0014.c b/app/dbio/cl_io_0014.c index 6d7eb31..06650cb 100644 --- a/app/dbio/cl_io_0014.c +++ b/app/dbio/cl_io_0014.c @@ -94,37 +94,51 @@ int cl_io_0014_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cl_io_0014.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0014.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cl_io_0014.pgc" + int h_cnt ; +/* exec sql end declare section */ +#line 20 "app/dbio/cl_io_0014.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0014_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from cls_month where acct_no = $1 and dr_amt > 0", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_int,&(h_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0014.pgc" +#line 31 "app/dbio/cl_io_0014.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0014_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select dr_amt from cls_month where acct_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 42 "app/dbio/cl_io_0014.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0014_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +148,27 @@ int cl_io_0014_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0014.pgc" - char h_key [ 16 ] ; +#line 54 "app/dbio/cl_io_0014.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0014.pgc" - long h_amount ; +#line 55 "app/dbio/cl_io_0014.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0014.pgc" +#line 56 "app/dbio/cl_io_0014.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0014_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cls_month ( acct_no , dr_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( acct_no ) do update set dr_amt = cls_month . dr_amt + EXCLUDED . dr_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0014.pgc" - +#line 68 "app/dbio/cl_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0014_touch"); @@ -172,33 +184,37 @@ long cl_io_0014_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/cl_io_0014.pgc" - char h_biz_date [ 9 ] ; +#line 81 "app/dbio/cl_io_0014.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0014.pgc" - long h_sum ; +#line 82 "app/dbio/cl_io_0014.pgc" + long h_dr ; + +#line 83 "app/dbio/cl_io_0014.pgc" + long h_cr ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0014.pgc" +#line 84 "app/dbio/cl_io_0014.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0014_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when confirm_yn = 'D' then dr_amt else 0 end ) , 0 ) , coalesce ( sum ( case when confirm_yn = 'C' then dr_amt else 0 end ) , 0 ) from cls_trial where close_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_dr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_cr),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0014.pgc" - +#line 96 "app/dbio/cl_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0014_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/cl_io_0014.pgc b/app/dbio/cl_io_0014.pgc index 66989a6..30f7f95 100644 --- a/app/dbio/cl_io_0014.pgc +++ b/app/dbio/cl_io_0014.pgc @@ -14,49 +14,58 @@ EXEC SQL INCLUDE sqlca; int cl_io_0014_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + int h_cnt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0014_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM cls_month + WHERE acct_no = :h_key + AND dr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0014_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + EXEC SQL SELECT dr_amt + INTO :h_amt + FROM cls_month + WHERE acct_no = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0014_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } int cl_io_0014_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0014_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO cls_month (acct_no, dr_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (acct_no) + DO UPDATE SET dr_amt = cls_month.dr_amt + EXCLUDED.dr_amt, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0014_touch"); return TX_EDB; @@ -69,24 +78,25 @@ int cl_io_0014_touch(const char *key, long amount) long cl_io_0014_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_dr; + long h_cr; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0014_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT + coalesce(sum(CASE WHEN confirm_yn = 'D' THEN dr_amt ELSE 0 END), 0), + coalesce(sum(CASE WHEN confirm_yn = 'C' THEN dr_amt ELSE 0 END), 0) + INTO :h_dr, :h_cr + FROM cls_trial + WHERE close_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0014_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/cl_io_0015.c b/app/dbio/cl_io_0015.c index ff1a1cc..5c3b278 100644 --- a/app/dbio/cl_io_0015.c +++ b/app/dbio/cl_io_0015.c @@ -92,39 +92,45 @@ struct sqlca_t *ECPGget_sqlca(void); int cl_io_0015_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ - + + #line 17 "app/dbio/cl_io_0015.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0015.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cl_io_0015.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/cl_io_0015.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0015_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( bal_amt ) from cls_ledger where journal_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/cl_io_0015.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0015_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +140,27 @@ int cl_io_0015_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0015.pgc" - char h_key [ 16 ] ; +#line 48 "app/dbio/cl_io_0015.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0015.pgc" - long h_amount ; +#line 49 "app/dbio/cl_io_0015.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0015.pgc" +#line 50 "app/dbio/cl_io_0015.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0015_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cls_account ( journal_no , bal_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( journal_no ) do update set bal_amt = cls_account . bal_amt + EXCLUDED . bal_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0015.pgc" - +#line 62 "app/dbio/cl_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0015_touch"); @@ -173,28 +177,26 @@ long cl_io_0015_total(const char *biz_date) -#line 72 "app/dbio/cl_io_0015.pgc" - char h_biz_date [ 9 ] ; +#line 75 "app/dbio/cl_io_0015.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0015.pgc" +#line 76 "app/dbio/cl_io_0015.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0015.pgc" +#line 77 "app/dbio/cl_io_0015.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0015_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( bal_amt ) , 0 ) from cls_account where post_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0015.pgc" - +#line 87 "app/dbio/cl_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0015_total"); diff --git a/app/dbio/cl_io_0015.pgc b/app/dbio/cl_io_0015.pgc index b7f63c4..c427359 100644 --- a/app/dbio/cl_io_0015.pgc +++ b/app/dbio/cl_io_0015.pgc @@ -14,49 +14,52 @@ EXEC SQL INCLUDE sqlca; int cl_io_0015_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0015_t - WHERE key = :h_key; - + EXEC SQL SELECT max(bal_amt) + INTO :h_amt:h_ind + FROM cls_ledger + WHERE journal_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0015_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } int cl_io_0015_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0015_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO cls_account (journal_no, bal_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (journal_no) + DO UPDATE SET bal_amt = cls_account.bal_amt + EXCLUDED.bal_amt, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0015_touch"); return TX_EDB; @@ -69,21 +72,19 @@ int cl_io_0015_touch(const char *key, long amount) long cl_io_0015_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(bal_amt), 0) INTO :h_sum - FROM cl_io_0015_t - WHERE biz_date = :h_biz_date; - + FROM cls_account + WHERE post_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0015_total"); return -1; diff --git a/app/dbio/cl_io_0016.c b/app/dbio/cl_io_0016.c index cce89a6..cf0adeb 100644 --- a/app/dbio/cl_io_0016.c +++ b/app/dbio/cl_io_0016.c @@ -94,37 +94,58 @@ int cl_io_0016_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cl_io_0016.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0016.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cl_io_0016.pgc" + long h_acc ; +/* exec sql end declare section */ +#line 20 "app/dbio/cl_io_0016.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0016_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cl_io_0016_fetch_cur cursor for select carry_amt from cls_daily_bal where slip_no = $1 order by biz_date */ +#line 31 "app/dbio/cl_io_0016.pgc" + +#line 31 "app/dbio/cl_io_0016.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cl_io_0016_fetch_cur cursor for select carry_amt from cls_daily_bal where slip_no = $1 order by biz_date", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 32 "app/dbio/cl_io_0016.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cl_io_0016_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0016.pgc" +#line 34 "app/dbio/cl_io_0016.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0016_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0016_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 39 "app/dbio/cl_io_0016.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0016_fetch"); - return TX_EDB; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0016_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 44 "app/dbio/cl_io_0016.pgc" + + *out_amount = h_acc; return TX_OK; } @@ -134,29 +155,27 @@ int cl_io_0016_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0016.pgc" - char h_key [ 16 ] ; +#line 52 "app/dbio/cl_io_0016.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0016.pgc" - long h_amount ; +#line 53 "app/dbio/cl_io_0016.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0016.pgc" +#line 54 "app/dbio/cl_io_0016.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0016_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cls_trial ( slip_no , carry_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( slip_no ) do update set carry_amt = cls_trial . carry_amt + EXCLUDED . carry_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0016.pgc" - +#line 66 "app/dbio/cl_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0016_touch"); @@ -173,32 +192,30 @@ long cl_io_0016_total(const char *biz_date) -#line 72 "app/dbio/cl_io_0016.pgc" - char h_biz_date [ 9 ] ; +#line 79 "app/dbio/cl_io_0016.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0016.pgc" - long h_sum ; +#line 80 "app/dbio/cl_io_0016.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0016.pgc" +#line 81 "app/dbio/cl_io_0016.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0016_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from cls_daily_bal where biz_date = $1 and carry_amt <> 0", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0016.pgc" - +#line 92 "app/dbio/cl_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0016_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cl_io_0016.pgc b/app/dbio/cl_io_0016.pgc index ccef9a7..f7f76a3 100644 --- a/app/dbio/cl_io_0016.pgc +++ b/app/dbio/cl_io_0016.pgc @@ -14,49 +14,56 @@ EXEC SQL INCLUDE sqlca; int cl_io_0016_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + long h_acc; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0016_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0016_fetch"); - return TX_EDB; + EXEC SQL DECLARE cl_io_0016_fetch_cur CURSOR FOR + SELECT carry_amt FROM cls_daily_bal + WHERE slip_no = :h_key + ORDER BY biz_date; + EXEC SQL OPEN cl_io_0016_fetch_cur; + for (;;) { + EXEC SQL FETCH cl_io_0016_fetch_cur INTO :h_amt; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0016_fetch"); + EXEC SQL CLOSE cl_io_0016_fetch_cur; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + EXEC SQL CLOSE cl_io_0016_fetch_cur; + *out_amount = h_acc; return TX_OK; } int cl_io_0016_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0016_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO cls_trial (slip_no, carry_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (slip_no) + DO UPDATE SET carry_amt = cls_trial.carry_amt + EXCLUDED.carry_amt, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0016_touch"); return TX_EDB; @@ -69,24 +76,23 @@ int cl_io_0016_touch(const char *key, long amount) long cl_io_0016_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0016_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM cls_daily_bal + WHERE biz_date = :h_bd + AND carry_amt <> 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0016_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cl_io_0017.c b/app/dbio/cl_io_0017.c index 5d608ce..653927d 100644 --- a/app/dbio/cl_io_0017.c +++ b/app/dbio/cl_io_0017.c @@ -96,27 +96,25 @@ int cl_io_0017_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cl_io_0017.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0017.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cl_io_0017.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0017_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( m . net_amt , 0 ) - ( select coalesce ( sum ( h . net_amt ) , 0 ) from cls_summary h where h . ledger_no = m . ledger_no ) from cls_ledger m where m . ledger_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0017.pgc" - +#line 31 "app/dbio/cl_io_0017.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +122,7 @@ int cl_io_0017_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0017_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -135,28 +133,26 @@ int cl_io_0017_touch(const char *key, long amount) #line 45 "app/dbio/cl_io_0017.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 46 "app/dbio/cl_io_0017.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/cl_io_0017.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0017_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cls_ledger ( ledger_no , net_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( ledger_no ) do update set net_amt = cls_ledger . net_amt + EXCLUDED . net_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0017.pgc" - +#line 59 "app/dbio/cl_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0017_touch"); @@ -172,33 +168,62 @@ long cl_io_0017_total(const char *biz_date) /* exec sql begin declare section */ + + #line 72 "app/dbio/cl_io_0017.pgc" - char h_biz_date [ 9 ] ; + char h_bd [ 9 ] ; #line 73 "app/dbio/cl_io_0017.pgc" - long h_sum ; -/* exec sql end declare section */ + char h_grp [ 20 ] ; + #line 74 "app/dbio/cl_io_0017.pgc" + long h_sub ; + +#line 75 "app/dbio/cl_io_0017.pgc" + long h_tot ; +/* exec sql end declare section */ +#line 76 "app/dbio/cl_io_0017.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + ECPGset_var( 0, ( h_bd ), __LINE__);\ + /* declare cl_io_0017_total_gc cursor for select dept_cd , coalesce ( sum ( net_amt ) , 0 ) from cls_ledger where close_dt = $1 group by dept_cd order by dept_cd */ +#line 89 "app/dbio/cl_io_0017.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0017_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), +#line 89 "app/dbio/cl_io_0017.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cl_io_0017_total_gc cursor for select dept_cd , coalesce ( sum ( net_amt ) , 0 ) from cls_ledger where close_dt = $1 group by dept_cd order by dept_cd", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 90 "app/dbio/cl_io_0017.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cl_io_0017_total_gc", ECPGt_EOIT, + ECPGt_char,(h_grp),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sub),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0017.pgc" +#line 92 "app/dbio/cl_io_0017.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0017_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0017_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 97 "app/dbio/cl_io_0017.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0017_total"); - return -1; + return -1; + } + h_tot += h_sub; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0017_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 102 "app/dbio/cl_io_0017.pgc" + + return h_tot; } diff --git a/app/dbio/cl_io_0017.pgc b/app/dbio/cl_io_0017.pgc index dc3cfff..fc0e232 100644 --- a/app/dbio/cl_io_0017.pgc +++ b/app/dbio/cl_io_0017.pgc @@ -14,49 +14,49 @@ EXEC SQL INCLUDE sqlca; int cl_io_0017_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0017_t - WHERE key = :h_key; - + EXEC SQL SELECT coalesce(m.net_amt, 0) + - (SELECT coalesce(sum(h.net_amt), 0) + FROM cls_summary h WHERE h.ledger_no = m.ledger_no) + INTO :h_amt + FROM cls_ledger m + WHERE m.ledger_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0017_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cl_io_0017_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0017_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO cls_ledger (ledger_no, net_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (ledger_no) + DO UPDATE SET net_amt = cls_ledger.net_amt + EXCLUDED.net_amt, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0017_touch"); return TX_EDB; @@ -69,24 +69,36 @@ int cl_io_0017_touch(const char *key, long amount) long cl_io_0017_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + char h_grp[20]; + long h_sub; + long h_tot; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0017_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0017_total"); - return -1; + EXEC SQL DECLARE cl_io_0017_total_gc CURSOR FOR + SELECT dept_cd, coalesce(sum(net_amt), 0) + FROM cls_ledger + WHERE close_dt = :h_bd + GROUP BY dept_cd + ORDER BY dept_cd; + EXEC SQL OPEN cl_io_0017_total_gc; + for (;;) { + EXEC SQL FETCH cl_io_0017_total_gc INTO :h_grp, :h_sub; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0017_total"); + EXEC SQL CLOSE cl_io_0017_total_gc; + return -1; + } + h_tot += h_sub; } - return h_sum; + EXEC SQL CLOSE cl_io_0017_total_gc; + return h_tot; } diff --git a/app/dbio/cl_io_0018.c b/app/dbio/cl_io_0018.c index 48d0791..8b6d16d 100644 --- a/app/dbio/cl_io_0018.c +++ b/app/dbio/cl_io_0018.c @@ -92,31 +92,43 @@ struct sqlca_t *ECPGget_sqlca(void); int cl_io_0018_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ + + + #line 17 "app/dbio/cl_io_0018.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0018.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_min ; + #line 19 "app/dbio/cl_io_0018.pgc" + long h_max ; + +#line 20 "app/dbio/cl_io_0018.pgc" + short h_i1 ; + +#line 21 "app/dbio/cl_io_0018.pgc" + short h_i2 ; +/* exec sql end declare section */ +#line 22 "app/dbio/cl_io_0018.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0018_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( tax_amt ) , max ( tax_amt ) from cls_summary where acct_no = $1 and post_yn <> 'D'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0018.pgc" - + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i1),(long)1,(long)1,sizeof(short), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i2),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 33 "app/dbio/cl_io_0018.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +136,9 @@ int cl_io_0018_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0018_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } @@ -134,29 +148,27 @@ int cl_io_0018_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0018.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/cl_io_0018.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0018.pgc" - long h_amount ; +#line 50 "app/dbio/cl_io_0018.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0018.pgc" +#line 51 "app/dbio/cl_io_0018.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0018_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cls_daily_bal ( acct_no , tax_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( acct_no ) do update set tax_amt = cls_daily_bal . tax_amt + EXCLUDED . tax_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0018.pgc" - +#line 63 "app/dbio/cl_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0018_touch"); @@ -173,28 +185,26 @@ long cl_io_0018_total(const char *biz_date) -#line 72 "app/dbio/cl_io_0018.pgc" - char h_biz_date [ 9 ] ; +#line 76 "app/dbio/cl_io_0018.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0018.pgc" +#line 77 "app/dbio/cl_io_0018.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0018.pgc" +#line 78 "app/dbio/cl_io_0018.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0018_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . tax_amt ) , 0 ) from cls_journal d join cls_daily_bal m on d . acct_no = m . acct_no where d . post_dt = $1 and m . post_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0018.pgc" - +#line 90 "app/dbio/cl_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0018_total"); diff --git a/app/dbio/cl_io_0018.pgc b/app/dbio/cl_io_0018.pgc index e2ae243..295e57f 100644 --- a/app/dbio/cl_io_0018.pgc +++ b/app/dbio/cl_io_0018.pgc @@ -14,49 +14,53 @@ EXEC SQL INCLUDE sqlca; int cl_io_0018_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_min; + long h_max; + short h_i1; + short h_i2; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0018_t - WHERE key = :h_key; - + EXEC SQL SELECT min(tax_amt), max(tax_amt) + INTO :h_min:h_i1, :h_max:h_i2 + FROM cls_summary + WHERE acct_no = :h_key + AND post_yn <> 'D'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0018_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } int cl_io_0018_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0018_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO cls_daily_bal (acct_no, tax_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (acct_no) + DO UPDATE SET tax_amt = cls_daily_bal.tax_amt + EXCLUDED.tax_amt, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0018_touch"); return TX_EDB; @@ -69,21 +73,21 @@ int cl_io_0018_touch(const char *key, long amount) long cl_io_0018_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.tax_amt), 0) INTO :h_sum - FROM cl_io_0018_t - WHERE biz_date = :h_biz_date; - + FROM cls_journal d + JOIN cls_daily_bal m ON d.acct_no = m.acct_no + WHERE d.post_dt = :h_bd + AND m.post_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0018_total"); return -1; diff --git a/app/dbio/cl_io_0019.c b/app/dbio/cl_io_0019.c index 0aa8ae7..6d7c1a2 100644 --- a/app/dbio/cl_io_0019.c +++ b/app/dbio/cl_io_0019.c @@ -96,26 +96,25 @@ int cl_io_0019_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cl_io_0019.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0019.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cl_io_0019.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0019_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . cr_amt ) , 0 ) from cls_summary a join cls_journal b on a . journal_no = b . journal_no where a . journal_no = $1 and b . close_yn = 'Y'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0019.pgc" +#line 31 "app/dbio/cl_io_0019.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int cl_io_0019_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0019_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -134,71 +133,74 @@ int cl_io_0019_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0019.pgc" - char h_key [ 16 ] ; - #line 46 "app/dbio/cl_io_0019.pgc" - long h_amount ; -/* exec sql end declare section */ + char h_key [ 20 ] ; + #line 47 "app/dbio/cl_io_0019.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 48 "app/dbio/cl_io_0019.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0019_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from cls_carry where journal_no = $1 and cr_amt < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/cl_io_0019.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0019_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cl_io_0019_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long cl_io_0019_total(const char *biz_date) { /* exec sql begin declare section */ - + + #line 72 "app/dbio/cl_io_0019.pgc" - char h_biz_date [ 9 ] ; + char h_bd [ 9 ] ; #line 73 "app/dbio/cl_io_0019.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_max ; + #line 74 "app/dbio/cl_io_0019.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 75 "app/dbio/cl_io_0019.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0019_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( cr_amt ) from cls_journal where biz_date = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 85 "app/dbio/cl_io_0019.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0019_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/cl_io_0019.pgc b/app/dbio/cl_io_0019.pgc index af29b6f..ec478db 100644 --- a/app/dbio/cl_io_0019.pgc +++ b/app/dbio/cl_io_0019.pgc @@ -14,20 +14,21 @@ EXEC SQL INCLUDE sqlca; int cl_io_0019_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0019_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(a.cr_amt), 0) + INTO :h_amt + FROM cls_summary a + JOIN cls_journal b ON a.journal_no = b.journal_no + WHERE a.journal_no = :h_key + AND b.close_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,58 +36,58 @@ int cl_io_0019_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0019_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cl_io_0019_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0019_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM cls_carry + WHERE journal_no = :h_key + AND cr_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0019_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cl_io_0019_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long cl_io_0019_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0019_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT max(cr_amt) + INTO :h_max:h_ind + FROM cls_journal + WHERE biz_date = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0019_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/cl_io_0020.c b/app/dbio/cl_io_0020.c index 4401ed6..4fdddab 100644 --- a/app/dbio/cl_io_0020.c +++ b/app/dbio/cl_io_0020.c @@ -94,37 +94,51 @@ int cl_io_0020_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cl_io_0020.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0020.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cl_io_0020.pgc" + int h_cnt ; +/* exec sql end declare section */ +#line 20 "app/dbio/cl_io_0020.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0020_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from cls_journal where slip_no = $1 and dr_amt > 0", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_int,&(h_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0020.pgc" +#line 31 "app/dbio/cl_io_0020.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select dr_amt from cls_journal where slip_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 42 "app/dbio/cl_io_0020.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0020_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +148,27 @@ int cl_io_0020_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0020.pgc" - char h_key [ 16 ] ; +#line 54 "app/dbio/cl_io_0020.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0020.pgc" - long h_amount ; +#line 55 "app/dbio/cl_io_0020.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0020.pgc" +#line 56 "app/dbio/cl_io_0020.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0020_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from cls_month where slip_no = $1 and dr_amt < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0020.pgc" - +#line 66 "app/dbio/cl_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0020_touch"); @@ -164,6 +176,7 @@ int cl_io_0020_touch(const char *key, long amount) } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cl_io_0020_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } @@ -173,32 +186,30 @@ long cl_io_0020_total(const char *biz_date) -#line 72 "app/dbio/cl_io_0020.pgc" - char h_biz_date [ 9 ] ; +#line 80 "app/dbio/cl_io_0020.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0020.pgc" - long h_sum ; +#line 81 "app/dbio/cl_io_0020.pgc" + long h_avg ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0020.pgc" +#line 82 "app/dbio/cl_io_0020.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0020_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( avg ( dr_amt ) , 0 ) :: bigint from cls_journal where close_dt = $1 and confirm_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0020.pgc" - +#line 93 "app/dbio/cl_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0020_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/cl_io_0020.pgc b/app/dbio/cl_io_0020.pgc index 95dbdd7..74e95c0 100644 --- a/app/dbio/cl_io_0020.pgc +++ b/app/dbio/cl_io_0020.pgc @@ -14,79 +14,86 @@ EXEC SQL INCLUDE sqlca; int cl_io_0020_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + int h_cnt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0020_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM cls_journal + WHERE slip_no = :h_key + AND dr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + EXEC SQL SELECT dr_amt + INTO :h_amt + FROM cls_journal + WHERE slip_no = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0020_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } int cl_io_0020_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0020_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM cls_month + WHERE slip_no = :h_key + AND dr_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0020_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cl_io_0020_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long cl_io_0020_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_avg; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0020_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT coalesce(avg(dr_amt), 0)::bigint + INTO :h_avg + FROM cls_journal + WHERE close_dt = :h_bd + AND confirm_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0020_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/cl_io_0021.c b/app/dbio/cl_io_0021.c index 10841fa..4ea089e 100644 --- a/app/dbio/cl_io_0021.c +++ b/app/dbio/cl_io_0021.c @@ -92,39 +92,45 @@ struct sqlca_t *ECPGget_sqlca(void); int cl_io_0021_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ - + + #line 17 "app/dbio/cl_io_0021.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0021.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cl_io_0021.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/cl_io_0021.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0021_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( bal_amt ) from cls_account where ledger_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/cl_io_0021.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0021_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +140,27 @@ int cl_io_0021_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0021.pgc" - char h_key [ 16 ] ; +#line 48 "app/dbio/cl_io_0021.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0021.pgc" - long h_amount ; +#line 49 "app/dbio/cl_io_0021.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0021.pgc" +#line 50 "app/dbio/cl_io_0021.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0021_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from cls_account where ledger_no = $1 and bal_amt < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0021.pgc" - +#line 60 "app/dbio/cl_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0021_touch"); @@ -164,6 +168,7 @@ int cl_io_0021_touch(const char *key, long amount) } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cl_io_0021_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } @@ -172,33 +177,37 @@ long cl_io_0021_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/cl_io_0021.pgc" - char h_biz_date [ 9 ] ; - -#line 73 "app/dbio/cl_io_0021.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/cl_io_0021.pgc" + char h_bd [ 9 ] ; + +#line 75 "app/dbio/cl_io_0021.pgc" + long h_dr ; + +#line 76 "app/dbio/cl_io_0021.pgc" + long h_cr ; +/* exec sql end declare section */ +#line 77 "app/dbio/cl_io_0021.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0021_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when post_yn = 'D' then bal_amt else 0 end ) , 0 ) , coalesce ( sum ( case when post_yn = 'C' then bal_amt else 0 end ) , 0 ) from cls_account where post_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_dr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_cr),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0021.pgc" - +#line 89 "app/dbio/cl_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0021_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/cl_io_0021.pgc b/app/dbio/cl_io_0021.pgc index f409cde..214bb66 100644 --- a/app/dbio/cl_io_0021.pgc +++ b/app/dbio/cl_io_0021.pgc @@ -14,79 +14,82 @@ EXEC SQL INCLUDE sqlca; int cl_io_0021_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0021_t - WHERE key = :h_key; - + EXEC SQL SELECT max(bal_amt) + INTO :h_amt:h_ind + FROM cls_account + WHERE ledger_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0021_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } int cl_io_0021_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0021_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM cls_account + WHERE ledger_no = :h_key + AND bal_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0021_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cl_io_0021_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long cl_io_0021_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_dr; + long h_cr; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0021_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT + coalesce(sum(CASE WHEN post_yn = 'D' THEN bal_amt ELSE 0 END), 0), + coalesce(sum(CASE WHEN post_yn = 'C' THEN bal_amt ELSE 0 END), 0) + INTO :h_dr, :h_cr + FROM cls_account + WHERE post_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0021_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/cl_io_0022.c b/app/dbio/cl_io_0022.c index 414a9f4..f2f1c80 100644 --- a/app/dbio/cl_io_0022.c +++ b/app/dbio/cl_io_0022.c @@ -94,37 +94,58 @@ int cl_io_0022_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cl_io_0022.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0022.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cl_io_0022.pgc" + long h_acc ; +/* exec sql end declare section */ +#line 20 "app/dbio/cl_io_0022.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0022_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cl_io_0022_fetch_cur cursor for select carry_amt from cls_trial where acct_no = $1 order by biz_date */ +#line 31 "app/dbio/cl_io_0022.pgc" + +#line 31 "app/dbio/cl_io_0022.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cl_io_0022_fetch_cur cursor for select carry_amt from cls_trial where acct_no = $1 order by biz_date", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 32 "app/dbio/cl_io_0022.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cl_io_0022_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0022.pgc" +#line 34 "app/dbio/cl_io_0022.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0022_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0022_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 39 "app/dbio/cl_io_0022.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0022_fetch"); - return TX_EDB; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0022_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 44 "app/dbio/cl_io_0022.pgc" + + *out_amount = h_acc; return TX_OK; } @@ -134,29 +155,27 @@ int cl_io_0022_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0022.pgc" - char h_key [ 16 ] ; +#line 52 "app/dbio/cl_io_0022.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0022.pgc" - long h_amount ; +#line 53 "app/dbio/cl_io_0022.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0022.pgc" +#line 54 "app/dbio/cl_io_0022.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0022_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from cls_trial where acct_no = $1 and carry_amt < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0022.pgc" - +#line 64 "app/dbio/cl_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0022_touch"); @@ -164,6 +183,7 @@ int cl_io_0022_touch(const char *key, long amount) } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cl_io_0022_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } @@ -173,28 +193,26 @@ long cl_io_0022_total(const char *biz_date) -#line 72 "app/dbio/cl_io_0022.pgc" - char h_biz_date [ 9 ] ; +#line 78 "app/dbio/cl_io_0022.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0022.pgc" +#line 79 "app/dbio/cl_io_0022.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0022.pgc" +#line 80 "app/dbio/cl_io_0022.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0022_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( carry_amt ) , 0 ) from cls_month where biz_date = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0022.pgc" - +#line 90 "app/dbio/cl_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0022_total"); diff --git a/app/dbio/cl_io_0022.pgc b/app/dbio/cl_io_0022.pgc index 728427d..b69c95f 100644 --- a/app/dbio/cl_io_0022.pgc +++ b/app/dbio/cl_io_0022.pgc @@ -14,76 +14,80 @@ EXEC SQL INCLUDE sqlca; int cl_io_0022_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + long h_acc; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0022_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0022_fetch"); - return TX_EDB; + EXEC SQL DECLARE cl_io_0022_fetch_cur CURSOR FOR + SELECT carry_amt FROM cls_trial + WHERE acct_no = :h_key + ORDER BY biz_date; + EXEC SQL OPEN cl_io_0022_fetch_cur; + for (;;) { + EXEC SQL FETCH cl_io_0022_fetch_cur INTO :h_amt; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0022_fetch"); + EXEC SQL CLOSE cl_io_0022_fetch_cur; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + EXEC SQL CLOSE cl_io_0022_fetch_cur; + *out_amount = h_acc; return TX_OK; } int cl_io_0022_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0022_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM cls_trial + WHERE acct_no = :h_key + AND carry_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0022_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cl_io_0022_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long cl_io_0022_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(carry_amt), 0) INTO :h_sum - FROM cl_io_0022_t - WHERE biz_date = :h_biz_date; - + FROM cls_month + WHERE biz_date = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0022_total"); return -1; diff --git a/app/dbio/cl_io_0023.c b/app/dbio/cl_io_0023.c index f33dc9f..8bad7af 100644 --- a/app/dbio/cl_io_0023.c +++ b/app/dbio/cl_io_0023.c @@ -96,27 +96,25 @@ int cl_io_0023_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cl_io_0023.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0023.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cl_io_0023.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0023_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( m . net_amt , 0 ) - ( select coalesce ( sum ( h . net_amt ) , 0 ) from cls_ledger h where h . journal_no = m . journal_no ) from cls_account m where m . journal_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0023.pgc" - +#line 31 "app/dbio/cl_io_0023.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +122,7 @@ int cl_io_0023_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0023_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -135,28 +133,26 @@ int cl_io_0023_touch(const char *key, long amount) #line 45 "app/dbio/cl_io_0023.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 46 "app/dbio/cl_io_0023.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/cl_io_0023.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0023_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from cls_ledger where journal_no = $1 and net_amt < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0023.pgc" - +#line 57 "app/dbio/cl_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0023_touch"); @@ -164,6 +160,7 @@ int cl_io_0023_touch(const char *key, long amount) } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cl_io_0023_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } @@ -173,32 +170,30 @@ long cl_io_0023_total(const char *biz_date) -#line 72 "app/dbio/cl_io_0023.pgc" - char h_biz_date [ 9 ] ; +#line 71 "app/dbio/cl_io_0023.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0023.pgc" - long h_sum ; +#line 72 "app/dbio/cl_io_0023.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0023.pgc" +#line 73 "app/dbio/cl_io_0023.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0023_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from cls_ledger where close_dt = $1 and net_amt <> 0", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0023.pgc" - +#line 84 "app/dbio/cl_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0023_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cl_io_0023.pgc b/app/dbio/cl_io_0023.pgc index af2acfc..55fdf12 100644 --- a/app/dbio/cl_io_0023.pgc +++ b/app/dbio/cl_io_0023.pgc @@ -14,79 +14,77 @@ EXEC SQL INCLUDE sqlca; int cl_io_0023_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0023_t - WHERE key = :h_key; - + EXEC SQL SELECT coalesce(m.net_amt, 0) + - (SELECT coalesce(sum(h.net_amt), 0) + FROM cls_ledger h WHERE h.journal_no = m.journal_no) + INTO :h_amt + FROM cls_account m + WHERE m.journal_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0023_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cl_io_0023_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0023_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM cls_ledger + WHERE journal_no = :h_key + AND net_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0023_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cl_io_0023_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long cl_io_0023_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0023_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM cls_ledger + WHERE close_dt = :h_bd + AND net_amt <> 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0023_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cl_io_0024.c b/app/dbio/cl_io_0024.c index 5e474eb..7303117 100644 --- a/app/dbio/cl_io_0024.c +++ b/app/dbio/cl_io_0024.c @@ -92,31 +92,43 @@ struct sqlca_t *ECPGget_sqlca(void); int cl_io_0024_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ + + + #line 17 "app/dbio/cl_io_0024.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0024.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_min ; + #line 19 "app/dbio/cl_io_0024.pgc" + long h_max ; + +#line 20 "app/dbio/cl_io_0024.pgc" + short h_i1 ; + +#line 21 "app/dbio/cl_io_0024.pgc" + short h_i2 ; +/* exec sql end declare section */ +#line 22 "app/dbio/cl_io_0024.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0024_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( tax_amt ) , max ( tax_amt ) from cls_ledger where slip_no = $1 and post_yn <> 'D'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0024.pgc" - + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i1),(long)1,(long)1,sizeof(short), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i2),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 33 "app/dbio/cl_io_0024.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +136,9 @@ int cl_io_0024_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0024_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } @@ -134,29 +148,27 @@ int cl_io_0024_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0024.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/cl_io_0024.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0024.pgc" - long h_amount ; +#line 50 "app/dbio/cl_io_0024.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0024.pgc" +#line 51 "app/dbio/cl_io_0024.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0024_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from cls_daily_bal where slip_no = $1 and tax_amt < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0024.pgc" - +#line 61 "app/dbio/cl_io_0024.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0024_touch"); @@ -164,6 +176,7 @@ int cl_io_0024_touch(const char *key, long amount) } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cl_io_0024_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } @@ -172,33 +185,62 @@ long cl_io_0024_total(const char *biz_date) /* exec sql begin declare section */ + + -#line 72 "app/dbio/cl_io_0024.pgc" - char h_biz_date [ 9 ] ; +#line 75 "app/dbio/cl_io_0024.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0024.pgc" - long h_sum ; +#line 76 "app/dbio/cl_io_0024.pgc" + char h_grp [ 20 ] ; + +#line 77 "app/dbio/cl_io_0024.pgc" + long h_sub ; + +#line 78 "app/dbio/cl_io_0024.pgc" + long h_tot ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0024.pgc" +#line 79 "app/dbio/cl_io_0024.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + ECPGset_var( 0, ( h_bd ), __LINE__);\ + /* declare cl_io_0024_total_gc cursor for select branch_cd , coalesce ( sum ( tax_amt ) , 0 ) from cls_trial where post_dt = $1 group by branch_cd order by branch_cd */ +#line 92 "app/dbio/cl_io_0024.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0024_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), +#line 92 "app/dbio/cl_io_0024.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cl_io_0024_total_gc cursor for select branch_cd , coalesce ( sum ( tax_amt ) , 0 ) from cls_trial where post_dt = $1 group by branch_cd order by branch_cd", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 93 "app/dbio/cl_io_0024.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cl_io_0024_total_gc", ECPGt_EOIT, + ECPGt_char,(h_grp),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sub),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0024.pgc" +#line 95 "app/dbio/cl_io_0024.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0024_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0024_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 100 "app/dbio/cl_io_0024.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0024_total"); - return -1; + return -1; + } + h_tot += h_sub; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cl_io_0024_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 105 "app/dbio/cl_io_0024.pgc" + + return h_tot; } diff --git a/app/dbio/cl_io_0024.pgc b/app/dbio/cl_io_0024.pgc index 923dcea..beface2 100644 --- a/app/dbio/cl_io_0024.pgc +++ b/app/dbio/cl_io_0024.pgc @@ -14,79 +14,94 @@ EXEC SQL INCLUDE sqlca; int cl_io_0024_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_min; + long h_max; + short h_i1; + short h_i2; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0024_t - WHERE key = :h_key; - + EXEC SQL SELECT min(tax_amt), max(tax_amt) + INTO :h_min:h_i1, :h_max:h_i2 + FROM cls_ledger + WHERE slip_no = :h_key + AND post_yn <> 'D'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0024_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } int cl_io_0024_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0024_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM cls_daily_bal + WHERE slip_no = :h_key + AND tax_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0024_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cl_io_0024_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long cl_io_0024_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + char h_grp[20]; + long h_sub; + long h_tot; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0024_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cl_io_0024_total"); - return -1; + EXEC SQL DECLARE cl_io_0024_total_gc CURSOR FOR + SELECT branch_cd, coalesce(sum(tax_amt), 0) + FROM cls_trial + WHERE post_dt = :h_bd + GROUP BY branch_cd + ORDER BY branch_cd; + EXEC SQL OPEN cl_io_0024_total_gc; + for (;;) { + EXEC SQL FETCH cl_io_0024_total_gc INTO :h_grp, :h_sub; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0024_total"); + EXEC SQL CLOSE cl_io_0024_total_gc; + return -1; + } + h_tot += h_sub; } - return h_sum; + EXEC SQL CLOSE cl_io_0024_total_gc; + return h_tot; } diff --git a/app/dbio/cl_io_0025.c b/app/dbio/cl_io_0025.c index 908a7ba..c687eee 100644 --- a/app/dbio/cl_io_0025.c +++ b/app/dbio/cl_io_0025.c @@ -96,26 +96,25 @@ int cl_io_0025_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cl_io_0025.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0025.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cl_io_0025.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0025_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . cr_amt ) , 0 ) from cls_ledger a join cls_daily_bal b on a . ledger_no = b . ledger_no where a . ledger_no = $1 and b . close_yn = 'Y'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0025.pgc" +#line 31 "app/dbio/cl_io_0025.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int cl_io_0025_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0025_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -134,29 +133,27 @@ int cl_io_0025_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0025.pgc" - char h_key [ 16 ] ; - #line 46 "app/dbio/cl_io_0025.pgc" - long h_amount ; -/* exec sql end declare section */ + char h_key [ 20 ] ; + #line 47 "app/dbio/cl_io_0025.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 48 "app/dbio/cl_io_0025.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0025_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cls_daily_bal set cr_amt = cr_amt + $1 where dept_cd in ( select dept_cd from cls_ledger where ledger_no = $2 )", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0025.pgc" - +#line 59 "app/dbio/cl_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0025_touch"); @@ -174,7 +171,7 @@ long cl_io_0025_total(const char *biz_date) #line 72 "app/dbio/cl_io_0025.pgc" - char h_biz_date [ 9 ] ; + char h_bd [ 9 ] ; #line 73 "app/dbio/cl_io_0025.pgc" long h_sum ; @@ -184,17 +181,15 @@ long cl_io_0025_total(const char *biz_date) if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0025_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . cr_amt ) , 0 ) from cls_summary d join cls_ledger m on d . ledger_no = m . ledger_no where d . biz_date = $1 and m . close_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0025.pgc" - +#line 86 "app/dbio/cl_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0025_total"); diff --git a/app/dbio/cl_io_0025.pgc b/app/dbio/cl_io_0025.pgc index 44fde1b..47bae12 100644 --- a/app/dbio/cl_io_0025.pgc +++ b/app/dbio/cl_io_0025.pgc @@ -14,20 +14,21 @@ EXEC SQL INCLUDE sqlca; int cl_io_0025_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0025_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(a.cr_amt), 0) + INTO :h_amt + FROM cls_ledger a + JOIN cls_daily_bal b ON a.ledger_no = b.ledger_no + WHERE a.ledger_no = :h_key + AND b.close_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +36,27 @@ int cl_io_0025_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cl_io_0025_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cl_io_0025_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0025_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE cls_daily_bal + SET cr_amt = cr_amt + :h_amt + WHERE dept_cd IN (SELECT dept_cd FROM cls_ledger + WHERE ledger_no = :h_key); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0025_touch"); return TX_EDB; @@ -69,21 +69,21 @@ int cl_io_0025_touch(const char *key, long amount) long cl_io_0025_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.cr_amt), 0) INTO :h_sum - FROM cl_io_0025_t - WHERE biz_date = :h_biz_date; - + FROM cls_summary d + JOIN cls_ledger m ON d.ledger_no = m.ledger_no + WHERE d.biz_date = :h_bd + AND m.close_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0025_total"); return -1; diff --git a/app/dbio/cl_io_0026.c b/app/dbio/cl_io_0026.c index b2bea54..69ff478 100644 --- a/app/dbio/cl_io_0026.c +++ b/app/dbio/cl_io_0026.c @@ -94,37 +94,51 @@ int cl_io_0026_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cl_io_0026.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cl_io_0026.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cl_io_0026.pgc" + int h_cnt ; +/* exec sql end declare section */ +#line 20 "app/dbio/cl_io_0026.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cl_io_0026_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from cls_daily_bal where acct_no = $1 and dr_amt > 0", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_int,&(h_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cl_io_0026.pgc" +#line 31 "app/dbio/cl_io_0026.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0026_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select dr_amt from cls_daily_bal where acct_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 42 "app/dbio/cl_io_0026.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0026_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +148,27 @@ int cl_io_0026_touch(const char *key, long amount) -#line 45 "app/dbio/cl_io_0026.pgc" - char h_key [ 16 ] ; +#line 54 "app/dbio/cl_io_0026.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cl_io_0026.pgc" - long h_amount ; +#line 55 "app/dbio/cl_io_0026.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cl_io_0026.pgc" +#line 56 "app/dbio/cl_io_0026.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cl_io_0026_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cls_summary set dr_amt = dr_amt + $1 where acct_cd in ( select acct_cd from cls_daily_bal where acct_no = $2 )", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cl_io_0026.pgc" - +#line 67 "app/dbio/cl_io_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0026_touch"); @@ -170,35 +182,39 @@ int cl_io_0026_touch(const char *key, long amount) long cl_io_0026_total(const char *biz_date) { /* exec sql begin declare section */ - + + -#line 72 "app/dbio/cl_io_0026.pgc" - char h_biz_date [ 9 ] ; +#line 80 "app/dbio/cl_io_0026.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cl_io_0026.pgc" - long h_sum ; +#line 81 "app/dbio/cl_io_0026.pgc" + long h_max ; + +#line 82 "app/dbio/cl_io_0026.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/cl_io_0026.pgc" +#line 83 "app/dbio/cl_io_0026.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cl_io_0026_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( dr_amt ) from cls_summary where close_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cl_io_0026.pgc" - + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 93 "app/dbio/cl_io_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0026_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/cl_io_0026.pgc b/app/dbio/cl_io_0026.pgc index a74bbac..a9fc2ce 100644 --- a/app/dbio/cl_io_0026.pgc +++ b/app/dbio/cl_io_0026.pgc @@ -14,49 +14,57 @@ EXEC SQL INCLUDE sqlca; int cl_io_0026_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + int h_cnt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cl_io_0026_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM cls_daily_bal + WHERE acct_no = :h_key + AND dr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0026_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + EXEC SQL SELECT dr_amt + INTO :h_amt + FROM cls_daily_bal + WHERE acct_no = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cl_io_0026_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } int cl_io_0026_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cl_io_0026_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE cls_summary + SET dr_amt = dr_amt + :h_amt + WHERE acct_cd IN (SELECT acct_cd FROM cls_daily_bal + WHERE acct_no = :h_key); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0026_touch"); return TX_EDB; @@ -69,24 +77,25 @@ int cl_io_0026_touch(const char *key, long amount) long cl_io_0026_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cl_io_0026_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT max(dr_amt) + INTO :h_max:h_ind + FROM cls_summary + WHERE close_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cl_io_0026_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/cm_io_0001.c b/app/dbio/cm_io_0001.c index f47f73b..4456eaf 100644 --- a/app/dbio/cm_io_0001.c +++ b/app/dbio/cm_io_0001.c @@ -96,26 +96,25 @@ int cm_io_0001_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cm_io_0001.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0001.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cm_io_0001.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0001_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . code_val ) , 0 ) from com_code a join com_code_val b on a . code_id = b . code_id where a . code_id = $1 and b . use_yn = 'Y'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0001.pgc" +#line 31 "app/dbio/cm_io_0001.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int cm_io_0001_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0001_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -134,29 +133,27 @@ int cm_io_0001_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0001.pgc" - char h_key [ 16 ] ; - #line 46 "app/dbio/cm_io_0001.pgc" - long h_amount ; -/* exec sql end declare section */ + char h_key [ 20 ] ; + #line 47 "app/dbio/cm_io_0001.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 48 "app/dbio/cm_io_0001.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0001_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update com_code set code_val = $1 , upd_ts = now ( ) where code_id = $2 and use_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0001.pgc" - +#line 59 "app/dbio/cm_io_0001.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0001_touch"); @@ -174,7 +171,7 @@ long cm_io_0001_total(const char *biz_date) #line 72 "app/dbio/cm_io_0001.pgc" - char h_biz_date [ 9 ] ; + char h_bd [ 9 ] ; #line 73 "app/dbio/cm_io_0001.pgc" long h_sum ; @@ -184,17 +181,15 @@ long cm_io_0001_total(const char *biz_date) if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0001_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( code_val ) , 0 ) from com_code where biz_date = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0001.pgc" - +#line 84 "app/dbio/cm_io_0001.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0001_total"); diff --git a/app/dbio/cm_io_0001.pgc b/app/dbio/cm_io_0001.pgc index 901ff1c..86a6266 100644 --- a/app/dbio/cm_io_0001.pgc +++ b/app/dbio/cm_io_0001.pgc @@ -14,20 +14,21 @@ EXEC SQL INCLUDE sqlca; int cm_io_0001_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0001_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(a.code_val), 0) + INTO :h_amt + FROM com_code a + JOIN com_code_val b ON a.code_id = b.code_id + WHERE a.code_id = :h_key + AND b.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +36,27 @@ int cm_io_0001_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0001_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cm_io_0001_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0001_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE com_code + SET code_val = :h_amt, upd_ts = now() + WHERE code_id = :h_key + AND use_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0001_touch"); return TX_EDB; @@ -69,21 +69,19 @@ int cm_io_0001_touch(const char *key, long amount) long cm_io_0001_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(code_val), 0) INTO :h_sum - FROM cm_io_0001_t - WHERE biz_date = :h_biz_date; - + FROM com_code + WHERE biz_date = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0001_total"); return -1; diff --git a/app/dbio/cm_io_0002.c b/app/dbio/cm_io_0002.c index dd48270..ac8a6d8 100644 --- a/app/dbio/cm_io_0002.c +++ b/app/dbio/cm_io_0002.c @@ -94,37 +94,51 @@ int cm_io_0002_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cm_io_0002.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0002.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cm_io_0002.pgc" + int h_cnt ; +/* exec sql end declare section */ +#line 20 "app/dbio/cm_io_0002.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0002_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from com_code_val where dept_cd = $1 and sort_seq > 0", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_int,&(h_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0002.pgc" +#line 31 "app/dbio/cm_io_0002.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select sort_seq from com_code_val where dept_cd = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 42 "app/dbio/cm_io_0002.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0002_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +148,27 @@ int cm_io_0002_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0002.pgc" - char h_key [ 16 ] ; +#line 54 "app/dbio/cm_io_0002.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0002.pgc" - long h_amount ; +#line 55 "app/dbio/cm_io_0002.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0002.pgc" +#line 56 "app/dbio/cm_io_0002.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0002_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update com_code_val set sort_seq = $1 , upd_ts = now ( ) where dept_cd = $2 and del_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0002.pgc" - +#line 67 "app/dbio/cm_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0002_touch"); @@ -173,32 +185,30 @@ long cm_io_0002_total(const char *biz_date) -#line 72 "app/dbio/cm_io_0002.pgc" - char h_biz_date [ 9 ] ; +#line 80 "app/dbio/cm_io_0002.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0002.pgc" - long h_sum ; +#line 81 "app/dbio/cm_io_0002.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0002.pgc" +#line 82 "app/dbio/cm_io_0002.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0002_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from com_branch where apply_dt = $1 and sort_seq <> 0", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0002.pgc" - +#line 93 "app/dbio/cm_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cm_io_0002.pgc b/app/dbio/cm_io_0002.pgc index 96e76ef..23655ad 100644 --- a/app/dbio/cm_io_0002.pgc +++ b/app/dbio/cm_io_0002.pgc @@ -14,49 +14,57 @@ EXEC SQL INCLUDE sqlca; int cm_io_0002_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + int h_cnt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0002_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM com_code_val + WHERE dept_cd = :h_key + AND sort_seq > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + EXEC SQL SELECT sort_seq + INTO :h_amt + FROM com_code_val + WHERE dept_cd = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0002_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } int cm_io_0002_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0002_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE com_code_val + SET sort_seq = :h_amt, upd_ts = now() + WHERE dept_cd = :h_key + AND del_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0002_touch"); return TX_EDB; @@ -69,24 +77,23 @@ int cm_io_0002_touch(const char *key, long amount) long cm_io_0002_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0002_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM com_branch + WHERE apply_dt = :h_bd + AND sort_seq <> 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cm_io_0003.c b/app/dbio/cm_io_0003.c index 2292227..98e37d8 100644 --- a/app/dbio/cm_io_0003.c +++ b/app/dbio/cm_io_0003.c @@ -92,39 +92,45 @@ struct sqlca_t *ECPGget_sqlca(void); int cm_io_0003_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ - + + #line 17 "app/dbio/cm_io_0003.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0003.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cm_io_0003.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/cm_io_0003.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0003_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( amount ) from com_param where branch_cd = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/cm_io_0003.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0003_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +140,27 @@ int cm_io_0003_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0003.pgc" - char h_key [ 16 ] ; +#line 48 "app/dbio/cm_io_0003.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0003.pgc" - long h_amount ; +#line 49 "app/dbio/cm_io_0003.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0003.pgc" +#line 50 "app/dbio/cm_io_0003.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0003_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update com_dept set amount = $1 , upd_ts = now ( ) where branch_cd = $2 and lock_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0003.pgc" - +#line 61 "app/dbio/cm_io_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0003_touch"); @@ -172,33 +176,62 @@ long cm_io_0003_total(const char *biz_date) /* exec sql begin declare section */ + + -#line 72 "app/dbio/cm_io_0003.pgc" - char h_biz_date [ 9 ] ; - -#line 73 "app/dbio/cm_io_0003.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/cm_io_0003.pgc" + char h_bd [ 9 ] ; + +#line 75 "app/dbio/cm_io_0003.pgc" + char h_grp [ 20 ] ; + +#line 76 "app/dbio/cm_io_0003.pgc" + long h_sub ; + +#line 77 "app/dbio/cm_io_0003.pgc" + long h_tot ; +/* exec sql end declare section */ +#line 78 "app/dbio/cm_io_0003.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + ECPGset_var( 0, ( h_bd ), __LINE__);\ + /* declare cm_io_0003_total_gc cursor for select branch_cd , coalesce ( sum ( amount ) , 0 ) from com_dept where reg_dt = $1 group by branch_cd order by branch_cd */ +#line 91 "app/dbio/cm_io_0003.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0003_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), +#line 91 "app/dbio/cm_io_0003.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cm_io_0003_total_gc cursor for select branch_cd , coalesce ( sum ( amount ) , 0 ) from com_dept where reg_dt = $1 group by branch_cd order by branch_cd", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 92 "app/dbio/cm_io_0003.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cm_io_0003_total_gc", ECPGt_EOIT, + ECPGt_char,(h_grp),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sub),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0003.pgc" +#line 94 "app/dbio/cm_io_0003.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0003_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0003_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 99 "app/dbio/cm_io_0003.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0003_total"); - return -1; + return -1; + } + h_tot += h_sub; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0003_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 104 "app/dbio/cm_io_0003.pgc" + + return h_tot; } diff --git a/app/dbio/cm_io_0003.pgc b/app/dbio/cm_io_0003.pgc index c473666..ad91e41 100644 --- a/app/dbio/cm_io_0003.pgc +++ b/app/dbio/cm_io_0003.pgc @@ -14,49 +14,51 @@ EXEC SQL INCLUDE sqlca; int cm_io_0003_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0003_t - WHERE key = :h_key; - + EXEC SQL SELECT max(amount) + INTO :h_amt:h_ind + FROM com_param + WHERE branch_cd = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0003_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } int cm_io_0003_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0003_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE com_dept + SET amount = :h_amt, upd_ts = now() + WHERE branch_cd = :h_key + AND lock_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0003_touch"); return TX_EDB; @@ -69,24 +71,36 @@ int cm_io_0003_touch(const char *key, long amount) long cm_io_0003_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + char h_grp[20]; + long h_sub; + long h_tot; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0003_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0003_total"); - return -1; + EXEC SQL DECLARE cm_io_0003_total_gc CURSOR FOR + SELECT branch_cd, coalesce(sum(amount), 0) + FROM com_dept + WHERE reg_dt = :h_bd + GROUP BY branch_cd + ORDER BY branch_cd; + EXEC SQL OPEN cm_io_0003_total_gc; + for (;;) { + EXEC SQL FETCH cm_io_0003_total_gc INTO :h_grp, :h_sub; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0003_total"); + EXEC SQL CLOSE cm_io_0003_total_gc; + return -1; + } + h_tot += h_sub; } - return h_sum; + EXEC SQL CLOSE cm_io_0003_total_gc; + return h_tot; } diff --git a/app/dbio/cm_io_0004.c b/app/dbio/cm_io_0004.c index 05b9e63..8eefd84 100644 --- a/app/dbio/cm_io_0004.c +++ b/app/dbio/cm_io_0004.c @@ -94,37 +94,58 @@ int cm_io_0004_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cm_io_0004.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0004.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cm_io_0004.pgc" + long h_acc ; +/* exec sql end declare section */ +#line 20 "app/dbio/cm_io_0004.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0004_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cm_io_0004_fetch_cur cursor for select weight_val from com_calendar where param_id = $1 order by biz_date */ +#line 31 "app/dbio/cm_io_0004.pgc" + +#line 31 "app/dbio/cm_io_0004.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cm_io_0004_fetch_cur cursor for select weight_val from com_calendar where param_id = $1 order by biz_date", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 32 "app/dbio/cm_io_0004.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cm_io_0004_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0004.pgc" +#line 34 "app/dbio/cm_io_0004.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0004_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0004_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 39 "app/dbio/cm_io_0004.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0004_fetch"); - return TX_EDB; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0004_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 44 "app/dbio/cm_io_0004.pgc" + + *out_amount = h_acc; return TX_OK; } @@ -134,29 +155,27 @@ int cm_io_0004_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0004.pgc" - char h_key [ 16 ] ; +#line 52 "app/dbio/cm_io_0004.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0004.pgc" - long h_amount ; +#line 53 "app/dbio/cm_io_0004.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0004.pgc" +#line 54 "app/dbio/cm_io_0004.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0004_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update com_branch set weight_val = $1 , upd_ts = now ( ) where param_id = $2 and use_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0004.pgc" - +#line 65 "app/dbio/cm_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0004_touch"); @@ -173,28 +192,26 @@ long cm_io_0004_total(const char *biz_date) -#line 72 "app/dbio/cm_io_0004.pgc" - char h_biz_date [ 9 ] ; +#line 78 "app/dbio/cm_io_0004.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0004.pgc" +#line 79 "app/dbio/cm_io_0004.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0004.pgc" +#line 80 "app/dbio/cm_io_0004.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0004_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . weight_val ) , 0 ) from com_calendar d join com_branch m on d . param_id = m . param_id where d . biz_date = $1 and m . use_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0004.pgc" - +#line 92 "app/dbio/cm_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0004_total"); diff --git a/app/dbio/cm_io_0004.pgc b/app/dbio/cm_io_0004.pgc index adf033d..b5ec290 100644 --- a/app/dbio/cm_io_0004.pgc +++ b/app/dbio/cm_io_0004.pgc @@ -14,49 +14,55 @@ EXEC SQL INCLUDE sqlca; int cm_io_0004_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + long h_acc; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0004_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0004_fetch"); - return TX_EDB; + EXEC SQL DECLARE cm_io_0004_fetch_cur CURSOR FOR + SELECT weight_val FROM com_calendar + WHERE param_id = :h_key + ORDER BY biz_date; + EXEC SQL OPEN cm_io_0004_fetch_cur; + for (;;) { + EXEC SQL FETCH cm_io_0004_fetch_cur INTO :h_amt; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0004_fetch"); + EXEC SQL CLOSE cm_io_0004_fetch_cur; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + EXEC SQL CLOSE cm_io_0004_fetch_cur; + *out_amount = h_acc; return TX_OK; } int cm_io_0004_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0004_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE com_branch + SET weight_val = :h_amt, upd_ts = now() + WHERE param_id = :h_key + AND use_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0004_touch"); return TX_EDB; @@ -69,21 +75,21 @@ int cm_io_0004_touch(const char *key, long amount) long cm_io_0004_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.weight_val), 0) INTO :h_sum - FROM cm_io_0004_t - WHERE biz_date = :h_biz_date; - + FROM com_calendar d + JOIN com_branch m ON d.param_id = m.param_id + WHERE d.biz_date = :h_bd + AND m.use_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0004_total"); return -1; diff --git a/app/dbio/cm_io_0005.c b/app/dbio/cm_io_0005.c index 3813a44..d16eba4 100644 --- a/app/dbio/cm_io_0005.c +++ b/app/dbio/cm_io_0005.c @@ -96,27 +96,25 @@ int cm_io_0005_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cm_io_0005.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0005.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cm_io_0005.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0005_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( m . level_no , 0 ) - ( select coalesce ( sum ( h . level_no ) , 0 ) from com_user h where h . code_id = m . code_id ) from com_param m where m . code_id = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0005.pgc" - +#line 31 "app/dbio/cm_io_0005.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +122,7 @@ int cm_io_0005_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0005_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -135,29 +133,27 @@ int cm_io_0005_touch(const char *key, long amount) #line 45 "app/dbio/cm_io_0005.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 46 "app/dbio/cm_io_0005.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/cm_io_0005.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0005_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update com_param set level_no = $1 , upd_ts = now ( ) where code_id = $2 and del_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/cm_io_0005.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0005_touch"); return TX_EDB; @@ -170,35 +166,39 @@ int cm_io_0005_touch(const char *key, long amount) long cm_io_0005_total(const char *biz_date) { /* exec sql begin declare section */ - + + +#line 71 "app/dbio/cm_io_0005.pgc" + char h_bd [ 9 ] ; + #line 72 "app/dbio/cm_io_0005.pgc" - char h_biz_date [ 9 ] ; + long h_max ; #line 73 "app/dbio/cm_io_0005.pgc" - long h_sum ; + short h_ind ; /* exec sql end declare section */ #line 74 "app/dbio/cm_io_0005.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0005_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( level_no ) from com_calendar where apply_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0005.pgc" - + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 84 "app/dbio/cm_io_0005.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0005_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/cm_io_0005.pgc b/app/dbio/cm_io_0005.pgc index 430287b..32c3a82 100644 --- a/app/dbio/cm_io_0005.pgc +++ b/app/dbio/cm_io_0005.pgc @@ -14,49 +14,48 @@ EXEC SQL INCLUDE sqlca; int cm_io_0005_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0005_t - WHERE key = :h_key; - + EXEC SQL SELECT coalesce(m.level_no, 0) + - (SELECT coalesce(sum(h.level_no), 0) + FROM com_user h WHERE h.code_id = m.code_id) + INTO :h_amt + FROM com_param m + WHERE m.code_id = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0005_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cm_io_0005_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0005_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE com_param + SET level_no = :h_amt, upd_ts = now() + WHERE code_id = :h_key + AND del_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0005_touch"); return TX_EDB; @@ -69,24 +68,25 @@ int cm_io_0005_touch(const char *key, long amount) long cm_io_0005_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0005_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT max(level_no) + INTO :h_max:h_ind + FROM com_calendar + WHERE apply_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0005_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/cm_io_0006.c b/app/dbio/cm_io_0006.c index 37bb03e..b129844 100644 --- a/app/dbio/cm_io_0006.c +++ b/app/dbio/cm_io_0006.c @@ -92,31 +92,43 @@ struct sqlca_t *ECPGget_sqlca(void); int cm_io_0006_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ + + + #line 17 "app/dbio/cm_io_0006.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0006.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_min ; + #line 19 "app/dbio/cm_io_0006.pgc" + long h_max ; + +#line 20 "app/dbio/cm_io_0006.pgc" + short h_i1 ; + +#line 21 "app/dbio/cm_io_0006.pgc" + short h_i2 ; +/* exec sql end declare section */ +#line 22 "app/dbio/cm_io_0006.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0006_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( use_cnt ) , max ( use_cnt ) from com_user where dept_cd = $1 and lock_yn <> 'D'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0006.pgc" - + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i1),(long)1,(long)1,sizeof(short), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i2),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 33 "app/dbio/cm_io_0006.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +136,9 @@ int cm_io_0006_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0006_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } @@ -134,29 +148,27 @@ int cm_io_0006_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0006.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/cm_io_0006.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0006.pgc" - long h_amount ; +#line 50 "app/dbio/cm_io_0006.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0006.pgc" +#line 51 "app/dbio/cm_io_0006.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0006_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update com_calendar set use_cnt = $1 , upd_ts = now ( ) where dept_cd = $2 and lock_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0006.pgc" - +#line 62 "app/dbio/cm_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0006_touch"); @@ -173,32 +185,30 @@ long cm_io_0006_total(const char *biz_date) -#line 72 "app/dbio/cm_io_0006.pgc" - char h_biz_date [ 9 ] ; +#line 75 "app/dbio/cm_io_0006.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0006.pgc" - long h_sum ; +#line 76 "app/dbio/cm_io_0006.pgc" + long h_avg ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0006.pgc" +#line 77 "app/dbio/cm_io_0006.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0006_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( avg ( use_cnt ) , 0 ) :: bigint from com_calendar where reg_dt = $1 and lock_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0006.pgc" - +#line 88 "app/dbio/cm_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0006_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/cm_io_0006.pgc b/app/dbio/cm_io_0006.pgc index ef1c8c7..1174a6e 100644 --- a/app/dbio/cm_io_0006.pgc +++ b/app/dbio/cm_io_0006.pgc @@ -14,49 +14,52 @@ EXEC SQL INCLUDE sqlca; int cm_io_0006_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_min; + long h_max; + short h_i1; + short h_i2; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0006_t - WHERE key = :h_key; - + EXEC SQL SELECT min(use_cnt), max(use_cnt) + INTO :h_min:h_i1, :h_max:h_i2 + FROM com_user + WHERE dept_cd = :h_key + AND lock_yn <> 'D'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0006_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } int cm_io_0006_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0006_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE com_calendar + SET use_cnt = :h_amt, upd_ts = now() + WHERE dept_cd = :h_key + AND lock_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0006_touch"); return TX_EDB; @@ -69,24 +72,23 @@ int cm_io_0006_touch(const char *key, long amount) long cm_io_0006_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_avg; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0006_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT coalesce(avg(use_cnt), 0)::bigint + INTO :h_avg + FROM com_calendar + WHERE reg_dt = :h_bd + AND lock_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0006_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/cm_io_0007.c b/app/dbio/cm_io_0007.c index 2c47a77..2bc72ae 100644 --- a/app/dbio/cm_io_0007.c +++ b/app/dbio/cm_io_0007.c @@ -96,26 +96,25 @@ int cm_io_0007_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cm_io_0007.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0007.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cm_io_0007.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0007_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . code_val ) , 0 ) from com_user a join com_menu b on a . branch_cd = b . branch_cd where a . branch_cd = $1 and b . use_yn = 'Y'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0007.pgc" +#line 31 "app/dbio/cm_io_0007.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int cm_io_0007_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0007_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -134,36 +133,32 @@ int cm_io_0007_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0007.pgc" - char h_key [ 16 ] ; - #line 46 "app/dbio/cm_io_0007.pgc" - long h_amount ; -/* exec sql end declare section */ + char h_key [ 20 ] ; + #line 47 "app/dbio/cm_io_0007.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 48 "app/dbio/cm_io_0007.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0007_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into com_code ( branch_cd , code_val , biz_date , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/cm_io_0007.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0007_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -172,33 +167,37 @@ long cm_io_0007_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/cm_io_0007.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/cm_io_0007.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0007.pgc" - long h_sum ; +#line 70 "app/dbio/cm_io_0007.pgc" + long h_dr ; + +#line 71 "app/dbio/cm_io_0007.pgc" + long h_cr ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0007.pgc" +#line 72 "app/dbio/cm_io_0007.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0007_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when use_yn = 'D' then code_val else 0 end ) , 0 ) , coalesce ( sum ( case when use_yn = 'C' then code_val else 0 end ) , 0 ) from com_code where biz_date = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_dr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_cr),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0007.pgc" - +#line 84 "app/dbio/cm_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0007_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/cm_io_0007.pgc b/app/dbio/cm_io_0007.pgc index a158e95..ea4fffb 100644 --- a/app/dbio/cm_io_0007.pgc +++ b/app/dbio/cm_io_0007.pgc @@ -14,20 +14,21 @@ EXEC SQL INCLUDE sqlca; int cm_io_0007_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0007_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(a.code_val), 0) + INTO :h_amt + FROM com_user a + JOIN com_menu b ON a.branch_cd = b.branch_cd + WHERE a.branch_cd = :h_key + AND b.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,58 +36,55 @@ int cm_io_0007_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0007_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cm_io_0007_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0007_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO com_code + (branch_cd, code_val, biz_date, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0007_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long cm_io_0007_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_dr; + long h_cr; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0007_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT + coalesce(sum(CASE WHEN use_yn = 'D' THEN code_val ELSE 0 END), 0), + coalesce(sum(CASE WHEN use_yn = 'C' THEN code_val ELSE 0 END), 0) + INTO :h_dr, :h_cr + FROM com_code + WHERE biz_date = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0007_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/cm_io_0008.c b/app/dbio/cm_io_0008.c index 039965d..57a28bc 100644 --- a/app/dbio/cm_io_0008.c +++ b/app/dbio/cm_io_0008.c @@ -94,37 +94,51 @@ int cm_io_0008_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cm_io_0008.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0008.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cm_io_0008.pgc" + int h_cnt ; +/* exec sql end declare section */ +#line 20 "app/dbio/cm_io_0008.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0008_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from com_menu where param_id = $1 and sort_seq > 0", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_int,&(h_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0008.pgc" +#line 31 "app/dbio/cm_io_0008.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0008_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select sort_seq from com_menu where param_id = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 42 "app/dbio/cm_io_0008.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0008_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } @@ -134,36 +148,32 @@ int cm_io_0008_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0008.pgc" - char h_key [ 16 ] ; +#line 54 "app/dbio/cm_io_0008.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0008.pgc" - long h_amount ; +#line 55 "app/dbio/cm_io_0008.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0008.pgc" +#line 56 "app/dbio/cm_io_0008.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0008_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into com_code_val ( param_id , sort_seq , apply_dt , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0008.pgc" - +#line 66 "app/dbio/cm_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0008_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,28 +183,26 @@ long cm_io_0008_total(const char *biz_date) -#line 72 "app/dbio/cm_io_0008.pgc" - char h_biz_date [ 9 ] ; +#line 77 "app/dbio/cm_io_0008.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0008.pgc" +#line 78 "app/dbio/cm_io_0008.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0008.pgc" +#line 79 "app/dbio/cm_io_0008.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0008_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( sort_seq ) , 0 ) from com_menu where apply_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0008.pgc" - +#line 89 "app/dbio/cm_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0008_total"); diff --git a/app/dbio/cm_io_0008.pgc b/app/dbio/cm_io_0008.pgc index aff6c85..cdc8c99 100644 --- a/app/dbio/cm_io_0008.pgc +++ b/app/dbio/cm_io_0008.pgc @@ -14,76 +14,79 @@ EXEC SQL INCLUDE sqlca; int cm_io_0008_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + int h_cnt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0008_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM com_menu + WHERE param_id = :h_key + AND sort_seq > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0008_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + EXEC SQL SELECT sort_seq + INTO :h_amt + FROM com_menu + WHERE param_id = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0008_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } int cm_io_0008_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0008_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO com_code_val + (param_id, sort_seq, apply_dt, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0008_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long cm_io_0008_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(sort_seq), 0) INTO :h_sum - FROM cm_io_0008_t - WHERE biz_date = :h_biz_date; - + FROM com_menu + WHERE apply_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0008_total"); return -1; diff --git a/app/dbio/cm_io_0009.c b/app/dbio/cm_io_0009.c index ef39882..87f1e20 100644 --- a/app/dbio/cm_io_0009.c +++ b/app/dbio/cm_io_0009.c @@ -92,39 +92,45 @@ struct sqlca_t *ECPGget_sqlca(void); int cm_io_0009_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ - + + #line 17 "app/dbio/cm_io_0009.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0009.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cm_io_0009.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/cm_io_0009.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0009_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( amount ) from com_dept where code_id = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/cm_io_0009.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0009_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } @@ -134,36 +140,32 @@ int cm_io_0009_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0009.pgc" - char h_key [ 16 ] ; +#line 48 "app/dbio/cm_io_0009.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0009.pgc" - long h_amount ; +#line 49 "app/dbio/cm_io_0009.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0009.pgc" +#line 50 "app/dbio/cm_io_0009.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0009_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into com_dept ( code_id , amount , reg_dt , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0009.pgc" - +#line 60 "app/dbio/cm_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0009_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,32 +175,30 @@ long cm_io_0009_total(const char *biz_date) -#line 72 "app/dbio/cm_io_0009.pgc" - char h_biz_date [ 9 ] ; +#line 71 "app/dbio/cm_io_0009.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0009.pgc" - long h_sum ; +#line 72 "app/dbio/cm_io_0009.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0009.pgc" +#line 73 "app/dbio/cm_io_0009.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0009_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from com_dept where reg_dt = $1 and amount <> 0", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0009.pgc" - +#line 84 "app/dbio/cm_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0009_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cm_io_0009.pgc b/app/dbio/cm_io_0009.pgc index 251aa76..0269150 100644 --- a/app/dbio/cm_io_0009.pgc +++ b/app/dbio/cm_io_0009.pgc @@ -14,79 +14,77 @@ EXEC SQL INCLUDE sqlca; int cm_io_0009_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0009_t - WHERE key = :h_key; - + EXEC SQL SELECT max(amount) + INTO :h_amt:h_ind + FROM com_dept + WHERE code_id = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0009_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } int cm_io_0009_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0009_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO com_dept + (code_id, amount, reg_dt, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0009_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long cm_io_0009_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0009_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM com_dept + WHERE reg_dt = :h_bd + AND amount <> 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0009_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cm_io_0010.c b/app/dbio/cm_io_0010.c index 3b03669..4865aa9 100644 --- a/app/dbio/cm_io_0010.c +++ b/app/dbio/cm_io_0010.c @@ -94,37 +94,58 @@ int cm_io_0010_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cm_io_0010.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0010.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cm_io_0010.pgc" + long h_acc ; +/* exec sql end declare section */ +#line 20 "app/dbio/cm_io_0010.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0010_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cm_io_0010_fetch_cur cursor for select weight_val from com_branch where dept_cd = $1 order by biz_date */ +#line 31 "app/dbio/cm_io_0010.pgc" + +#line 31 "app/dbio/cm_io_0010.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cm_io_0010_fetch_cur cursor for select weight_val from com_branch where dept_cd = $1 order by biz_date", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 32 "app/dbio/cm_io_0010.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cm_io_0010_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0010.pgc" +#line 34 "app/dbio/cm_io_0010.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0010_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0010_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 39 "app/dbio/cm_io_0010.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0010_fetch"); - return TX_EDB; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0010_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 44 "app/dbio/cm_io_0010.pgc" + + *out_amount = h_acc; return TX_OK; } @@ -134,36 +155,32 @@ int cm_io_0010_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0010.pgc" - char h_key [ 16 ] ; +#line 52 "app/dbio/cm_io_0010.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0010.pgc" - long h_amount ; +#line 53 "app/dbio/cm_io_0010.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0010.pgc" +#line 54 "app/dbio/cm_io_0010.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0010_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into com_branch ( dept_cd , weight_val , biz_date , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0010.pgc" - +#line 64 "app/dbio/cm_io_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0010_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -172,33 +189,62 @@ long cm_io_0010_total(const char *biz_date) /* exec sql begin declare section */ + + -#line 72 "app/dbio/cm_io_0010.pgc" - char h_biz_date [ 9 ] ; +#line 75 "app/dbio/cm_io_0010.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0010.pgc" - long h_sum ; +#line 76 "app/dbio/cm_io_0010.pgc" + char h_grp [ 20 ] ; + +#line 77 "app/dbio/cm_io_0010.pgc" + long h_sub ; + +#line 78 "app/dbio/cm_io_0010.pgc" + long h_tot ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0010.pgc" +#line 79 "app/dbio/cm_io_0010.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + ECPGset_var( 1, ( h_bd ), __LINE__);\ + /* declare cm_io_0010_total_gc cursor for select dept_cd , coalesce ( sum ( weight_val ) , 0 ) from com_code_val where biz_date = $1 group by dept_cd order by dept_cd */ +#line 92 "app/dbio/cm_io_0010.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0010_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), +#line 92 "app/dbio/cm_io_0010.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cm_io_0010_total_gc cursor for select dept_cd , coalesce ( sum ( weight_val ) , 0 ) from com_code_val where biz_date = $1 group by dept_cd order by dept_cd", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 93 "app/dbio/cm_io_0010.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cm_io_0010_total_gc", ECPGt_EOIT, + ECPGt_char,(h_grp),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sub),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0010.pgc" +#line 95 "app/dbio/cm_io_0010.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0010_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0010_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 100 "app/dbio/cm_io_0010.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0010_total"); - return -1; + return -1; + } + h_tot += h_sub; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0010_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 105 "app/dbio/cm_io_0010.pgc" + + return h_tot; } diff --git a/app/dbio/cm_io_0010.pgc b/app/dbio/cm_io_0010.pgc index 38661b0..66c78bc 100644 --- a/app/dbio/cm_io_0010.pgc +++ b/app/dbio/cm_io_0010.pgc @@ -14,79 +14,94 @@ EXEC SQL INCLUDE sqlca; int cm_io_0010_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + long h_acc; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0010_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0010_fetch"); - return TX_EDB; + EXEC SQL DECLARE cm_io_0010_fetch_cur CURSOR FOR + SELECT weight_val FROM com_branch + WHERE dept_cd = :h_key + ORDER BY biz_date; + EXEC SQL OPEN cm_io_0010_fetch_cur; + for (;;) { + EXEC SQL FETCH cm_io_0010_fetch_cur INTO :h_amt; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0010_fetch"); + EXEC SQL CLOSE cm_io_0010_fetch_cur; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + EXEC SQL CLOSE cm_io_0010_fetch_cur; + *out_amount = h_acc; return TX_OK; } int cm_io_0010_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0010_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO com_branch + (dept_cd, weight_val, biz_date, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0010_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long cm_io_0010_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + char h_grp[20]; + long h_sub; + long h_tot; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0010_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0010_total"); - return -1; + EXEC SQL DECLARE cm_io_0010_total_gc CURSOR FOR + SELECT dept_cd, coalesce(sum(weight_val), 0) + FROM com_code_val + WHERE biz_date = :h_bd + GROUP BY dept_cd + ORDER BY dept_cd; + EXEC SQL OPEN cm_io_0010_total_gc; + for (;;) { + EXEC SQL FETCH cm_io_0010_total_gc INTO :h_grp, :h_sub; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0010_total"); + EXEC SQL CLOSE cm_io_0010_total_gc; + return -1; + } + h_tot += h_sub; } - return h_sum; + EXEC SQL CLOSE cm_io_0010_total_gc; + return h_tot; } diff --git a/app/dbio/cm_io_0011.c b/app/dbio/cm_io_0011.c index 745790d..075199a 100644 --- a/app/dbio/cm_io_0011.c +++ b/app/dbio/cm_io_0011.c @@ -96,27 +96,25 @@ int cm_io_0011_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cm_io_0011.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0011.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cm_io_0011.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0011_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( m . level_no , 0 ) - ( select coalesce ( sum ( h . level_no ) , 0 ) from com_param h where h . branch_cd = m . branch_cd ) from com_dept m where m . branch_cd = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0011.pgc" - +#line 31 "app/dbio/cm_io_0011.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +122,7 @@ int cm_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -135,35 +133,31 @@ int cm_io_0011_touch(const char *key, long amount) #line 45 "app/dbio/cm_io_0011.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 46 "app/dbio/cm_io_0011.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/cm_io_0011.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0011_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into com_param ( branch_cd , level_no , apply_dt , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0011.pgc" - +#line 57 "app/dbio/cm_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0011_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,28 +167,26 @@ long cm_io_0011_total(const char *biz_date) -#line 72 "app/dbio/cm_io_0011.pgc" - char h_biz_date [ 9 ] ; +#line 68 "app/dbio/cm_io_0011.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0011.pgc" +#line 69 "app/dbio/cm_io_0011.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0011.pgc" +#line 70 "app/dbio/cm_io_0011.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0011_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . level_no ) , 0 ) from com_param d join com_dept m on d . branch_cd = m . branch_cd where d . apply_dt = $1 and m . del_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0011.pgc" - +#line 82 "app/dbio/cm_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0011_total"); diff --git a/app/dbio/cm_io_0011.pgc b/app/dbio/cm_io_0011.pgc index 1375176..1fb6a01 100644 --- a/app/dbio/cm_io_0011.pgc +++ b/app/dbio/cm_io_0011.pgc @@ -14,76 +14,72 @@ EXEC SQL INCLUDE sqlca; int cm_io_0011_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0011_t - WHERE key = :h_key; - + EXEC SQL SELECT coalesce(m.level_no, 0) + - (SELECT coalesce(sum(h.level_no), 0) + FROM com_param h WHERE h.branch_cd = m.branch_cd) + INTO :h_amt + FROM com_dept m + WHERE m.branch_cd = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cm_io_0011_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0011_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO com_param + (branch_cd, level_no, apply_dt, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0011_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long cm_io_0011_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.level_no), 0) INTO :h_sum - FROM cm_io_0011_t - WHERE biz_date = :h_biz_date; - + FROM com_param d + JOIN com_dept m ON d.branch_cd = m.branch_cd + WHERE d.apply_dt = :h_bd + AND m.del_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0011_total"); return -1; diff --git a/app/dbio/cm_io_0012.c b/app/dbio/cm_io_0012.c index a901eea..aec566d 100644 --- a/app/dbio/cm_io_0012.c +++ b/app/dbio/cm_io_0012.c @@ -92,31 +92,43 @@ struct sqlca_t *ECPGget_sqlca(void); int cm_io_0012_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ + + + #line 17 "app/dbio/cm_io_0012.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0012.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_min ; + #line 19 "app/dbio/cm_io_0012.pgc" + long h_max ; + +#line 20 "app/dbio/cm_io_0012.pgc" + short h_i1 ; + +#line 21 "app/dbio/cm_io_0012.pgc" + short h_i2 ; +/* exec sql end declare section */ +#line 22 "app/dbio/cm_io_0012.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0012_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( use_cnt ) , max ( use_cnt ) from com_param where param_id = $1 and lock_yn <> 'D'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0012.pgc" - + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i1),(long)1,(long)1,sizeof(short), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i2),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 33 "app/dbio/cm_io_0012.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +136,9 @@ int cm_io_0012_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0012_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } @@ -134,71 +148,71 @@ int cm_io_0012_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0012.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/cm_io_0012.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0012.pgc" - long h_amount ; +#line 50 "app/dbio/cm_io_0012.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0012.pgc" +#line 51 "app/dbio/cm_io_0012.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0012_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into com_calendar ( param_id , use_cnt , reg_dt , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0012.pgc" - +#line 61 "app/dbio/cm_io_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0012_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long cm_io_0012_total(const char *biz_date) { /* exec sql begin declare section */ - + + #line 72 "app/dbio/cm_io_0012.pgc" - char h_biz_date [ 9 ] ; + char h_bd [ 9 ] ; #line 73 "app/dbio/cm_io_0012.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_max ; + #line 74 "app/dbio/cm_io_0012.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 75 "app/dbio/cm_io_0012.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0012_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( use_cnt ) from com_param where reg_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 85 "app/dbio/cm_io_0012.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0012_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/cm_io_0012.pgc b/app/dbio/cm_io_0012.pgc index aa625e3..85dff69 100644 --- a/app/dbio/cm_io_0012.pgc +++ b/app/dbio/cm_io_0012.pgc @@ -14,79 +14,80 @@ EXEC SQL INCLUDE sqlca; int cm_io_0012_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_min; + long h_max; + short h_i1; + short h_i2; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0012_t - WHERE key = :h_key; - + EXEC SQL SELECT min(use_cnt), max(use_cnt) + INTO :h_min:h_i1, :h_max:h_i2 + FROM com_param + WHERE param_id = :h_key + AND lock_yn <> 'D'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0012_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } int cm_io_0012_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0012_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO com_calendar + (param_id, use_cnt, reg_dt, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0012_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long cm_io_0012_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0012_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT max(use_cnt) + INTO :h_max:h_ind + FROM com_param + WHERE reg_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0012_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/cm_io_0013.c b/app/dbio/cm_io_0013.c index 4591f2f..16717a8 100644 --- a/app/dbio/cm_io_0013.c +++ b/app/dbio/cm_io_0013.c @@ -96,26 +96,25 @@ int cm_io_0013_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cm_io_0013.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0013.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cm_io_0013.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0013_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . code_val ) , 0 ) from com_param a join com_calendar b on a . code_id = b . code_id where a . code_id = $1 and b . use_yn = 'Y'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0013.pgc" +#line 31 "app/dbio/cm_io_0013.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int cm_io_0013_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0013_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -134,29 +133,27 @@ int cm_io_0013_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0013.pgc" - char h_key [ 16 ] ; - #line 46 "app/dbio/cm_io_0013.pgc" - long h_amount ; -/* exec sql end declare section */ + char h_key [ 20 ] ; + #line 47 "app/dbio/cm_io_0013.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 48 "app/dbio/cm_io_0013.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0013_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into com_param ( code_id , code_val , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( code_id ) do update set code_val = com_param . code_val + EXCLUDED . code_val , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0013.pgc" - +#line 60 "app/dbio/cm_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0013_touch"); @@ -173,32 +170,30 @@ long cm_io_0013_total(const char *biz_date) -#line 72 "app/dbio/cm_io_0013.pgc" - char h_biz_date [ 9 ] ; - #line 73 "app/dbio/cm_io_0013.pgc" - long h_sum ; -/* exec sql end declare section */ + char h_bd [ 9 ] ; + #line 74 "app/dbio/cm_io_0013.pgc" + long h_avg ; +/* exec sql end declare section */ +#line 75 "app/dbio/cm_io_0013.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0013_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( avg ( code_val ) , 0 ) :: bigint from com_param where biz_date = $1 and use_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0013.pgc" - +#line 86 "app/dbio/cm_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0013_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/cm_io_0013.pgc b/app/dbio/cm_io_0013.pgc index db36460..316b23f 100644 --- a/app/dbio/cm_io_0013.pgc +++ b/app/dbio/cm_io_0013.pgc @@ -14,20 +14,21 @@ EXEC SQL INCLUDE sqlca; int cm_io_0013_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0013_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(a.code_val), 0) + INTO :h_amt + FROM com_param a + JOIN com_calendar b ON a.code_id = b.code_id + WHERE a.code_id = :h_key + AND b.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +36,28 @@ int cm_io_0013_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0013_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cm_io_0013_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0013_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO com_param (code_id, code_val, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (code_id) + DO UPDATE SET code_val = com_param.code_val + EXCLUDED.code_val, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0013_touch"); return TX_EDB; @@ -69,24 +70,23 @@ int cm_io_0013_touch(const char *key, long amount) long cm_io_0013_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_avg; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0013_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT coalesce(avg(code_val), 0)::bigint + INTO :h_avg + FROM com_param + WHERE biz_date = :h_bd + AND use_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0013_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/cm_io_0014.c b/app/dbio/cm_io_0014.c index 6d2320c..6a2b9c6 100644 --- a/app/dbio/cm_io_0014.c +++ b/app/dbio/cm_io_0014.c @@ -94,37 +94,51 @@ int cm_io_0014_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cm_io_0014.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0014.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cm_io_0014.pgc" + int h_cnt ; +/* exec sql end declare section */ +#line 20 "app/dbio/cm_io_0014.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0014_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from com_calendar where dept_cd = $1 and sort_seq > 0", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_int,&(h_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0014.pgc" +#line 31 "app/dbio/cm_io_0014.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0014_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select sort_seq from com_calendar where dept_cd = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 42 "app/dbio/cm_io_0014.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0014_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +148,27 @@ int cm_io_0014_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0014.pgc" - char h_key [ 16 ] ; +#line 54 "app/dbio/cm_io_0014.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0014.pgc" - long h_amount ; +#line 55 "app/dbio/cm_io_0014.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0014.pgc" +#line 56 "app/dbio/cm_io_0014.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0014_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into com_calendar ( dept_cd , sort_seq , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( dept_cd ) do update set sort_seq = com_calendar . sort_seq + EXCLUDED . sort_seq , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0014.pgc" - +#line 68 "app/dbio/cm_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0014_touch"); @@ -172,33 +184,37 @@ long cm_io_0014_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/cm_io_0014.pgc" - char h_biz_date [ 9 ] ; +#line 81 "app/dbio/cm_io_0014.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0014.pgc" - long h_sum ; +#line 82 "app/dbio/cm_io_0014.pgc" + long h_dr ; + +#line 83 "app/dbio/cm_io_0014.pgc" + long h_cr ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0014.pgc" +#line 84 "app/dbio/cm_io_0014.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0014_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when del_yn = 'D' then sort_seq else 0 end ) , 0 ) , coalesce ( sum ( case when del_yn = 'C' then sort_seq else 0 end ) , 0 ) from com_menu where apply_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_dr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_cr),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0014.pgc" - +#line 96 "app/dbio/cm_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0014_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/cm_io_0014.pgc b/app/dbio/cm_io_0014.pgc index 6bb9e7c..bf9f396 100644 --- a/app/dbio/cm_io_0014.pgc +++ b/app/dbio/cm_io_0014.pgc @@ -14,49 +14,58 @@ EXEC SQL INCLUDE sqlca; int cm_io_0014_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + int h_cnt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0014_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM com_calendar + WHERE dept_cd = :h_key + AND sort_seq > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0014_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + EXEC SQL SELECT sort_seq + INTO :h_amt + FROM com_calendar + WHERE dept_cd = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0014_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } int cm_io_0014_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0014_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO com_calendar (dept_cd, sort_seq, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (dept_cd) + DO UPDATE SET sort_seq = com_calendar.sort_seq + EXCLUDED.sort_seq, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0014_touch"); return TX_EDB; @@ -69,24 +78,25 @@ int cm_io_0014_touch(const char *key, long amount) long cm_io_0014_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_dr; + long h_cr; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0014_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT + coalesce(sum(CASE WHEN del_yn = 'D' THEN sort_seq ELSE 0 END), 0), + coalesce(sum(CASE WHEN del_yn = 'C' THEN sort_seq ELSE 0 END), 0) + INTO :h_dr, :h_cr + FROM com_menu + WHERE apply_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0014_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/cm_io_0015.c b/app/dbio/cm_io_0015.c index 8b62a7d..f42a2a5 100644 --- a/app/dbio/cm_io_0015.c +++ b/app/dbio/cm_io_0015.c @@ -92,39 +92,45 @@ struct sqlca_t *ECPGget_sqlca(void); int cm_io_0015_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ - + + #line 17 "app/dbio/cm_io_0015.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0015.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cm_io_0015.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/cm_io_0015.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0015_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( amount ) from com_code where branch_cd = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/cm_io_0015.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0015_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +140,27 @@ int cm_io_0015_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0015.pgc" - char h_key [ 16 ] ; +#line 48 "app/dbio/cm_io_0015.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0015.pgc" - long h_amount ; +#line 49 "app/dbio/cm_io_0015.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0015.pgc" +#line 50 "app/dbio/cm_io_0015.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0015_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into com_user ( branch_cd , amount , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( branch_cd ) do update set amount = com_user . amount + EXCLUDED . amount , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0015.pgc" - +#line 62 "app/dbio/cm_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0015_touch"); @@ -173,28 +177,26 @@ long cm_io_0015_total(const char *biz_date) -#line 72 "app/dbio/cm_io_0015.pgc" - char h_biz_date [ 9 ] ; +#line 75 "app/dbio/cm_io_0015.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0015.pgc" +#line 76 "app/dbio/cm_io_0015.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0015.pgc" +#line 77 "app/dbio/cm_io_0015.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0015_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from com_user where reg_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0015.pgc" - +#line 87 "app/dbio/cm_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0015_total"); diff --git a/app/dbio/cm_io_0015.pgc b/app/dbio/cm_io_0015.pgc index f8032fc..3cdf11f 100644 --- a/app/dbio/cm_io_0015.pgc +++ b/app/dbio/cm_io_0015.pgc @@ -14,49 +14,52 @@ EXEC SQL INCLUDE sqlca; int cm_io_0015_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0015_t - WHERE key = :h_key; - + EXEC SQL SELECT max(amount) + INTO :h_amt:h_ind + FROM com_code + WHERE branch_cd = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0015_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } int cm_io_0015_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0015_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO com_user (branch_cd, amount, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (branch_cd) + DO UPDATE SET amount = com_user.amount + EXCLUDED.amount, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0015_touch"); return TX_EDB; @@ -69,21 +72,19 @@ int cm_io_0015_touch(const char *key, long amount) long cm_io_0015_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; - - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; EXEC SQL SELECT coalesce(sum(amount), 0) INTO :h_sum - FROM cm_io_0015_t - WHERE biz_date = :h_biz_date; - + FROM com_user + WHERE reg_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0015_total"); return -1; diff --git a/app/dbio/cm_io_0016.c b/app/dbio/cm_io_0016.c index d1d3572..e2a1174 100644 --- a/app/dbio/cm_io_0016.c +++ b/app/dbio/cm_io_0016.c @@ -94,37 +94,58 @@ int cm_io_0016_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cm_io_0016.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0016.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cm_io_0016.pgc" + long h_acc ; +/* exec sql end declare section */ +#line 20 "app/dbio/cm_io_0016.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0016_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cm_io_0016_fetch_cur cursor for select weight_val from com_code_val where param_id = $1 order by biz_date */ +#line 31 "app/dbio/cm_io_0016.pgc" + +#line 31 "app/dbio/cm_io_0016.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cm_io_0016_fetch_cur cursor for select weight_val from com_code_val where param_id = $1 order by biz_date", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 32 "app/dbio/cm_io_0016.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cm_io_0016_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0016.pgc" +#line 34 "app/dbio/cm_io_0016.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0016_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0016_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 39 "app/dbio/cm_io_0016.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0016_fetch"); - return TX_EDB; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0016_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 44 "app/dbio/cm_io_0016.pgc" + + *out_amount = h_acc; return TX_OK; } @@ -134,29 +155,27 @@ int cm_io_0016_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0016.pgc" - char h_key [ 16 ] ; +#line 52 "app/dbio/cm_io_0016.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0016.pgc" - long h_amount ; +#line 53 "app/dbio/cm_io_0016.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0016.pgc" +#line 54 "app/dbio/cm_io_0016.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0016_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into com_menu ( param_id , weight_val , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( param_id ) do update set weight_val = com_menu . weight_val + EXCLUDED . weight_val , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0016.pgc" - +#line 66 "app/dbio/cm_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0016_touch"); @@ -173,32 +192,30 @@ long cm_io_0016_total(const char *biz_date) -#line 72 "app/dbio/cm_io_0016.pgc" - char h_biz_date [ 9 ] ; +#line 79 "app/dbio/cm_io_0016.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0016.pgc" - long h_sum ; +#line 80 "app/dbio/cm_io_0016.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0016.pgc" +#line 81 "app/dbio/cm_io_0016.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0016_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from com_code_val where biz_date = $1 and weight_val <> 0", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0016.pgc" - +#line 92 "app/dbio/cm_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0016_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cm_io_0016.pgc b/app/dbio/cm_io_0016.pgc index a05a7c1..4452559 100644 --- a/app/dbio/cm_io_0016.pgc +++ b/app/dbio/cm_io_0016.pgc @@ -14,49 +14,56 @@ EXEC SQL INCLUDE sqlca; int cm_io_0016_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + long h_acc; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0016_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0016_fetch"); - return TX_EDB; + EXEC SQL DECLARE cm_io_0016_fetch_cur CURSOR FOR + SELECT weight_val FROM com_code_val + WHERE param_id = :h_key + ORDER BY biz_date; + EXEC SQL OPEN cm_io_0016_fetch_cur; + for (;;) { + EXEC SQL FETCH cm_io_0016_fetch_cur INTO :h_amt; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0016_fetch"); + EXEC SQL CLOSE cm_io_0016_fetch_cur; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + EXEC SQL CLOSE cm_io_0016_fetch_cur; + *out_amount = h_acc; return TX_OK; } int cm_io_0016_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0016_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO com_menu (param_id, weight_val, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (param_id) + DO UPDATE SET weight_val = com_menu.weight_val + EXCLUDED.weight_val, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0016_touch"); return TX_EDB; @@ -69,24 +76,23 @@ int cm_io_0016_touch(const char *key, long amount) long cm_io_0016_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0016_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM com_code_val + WHERE biz_date = :h_bd + AND weight_val <> 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0016_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cm_io_0017.c b/app/dbio/cm_io_0017.c index e8a4e7f..1b41669 100644 --- a/app/dbio/cm_io_0017.c +++ b/app/dbio/cm_io_0017.c @@ -96,27 +96,25 @@ int cm_io_0017_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cm_io_0017.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0017.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cm_io_0017.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0017_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( m . level_no , 0 ) - ( select coalesce ( sum ( h . level_no ) , 0 ) from com_dept h where h . code_id = m . code_id ) from com_code m where m . code_id = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0017.pgc" - +#line 31 "app/dbio/cm_io_0017.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +122,7 @@ int cm_io_0017_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0017_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -135,28 +133,26 @@ int cm_io_0017_touch(const char *key, long amount) #line 45 "app/dbio/cm_io_0017.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 46 "app/dbio/cm_io_0017.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/cm_io_0017.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0017_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into com_code ( code_id , level_no , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( code_id ) do update set level_no = com_code . level_no + EXCLUDED . level_no , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0017.pgc" - +#line 59 "app/dbio/cm_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0017_touch"); @@ -172,33 +168,62 @@ long cm_io_0017_total(const char *biz_date) /* exec sql begin declare section */ + + #line 72 "app/dbio/cm_io_0017.pgc" - char h_biz_date [ 9 ] ; + char h_bd [ 9 ] ; #line 73 "app/dbio/cm_io_0017.pgc" - long h_sum ; -/* exec sql end declare section */ + char h_grp [ 20 ] ; + #line 74 "app/dbio/cm_io_0017.pgc" + long h_sub ; + +#line 75 "app/dbio/cm_io_0017.pgc" + long h_tot ; +/* exec sql end declare section */ +#line 76 "app/dbio/cm_io_0017.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + ECPGset_var( 0, ( h_bd ), __LINE__);\ + /* declare cm_io_0017_total_gc cursor for select grp_cd , coalesce ( sum ( level_no ) , 0 ) from com_code where apply_dt = $1 group by grp_cd order by grp_cd */ +#line 89 "app/dbio/cm_io_0017.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0017_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), +#line 89 "app/dbio/cm_io_0017.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cm_io_0017_total_gc cursor for select grp_cd , coalesce ( sum ( level_no ) , 0 ) from com_code where apply_dt = $1 group by grp_cd order by grp_cd", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 90 "app/dbio/cm_io_0017.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cm_io_0017_total_gc", ECPGt_EOIT, + ECPGt_char,(h_grp),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sub),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0017.pgc" +#line 92 "app/dbio/cm_io_0017.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0017_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0017_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 97 "app/dbio/cm_io_0017.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0017_total"); - return -1; + return -1; + } + h_tot += h_sub; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0017_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 102 "app/dbio/cm_io_0017.pgc" + + return h_tot; } diff --git a/app/dbio/cm_io_0017.pgc b/app/dbio/cm_io_0017.pgc index 8f9967e..ba76ba8 100644 --- a/app/dbio/cm_io_0017.pgc +++ b/app/dbio/cm_io_0017.pgc @@ -14,49 +14,49 @@ EXEC SQL INCLUDE sqlca; int cm_io_0017_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0017_t - WHERE key = :h_key; - + EXEC SQL SELECT coalesce(m.level_no, 0) + - (SELECT coalesce(sum(h.level_no), 0) + FROM com_dept h WHERE h.code_id = m.code_id) + INTO :h_amt + FROM com_code m + WHERE m.code_id = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0017_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cm_io_0017_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0017_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO com_code (code_id, level_no, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (code_id) + DO UPDATE SET level_no = com_code.level_no + EXCLUDED.level_no, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0017_touch"); return TX_EDB; @@ -69,24 +69,36 @@ int cm_io_0017_touch(const char *key, long amount) long cm_io_0017_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + char h_grp[20]; + long h_sub; + long h_tot; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0017_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0017_total"); - return -1; + EXEC SQL DECLARE cm_io_0017_total_gc CURSOR FOR + SELECT grp_cd, coalesce(sum(level_no), 0) + FROM com_code + WHERE apply_dt = :h_bd + GROUP BY grp_cd + ORDER BY grp_cd; + EXEC SQL OPEN cm_io_0017_total_gc; + for (;;) { + EXEC SQL FETCH cm_io_0017_total_gc INTO :h_grp, :h_sub; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0017_total"); + EXEC SQL CLOSE cm_io_0017_total_gc; + return -1; + } + h_tot += h_sub; } - return h_sum; + EXEC SQL CLOSE cm_io_0017_total_gc; + return h_tot; } diff --git a/app/dbio/cm_io_0018.c b/app/dbio/cm_io_0018.c index dea3649..28e98db 100644 --- a/app/dbio/cm_io_0018.c +++ b/app/dbio/cm_io_0018.c @@ -92,31 +92,43 @@ struct sqlca_t *ECPGget_sqlca(void); int cm_io_0018_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ + + + #line 17 "app/dbio/cm_io_0018.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0018.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_min ; + #line 19 "app/dbio/cm_io_0018.pgc" + long h_max ; + +#line 20 "app/dbio/cm_io_0018.pgc" + short h_i1 ; + +#line 21 "app/dbio/cm_io_0018.pgc" + short h_i2 ; +/* exec sql end declare section */ +#line 22 "app/dbio/cm_io_0018.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0018_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( use_cnt ) , max ( use_cnt ) from com_dept where dept_cd = $1 and lock_yn <> 'D'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0018.pgc" - + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i1),(long)1,(long)1,sizeof(short), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i2),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 33 "app/dbio/cm_io_0018.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +136,9 @@ int cm_io_0018_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0018_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } @@ -134,29 +148,27 @@ int cm_io_0018_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0018.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/cm_io_0018.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0018.pgc" - long h_amount ; +#line 50 "app/dbio/cm_io_0018.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0018.pgc" +#line 51 "app/dbio/cm_io_0018.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0018_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into com_code_val ( dept_cd , use_cnt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( dept_cd ) do update set use_cnt = com_code_val . use_cnt + EXCLUDED . use_cnt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0018.pgc" - +#line 63 "app/dbio/cm_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0018_touch"); @@ -173,28 +185,26 @@ long cm_io_0018_total(const char *biz_date) -#line 72 "app/dbio/cm_io_0018.pgc" - char h_biz_date [ 9 ] ; +#line 76 "app/dbio/cm_io_0018.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0018.pgc" +#line 77 "app/dbio/cm_io_0018.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0018.pgc" +#line 78 "app/dbio/cm_io_0018.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0018_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . use_cnt ) , 0 ) from com_branch d join com_code_val m on d . dept_cd = m . dept_cd where d . reg_dt = $1 and m . lock_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0018.pgc" - +#line 90 "app/dbio/cm_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0018_total"); diff --git a/app/dbio/cm_io_0018.pgc b/app/dbio/cm_io_0018.pgc index a38e2a9..6fae6b3 100644 --- a/app/dbio/cm_io_0018.pgc +++ b/app/dbio/cm_io_0018.pgc @@ -14,49 +14,53 @@ EXEC SQL INCLUDE sqlca; int cm_io_0018_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_min; + long h_max; + short h_i1; + short h_i2; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0018_t - WHERE key = :h_key; - + EXEC SQL SELECT min(use_cnt), max(use_cnt) + INTO :h_min:h_i1, :h_max:h_i2 + FROM com_dept + WHERE dept_cd = :h_key + AND lock_yn <> 'D'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0018_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } int cm_io_0018_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0018_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO com_code_val (dept_cd, use_cnt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (dept_cd) + DO UPDATE SET use_cnt = com_code_val.use_cnt + EXCLUDED.use_cnt, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0018_touch"); return TX_EDB; @@ -69,21 +73,21 @@ int cm_io_0018_touch(const char *key, long amount) long cm_io_0018_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.use_cnt), 0) INTO :h_sum - FROM cm_io_0018_t - WHERE biz_date = :h_biz_date; - + FROM com_branch d + JOIN com_code_val m ON d.dept_cd = m.dept_cd + WHERE d.reg_dt = :h_bd + AND m.lock_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0018_total"); return -1; diff --git a/app/dbio/cm_io_0019.c b/app/dbio/cm_io_0019.c index 62b287e..feb56d8 100644 --- a/app/dbio/cm_io_0019.c +++ b/app/dbio/cm_io_0019.c @@ -96,26 +96,25 @@ int cm_io_0019_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cm_io_0019.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0019.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cm_io_0019.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0019_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . code_val ) , 0 ) from com_dept a join com_branch b on a . branch_cd = b . branch_cd where a . branch_cd = $1 and b . use_yn = 'Y'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0019.pgc" +#line 31 "app/dbio/cm_io_0019.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int cm_io_0019_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0019_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -134,71 +133,74 @@ int cm_io_0019_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0019.pgc" - char h_key [ 16 ] ; - #line 46 "app/dbio/cm_io_0019.pgc" - long h_amount ; -/* exec sql end declare section */ + char h_key [ 20 ] ; + #line 47 "app/dbio/cm_io_0019.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 48 "app/dbio/cm_io_0019.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0019_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from com_param where branch_cd = $1 and code_val < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/cm_io_0019.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0019_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cm_io_0019_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long cm_io_0019_total(const char *biz_date) { /* exec sql begin declare section */ - + + #line 72 "app/dbio/cm_io_0019.pgc" - char h_biz_date [ 9 ] ; + char h_bd [ 9 ] ; #line 73 "app/dbio/cm_io_0019.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_max ; + #line 74 "app/dbio/cm_io_0019.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 75 "app/dbio/cm_io_0019.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0019_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( code_val ) from com_branch where biz_date = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 85 "app/dbio/cm_io_0019.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0019_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/cm_io_0019.pgc b/app/dbio/cm_io_0019.pgc index a2e3824..30b0bd6 100644 --- a/app/dbio/cm_io_0019.pgc +++ b/app/dbio/cm_io_0019.pgc @@ -14,20 +14,21 @@ EXEC SQL INCLUDE sqlca; int cm_io_0019_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0019_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(a.code_val), 0) + INTO :h_amt + FROM com_dept a + JOIN com_branch b ON a.branch_cd = b.branch_cd + WHERE a.branch_cd = :h_key + AND b.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,58 +36,58 @@ int cm_io_0019_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0019_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cm_io_0019_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0019_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM com_param + WHERE branch_cd = :h_key + AND code_val < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0019_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cm_io_0019_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long cm_io_0019_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0019_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT max(code_val) + INTO :h_max:h_ind + FROM com_branch + WHERE biz_date = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0019_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/cm_io_0020.c b/app/dbio/cm_io_0020.c index 90accd2..e11a901 100644 --- a/app/dbio/cm_io_0020.c +++ b/app/dbio/cm_io_0020.c @@ -94,37 +94,51 @@ int cm_io_0020_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cm_io_0020.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0020.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cm_io_0020.pgc" + int h_cnt ; +/* exec sql end declare section */ +#line 20 "app/dbio/cm_io_0020.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0020_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from com_branch where param_id = $1 and sort_seq > 0", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_int,&(h_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0020.pgc" +#line 31 "app/dbio/cm_io_0020.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select sort_seq from com_branch where param_id = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 42 "app/dbio/cm_io_0020.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0020_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +148,27 @@ int cm_io_0020_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0020.pgc" - char h_key [ 16 ] ; +#line 54 "app/dbio/cm_io_0020.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0020.pgc" - long h_amount ; +#line 55 "app/dbio/cm_io_0020.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0020.pgc" +#line 56 "app/dbio/cm_io_0020.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0020_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from com_calendar where param_id = $1 and sort_seq < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0020.pgc" - +#line 66 "app/dbio/cm_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0020_touch"); @@ -164,6 +176,7 @@ int cm_io_0020_touch(const char *key, long amount) } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cm_io_0020_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } @@ -173,32 +186,30 @@ long cm_io_0020_total(const char *biz_date) -#line 72 "app/dbio/cm_io_0020.pgc" - char h_biz_date [ 9 ] ; +#line 80 "app/dbio/cm_io_0020.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0020.pgc" - long h_sum ; +#line 81 "app/dbio/cm_io_0020.pgc" + long h_avg ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0020.pgc" +#line 82 "app/dbio/cm_io_0020.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0020_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( avg ( sort_seq ) , 0 ) :: bigint from com_branch where apply_dt = $1 and del_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0020.pgc" - +#line 93 "app/dbio/cm_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0020_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/cm_io_0020.pgc b/app/dbio/cm_io_0020.pgc index 2129ed9..996c057 100644 --- a/app/dbio/cm_io_0020.pgc +++ b/app/dbio/cm_io_0020.pgc @@ -14,79 +14,86 @@ EXEC SQL INCLUDE sqlca; int cm_io_0020_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + int h_cnt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0020_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM com_branch + WHERE param_id = :h_key + AND sort_seq > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + EXEC SQL SELECT sort_seq + INTO :h_amt + FROM com_branch + WHERE param_id = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0020_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } int cm_io_0020_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0020_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM com_calendar + WHERE param_id = :h_key + AND sort_seq < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0020_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cm_io_0020_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long cm_io_0020_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_avg; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0020_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT coalesce(avg(sort_seq), 0)::bigint + INTO :h_avg + FROM com_branch + WHERE apply_dt = :h_bd + AND del_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0020_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/cm_io_0021.c b/app/dbio/cm_io_0021.c index c52f13d..feea541 100644 --- a/app/dbio/cm_io_0021.c +++ b/app/dbio/cm_io_0021.c @@ -92,39 +92,45 @@ struct sqlca_t *ECPGget_sqlca(void); int cm_io_0021_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ - + + #line 17 "app/dbio/cm_io_0021.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0021.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cm_io_0021.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/cm_io_0021.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0021_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( amount ) from com_user where code_id = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/cm_io_0021.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0021_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +140,27 @@ int cm_io_0021_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0021.pgc" - char h_key [ 16 ] ; +#line 48 "app/dbio/cm_io_0021.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0021.pgc" - long h_amount ; +#line 49 "app/dbio/cm_io_0021.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0021.pgc" +#line 50 "app/dbio/cm_io_0021.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0021_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from com_user where code_id = $1 and amount < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0021.pgc" - +#line 60 "app/dbio/cm_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0021_touch"); @@ -164,6 +168,7 @@ int cm_io_0021_touch(const char *key, long amount) } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cm_io_0021_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } @@ -172,33 +177,37 @@ long cm_io_0021_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/cm_io_0021.pgc" - char h_biz_date [ 9 ] ; - -#line 73 "app/dbio/cm_io_0021.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/cm_io_0021.pgc" + char h_bd [ 9 ] ; + +#line 75 "app/dbio/cm_io_0021.pgc" + long h_dr ; + +#line 76 "app/dbio/cm_io_0021.pgc" + long h_cr ; +/* exec sql end declare section */ +#line 77 "app/dbio/cm_io_0021.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0021_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when lock_yn = 'D' then amount else 0 end ) , 0 ) , coalesce ( sum ( case when lock_yn = 'C' then amount else 0 end ) , 0 ) from com_user where reg_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_dr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_cr),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0021.pgc" - +#line 89 "app/dbio/cm_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0021_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/cm_io_0021.pgc b/app/dbio/cm_io_0021.pgc index 9f359b4..a8bed7c 100644 --- a/app/dbio/cm_io_0021.pgc +++ b/app/dbio/cm_io_0021.pgc @@ -14,79 +14,82 @@ EXEC SQL INCLUDE sqlca; int cm_io_0021_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0021_t - WHERE key = :h_key; - + EXEC SQL SELECT max(amount) + INTO :h_amt:h_ind + FROM com_user + WHERE code_id = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0021_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } int cm_io_0021_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0021_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM com_user + WHERE code_id = :h_key + AND amount < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0021_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cm_io_0021_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long cm_io_0021_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_dr; + long h_cr; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0021_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT + coalesce(sum(CASE WHEN lock_yn = 'D' THEN amount ELSE 0 END), 0), + coalesce(sum(CASE WHEN lock_yn = 'C' THEN amount ELSE 0 END), 0) + INTO :h_dr, :h_cr + FROM com_user + WHERE reg_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0021_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/cm_io_0022.c b/app/dbio/cm_io_0022.c index 5392a17..630e84b 100644 --- a/app/dbio/cm_io_0022.c +++ b/app/dbio/cm_io_0022.c @@ -94,37 +94,58 @@ int cm_io_0022_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cm_io_0022.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0022.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cm_io_0022.pgc" + long h_acc ; +/* exec sql end declare section */ +#line 20 "app/dbio/cm_io_0022.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0022_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cm_io_0022_fetch_cur cursor for select weight_val from com_menu where dept_cd = $1 order by biz_date */ +#line 31 "app/dbio/cm_io_0022.pgc" + +#line 31 "app/dbio/cm_io_0022.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cm_io_0022_fetch_cur cursor for select weight_val from com_menu where dept_cd = $1 order by biz_date", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 32 "app/dbio/cm_io_0022.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cm_io_0022_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0022.pgc" +#line 34 "app/dbio/cm_io_0022.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0022_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0022_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 39 "app/dbio/cm_io_0022.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0022_fetch"); - return TX_EDB; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0022_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 44 "app/dbio/cm_io_0022.pgc" + + *out_amount = h_acc; return TX_OK; } @@ -134,29 +155,27 @@ int cm_io_0022_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0022.pgc" - char h_key [ 16 ] ; +#line 52 "app/dbio/cm_io_0022.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0022.pgc" - long h_amount ; +#line 53 "app/dbio/cm_io_0022.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0022.pgc" +#line 54 "app/dbio/cm_io_0022.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0022_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from com_menu where dept_cd = $1 and weight_val < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0022.pgc" - +#line 64 "app/dbio/cm_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0022_touch"); @@ -164,6 +183,7 @@ int cm_io_0022_touch(const char *key, long amount) } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cm_io_0022_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } @@ -173,28 +193,26 @@ long cm_io_0022_total(const char *biz_date) -#line 72 "app/dbio/cm_io_0022.pgc" - char h_biz_date [ 9 ] ; +#line 78 "app/dbio/cm_io_0022.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0022.pgc" +#line 79 "app/dbio/cm_io_0022.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0022.pgc" +#line 80 "app/dbio/cm_io_0022.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0022_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( weight_val ) , 0 ) from com_calendar where biz_date = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0022.pgc" - +#line 90 "app/dbio/cm_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0022_total"); diff --git a/app/dbio/cm_io_0022.pgc b/app/dbio/cm_io_0022.pgc index cfb36db..8cd4c2b 100644 --- a/app/dbio/cm_io_0022.pgc +++ b/app/dbio/cm_io_0022.pgc @@ -14,76 +14,80 @@ EXEC SQL INCLUDE sqlca; int cm_io_0022_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + long h_acc; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0022_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0022_fetch"); - return TX_EDB; + EXEC SQL DECLARE cm_io_0022_fetch_cur CURSOR FOR + SELECT weight_val FROM com_menu + WHERE dept_cd = :h_key + ORDER BY biz_date; + EXEC SQL OPEN cm_io_0022_fetch_cur; + for (;;) { + EXEC SQL FETCH cm_io_0022_fetch_cur INTO :h_amt; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0022_fetch"); + EXEC SQL CLOSE cm_io_0022_fetch_cur; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + EXEC SQL CLOSE cm_io_0022_fetch_cur; + *out_amount = h_acc; return TX_OK; } int cm_io_0022_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0022_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM com_menu + WHERE dept_cd = :h_key + AND weight_val < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0022_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cm_io_0022_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long cm_io_0022_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(weight_val), 0) INTO :h_sum - FROM cm_io_0022_t - WHERE biz_date = :h_biz_date; - + FROM com_calendar + WHERE biz_date = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0022_total"); return -1; diff --git a/app/dbio/cm_io_0023.c b/app/dbio/cm_io_0023.c index abd6314..21fecc3 100644 --- a/app/dbio/cm_io_0023.c +++ b/app/dbio/cm_io_0023.c @@ -96,27 +96,25 @@ int cm_io_0023_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cm_io_0023.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0023.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cm_io_0023.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0023_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( m . level_no , 0 ) - ( select coalesce ( sum ( h . level_no ) , 0 ) from com_code h where h . branch_cd = m . branch_cd ) from com_user m where m . branch_cd = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0023.pgc" - +#line 31 "app/dbio/cm_io_0023.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +122,7 @@ int cm_io_0023_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0023_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -135,28 +133,26 @@ int cm_io_0023_touch(const char *key, long amount) #line 45 "app/dbio/cm_io_0023.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 46 "app/dbio/cm_io_0023.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/cm_io_0023.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0023_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from com_code where branch_cd = $1 and level_no < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0023.pgc" - +#line 57 "app/dbio/cm_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0023_touch"); @@ -164,6 +160,7 @@ int cm_io_0023_touch(const char *key, long amount) } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cm_io_0023_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } @@ -173,32 +170,30 @@ long cm_io_0023_total(const char *biz_date) -#line 72 "app/dbio/cm_io_0023.pgc" - char h_biz_date [ 9 ] ; +#line 71 "app/dbio/cm_io_0023.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0023.pgc" - long h_sum ; +#line 72 "app/dbio/cm_io_0023.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0023.pgc" +#line 73 "app/dbio/cm_io_0023.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0023_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from com_code where apply_dt = $1 and level_no <> 0", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0023.pgc" - +#line 84 "app/dbio/cm_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0023_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cm_io_0023.pgc b/app/dbio/cm_io_0023.pgc index 815a745..c1b3250 100644 --- a/app/dbio/cm_io_0023.pgc +++ b/app/dbio/cm_io_0023.pgc @@ -14,79 +14,77 @@ EXEC SQL INCLUDE sqlca; int cm_io_0023_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0023_t - WHERE key = :h_key; - + EXEC SQL SELECT coalesce(m.level_no, 0) + - (SELECT coalesce(sum(h.level_no), 0) + FROM com_code h WHERE h.branch_cd = m.branch_cd) + INTO :h_amt + FROM com_user m + WHERE m.branch_cd = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0023_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cm_io_0023_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0023_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM com_code + WHERE branch_cd = :h_key + AND level_no < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0023_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cm_io_0023_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long cm_io_0023_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0023_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM com_code + WHERE apply_dt = :h_bd + AND level_no <> 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0023_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/cm_io_0024.c b/app/dbio/cm_io_0024.c index 9055231..0a9b294 100644 --- a/app/dbio/cm_io_0024.c +++ b/app/dbio/cm_io_0024.c @@ -92,31 +92,43 @@ struct sqlca_t *ECPGget_sqlca(void); int cm_io_0024_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ + + + #line 17 "app/dbio/cm_io_0024.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0024.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_min ; + #line 19 "app/dbio/cm_io_0024.pgc" + long h_max ; + +#line 20 "app/dbio/cm_io_0024.pgc" + short h_i1 ; + +#line 21 "app/dbio/cm_io_0024.pgc" + short h_i2 ; +/* exec sql end declare section */ +#line 22 "app/dbio/cm_io_0024.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0024_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( use_cnt ) , max ( use_cnt ) from com_code where param_id = $1 and lock_yn <> 'D'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0024.pgc" - + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i1),(long)1,(long)1,sizeof(short), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i2),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 33 "app/dbio/cm_io_0024.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +136,9 @@ int cm_io_0024_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0024_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } @@ -134,29 +148,27 @@ int cm_io_0024_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0024.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/cm_io_0024.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0024.pgc" - long h_amount ; +#line 50 "app/dbio/cm_io_0024.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0024.pgc" +#line 51 "app/dbio/cm_io_0024.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0024_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from com_code_val where param_id = $1 and use_cnt < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0024.pgc" - +#line 61 "app/dbio/cm_io_0024.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0024_touch"); @@ -164,6 +176,7 @@ int cm_io_0024_touch(const char *key, long amount) } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cm_io_0024_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } @@ -172,33 +185,62 @@ long cm_io_0024_total(const char *biz_date) /* exec sql begin declare section */ + + -#line 72 "app/dbio/cm_io_0024.pgc" - char h_biz_date [ 9 ] ; +#line 75 "app/dbio/cm_io_0024.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0024.pgc" - long h_sum ; +#line 76 "app/dbio/cm_io_0024.pgc" + char h_grp [ 20 ] ; + +#line 77 "app/dbio/cm_io_0024.pgc" + long h_sub ; + +#line 78 "app/dbio/cm_io_0024.pgc" + long h_tot ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0024.pgc" +#line 79 "app/dbio/cm_io_0024.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + ECPGset_var( 0, ( h_bd ), __LINE__);\ + /* declare cm_io_0024_total_gc cursor for select code_type , coalesce ( sum ( use_cnt ) , 0 ) from com_menu where reg_dt = $1 group by code_type order by code_type */ +#line 92 "app/dbio/cm_io_0024.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0024_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), +#line 92 "app/dbio/cm_io_0024.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cm_io_0024_total_gc cursor for select code_type , coalesce ( sum ( use_cnt ) , 0 ) from com_menu where reg_dt = $1 group by code_type order by code_type", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 93 "app/dbio/cm_io_0024.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cm_io_0024_total_gc", ECPGt_EOIT, + ECPGt_char,(h_grp),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sub),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0024.pgc" +#line 95 "app/dbio/cm_io_0024.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0024_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0024_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 100 "app/dbio/cm_io_0024.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0024_total"); - return -1; + return -1; + } + h_tot += h_sub; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cm_io_0024_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 105 "app/dbio/cm_io_0024.pgc" + + return h_tot; } diff --git a/app/dbio/cm_io_0024.pgc b/app/dbio/cm_io_0024.pgc index 6539de7..b313259 100644 --- a/app/dbio/cm_io_0024.pgc +++ b/app/dbio/cm_io_0024.pgc @@ -14,79 +14,94 @@ EXEC SQL INCLUDE sqlca; int cm_io_0024_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_min; + long h_max; + short h_i1; + short h_i2; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0024_t - WHERE key = :h_key; - + EXEC SQL SELECT min(use_cnt), max(use_cnt) + INTO :h_min:h_i1, :h_max:h_i2 + FROM com_code + WHERE param_id = :h_key + AND lock_yn <> 'D'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0024_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } int cm_io_0024_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0024_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM com_code_val + WHERE param_id = :h_key + AND use_cnt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0024_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "cm_io_0024_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long cm_io_0024_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + char h_grp[20]; + long h_sub; + long h_tot; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0024_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("cm_io_0024_total"); - return -1; + EXEC SQL DECLARE cm_io_0024_total_gc CURSOR FOR + SELECT code_type, coalesce(sum(use_cnt), 0) + FROM com_menu + WHERE reg_dt = :h_bd + GROUP BY code_type + ORDER BY code_type; + EXEC SQL OPEN cm_io_0024_total_gc; + for (;;) { + EXEC SQL FETCH cm_io_0024_total_gc INTO :h_grp, :h_sub; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0024_total"); + EXEC SQL CLOSE cm_io_0024_total_gc; + return -1; + } + h_tot += h_sub; } - return h_sum; + EXEC SQL CLOSE cm_io_0024_total_gc; + return h_tot; } diff --git a/app/dbio/cm_io_0025.c b/app/dbio/cm_io_0025.c index 844ed89..4b79278 100644 --- a/app/dbio/cm_io_0025.c +++ b/app/dbio/cm_io_0025.c @@ -96,26 +96,25 @@ int cm_io_0025_fetch(const char *key, long *out_amount) #line 17 "app/dbio/cm_io_0025.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0025.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/cm_io_0025.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0025_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . code_val ) , 0 ) from com_code a join com_code_val b on a . code_id = b . code_id where a . code_id = $1 and b . use_yn = 'Y'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0025.pgc" +#line 31 "app/dbio/cm_io_0025.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int cm_io_0025_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0025_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -134,29 +133,27 @@ int cm_io_0025_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0025.pgc" - char h_key [ 16 ] ; - #line 46 "app/dbio/cm_io_0025.pgc" - long h_amount ; -/* exec sql end declare section */ + char h_key [ 20 ] ; + #line 47 "app/dbio/cm_io_0025.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 48 "app/dbio/cm_io_0025.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0025_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update com_code_val set code_val = code_val + $1 where grp_cd in ( select grp_cd from com_code where code_id = $2 )", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0025.pgc" - +#line 59 "app/dbio/cm_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0025_touch"); @@ -174,7 +171,7 @@ long cm_io_0025_total(const char *biz_date) #line 72 "app/dbio/cm_io_0025.pgc" - char h_biz_date [ 9 ] ; + char h_bd [ 9 ] ; #line 73 "app/dbio/cm_io_0025.pgc" long h_sum ; @@ -184,17 +181,15 @@ long cm_io_0025_total(const char *biz_date) if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0025_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . code_val ) , 0 ) from com_dept d join com_code m on d . code_id = m . code_id where d . biz_date = $1 and m . use_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0025.pgc" - +#line 86 "app/dbio/cm_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0025_total"); diff --git a/app/dbio/cm_io_0025.pgc b/app/dbio/cm_io_0025.pgc index 5b7aae9..49856fe 100644 --- a/app/dbio/cm_io_0025.pgc +++ b/app/dbio/cm_io_0025.pgc @@ -14,20 +14,21 @@ EXEC SQL INCLUDE sqlca; int cm_io_0025_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0025_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(a.code_val), 0) + INTO :h_amt + FROM com_code a + JOIN com_code_val b ON a.code_id = b.code_id + WHERE a.code_id = :h_key + AND b.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +36,27 @@ int cm_io_0025_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("cm_io_0025_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int cm_io_0025_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0025_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE com_code_val + SET code_val = code_val + :h_amt + WHERE grp_cd IN (SELECT grp_cd FROM com_code + WHERE code_id = :h_key); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0025_touch"); return TX_EDB; @@ -69,21 +69,21 @@ int cm_io_0025_touch(const char *key, long amount) long cm_io_0025_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.code_val), 0) INTO :h_sum - FROM cm_io_0025_t - WHERE biz_date = :h_biz_date; - + FROM com_dept d + JOIN com_code m ON d.code_id = m.code_id + WHERE d.biz_date = :h_bd + AND m.use_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0025_total"); return -1; diff --git a/app/dbio/cm_io_0026.c b/app/dbio/cm_io_0026.c index 3e7bc48..63f732a 100644 --- a/app/dbio/cm_io_0026.c +++ b/app/dbio/cm_io_0026.c @@ -94,37 +94,51 @@ int cm_io_0026_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/cm_io_0026.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/cm_io_0026.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/cm_io_0026.pgc" + int h_cnt ; +/* exec sql end declare section */ +#line 20 "app/dbio/cm_io_0026.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from cm_io_0026_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from com_code_val where dept_cd = $1 and sort_seq > 0", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_int,&(h_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/cm_io_0026.pgc" +#line 31 "app/dbio/cm_io_0026.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0026_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select sort_seq from com_code_val where dept_cd = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 42 "app/dbio/cm_io_0026.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0026_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +148,27 @@ int cm_io_0026_touch(const char *key, long amount) -#line 45 "app/dbio/cm_io_0026.pgc" - char h_key [ 16 ] ; +#line 54 "app/dbio/cm_io_0026.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/cm_io_0026.pgc" - long h_amount ; +#line 55 "app/dbio/cm_io_0026.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/cm_io_0026.pgc" +#line 56 "app/dbio/cm_io_0026.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update cm_io_0026_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update com_dept set sort_seq = sort_seq + $1 where dept_cd in ( select dept_cd from com_code_val where dept_cd = $2 )", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/cm_io_0026.pgc" - +#line 67 "app/dbio/cm_io_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0026_touch"); @@ -170,35 +182,39 @@ int cm_io_0026_touch(const char *key, long amount) long cm_io_0026_total(const char *biz_date) { /* exec sql begin declare section */ - + + -#line 72 "app/dbio/cm_io_0026.pgc" - char h_biz_date [ 9 ] ; +#line 80 "app/dbio/cm_io_0026.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/cm_io_0026.pgc" - long h_sum ; +#line 81 "app/dbio/cm_io_0026.pgc" + long h_max ; + +#line 82 "app/dbio/cm_io_0026.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/cm_io_0026.pgc" +#line 83 "app/dbio/cm_io_0026.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from cm_io_0026_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( sort_seq ) from com_dept where apply_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/cm_io_0026.pgc" - + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 93 "app/dbio/cm_io_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0026_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/cm_io_0026.pgc b/app/dbio/cm_io_0026.pgc index 196d66c..9564e96 100644 --- a/app/dbio/cm_io_0026.pgc +++ b/app/dbio/cm_io_0026.pgc @@ -14,49 +14,57 @@ EXEC SQL INCLUDE sqlca; int cm_io_0026_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + int h_cnt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM cm_io_0026_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM com_code_val + WHERE dept_cd = :h_key + AND sort_seq > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0026_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + EXEC SQL SELECT sort_seq + INTO :h_amt + FROM com_code_val + WHERE dept_cd = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("cm_io_0026_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } int cm_io_0026_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE cm_io_0026_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE com_dept + SET sort_seq = sort_seq + :h_amt + WHERE dept_cd IN (SELECT dept_cd FROM com_code_val + WHERE dept_cd = :h_key); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0026_touch"); return TX_EDB; @@ -69,24 +77,25 @@ int cm_io_0026_touch(const char *key, long amount) long cm_io_0026_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM cm_io_0026_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT max(sort_seq) + INTO :h_max:h_ind + FROM com_dept + WHERE apply_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("cm_io_0026_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/lg_io_0001.c b/app/dbio/lg_io_0001.c index 169e8b2..3e4b067 100644 --- a/app/dbio/lg_io_0001.c +++ b/app/dbio/lg_io_0001.c @@ -96,26 +96,25 @@ int lg_io_0001_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0001.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0001.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0001.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0001_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select dr_amt from lg_ledger_line where ledger_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/lg_io_0001.pgc" +#line 29 "app/dbio/lg_io_0001.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int lg_io_0001_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0001_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int lg_io_0001_touch(const char *key, long amount) -#line 45 "app/dbio/lg_io_0001.pgc" - char h_key [ 16 ] ; +#line 44 "app/dbio/lg_io_0001.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/lg_io_0001.pgc" - long h_amount ; +#line 45 "app/dbio/lg_io_0001.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/lg_io_0001.pgc" +#line 46 "app/dbio/lg_io_0001.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0001_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_ledger_line set dr_amt = $1 , upd_ts = now ( ) where ledger_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0001.pgc" - +#line 56 "app/dbio/lg_io_0001.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0001_touch"); @@ -173,27 +170,26 @@ long lg_io_0001_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0001.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/lg_io_0001.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0001.pgc" +#line 70 "app/dbio/lg_io_0001.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0001.pgc" +#line 71 "app/dbio/lg_io_0001.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0001_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( dr_amt ) , 0 ) from lg_ledger_line where post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0001.pgc" +#line 81 "app/dbio/lg_io_0001.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/lg_io_0001.pgc b/app/dbio/lg_io_0001.pgc index 51f4cf7..1a26200 100644 --- a/app/dbio/lg_io_0001.pgc +++ b/app/dbio/lg_io_0001.pgc @@ -14,20 +14,19 @@ EXEC SQL INCLUDE sqlca; int lg_io_0001_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0001_t - WHERE key = :h_key; + EXEC SQL SELECT dr_amt + INTO :h_val + FROM lg_ledger_line + WHERE ledger_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +34,26 @@ int lg_io_0001_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0001_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int lg_io_0001_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0001_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE lg_ledger_line + SET dr_amt = :h_amt, upd_ts = now() + WHERE ledger_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0001_touch"); return TX_EDB; @@ -69,20 +66,19 @@ int lg_io_0001_touch(const char *key, long amount) long lg_io_0001_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(dr_amt), 0) INTO :h_sum - FROM lg_io_0001_t - WHERE biz_date = :h_biz_date; + FROM lg_ledger_line + WHERE post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0001_total"); diff --git a/app/dbio/lg_io_0002.c b/app/dbio/lg_io_0002.c index add71c1..8744192 100644 --- a/app/dbio/lg_io_0002.c +++ b/app/dbio/lg_io_0002.c @@ -94,27 +94,30 @@ int lg_io_0002_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/lg_io_0002.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0002.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/lg_io_0002.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/lg_io_0002.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0002_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select cr_amt from lg_ledger_line where ledger_key = $1 and post_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/lg_io_0002.pgc" @@ -124,7 +127,7 @@ int lg_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } @@ -135,28 +138,26 @@ int lg_io_0002_touch(const char *key, long amount) #line 45 "app/dbio/lg_io_0002.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/lg_io_0002.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/lg_io_0002.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0002_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_ledger_line set dr_amt = $1 , post_flag = 'Y' , upd_ts = now ( ) where ledger_key = $2 and post_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0002.pgc" - +#line 57 "app/dbio/lg_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0002_touch"); @@ -173,32 +174,31 @@ long lg_io_0002_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0002.pgc" - char h_biz_date [ 9 ] ; +#line 70 "app/dbio/lg_io_0002.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0002.pgc" - long h_sum ; +#line 71 "app/dbio/lg_io_0002.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0002.pgc" +#line 72 "app/dbio/lg_io_0002.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0002_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from lg_ledger_line where post_dt = $1 and post_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0002.pgc" +#line 82 "app/dbio/lg_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/lg_io_0002.pgc b/app/dbio/lg_io_0002.pgc index 59c8640..c58da09 100644 --- a/app/dbio/lg_io_0002.pgc +++ b/app/dbio/lg_io_0002.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int lg_io_0002_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0002_t - WHERE key = :h_key; + EXEC SQL SELECT cr_amt + INTO :h_val:h_ind + FROM lg_ledger_line + WHERE ledger_key = :h_key AND post_flag = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +35,26 @@ int lg_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } int lg_io_0002_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0002_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE lg_ledger_line + SET dr_amt = :h_amt, post_flag = 'Y', upd_ts = now() + WHERE ledger_key = :h_key AND post_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0002_touch"); return TX_EDB; @@ -69,24 +67,23 @@ int lg_io_0002_touch(const char *key, long amount) long lg_io_0002_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM lg_io_0002_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM lg_ledger_line + WHERE post_dt = :h_dt AND post_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/lg_io_0003.c b/app/dbio/lg_io_0003.c index 70d9a30..1057c1f 100644 --- a/app/dbio/lg_io_0003.c +++ b/app/dbio/lg_io_0003.c @@ -96,24 +96,23 @@ int lg_io_0003_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0003.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0003.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0003.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0003_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a . dr_amt from lg_ledger_line a join lg_ledger_acct b on a . ledger_key = b . ledger_key where a . ledger_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/lg_io_0003.pgc" @@ -124,7 +123,7 @@ int lg_io_0003_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0003_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -135,28 +134,28 @@ int lg_io_0003_touch(const char *key, long amount) #line 45 "app/dbio/lg_io_0003.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/lg_io_0003.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/lg_io_0003.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0003_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_ledger_line set cr_amt = $1 where ledger_key = $2 and dr_amt >= $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0003.pgc" - +#line 57 "app/dbio/lg_io_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0003_touch"); @@ -172,33 +171,38 @@ long lg_io_0003_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/lg_io_0003.pgc" - char h_biz_date [ 9 ] ; +#line 70 "app/dbio/lg_io_0003.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0003.pgc" - long h_sum ; +#line 71 "app/dbio/lg_io_0003.pgc" + long h_max ; + +#line 72 "app/dbio/lg_io_0003.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0003.pgc" +#line 73 "app/dbio/lg_io_0003.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0003_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( dr_amt ) from lg_ledger_line where post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0003.pgc" + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 83 "app/dbio/lg_io_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0003_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/lg_io_0003.pgc b/app/dbio/lg_io_0003.pgc index 20a8ec8..73b0142 100644 --- a/app/dbio/lg_io_0003.pgc +++ b/app/dbio/lg_io_0003.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int lg_io_0003_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0003_t - WHERE key = :h_key; + EXEC SQL SELECT a.dr_amt + INTO :h_val + FROM lg_ledger_line a + JOIN lg_ledger_acct b ON a.ledger_key = b.ledger_key + WHERE a.ledger_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +35,26 @@ int lg_io_0003_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0003_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int lg_io_0003_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0003_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE lg_ledger_line + SET cr_amt = :h_amt + WHERE ledger_key = :h_key AND dr_amt >= :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0003_touch"); return TX_EDB; @@ -69,24 +67,26 @@ int lg_io_0003_touch(const char *key, long amount) long lg_io_0003_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM lg_io_0003_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(dr_amt) + INTO :h_max:h_ind + FROM lg_ledger_line + WHERE post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0003_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/lg_io_0004.c b/app/dbio/lg_io_0004.c index 6c8dae3..83f2ba4 100644 --- a/app/dbio/lg_io_0004.c +++ b/app/dbio/lg_io_0004.c @@ -96,35 +96,32 @@ int lg_io_0004_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0004.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0004.pgc" - long h_amount ; + long h_flag ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0004.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0004_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when exists ( select 1 from lg_ledger_line where ledger_key = $1 and post_flag = 'N' ) then 1 else 0 end", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/lg_io_0004.pgc" +#line 29 "app/dbio/lg_io_0004.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0004_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } @@ -134,36 +131,32 @@ int lg_io_0004_touch(const char *key, long amount) -#line 45 "app/dbio/lg_io_0004.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/lg_io_0004.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/lg_io_0004.pgc" - long h_amount ; +#line 43 "app/dbio/lg_io_0004.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/lg_io_0004.pgc" +#line 44 "app/dbio/lg_io_0004.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0004_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into lg_ledger_bal ( ledger_key , dr_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0004.pgc" - +#line 53 "app/dbio/lg_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,27 +166,26 @@ long lg_io_0004_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0004.pgc" - char h_biz_date [ 9 ] ; +#line 64 "app/dbio/lg_io_0004.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0004.pgc" +#line 65 "app/dbio/lg_io_0004.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0004.pgc" +#line 66 "app/dbio/lg_io_0004.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0004_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . dr_amt ) , 0 ) from lg_ledger_line a join lg_ledger_acct b on a . ledger_key = b . ledger_key where a . post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0004.pgc" +#line 77 "app/dbio/lg_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/lg_io_0004.pgc b/app/dbio/lg_io_0004.pgc index 664c098..7438b02 100644 --- a/app/dbio/lg_io_0004.pgc +++ b/app/dbio/lg_io_0004.pgc @@ -14,75 +14,67 @@ EXEC SQL INCLUDE sqlca; int lg_io_0004_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_flag; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0004_t - WHERE key = :h_key; + EXEC SQL SELECT CASE WHEN EXISTS ( + SELECT 1 FROM lg_ledger_line + WHERE ledger_key = :h_key AND post_flag = 'N') THEN 1 ELSE 0 END + INTO :h_flag; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0004_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } int lg_io_0004_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0004_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO lg_ledger_bal (ledger_key, dr_amt, upd_ts) + VALUES (:h_key, :h_amt, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long lg_io_0004_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.dr_amt), 0) INTO :h_sum - FROM lg_io_0004_t - WHERE biz_date = :h_biz_date; + FROM lg_ledger_line a + JOIN lg_ledger_acct b ON a.ledger_key = b.ledger_key + WHERE a.post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0004_total"); diff --git a/app/dbio/lg_io_0005.c b/app/dbio/lg_io_0005.c index 1d939f5..5b0ccba 100644 --- a/app/dbio/lg_io_0005.c +++ b/app/dbio/lg_io_0005.c @@ -94,37 +94,40 @@ int lg_io_0005_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/lg_io_0005.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0005.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/lg_io_0005.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/lg_io_0005.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0005_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( dr_amt ) from lg_ledger_line where gl_acct = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/lg_io_0005.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0005_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,35 +138,31 @@ int lg_io_0005_touch(const char *key, long amount) #line 45 "app/dbio/lg_io_0005.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/lg_io_0005.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/lg_io_0005.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0005_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into lg_ledger_line ( ledger_key , dr_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( ledger_key ) do update set dr_amt = excluded . dr_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/lg_io_0005.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0005_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,32 +172,52 @@ long lg_io_0005_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0005.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/lg_io_0005.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0005.pgc" - long h_sum ; +#line 70 "app/dbio/lg_io_0005.pgc" + long h_grp ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0005.pgc" +#line 71 "app/dbio/lg_io_0005.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0005_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_dt ), __LINE__);\ + /* declare lg_io_0005_total_cur cursor for select coalesce ( sum ( dr_amt ) , 0 ) from lg_ledger_line where post_dt = $1 group by gl_acct */ +#line 82 "app/dbio/lg_io_0005.pgc" + +#line 82 "app/dbio/lg_io_0005.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare lg_io_0005_total_cur cursor for select coalesce ( sum ( dr_amt ) , 0 ) from lg_ledger_line where post_dt = $1 group by gl_acct", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 83 "app/dbio/lg_io_0005.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch lg_io_0005_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 85 "app/dbio/lg_io_0005.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("lg_io_0005_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0005_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 90 "app/dbio/lg_io_0005.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("lg_io_0005_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0005_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 95 "app/dbio/lg_io_0005.pgc" + + return acc; } diff --git a/app/dbio/lg_io_0005.pgc b/app/dbio/lg_io_0005.pgc index aaea0f6..c514bbe 100644 --- a/app/dbio/lg_io_0005.pgc +++ b/app/dbio/lg_io_0005.pgc @@ -14,79 +14,84 @@ EXEC SQL INCLUDE sqlca; int lg_io_0005_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0005_t - WHERE key = :h_key; + EXEC SQL SELECT max(dr_amt) + INTO :h_val:h_ind + FROM lg_ledger_line + WHERE gl_acct = :h_key; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0005_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int lg_io_0005_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0005_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO lg_ledger_line (ledger_key, dr_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (ledger_key) + DO UPDATE SET dr_amt = excluded.dr_amt, upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0005_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long lg_io_0005_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM lg_io_0005_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("lg_io_0005_total"); - return -1; + EXEC SQL DECLARE lg_io_0005_total_cur CURSOR FOR + SELECT coalesce(sum(dr_amt), 0) FROM lg_ledger_line + WHERE post_dt = :h_dt GROUP BY gl_acct; + EXEC SQL OPEN lg_io_0005_total_cur; + for (;;) { + EXEC SQL FETCH lg_io_0005_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("lg_io_0005_total"); + EXEC SQL CLOSE lg_io_0005_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE lg_io_0005_total_cur; + return acc; } diff --git a/app/dbio/lg_io_0006.c b/app/dbio/lg_io_0006.c index 08c670c..e846e93 100644 --- a/app/dbio/lg_io_0006.c +++ b/app/dbio/lg_io_0006.c @@ -94,37 +94,40 @@ int lg_io_0006_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/lg_io_0006.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0006.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/lg_io_0006.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/lg_io_0006.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0006_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( dr_amt ) from lg_ledger_line where gl_acct = $1 and post_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/lg_io_0006.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0006_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,24 @@ int lg_io_0006_touch(const char *key, long amount) #line 45 "app/dbio/lg_io_0006.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/lg_io_0006.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/lg_io_0006.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0006_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from lg_ledger_bal where ledger_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0006.pgc" - +#line 56 "app/dbio/lg_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0006_touch"); @@ -173,27 +172,26 @@ long lg_io_0006_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0006.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/lg_io_0006.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0006.pgc" +#line 70 "app/dbio/lg_io_0006.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0006.pgc" +#line 71 "app/dbio/lg_io_0006.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0006_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when post_flag = 'Y' then dr_amt else 0 end ) , 0 ) from lg_ledger_line where post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0006.pgc" +#line 81 "app/dbio/lg_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/lg_io_0006.pgc b/app/dbio/lg_io_0006.pgc index 42fb792..0cb31ed 100644 --- a/app/dbio/lg_io_0006.pgc +++ b/app/dbio/lg_io_0006.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int lg_io_0006_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0006_t - WHERE key = :h_key; + EXEC SQL SELECT min(dr_amt) + INTO :h_val:h_ind + FROM lg_ledger_line + WHERE gl_acct = :h_key AND post_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0006_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int lg_io_0006_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0006_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM lg_ledger_bal + WHERE ledger_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0006_touch"); return TX_EDB; @@ -69,20 +66,19 @@ int lg_io_0006_touch(const char *key, long amount) long lg_io_0006_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(CASE WHEN post_flag = 'Y' THEN dr_amt ELSE 0 END), 0) INTO :h_sum - FROM lg_io_0006_t - WHERE biz_date = :h_biz_date; + FROM lg_ledger_line + WHERE post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0006_total"); diff --git a/app/dbio/lg_io_0007.c b/app/dbio/lg_io_0007.c index 78f4afd..884bbc0 100644 --- a/app/dbio/lg_io_0007.c +++ b/app/dbio/lg_io_0007.c @@ -96,35 +96,32 @@ int lg_io_0007_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0007.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0007.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0007.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0007_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( dr_amt ) , 0 ) from lg_ledger_line where gl_acct = $1 and post_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/lg_io_0007.pgc" +#line 29 "app/dbio/lg_io_0007.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0007_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +131,27 @@ int lg_io_0007_touch(const char *key, long amount) -#line 45 "app/dbio/lg_io_0007.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/lg_io_0007.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/lg_io_0007.pgc" - long h_amount ; +#line 43 "app/dbio/lg_io_0007.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/lg_io_0007.pgc" +#line 44 "app/dbio/lg_io_0007.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0007_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from lg_ledger_bal where gl_acct = $1 and dr_amt < $2 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0007.pgc" - +#line 53 "app/dbio/lg_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0007_touch"); @@ -173,32 +168,31 @@ long lg_io_0007_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0007.pgc" - char h_biz_date [ 9 ] ; +#line 66 "app/dbio/lg_io_0007.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0007.pgc" - long h_sum ; +#line 67 "app/dbio/lg_io_0007.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0007.pgc" +#line 68 "app/dbio/lg_io_0007.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0007_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct gl_acct ) from lg_ledger_line where post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0007.pgc" +#line 78 "app/dbio/lg_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0007_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/lg_io_0007.pgc b/app/dbio/lg_io_0007.pgc index 3b03b8f..1d322f0 100644 --- a/app/dbio/lg_io_0007.pgc +++ b/app/dbio/lg_io_0007.pgc @@ -14,49 +14,43 @@ EXEC SQL INCLUDE sqlca; int lg_io_0007_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0007_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(dr_amt), 0) + INTO :h_val + FROM lg_ledger_line + WHERE gl_acct = :h_key AND post_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0007_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int lg_io_0007_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0007_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM lg_ledger_bal + WHERE gl_acct = :h_key AND dr_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0007_touch"); return TX_EDB; @@ -69,24 +63,23 @@ int lg_io_0007_touch(const char *key, long amount) long lg_io_0007_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM lg_io_0007_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(distinct gl_acct) + INTO :h_cnt + FROM lg_ledger_line + WHERE post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0007_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/lg_io_0008.c b/app/dbio/lg_io_0008.c index e0a3b2c..2430497 100644 --- a/app/dbio/lg_io_0008.c +++ b/app/dbio/lg_io_0008.c @@ -96,35 +96,53 @@ int lg_io_0008_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0008.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0008.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0008.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0008_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare lg_io_0008_fetch_cur cursor for select dr_amt from lg_ledger_line where ledger_key = $1 order by post_dt desc */ +#line 28 "app/dbio/lg_io_0008.pgc" + +#line 28 "app/dbio/lg_io_0008.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare lg_io_0008_fetch_cur cursor for select dr_amt from lg_ledger_line where ledger_key = $1 order by post_dt desc", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 29 "app/dbio/lg_io_0008.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch lg_io_0008_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/lg_io_0008.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0008_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 33 "app/dbio/lg_io_0008.pgc" + return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0008_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0008_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 38 "app/dbio/lg_io_0008.pgc" + return TX_EDB; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0008_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 41 "app/dbio/lg_io_0008.pgc" + + *out_amount = h_val; return TX_OK; } @@ -134,29 +152,29 @@ int lg_io_0008_touch(const char *key, long amount) -#line 45 "app/dbio/lg_io_0008.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/lg_io_0008.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/lg_io_0008.pgc" - long h_amount ; +#line 50 "app/dbio/lg_io_0008.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/lg_io_0008.pgc" +#line 51 "app/dbio/lg_io_0008.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0008_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_ledger_line set dr_amt = dr_amt + $1 , post_flag = case when dr_amt + $2 > 0 then 'Y' else 'N' end , upd_ts = now ( ) where ledger_key = $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0008.pgc" - +#line 63 "app/dbio/lg_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0008_touch"); @@ -173,27 +191,26 @@ long lg_io_0008_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0008.pgc" - char h_biz_date [ 9 ] ; +#line 76 "app/dbio/lg_io_0008.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0008.pgc" +#line 77 "app/dbio/lg_io_0008.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0008.pgc" +#line 78 "app/dbio/lg_io_0008.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0008_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( dr_amt ) , 0 ) from lg_ledger_line where post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0008.pgc" +#line 88 "app/dbio/lg_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/lg_io_0008.pgc b/app/dbio/lg_io_0008.pgc index 480f355..41bd33f 100644 --- a/app/dbio/lg_io_0008.pgc +++ b/app/dbio/lg_io_0008.pgc @@ -14,49 +14,53 @@ EXEC SQL INCLUDE sqlca; int lg_io_0008_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0008_t - WHERE key = :h_key; + EXEC SQL DECLARE lg_io_0008_fetch_cur CURSOR FOR + SELECT dr_amt FROM lg_ledger_line + WHERE ledger_key = :h_key ORDER BY post_dt DESC; + EXEC SQL OPEN lg_io_0008_fetch_cur; + EXEC SQL FETCH lg_io_0008_fetch_cur INTO :h_val; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE lg_io_0008_fetch_cur; return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0008_fetch"); + EXEC SQL CLOSE lg_io_0008_fetch_cur; return TX_EDB; } - *out_amount = h_amount; + EXEC SQL CLOSE lg_io_0008_fetch_cur; + *out_amount = h_val; return TX_OK; } int lg_io_0008_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0008_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE lg_ledger_line + SET dr_amt = dr_amt + :h_amt, + post_flag = CASE WHEN dr_amt + :h_amt > 0 THEN 'Y' ELSE 'N' END, + upd_ts = now() + WHERE ledger_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0008_touch"); return TX_EDB; @@ -69,20 +73,19 @@ int lg_io_0008_touch(const char *key, long amount) long lg_io_0008_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(dr_amt), 0) INTO :h_sum - FROM lg_io_0008_t - WHERE biz_date = :h_biz_date; + FROM lg_ledger_line + WHERE post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0008_total"); diff --git a/app/dbio/lg_io_0009.c b/app/dbio/lg_io_0009.c index 3cbf874..dba4146 100644 --- a/app/dbio/lg_io_0009.c +++ b/app/dbio/lg_io_0009.c @@ -96,26 +96,25 @@ int lg_io_0009_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0009.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0009.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0009.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0009_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select dr_amt from lg_ledger_line where ledger_key in ( select ledger_key from lg_ledger_acct where gl_acct = $1 ) order by dr_amt desc limit 1", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/lg_io_0009.pgc" +#line 32 "app/dbio/lg_io_0009.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int lg_io_0009_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0009_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int lg_io_0009_touch(const char *key, long amount) -#line 45 "app/dbio/lg_io_0009.pgc" - char h_key [ 16 ] ; - -#line 46 "app/dbio/lg_io_0009.pgc" - long h_amount ; -/* exec sql end declare section */ #line 47 "app/dbio/lg_io_0009.pgc" + char h_key [ 32 ] ; + +#line 48 "app/dbio/lg_io_0009.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 49 "app/dbio/lg_io_0009.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0009_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_ledger_line set dr_amt = $1 , upd_ts = now ( ) where ledger_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0009.pgc" - +#line 59 "app/dbio/lg_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0009_touch"); @@ -174,31 +171,30 @@ long lg_io_0009_total(const char *biz_date) #line 72 "app/dbio/lg_io_0009.pgc" - char h_biz_date [ 9 ] ; + char h_dt [ 16 ] ; #line 73 "app/dbio/lg_io_0009.pgc" - long h_sum ; + long h_cnt ; /* exec sql end declare section */ #line 74 "app/dbio/lg_io_0009.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0009_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from lg_ledger_line where post_dt = $1 and post_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0009.pgc" +#line 84 "app/dbio/lg_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0009_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/lg_io_0009.pgc b/app/dbio/lg_io_0009.pgc index d3a12f2..021e9ea 100644 --- a/app/dbio/lg_io_0009.pgc +++ b/app/dbio/lg_io_0009.pgc @@ -14,20 +14,22 @@ EXEC SQL INCLUDE sqlca; int lg_io_0009_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0009_t - WHERE key = :h_key; + EXEC SQL SELECT dr_amt + INTO :h_val + FROM lg_ledger_line + WHERE ledger_key IN ( + SELECT ledger_key FROM lg_ledger_acct WHERE gl_acct = :h_key) + ORDER BY dr_amt DESC + LIMIT 1; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +37,26 @@ int lg_io_0009_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0009_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int lg_io_0009_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0009_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE lg_ledger_line + SET dr_amt = :h_amt, upd_ts = now() + WHERE ledger_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0009_touch"); return TX_EDB; @@ -69,24 +69,23 @@ int lg_io_0009_touch(const char *key, long amount) long lg_io_0009_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM lg_io_0009_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM lg_ledger_line + WHERE post_dt = :h_dt AND post_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0009_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/lg_io_0010.c b/app/dbio/lg_io_0010.c index 2299be6..c0371ac 100644 --- a/app/dbio/lg_io_0010.c +++ b/app/dbio/lg_io_0010.c @@ -96,26 +96,25 @@ int lg_io_0010_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0010.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0010.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0010.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0010_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select dr_amt from lg_ledger_line where ledger_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/lg_io_0010.pgc" +#line 29 "app/dbio/lg_io_0010.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int lg_io_0010_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0010_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int lg_io_0010_touch(const char *key, long amount) -#line 45 "app/dbio/lg_io_0010.pgc" - char h_key [ 16 ] ; +#line 44 "app/dbio/lg_io_0010.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/lg_io_0010.pgc" - long h_amount ; +#line 45 "app/dbio/lg_io_0010.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/lg_io_0010.pgc" +#line 46 "app/dbio/lg_io_0010.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0010_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_ledger_line set dr_amt = $1 , post_flag = 'Y' , upd_ts = now ( ) where ledger_key = $2 and post_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0010.pgc" - +#line 56 "app/dbio/lg_io_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0010_touch"); @@ -172,33 +169,38 @@ long lg_io_0010_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/lg_io_0010.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/lg_io_0010.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0010.pgc" - long h_sum ; +#line 70 "app/dbio/lg_io_0010.pgc" + long h_max ; + +#line 71 "app/dbio/lg_io_0010.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0010.pgc" +#line 72 "app/dbio/lg_io_0010.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0010_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( dr_amt ) from lg_ledger_line where post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0010.pgc" + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 82 "app/dbio/lg_io_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0010_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/lg_io_0010.pgc b/app/dbio/lg_io_0010.pgc index e5725a4..a7c4185 100644 --- a/app/dbio/lg_io_0010.pgc +++ b/app/dbio/lg_io_0010.pgc @@ -14,20 +14,19 @@ EXEC SQL INCLUDE sqlca; int lg_io_0010_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0010_t - WHERE key = :h_key; + EXEC SQL SELECT dr_amt + INTO :h_val + FROM lg_ledger_line + WHERE ledger_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +34,26 @@ int lg_io_0010_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0010_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int lg_io_0010_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0010_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE lg_ledger_line + SET dr_amt = :h_amt, post_flag = 'Y', upd_ts = now() + WHERE ledger_key = :h_key AND post_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0010_touch"); return TX_EDB; @@ -69,24 +66,26 @@ int lg_io_0010_touch(const char *key, long amount) long lg_io_0010_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM lg_io_0010_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(dr_amt) + INTO :h_max:h_ind + FROM lg_ledger_line + WHERE post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0010_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/lg_io_0011.c b/app/dbio/lg_io_0011.c index ae25af8..cdceaaf 100644 --- a/app/dbio/lg_io_0011.c +++ b/app/dbio/lg_io_0011.c @@ -94,27 +94,30 @@ int lg_io_0011_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/lg_io_0011.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0011.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/lg_io_0011.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/lg_io_0011.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0011_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select cr_amt from lg_ledger_line where ledger_key = $1 and post_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/lg_io_0011.pgc" @@ -124,7 +127,7 @@ int lg_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } @@ -135,28 +138,28 @@ int lg_io_0011_touch(const char *key, long amount) #line 45 "app/dbio/lg_io_0011.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/lg_io_0011.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/lg_io_0011.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0011_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_ledger_line set cr_amt = $1 where ledger_key = $2 and dr_amt >= $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0011.pgc" - +#line 57 "app/dbio/lg_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0011_touch"); @@ -173,27 +176,26 @@ long lg_io_0011_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0011.pgc" - char h_biz_date [ 9 ] ; +#line 70 "app/dbio/lg_io_0011.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0011.pgc" +#line 71 "app/dbio/lg_io_0011.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0011.pgc" +#line 72 "app/dbio/lg_io_0011.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0011_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . dr_amt ) , 0 ) from lg_ledger_line a join lg_ledger_acct b on a . ledger_key = b . ledger_key where a . post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0011.pgc" +#line 83 "app/dbio/lg_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/lg_io_0011.pgc b/app/dbio/lg_io_0011.pgc index ed92ace..50824db 100644 --- a/app/dbio/lg_io_0011.pgc +++ b/app/dbio/lg_io_0011.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int lg_io_0011_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0011_t - WHERE key = :h_key; + EXEC SQL SELECT cr_amt + INTO :h_val:h_ind + FROM lg_ledger_line + WHERE ledger_key = :h_key AND post_flag = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +35,26 @@ int lg_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } int lg_io_0011_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0011_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE lg_ledger_line + SET cr_amt = :h_amt + WHERE ledger_key = :h_key AND dr_amt >= :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0011_touch"); return TX_EDB; @@ -69,20 +67,20 @@ int lg_io_0011_touch(const char *key, long amount) long lg_io_0011_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.dr_amt), 0) INTO :h_sum - FROM lg_io_0011_t - WHERE biz_date = :h_biz_date; + FROM lg_ledger_line a + JOIN lg_ledger_acct b ON a.ledger_key = b.ledger_key + WHERE a.post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0011_total"); diff --git a/app/dbio/lg_io_0012.c b/app/dbio/lg_io_0012.c index 2e77495..e084a03 100644 --- a/app/dbio/lg_io_0012.c +++ b/app/dbio/lg_io_0012.c @@ -96,24 +96,23 @@ int lg_io_0012_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0012.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0012.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0012.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0012_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a . dr_amt from lg_ledger_line a join lg_ledger_acct b on a . ledger_key = b . ledger_key where a . ledger_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/lg_io_0012.pgc" @@ -124,7 +123,7 @@ int lg_io_0012_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0012_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -135,35 +134,31 @@ int lg_io_0012_touch(const char *key, long amount) #line 45 "app/dbio/lg_io_0012.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/lg_io_0012.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/lg_io_0012.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0012_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into lg_ledger_bal ( ledger_key , dr_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0012.pgc" - +#line 56 "app/dbio/lg_io_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0012_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,32 +168,52 @@ long lg_io_0012_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0012.pgc" - char h_biz_date [ 9 ] ; +#line 67 "app/dbio/lg_io_0012.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0012.pgc" - long h_sum ; +#line 68 "app/dbio/lg_io_0012.pgc" + long h_grp ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0012.pgc" +#line 69 "app/dbio/lg_io_0012.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0012_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_dt ), __LINE__);\ + /* declare lg_io_0012_total_cur cursor for select coalesce ( sum ( dr_amt ) , 0 ) from lg_ledger_line where post_dt = $1 group by gl_acct */ +#line 80 "app/dbio/lg_io_0012.pgc" + +#line 80 "app/dbio/lg_io_0012.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare lg_io_0012_total_cur cursor for select coalesce ( sum ( dr_amt ) , 0 ) from lg_ledger_line where post_dt = $1 group by gl_acct", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 81 "app/dbio/lg_io_0012.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch lg_io_0012_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0012.pgc" +#line 83 "app/dbio/lg_io_0012.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("lg_io_0012_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0012_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 88 "app/dbio/lg_io_0012.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("lg_io_0012_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0012_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 93 "app/dbio/lg_io_0012.pgc" + + return acc; } diff --git a/app/dbio/lg_io_0012.pgc b/app/dbio/lg_io_0012.pgc index d4724f6..f7607a2 100644 --- a/app/dbio/lg_io_0012.pgc +++ b/app/dbio/lg_io_0012.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int lg_io_0012_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0012_t - WHERE key = :h_key; + EXEC SQL SELECT a.dr_amt + INTO :h_val + FROM lg_ledger_line a + JOIN lg_ledger_acct b ON a.ledger_key = b.ledger_key + WHERE a.ledger_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,58 +35,61 @@ int lg_io_0012_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0012_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int lg_io_0012_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0012_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO lg_ledger_bal (ledger_key, dr_amt, upd_ts) + VALUES (:h_key, :h_amt, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0012_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long lg_io_0012_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM lg_io_0012_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("lg_io_0012_total"); - return -1; + EXEC SQL DECLARE lg_io_0012_total_cur CURSOR FOR + SELECT coalesce(sum(dr_amt), 0) FROM lg_ledger_line + WHERE post_dt = :h_dt GROUP BY gl_acct; + EXEC SQL OPEN lg_io_0012_total_cur; + for (;;) { + EXEC SQL FETCH lg_io_0012_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("lg_io_0012_total"); + EXEC SQL CLOSE lg_io_0012_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE lg_io_0012_total_cur; + return acc; } diff --git a/app/dbio/lg_io_0013.c b/app/dbio/lg_io_0013.c index 5cabd68..977034e 100644 --- a/app/dbio/lg_io_0013.c +++ b/app/dbio/lg_io_0013.c @@ -96,35 +96,32 @@ int lg_io_0013_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0013.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0013.pgc" - long h_amount ; + long h_flag ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0013.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0013_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when exists ( select 1 from lg_ledger_line where ledger_key = $1 and post_flag = 'N' ) then 1 else 0 end", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/lg_io_0013.pgc" +#line 29 "app/dbio/lg_io_0013.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0013_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } @@ -134,36 +131,32 @@ int lg_io_0013_touch(const char *key, long amount) -#line 45 "app/dbio/lg_io_0013.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/lg_io_0013.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/lg_io_0013.pgc" - long h_amount ; +#line 43 "app/dbio/lg_io_0013.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/lg_io_0013.pgc" +#line 44 "app/dbio/lg_io_0013.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0013_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into lg_ledger_line ( ledger_key , dr_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( ledger_key ) do update set dr_amt = excluded . dr_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0013.pgc" - +#line 55 "app/dbio/lg_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,27 +166,26 @@ long lg_io_0013_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0013.pgc" - char h_biz_date [ 9 ] ; +#line 66 "app/dbio/lg_io_0013.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0013.pgc" +#line 67 "app/dbio/lg_io_0013.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0013.pgc" +#line 68 "app/dbio/lg_io_0013.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0013_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when post_flag = 'Y' then dr_amt else 0 end ) , 0 ) from lg_ledger_line where post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0013.pgc" +#line 78 "app/dbio/lg_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/lg_io_0013.pgc b/app/dbio/lg_io_0013.pgc index 9d35872..64dfdb4 100644 --- a/app/dbio/lg_io_0013.pgc +++ b/app/dbio/lg_io_0013.pgc @@ -14,75 +14,68 @@ EXEC SQL INCLUDE sqlca; int lg_io_0013_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_flag; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0013_t - WHERE key = :h_key; + EXEC SQL SELECT CASE WHEN EXISTS ( + SELECT 1 FROM lg_ledger_line + WHERE ledger_key = :h_key AND post_flag = 'N') THEN 1 ELSE 0 END + INTO :h_flag; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0013_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } int lg_io_0013_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0013_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO lg_ledger_line (ledger_key, dr_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (ledger_key) + DO UPDATE SET dr_amt = excluded.dr_amt, upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long lg_io_0013_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(CASE WHEN post_flag = 'Y' THEN dr_amt ELSE 0 END), 0) INTO :h_sum - FROM lg_io_0013_t - WHERE biz_date = :h_biz_date; + FROM lg_ledger_line + WHERE post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0013_total"); diff --git a/app/dbio/lg_io_0014.c b/app/dbio/lg_io_0014.c index 9f1536b..2954ef6 100644 --- a/app/dbio/lg_io_0014.c +++ b/app/dbio/lg_io_0014.c @@ -94,37 +94,40 @@ int lg_io_0014_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/lg_io_0014.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0014.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/lg_io_0014.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/lg_io_0014.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0014_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( dr_amt ) from lg_ledger_line where gl_acct = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/lg_io_0014.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0014_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,24 @@ int lg_io_0014_touch(const char *key, long amount) #line 45 "app/dbio/lg_io_0014.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/lg_io_0014.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/lg_io_0014.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0014_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from lg_ledger_bal where ledger_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0014.pgc" - +#line 56 "app/dbio/lg_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0014_touch"); @@ -173,32 +172,31 @@ long lg_io_0014_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0014.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/lg_io_0014.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0014.pgc" - long h_sum ; +#line 70 "app/dbio/lg_io_0014.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0014.pgc" +#line 71 "app/dbio/lg_io_0014.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0014_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct gl_acct ) from lg_ledger_line where post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0014.pgc" +#line 81 "app/dbio/lg_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0014_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/lg_io_0014.pgc b/app/dbio/lg_io_0014.pgc index 46a7e73..49d5ae3 100644 --- a/app/dbio/lg_io_0014.pgc +++ b/app/dbio/lg_io_0014.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int lg_io_0014_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0014_t - WHERE key = :h_key; + EXEC SQL SELECT max(dr_amt) + INTO :h_val:h_ind + FROM lg_ledger_line + WHERE gl_acct = :h_key; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0014_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int lg_io_0014_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0014_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM lg_ledger_bal + WHERE ledger_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0014_touch"); return TX_EDB; @@ -69,24 +66,23 @@ int lg_io_0014_touch(const char *key, long amount) long lg_io_0014_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM lg_io_0014_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(distinct gl_acct) + INTO :h_cnt + FROM lg_ledger_line + WHERE post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0014_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/lg_io_0015.c b/app/dbio/lg_io_0015.c index 1b04609..0b47262 100644 --- a/app/dbio/lg_io_0015.c +++ b/app/dbio/lg_io_0015.c @@ -94,37 +94,40 @@ int lg_io_0015_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/lg_io_0015.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0015.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/lg_io_0015.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/lg_io_0015.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0015_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( dr_amt ) from lg_ledger_line where gl_acct = $1 and post_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/lg_io_0015.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0015_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,26 @@ int lg_io_0015_touch(const char *key, long amount) #line 45 "app/dbio/lg_io_0015.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/lg_io_0015.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/lg_io_0015.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0015_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from lg_ledger_bal where gl_acct = $1 and dr_amt < $2 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0015.pgc" - +#line 56 "app/dbio/lg_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0015_touch"); @@ -173,27 +174,26 @@ long lg_io_0015_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0015.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/lg_io_0015.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0015.pgc" +#line 70 "app/dbio/lg_io_0015.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0015.pgc" +#line 71 "app/dbio/lg_io_0015.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0015_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( dr_amt ) , 0 ) from lg_ledger_line where post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0015.pgc" +#line 81 "app/dbio/lg_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/lg_io_0015.pgc b/app/dbio/lg_io_0015.pgc index 9a5e22b..dfcc4ed 100644 --- a/app/dbio/lg_io_0015.pgc +++ b/app/dbio/lg_io_0015.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int lg_io_0015_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0015_t - WHERE key = :h_key; + EXEC SQL SELECT min(dr_amt) + INTO :h_val:h_ind + FROM lg_ledger_line + WHERE gl_acct = :h_key AND post_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0015_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int lg_io_0015_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0015_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM lg_ledger_bal + WHERE gl_acct = :h_key AND dr_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0015_touch"); return TX_EDB; @@ -69,20 +66,19 @@ int lg_io_0015_touch(const char *key, long amount) long lg_io_0015_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(dr_amt), 0) INTO :h_sum - FROM lg_io_0015_t - WHERE biz_date = :h_biz_date; + FROM lg_ledger_line + WHERE post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0015_total"); diff --git a/app/dbio/lg_io_0016.c b/app/dbio/lg_io_0016.c index be98ad2..6dab384 100644 --- a/app/dbio/lg_io_0016.c +++ b/app/dbio/lg_io_0016.c @@ -96,35 +96,32 @@ int lg_io_0016_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0016.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0016.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0016.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0016_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( dr_amt ) , 0 ) from lg_ledger_line where gl_acct = $1 and post_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/lg_io_0016.pgc" +#line 29 "app/dbio/lg_io_0016.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0016_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +131,29 @@ int lg_io_0016_touch(const char *key, long amount) -#line 45 "app/dbio/lg_io_0016.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/lg_io_0016.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/lg_io_0016.pgc" - long h_amount ; +#line 43 "app/dbio/lg_io_0016.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/lg_io_0016.pgc" +#line 44 "app/dbio/lg_io_0016.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0016_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_ledger_line set dr_amt = dr_amt + $1 , post_flag = case when dr_amt + $2 > 0 then 'Y' else 'N' end , upd_ts = now ( ) where ledger_key = $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0016.pgc" - +#line 56 "app/dbio/lg_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0016_touch"); @@ -173,32 +170,31 @@ long lg_io_0016_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0016.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/lg_io_0016.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0016.pgc" - long h_sum ; +#line 70 "app/dbio/lg_io_0016.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0016.pgc" +#line 71 "app/dbio/lg_io_0016.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0016_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from lg_ledger_line where post_dt = $1 and post_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0016.pgc" +#line 81 "app/dbio/lg_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0016_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/lg_io_0016.pgc b/app/dbio/lg_io_0016.pgc index 3d90e62..3eaa0be 100644 --- a/app/dbio/lg_io_0016.pgc +++ b/app/dbio/lg_io_0016.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int lg_io_0016_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0016_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(dr_amt), 0) + INTO :h_val + FROM lg_ledger_line + WHERE gl_acct = :h_key AND post_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0016_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int lg_io_0016_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0016_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE lg_ledger_line + SET dr_amt = dr_amt + :h_amt, + post_flag = CASE WHEN dr_amt + :h_amt > 0 THEN 'Y' ELSE 'N' END, + upd_ts = now() + WHERE ledger_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0016_touch"); return TX_EDB; @@ -69,24 +66,23 @@ int lg_io_0016_touch(const char *key, long amount) long lg_io_0016_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM lg_io_0016_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM lg_ledger_line + WHERE post_dt = :h_dt AND post_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0016_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/lg_io_0017.c b/app/dbio/lg_io_0017.c index c2c9715..153f6c8 100644 --- a/app/dbio/lg_io_0017.c +++ b/app/dbio/lg_io_0017.c @@ -96,35 +96,53 @@ int lg_io_0017_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0017.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0017.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0017.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0017_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare lg_io_0017_fetch_cur cursor for select dr_amt from lg_ledger_line where ledger_key = $1 order by post_dt desc */ +#line 28 "app/dbio/lg_io_0017.pgc" + +#line 28 "app/dbio/lg_io_0017.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare lg_io_0017_fetch_cur cursor for select dr_amt from lg_ledger_line where ledger_key = $1 order by post_dt desc", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 29 "app/dbio/lg_io_0017.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch lg_io_0017_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/lg_io_0017.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0017_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 33 "app/dbio/lg_io_0017.pgc" + return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0017_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0017_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 38 "app/dbio/lg_io_0017.pgc" + return TX_EDB; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0017_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 41 "app/dbio/lg_io_0017.pgc" + + *out_amount = h_val; return TX_OK; } @@ -134,29 +152,27 @@ int lg_io_0017_touch(const char *key, long amount) -#line 45 "app/dbio/lg_io_0017.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/lg_io_0017.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/lg_io_0017.pgc" - long h_amount ; +#line 50 "app/dbio/lg_io_0017.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/lg_io_0017.pgc" +#line 51 "app/dbio/lg_io_0017.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0017_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_ledger_line set dr_amt = $1 , upd_ts = now ( ) where ledger_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0017.pgc" - +#line 61 "app/dbio/lg_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0017_touch"); @@ -172,33 +188,38 @@ long lg_io_0017_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/lg_io_0017.pgc" - char h_biz_date [ 9 ] ; - -#line 73 "app/dbio/lg_io_0017.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/lg_io_0017.pgc" + char h_dt [ 16 ] ; + +#line 75 "app/dbio/lg_io_0017.pgc" + long h_max ; + +#line 76 "app/dbio/lg_io_0017.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 77 "app/dbio/lg_io_0017.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0017_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( dr_amt ) from lg_ledger_line where post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0017.pgc" + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 87 "app/dbio/lg_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0017_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/lg_io_0017.pgc b/app/dbio/lg_io_0017.pgc index 9181e45..9a08163 100644 --- a/app/dbio/lg_io_0017.pgc +++ b/app/dbio/lg_io_0017.pgc @@ -14,49 +14,51 @@ EXEC SQL INCLUDE sqlca; int lg_io_0017_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0017_t - WHERE key = :h_key; + EXEC SQL DECLARE lg_io_0017_fetch_cur CURSOR FOR + SELECT dr_amt FROM lg_ledger_line + WHERE ledger_key = :h_key ORDER BY post_dt DESC; + EXEC SQL OPEN lg_io_0017_fetch_cur; + EXEC SQL FETCH lg_io_0017_fetch_cur INTO :h_val; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE lg_io_0017_fetch_cur; return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0017_fetch"); + EXEC SQL CLOSE lg_io_0017_fetch_cur; return TX_EDB; } - *out_amount = h_amount; + EXEC SQL CLOSE lg_io_0017_fetch_cur; + *out_amount = h_val; return TX_OK; } int lg_io_0017_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0017_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE lg_ledger_line + SET dr_amt = :h_amt, upd_ts = now() + WHERE ledger_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0017_touch"); return TX_EDB; @@ -69,24 +71,26 @@ int lg_io_0017_touch(const char *key, long amount) long lg_io_0017_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM lg_io_0017_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(dr_amt) + INTO :h_max:h_ind + FROM lg_ledger_line + WHERE post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0017_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/lg_io_0018.c b/app/dbio/lg_io_0018.c index d1463ef..4b94951 100644 --- a/app/dbio/lg_io_0018.c +++ b/app/dbio/lg_io_0018.c @@ -96,26 +96,25 @@ int lg_io_0018_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0018.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0018.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0018.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0018_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select dr_amt from lg_ledger_line where ledger_key in ( select ledger_key from lg_ledger_acct where gl_acct = $1 ) order by dr_amt desc limit 1", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/lg_io_0018.pgc" +#line 32 "app/dbio/lg_io_0018.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int lg_io_0018_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0018_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int lg_io_0018_touch(const char *key, long amount) -#line 45 "app/dbio/lg_io_0018.pgc" - char h_key [ 16 ] ; - -#line 46 "app/dbio/lg_io_0018.pgc" - long h_amount ; -/* exec sql end declare section */ #line 47 "app/dbio/lg_io_0018.pgc" + char h_key [ 32 ] ; + +#line 48 "app/dbio/lg_io_0018.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 49 "app/dbio/lg_io_0018.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0018_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_ledger_line set dr_amt = $1 , post_flag = 'Y' , upd_ts = now ( ) where ledger_key = $2 and post_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0018.pgc" - +#line 59 "app/dbio/lg_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0018_touch"); @@ -174,7 +171,7 @@ long lg_io_0018_total(const char *biz_date) #line 72 "app/dbio/lg_io_0018.pgc" - char h_biz_date [ 9 ] ; + char h_dt [ 16 ] ; #line 73 "app/dbio/lg_io_0018.pgc" long h_sum ; @@ -184,12 +181,11 @@ long lg_io_0018_total(const char *biz_date) if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0018_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . dr_amt ) , 0 ) from lg_ledger_line a join lg_ledger_acct b on a . ledger_key = b . ledger_key where a . post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} diff --git a/app/dbio/lg_io_0018.pgc b/app/dbio/lg_io_0018.pgc index 131f2d1..9b3d852 100644 --- a/app/dbio/lg_io_0018.pgc +++ b/app/dbio/lg_io_0018.pgc @@ -14,20 +14,22 @@ EXEC SQL INCLUDE sqlca; int lg_io_0018_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0018_t - WHERE key = :h_key; + EXEC SQL SELECT dr_amt + INTO :h_val + FROM lg_ledger_line + WHERE ledger_key IN ( + SELECT ledger_key FROM lg_ledger_acct WHERE gl_acct = :h_key) + ORDER BY dr_amt DESC + LIMIT 1; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +37,26 @@ int lg_io_0018_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0018_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int lg_io_0018_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0018_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE lg_ledger_line + SET dr_amt = :h_amt, post_flag = 'Y', upd_ts = now() + WHERE ledger_key = :h_key AND post_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0018_touch"); return TX_EDB; @@ -69,20 +69,20 @@ int lg_io_0018_touch(const char *key, long amount) long lg_io_0018_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.dr_amt), 0) INTO :h_sum - FROM lg_io_0018_t - WHERE biz_date = :h_biz_date; + FROM lg_ledger_line a + JOIN lg_ledger_acct b ON a.ledger_key = b.ledger_key + WHERE a.post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0018_total"); diff --git a/app/dbio/lg_io_0019.c b/app/dbio/lg_io_0019.c index 480b837..74eee0b 100644 --- a/app/dbio/lg_io_0019.c +++ b/app/dbio/lg_io_0019.c @@ -96,26 +96,25 @@ int lg_io_0019_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0019.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0019.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0019.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0019_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select dr_amt from lg_ledger_line where ledger_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/lg_io_0019.pgc" +#line 29 "app/dbio/lg_io_0019.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int lg_io_0019_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0019_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,29 @@ int lg_io_0019_touch(const char *key, long amount) -#line 45 "app/dbio/lg_io_0019.pgc" - char h_key [ 16 ] ; +#line 44 "app/dbio/lg_io_0019.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/lg_io_0019.pgc" - long h_amount ; +#line 45 "app/dbio/lg_io_0019.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/lg_io_0019.pgc" +#line 46 "app/dbio/lg_io_0019.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0019_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_ledger_line set cr_amt = $1 where ledger_key = $2 and dr_amt >= $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0019.pgc" - +#line 56 "app/dbio/lg_io_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0019_touch"); @@ -173,32 +172,52 @@ long lg_io_0019_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0019.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/lg_io_0019.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0019.pgc" - long h_sum ; +#line 70 "app/dbio/lg_io_0019.pgc" + long h_grp ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0019.pgc" +#line 71 "app/dbio/lg_io_0019.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0019_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_dt ), __LINE__);\ + /* declare lg_io_0019_total_cur cursor for select coalesce ( sum ( dr_amt ) , 0 ) from lg_ledger_line where post_dt = $1 group by gl_acct */ +#line 82 "app/dbio/lg_io_0019.pgc" + +#line 82 "app/dbio/lg_io_0019.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare lg_io_0019_total_cur cursor for select coalesce ( sum ( dr_amt ) , 0 ) from lg_ledger_line where post_dt = $1 group by gl_acct", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 83 "app/dbio/lg_io_0019.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch lg_io_0019_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 85 "app/dbio/lg_io_0019.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("lg_io_0019_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0019_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 90 "app/dbio/lg_io_0019.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("lg_io_0019_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0019_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 95 "app/dbio/lg_io_0019.pgc" + + return acc; } diff --git a/app/dbio/lg_io_0019.pgc b/app/dbio/lg_io_0019.pgc index 18e9cd0..d398e09 100644 --- a/app/dbio/lg_io_0019.pgc +++ b/app/dbio/lg_io_0019.pgc @@ -14,20 +14,19 @@ EXEC SQL INCLUDE sqlca; int lg_io_0019_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0019_t - WHERE key = :h_key; + EXEC SQL SELECT dr_amt + INTO :h_val + FROM lg_ledger_line + WHERE ledger_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +34,26 @@ int lg_io_0019_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0019_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int lg_io_0019_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0019_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE lg_ledger_line + SET cr_amt = :h_amt + WHERE ledger_key = :h_key AND dr_amt >= :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0019_touch"); return TX_EDB; @@ -69,24 +66,32 @@ int lg_io_0019_touch(const char *key, long amount) long lg_io_0019_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM lg_io_0019_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("lg_io_0019_total"); - return -1; + EXEC SQL DECLARE lg_io_0019_total_cur CURSOR FOR + SELECT coalesce(sum(dr_amt), 0) FROM lg_ledger_line + WHERE post_dt = :h_dt GROUP BY gl_acct; + EXEC SQL OPEN lg_io_0019_total_cur; + for (;;) { + EXEC SQL FETCH lg_io_0019_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("lg_io_0019_total"); + EXEC SQL CLOSE lg_io_0019_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE lg_io_0019_total_cur; + return acc; } diff --git a/app/dbio/lg_io_0020.c b/app/dbio/lg_io_0020.c index 2e6cb9c..5bf8792 100644 --- a/app/dbio/lg_io_0020.c +++ b/app/dbio/lg_io_0020.c @@ -94,27 +94,30 @@ int lg_io_0020_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/lg_io_0020.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0020.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/lg_io_0020.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/lg_io_0020.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0020_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select cr_amt from lg_ledger_line where ledger_key = $1 and post_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/lg_io_0020.pgc" @@ -124,7 +127,7 @@ int lg_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } @@ -135,35 +138,31 @@ int lg_io_0020_touch(const char *key, long amount) #line 45 "app/dbio/lg_io_0020.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/lg_io_0020.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/lg_io_0020.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0020_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into lg_ledger_bal ( ledger_key , dr_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0020.pgc" - +#line 56 "app/dbio/lg_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,27 +172,26 @@ long lg_io_0020_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0020.pgc" - char h_biz_date [ 9 ] ; +#line 67 "app/dbio/lg_io_0020.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0020.pgc" +#line 68 "app/dbio/lg_io_0020.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0020.pgc" +#line 69 "app/dbio/lg_io_0020.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0020_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when post_flag = 'Y' then dr_amt else 0 end ) , 0 ) from lg_ledger_line where post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0020.pgc" +#line 79 "app/dbio/lg_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/lg_io_0020.pgc b/app/dbio/lg_io_0020.pgc index 712238f..df43d13 100644 --- a/app/dbio/lg_io_0020.pgc +++ b/app/dbio/lg_io_0020.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int lg_io_0020_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0020_t - WHERE key = :h_key; + EXEC SQL SELECT cr_amt + INTO :h_val:h_ind + FROM lg_ledger_line + WHERE ledger_key = :h_key AND post_flag = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,54 +35,48 @@ int lg_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } int lg_io_0020_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0020_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO lg_ledger_bal (ledger_key, dr_amt, upd_ts) + VALUES (:h_key, :h_amt, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long lg_io_0020_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(CASE WHEN post_flag = 'Y' THEN dr_amt ELSE 0 END), 0) INTO :h_sum - FROM lg_io_0020_t - WHERE biz_date = :h_biz_date; + FROM lg_ledger_line + WHERE post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0020_total"); diff --git a/app/dbio/lg_io_0021.c b/app/dbio/lg_io_0021.c index d9192d9..34beda1 100644 --- a/app/dbio/lg_io_0021.c +++ b/app/dbio/lg_io_0021.c @@ -96,24 +96,23 @@ int lg_io_0021_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0021.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0021.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0021.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0021_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a . dr_amt from lg_ledger_line a join lg_ledger_acct b on a . ledger_key = b . ledger_key where a . ledger_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/lg_io_0021.pgc" @@ -124,7 +123,7 @@ int lg_io_0021_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0021_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -135,35 +134,31 @@ int lg_io_0021_touch(const char *key, long amount) #line 45 "app/dbio/lg_io_0021.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/lg_io_0021.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/lg_io_0021.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0021_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into lg_ledger_line ( ledger_key , dr_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( ledger_key ) do update set dr_amt = excluded . dr_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/lg_io_0021.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0021_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,32 +168,31 @@ long lg_io_0021_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0021.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/lg_io_0021.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0021.pgc" - long h_sum ; +#line 70 "app/dbio/lg_io_0021.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0021.pgc" +#line 71 "app/dbio/lg_io_0021.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0021_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct gl_acct ) from lg_ledger_line where post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0021.pgc" +#line 81 "app/dbio/lg_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0021_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/lg_io_0021.pgc b/app/dbio/lg_io_0021.pgc index eea6f1b..c92682a 100644 --- a/app/dbio/lg_io_0021.pgc +++ b/app/dbio/lg_io_0021.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int lg_io_0021_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0021_t - WHERE key = :h_key; + EXEC SQL SELECT a.dr_amt + INTO :h_val + FROM lg_ledger_line a + JOIN lg_ledger_acct b ON a.ledger_key = b.ledger_key + WHERE a.ledger_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,58 +35,54 @@ int lg_io_0021_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("lg_io_0021_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int lg_io_0021_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0021_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO lg_ledger_line (ledger_key, dr_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (ledger_key) + DO UPDATE SET dr_amt = excluded.dr_amt, upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0021_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long lg_io_0021_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM lg_io_0021_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(distinct gl_acct) + INTO :h_cnt + FROM lg_ledger_line + WHERE post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0021_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/lg_io_0022.c b/app/dbio/lg_io_0022.c index efde278..f825674 100644 --- a/app/dbio/lg_io_0022.c +++ b/app/dbio/lg_io_0022.c @@ -96,35 +96,32 @@ int lg_io_0022_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0022.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0022.pgc" - long h_amount ; + long h_flag ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0022.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0022_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when exists ( select 1 from lg_ledger_line where ledger_key = $1 and post_flag = 'N' ) then 1 else 0 end", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/lg_io_0022.pgc" +#line 29 "app/dbio/lg_io_0022.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0022_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } @@ -134,29 +131,25 @@ int lg_io_0022_touch(const char *key, long amount) -#line 45 "app/dbio/lg_io_0022.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/lg_io_0022.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/lg_io_0022.pgc" - long h_amount ; +#line 43 "app/dbio/lg_io_0022.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/lg_io_0022.pgc" +#line 44 "app/dbio/lg_io_0022.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0022_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from lg_ledger_bal where ledger_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0022.pgc" - +#line 53 "app/dbio/lg_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0022_touch"); @@ -173,27 +166,26 @@ long lg_io_0022_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0022.pgc" - char h_biz_date [ 9 ] ; +#line 66 "app/dbio/lg_io_0022.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0022.pgc" +#line 67 "app/dbio/lg_io_0022.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0022.pgc" +#line 68 "app/dbio/lg_io_0022.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0022_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( dr_amt ) , 0 ) from lg_ledger_line where post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0022.pgc" +#line 78 "app/dbio/lg_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/lg_io_0022.pgc b/app/dbio/lg_io_0022.pgc index 9570705..10e3d16 100644 --- a/app/dbio/lg_io_0022.pgc +++ b/app/dbio/lg_io_0022.pgc @@ -14,49 +14,43 @@ EXEC SQL INCLUDE sqlca; int lg_io_0022_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_flag; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0022_t - WHERE key = :h_key; + EXEC SQL SELECT CASE WHEN EXISTS ( + SELECT 1 FROM lg_ledger_line + WHERE ledger_key = :h_key AND post_flag = 'N') THEN 1 ELSE 0 END + INTO :h_flag; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0022_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } int lg_io_0022_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0022_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM lg_ledger_bal + WHERE ledger_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0022_touch"); return TX_EDB; @@ -69,20 +63,19 @@ int lg_io_0022_touch(const char *key, long amount) long lg_io_0022_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(dr_amt), 0) INTO :h_sum - FROM lg_io_0022_t - WHERE biz_date = :h_biz_date; + FROM lg_ledger_line + WHERE post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0022_total"); diff --git a/app/dbio/lg_io_0023.c b/app/dbio/lg_io_0023.c index 2fd2f53..9641033 100644 --- a/app/dbio/lg_io_0023.c +++ b/app/dbio/lg_io_0023.c @@ -94,37 +94,40 @@ int lg_io_0023_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/lg_io_0023.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0023.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/lg_io_0023.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/lg_io_0023.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0023_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( dr_amt ) from lg_ledger_line where gl_acct = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/lg_io_0023.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0023_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,26 @@ int lg_io_0023_touch(const char *key, long amount) #line 45 "app/dbio/lg_io_0023.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/lg_io_0023.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/lg_io_0023.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0023_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from lg_ledger_bal where gl_acct = $1 and dr_amt < $2 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0023.pgc" - +#line 56 "app/dbio/lg_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0023_touch"); @@ -173,32 +174,31 @@ long lg_io_0023_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0023.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/lg_io_0023.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0023.pgc" - long h_sum ; +#line 70 "app/dbio/lg_io_0023.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0023.pgc" +#line 71 "app/dbio/lg_io_0023.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0023_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from lg_ledger_line where post_dt = $1 and post_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0023.pgc" +#line 81 "app/dbio/lg_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0023_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/lg_io_0023.pgc b/app/dbio/lg_io_0023.pgc index f8e52d8..a5bbaa6 100644 --- a/app/dbio/lg_io_0023.pgc +++ b/app/dbio/lg_io_0023.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int lg_io_0023_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0023_t - WHERE key = :h_key; + EXEC SQL SELECT max(dr_amt) + INTO :h_val:h_ind + FROM lg_ledger_line + WHERE gl_acct = :h_key; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0023_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int lg_io_0023_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0023_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM lg_ledger_bal + WHERE gl_acct = :h_key AND dr_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0023_touch"); return TX_EDB; @@ -69,24 +66,23 @@ int lg_io_0023_touch(const char *key, long amount) long lg_io_0023_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM lg_io_0023_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM lg_ledger_line + WHERE post_dt = :h_dt AND post_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0023_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/lg_io_0024.c b/app/dbio/lg_io_0024.c index 6edeb91..047156b 100644 --- a/app/dbio/lg_io_0024.c +++ b/app/dbio/lg_io_0024.c @@ -94,37 +94,40 @@ int lg_io_0024_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/lg_io_0024.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0024.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/lg_io_0024.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/lg_io_0024.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0024_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( dr_amt ) from lg_ledger_line where gl_acct = $1 and post_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/lg_io_0024.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0024_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,28 @@ int lg_io_0024_touch(const char *key, long amount) #line 45 "app/dbio/lg_io_0024.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/lg_io_0024.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/lg_io_0024.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0024_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_ledger_line set dr_amt = dr_amt + $1 , post_flag = case when dr_amt + $2 > 0 then 'Y' else 'N' end , upd_ts = now ( ) where ledger_key = $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0024.pgc" - +#line 59 "app/dbio/lg_io_0024.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0024_touch"); @@ -172,27 +175,30 @@ long lg_io_0024_total(const char *biz_date) /* exec sql begin declare section */ + #line 72 "app/dbio/lg_io_0024.pgc" - char h_biz_date [ 9 ] ; + char h_dt [ 16 ] ; #line 73 "app/dbio/lg_io_0024.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_max ; + #line 74 "app/dbio/lg_io_0024.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 75 "app/dbio/lg_io_0024.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0024_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( dr_amt ) from lg_ledger_line where post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 85 "app/dbio/lg_io_0024.pgc" @@ -200,5 +206,7 @@ long lg_io_0024_total(const char *biz_date) TX_DBIO_LOG_ERR("lg_io_0024_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/lg_io_0024.pgc b/app/dbio/lg_io_0024.pgc index ef11537..d19f41c 100644 --- a/app/dbio/lg_io_0024.pgc +++ b/app/dbio/lg_io_0024.pgc @@ -14,49 +14,49 @@ EXEC SQL INCLUDE sqlca; int lg_io_0024_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0024_t - WHERE key = :h_key; + EXEC SQL SELECT min(dr_amt) + INTO :h_val:h_ind + FROM lg_ledger_line + WHERE gl_acct = :h_key AND post_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0024_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int lg_io_0024_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0024_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE lg_ledger_line + SET dr_amt = dr_amt + :h_amt, + post_flag = CASE WHEN dr_amt + :h_amt > 0 THEN 'Y' ELSE 'N' END, + upd_ts = now() + WHERE ledger_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0024_touch"); return TX_EDB; @@ -69,24 +69,26 @@ int lg_io_0024_touch(const char *key, long amount) long lg_io_0024_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM lg_io_0024_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(dr_amt) + INTO :h_max:h_ind + FROM lg_ledger_line + WHERE post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0024_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/lg_io_0025.c b/app/dbio/lg_io_0025.c index 29aced9..55d6633 100644 --- a/app/dbio/lg_io_0025.c +++ b/app/dbio/lg_io_0025.c @@ -96,35 +96,32 @@ int lg_io_0025_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0025.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0025.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0025.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0025_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( dr_amt ) , 0 ) from lg_ledger_line where gl_acct = $1 and post_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/lg_io_0025.pgc" +#line 29 "app/dbio/lg_io_0025.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0025_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +131,27 @@ int lg_io_0025_touch(const char *key, long amount) -#line 45 "app/dbio/lg_io_0025.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/lg_io_0025.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/lg_io_0025.pgc" - long h_amount ; +#line 43 "app/dbio/lg_io_0025.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/lg_io_0025.pgc" +#line 44 "app/dbio/lg_io_0025.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0025_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_ledger_line set dr_amt = $1 , upd_ts = now ( ) where ledger_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0025.pgc" - +#line 54 "app/dbio/lg_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0025_touch"); @@ -173,27 +168,26 @@ long lg_io_0025_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0025.pgc" - char h_biz_date [ 9 ] ; +#line 67 "app/dbio/lg_io_0025.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/lg_io_0025.pgc" +#line 68 "app/dbio/lg_io_0025.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/lg_io_0025.pgc" +#line 69 "app/dbio/lg_io_0025.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0025_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . dr_amt ) , 0 ) from lg_ledger_line a join lg_ledger_acct b on a . ledger_key = b . ledger_key where a . post_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0025.pgc" +#line 80 "app/dbio/lg_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/lg_io_0025.pgc b/app/dbio/lg_io_0025.pgc index eb933d3..d029371 100644 --- a/app/dbio/lg_io_0025.pgc +++ b/app/dbio/lg_io_0025.pgc @@ -14,49 +14,44 @@ EXEC SQL INCLUDE sqlca; int lg_io_0025_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0025_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(dr_amt), 0) + INTO :h_val + FROM lg_ledger_line + WHERE gl_acct = :h_key AND post_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0025_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int lg_io_0025_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0025_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE lg_ledger_line + SET dr_amt = :h_amt, upd_ts = now() + WHERE ledger_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0025_touch"); return TX_EDB; @@ -69,20 +64,20 @@ int lg_io_0025_touch(const char *key, long amount) long lg_io_0025_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.dr_amt), 0) INTO :h_sum - FROM lg_io_0025_t - WHERE biz_date = :h_biz_date; + FROM lg_ledger_line a + JOIN lg_ledger_acct b ON a.ledger_key = b.ledger_key + WHERE a.post_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0025_total"); diff --git a/app/dbio/lg_io_0026.c b/app/dbio/lg_io_0026.c index 5c5eafb..1cd8730 100644 --- a/app/dbio/lg_io_0026.c +++ b/app/dbio/lg_io_0026.c @@ -96,35 +96,53 @@ int lg_io_0026_fetch(const char *key, long *out_amount) #line 17 "app/dbio/lg_io_0026.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/lg_io_0026.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/lg_io_0026.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from lg_io_0026_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare lg_io_0026_fetch_cur cursor for select dr_amt from lg_ledger_line where ledger_key = $1 order by post_dt desc */ +#line 28 "app/dbio/lg_io_0026.pgc" + +#line 28 "app/dbio/lg_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare lg_io_0026_fetch_cur cursor for select dr_amt from lg_ledger_line where ledger_key = $1 order by post_dt desc", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 29 "app/dbio/lg_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch lg_io_0026_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/lg_io_0026.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0026_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 33 "app/dbio/lg_io_0026.pgc" + return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0026_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0026_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 38 "app/dbio/lg_io_0026.pgc" + return TX_EDB; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0026_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 41 "app/dbio/lg_io_0026.pgc" + + *out_amount = h_val; return TX_OK; } @@ -134,29 +152,27 @@ int lg_io_0026_touch(const char *key, long amount) -#line 45 "app/dbio/lg_io_0026.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/lg_io_0026.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/lg_io_0026.pgc" - long h_amount ; +#line 50 "app/dbio/lg_io_0026.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/lg_io_0026.pgc" +#line 51 "app/dbio/lg_io_0026.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_io_0026_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update lg_ledger_line set dr_amt = $1 , post_flag = 'Y' , upd_ts = now ( ) where ledger_key = $2 and post_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/lg_io_0026.pgc" - +#line 61 "app/dbio/lg_io_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0026_touch"); @@ -173,32 +189,52 @@ long lg_io_0026_total(const char *biz_date) -#line 72 "app/dbio/lg_io_0026.pgc" - char h_biz_date [ 9 ] ; - -#line 73 "app/dbio/lg_io_0026.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/lg_io_0026.pgc" + char h_dt [ 16 ] ; + +#line 75 "app/dbio/lg_io_0026.pgc" + long h_grp ; +/* exec sql end declare section */ +#line 76 "app/dbio/lg_io_0026.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from lg_io_0026_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 1, ( h_dt ), __LINE__);\ + /* declare lg_io_0026_total_cur cursor for select coalesce ( sum ( dr_amt ) , 0 ) from lg_ledger_line where post_dt = $1 group by gl_acct */ +#line 87 "app/dbio/lg_io_0026.pgc" + +#line 87 "app/dbio/lg_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare lg_io_0026_total_cur cursor for select coalesce ( sum ( dr_amt ) , 0 ) from lg_ledger_line where post_dt = $1 group by gl_acct", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 88 "app/dbio/lg_io_0026.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch lg_io_0026_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/lg_io_0026.pgc" +#line 90 "app/dbio/lg_io_0026.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("lg_io_0026_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0026_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 95 "app/dbio/lg_io_0026.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("lg_io_0026_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close lg_io_0026_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 100 "app/dbio/lg_io_0026.pgc" + + return acc; } diff --git a/app/dbio/lg_io_0026.pgc b/app/dbio/lg_io_0026.pgc index 2af3d09..092d96f 100644 --- a/app/dbio/lg_io_0026.pgc +++ b/app/dbio/lg_io_0026.pgc @@ -14,49 +14,51 @@ EXEC SQL INCLUDE sqlca; int lg_io_0026_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM lg_io_0026_t - WHERE key = :h_key; + EXEC SQL DECLARE lg_io_0026_fetch_cur CURSOR FOR + SELECT dr_amt FROM lg_ledger_line + WHERE ledger_key = :h_key ORDER BY post_dt DESC; + EXEC SQL OPEN lg_io_0026_fetch_cur; + EXEC SQL FETCH lg_io_0026_fetch_cur INTO :h_val; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE lg_io_0026_fetch_cur; return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0026_fetch"); + EXEC SQL CLOSE lg_io_0026_fetch_cur; return TX_EDB; } - *out_amount = h_amount; + EXEC SQL CLOSE lg_io_0026_fetch_cur; + *out_amount = h_val; return TX_OK; } int lg_io_0026_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE lg_io_0026_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE lg_ledger_line + SET dr_amt = :h_amt, post_flag = 'Y', upd_ts = now() + WHERE ledger_key = :h_key AND post_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("lg_io_0026_touch"); return TX_EDB; @@ -69,24 +71,32 @@ int lg_io_0026_touch(const char *key, long amount) long lg_io_0026_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM lg_io_0026_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("lg_io_0026_total"); - return -1; + EXEC SQL DECLARE lg_io_0026_total_cur CURSOR FOR + SELECT coalesce(sum(dr_amt), 0) FROM lg_ledger_line + WHERE post_dt = :h_dt GROUP BY gl_acct; + EXEC SQL OPEN lg_io_0026_total_cur; + for (;;) { + EXEC SQL FETCH lg_io_0026_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("lg_io_0026_total"); + EXEC SQL CLOSE lg_io_0026_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE lg_io_0026_total_cur; + return acc; } diff --git a/app/dbio/mg_io_0001.c b/app/dbio/mg_io_0001.c index 2de91e6..6c9091c 100644 --- a/app/dbio/mg_io_0001.c +++ b/app/dbio/mg_io_0001.c @@ -110,7 +110,7 @@ int mg_io_0001_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0001_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt from mg_io_0001_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), @@ -150,7 +150,7 @@ int mg_io_0001_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0001_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0001_t set appr_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), @@ -188,7 +188,7 @@ long mg_io_0001_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0001_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( appr_amt ) , 0 ) from mg_io_0001_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), @@ -202,3 +202,4 @@ long mg_io_0001_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0001.pgc b/app/dbio/mg_io_0001.pgc index 70b7863..6632ca1 100644 --- a/app/dbio/mg_io_0001.pgc +++ b/app/dbio/mg_io_0001.pgc @@ -24,10 +24,10 @@ int mg_io_0001_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT appr_amt INTO :h_amount FROM mg_io_0001_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +54,8 @@ int mg_io_0001_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE mg_io_0001_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET appr_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0001_touch"); @@ -79,7 +79,7 @@ long mg_io_0001_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(appr_amt), 0) INTO :h_sum FROM mg_io_0001_t WHERE biz_date = :h_biz_date; @@ -90,3 +90,4 @@ long mg_io_0001_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0002.c b/app/dbio/mg_io_0002.c index 31cb03b..5e24df8 100644 --- a/app/dbio/mg_io_0002.c +++ b/app/dbio/mg_io_0002.c @@ -94,14 +94,22 @@ int mg_io_0002_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + + #line 17 "app/dbio/mg_io_0002.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/mg_io_0002.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_appr ; + #line 19 "app/dbio/mg_io_0002.pgc" + long h_fee ; + +#line 20 "app/dbio/mg_io_0002.pgc" + long h_vat ; +/* exec sql end declare section */ +#line 21 "app/dbio/mg_io_0002.pgc" if (!key || !out_amount) @@ -110,12 +118,16 @@ int mg_io_0002_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0002_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt , fee_amt , vat_amt from mg_io_0002_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_appr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_vat),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0002.pgc" +#line 32 "app/dbio/mg_io_0002.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +136,7 @@ int mg_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -134,13 +146,13 @@ int mg_io_0002_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0002.pgc" +#line 47 "app/dbio/mg_io_0002.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0002.pgc" +#line 48 "app/dbio/mg_io_0002.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0002.pgc" +#line 49 "app/dbio/mg_io_0002.pgc" if (!key) @@ -150,12 +162,12 @@ int mg_io_0002_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0002_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0002_t set net_amt = $1 , upd_ts = now ( ) where mcht_no = $2 and status_cd = '00' and appr_amt > 0", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0002.pgc" +#line 60 "app/dbio/mg_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +185,13 @@ long mg_io_0002_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0002.pgc" +#line 74 "app/dbio/mg_io_0002.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0002.pgc" - long h_sum ; +#line 75 "app/dbio/mg_io_0002.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0002.pgc" +#line 76 "app/dbio/mg_io_0002.pgc" if (!biz_date) @@ -188,17 +200,18 @@ long mg_io_0002_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0002_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mg_io_0002_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0002.pgc" +#line 87 "app/dbio/mg_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/mg_io_0002.pgc b/app/dbio/mg_io_0002.pgc index 4aee918..10ad1f5 100644 --- a/app/dbio/mg_io_0002.pgc +++ b/app/dbio/mg_io_0002.pgc @@ -15,7 +15,9 @@ int mg_io_0002_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; - long h_amount; + long h_appr; + long h_fee; + long h_vat; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +26,10 @@ int mg_io_0002_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mg_io_0002_t - WHERE key = :h_key; + EXEC SQL SELECT appr_amt, fee_amt, vat_amt + INTO :h_appr, :h_fee, :h_vat + FROM mg_io_0002_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,7 +37,7 @@ int mg_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -54,8 +56,8 @@ int mg_io_0002_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE mg_io_0002_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET net_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key AND status_cd = '00' AND appr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0002_touch"); @@ -70,7 +72,7 @@ long mg_io_0002_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,8 +81,8 @@ long mg_io_0002_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_cnt FROM mg_io_0002_t WHERE biz_date = :h_biz_date; @@ -88,5 +90,6 @@ long mg_io_0002_total(const char *biz_date) TX_DBIO_LOG_ERR("mg_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/mg_io_0003.c b/app/dbio/mg_io_0003.c index 14c0d32..18ae4b1 100644 --- a/app/dbio/mg_io_0003.c +++ b/app/dbio/mg_io_0003.c @@ -110,12 +110,12 @@ int mg_io_0003_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0003_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select h . net_amt from mg_io_0003_t h join mg_io_0003_map_t m on m . mcht_no = h . mcht_no where h . mcht_no = $1 and m . use_yn = 'Y'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0003.pgc" +#line 31 "app/dbio/mg_io_0003.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int mg_io_0003_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0003.pgc" +#line 46 "app/dbio/mg_io_0003.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0003.pgc" +#line 47 "app/dbio/mg_io_0003.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0003.pgc" +#line 48 "app/dbio/mg_io_0003.pgc" if (!key) @@ -150,10 +150,10 @@ int mg_io_0003_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0003_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_io_0003_log_t ( mcht_no , appr_amt , reg_ts ) values ( $1 , $2 , now ( ) )", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} #line 58 "app/dbio/mg_io_0003.pgc" @@ -162,8 +162,6 @@ int mg_io_0003_touch(const char *key, long amount) TX_DBIO_LOG_ERR("mg_io_0003_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -172,14 +170,18 @@ long mg_io_0003_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/mg_io_0003.pgc" +#line 70 "app/dbio/mg_io_0003.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0003.pgc" - long h_sum ; +#line 71 "app/dbio/mg_io_0003.pgc" + long h_avg ; + +#line 72 "app/dbio/mg_io_0003.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0003.pgc" +#line 73 "app/dbio/mg_io_0003.pgc" if (!biz_date) @@ -188,17 +190,20 @@ long mg_io_0003_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0003_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select avg ( appr_amt ) from mg_io_0003_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0003.pgc" + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 84 "app/dbio/mg_io_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0003_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/mg_io_0003.pgc b/app/dbio/mg_io_0003.pgc index 64fc090..69e2c51 100644 --- a/app/dbio/mg_io_0003.pgc +++ b/app/dbio/mg_io_0003.pgc @@ -24,10 +24,11 @@ int mg_io_0003_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT h.net_amt INTO :h_amount - FROM mg_io_0003_t - WHERE key = :h_key; + FROM mg_io_0003_t h + JOIN mg_io_0003_map_t m ON m.mcht_no = h.mcht_no + WHERE h.mcht_no = :h_key AND m.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,16 +54,13 @@ int mg_io_0003_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE mg_io_0003_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL INSERT INTO mg_io_0003_log_t (mcht_no, appr_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0003_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -70,7 +68,8 @@ long mg_io_0003_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_avg; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +78,17 @@ long mg_io_0003_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mg_io_0003_t + EXEC SQL SELECT avg(appr_amt) + INTO :h_avg :h_ind + FROM mg_io_0003_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0003_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/mg_io_0004.c b/app/dbio/mg_io_0004.c index 6dcf186..87b29f0 100644 --- a/app/dbio/mg_io_0004.c +++ b/app/dbio/mg_io_0004.c @@ -94,14 +94,18 @@ int mg_io_0004_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/mg_io_0004.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/mg_io_0004.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/mg_io_0004.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/mg_io_0004.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int mg_io_0004_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0004_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select bal_amt from mg_io_0004_bal_t where acct_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0004.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/mg_io_0004.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int mg_io_0004_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0004_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int mg_io_0004_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0004.pgc" +#line 48 "app/dbio/mg_io_0004.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0004.pgc" +#line 49 "app/dbio/mg_io_0004.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0004.pgc" +#line 50 "app/dbio/mg_io_0004.pgc" if (!key) @@ -150,20 +156,31 @@ int mg_io_0004_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0004_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0004_bal_t set bal_amt = $1 , upd_ts = now ( ) where acct_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0004.pgc" +#line 61 "app/dbio/mg_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_io_0004_bal_t ( acct_no , bal_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 69 "app/dbio/mg_io_0004.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0004_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -173,13 +190,13 @@ long mg_io_0004_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0004.pgc" +#line 81 "app/dbio/mg_io_0004.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0004.pgc" +#line 82 "app/dbio/mg_io_0004.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0004.pgc" +#line 83 "app/dbio/mg_io_0004.pgc" if (!biz_date) @@ -188,17 +205,20 @@ long mg_io_0004_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0004_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( net_amt ) , 0 ) from mg_io_0004_t where biz_date = $1 group by biz_date having sum ( net_amt ) > 0 limit 1", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0004.pgc" +#line 97 "app/dbio/mg_io_0004.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0004_total"); return -1; } return h_sum; } + diff --git a/app/dbio/mg_io_0004.pgc b/app/dbio/mg_io_0004.pgc index 8d8131c..ee21afc 100644 --- a/app/dbio/mg_io_0004.pgc +++ b/app/dbio/mg_io_0004.pgc @@ -16,6 +16,7 @@ int mg_io_0004_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int mg_io_0004_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mg_io_0004_t - WHERE key = :h_key; + EXEC SQL SELECT bal_amt + INTO :h_amount :h_ind + FROM mg_io_0004_bal_t + WHERE acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int mg_io_0004_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0004_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -53,16 +56,22 @@ int mg_io_0004_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE mg_io_0004_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE mg_io_0004_bal_t + SET bal_amt = :h_amount, upd_ts = now() + WHERE acct_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + EXEC SQL INSERT INTO mg_io_0004_bal_t (acct_no, bal_amt, upd_ts) + VALUES (:h_key, :h_amount, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0004_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -79,14 +88,20 @@ long mg_io_0004_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(net_amt), 0) INTO :h_sum FROM mg_io_0004_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + GROUP BY biz_date + HAVING sum(net_amt) > 0 + LIMIT 1; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0004_total"); return -1; } return h_sum; } + diff --git a/app/dbio/mg_io_0005.c b/app/dbio/mg_io_0005.c index 60d1ef2..708eb77 100644 --- a/app/dbio/mg_io_0005.c +++ b/app/dbio/mg_io_0005.c @@ -110,12 +110,12 @@ int mg_io_0005_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0005_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select req_amt from mg_io_0005_t where mcht_no = $1 and status_cd = '00' and cancel_yn = 'N'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0005.pgc" +#line 31 "app/dbio/mg_io_0005.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int mg_io_0005_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0005.pgc" +#line 46 "app/dbio/mg_io_0005.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0005.pgc" +#line 47 "app/dbio/mg_io_0005.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0005.pgc" +#line 48 "app/dbio/mg_io_0005.pgc" if (!key) @@ -150,9 +150,7 @@ int mg_io_0005_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0005_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from mg_io_0005_tmp_t where ref_key = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/mg_io_0005.pgc" @@ -172,14 +170,18 @@ long mg_io_0005_total(const char *biz_date) /* exec sql begin declare section */ + #line 72 "app/dbio/mg_io_0005.pgc" char h_biz_date [ 9 ] ; #line 73 "app/dbio/mg_io_0005.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_row ; + #line 74 "app/dbio/mg_io_0005.pgc" + long acc = 0 ; +/* exec sql end declare section */ +#line 75 "app/dbio/mg_io_0005.pgc" if (!biz_date) @@ -188,17 +190,42 @@ long mg_io_0005_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0005_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0005.pgc" + ECPGset_var( 0, ( h_biz_date ), __LINE__);\ + /* declare cur_mg_io_0005_t cursor for select net_amt from mg_io_0005_sum_t where biz_date = $1 */ +#line 84 "app/dbio/mg_io_0005.pgc" +#line 84 "app/dbio/mg_io_0005.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_mg_io_0005_t cursor for select net_amt from mg_io_0005_sum_t where biz_date = $1 ", + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 85 "app/dbio/mg_io_0005.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0005_total"); return -1; } - return h_sum; + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_mg_io_0005_t", ECPGt_EOIT, + ECPGt_long,&(h_row),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 91 "app/dbio/mg_io_0005.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0005_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_io_0005_t", ECPGt_EOIT, ECPGt_EORT);} +#line 96 "app/dbio/mg_io_0005.pgc" + + return -1; + } + acc += h_row; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_io_0005_t", ECPGt_EOIT, ECPGt_EORT);} +#line 101 "app/dbio/mg_io_0005.pgc" + + + return acc; } + diff --git a/app/dbio/mg_io_0005.pgc b/app/dbio/mg_io_0005.pgc index 83a73d3..495b6c3 100644 --- a/app/dbio/mg_io_0005.pgc +++ b/app/dbio/mg_io_0005.pgc @@ -24,10 +24,11 @@ int mg_io_0005_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT req_amt INTO :h_amount FROM mg_io_0005_t - WHERE key = :h_key; + WHERE mcht_no = :h_key AND status_cd = '00' + AND cancel_yn = 'N'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,8 @@ int mg_io_0005_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE mg_io_0005_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM mg_io_0005_tmp_t + WHERE ref_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0005_touch"); @@ -70,7 +70,8 @@ long mg_io_0005_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_row; + long acc = 0; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +80,26 @@ long mg_io_0005_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mg_io_0005_t - WHERE biz_date = :h_biz_date; - + EXEC SQL DECLARE cur_mg_io_0005_t CURSOR FOR + SELECT net_amt FROM mg_io_0005_sum_t WHERE biz_date = :h_biz_date; + EXEC SQL OPEN cur_mg_io_0005_t; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0005_total"); return -1; } - return h_sum; + for (;;) { + EXEC SQL FETCH cur_mg_io_0005_t INTO :h_row; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0005_total"); + EXEC SQL CLOSE cur_mg_io_0005_t; + return -1; + } + acc += h_row; + } + EXEC SQL CLOSE cur_mg_io_0005_t; + + return acc; } + diff --git a/app/dbio/mg_io_0006.c b/app/dbio/mg_io_0006.c index fc61a3d..70d19d0 100644 --- a/app/dbio/mg_io_0006.c +++ b/app/dbio/mg_io_0006.c @@ -94,14 +94,18 @@ int mg_io_0006_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/mg_io_0006.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/mg_io_0006.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/mg_io_0006.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/mg_io_0006.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int mg_io_0006_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0006_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( appr_amt ) from mg_io_0006_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0006.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/mg_io_0006.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int mg_io_0006_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0006_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int mg_io_0006_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0006.pgc" +#line 48 "app/dbio/mg_io_0006.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0006.pgc" +#line 49 "app/dbio/mg_io_0006.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0006.pgc" +#line 50 "app/dbio/mg_io_0006.pgc" if (!key) @@ -150,12 +156,14 @@ int mg_io_0006_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0006_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0006_t set fee_amt = $1 , vat_amt = $2 / 10 , upd_ts = now ( ) where mcht_no = $3 ", + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + 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_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0006.pgc" +#line 61 "app/dbio/mg_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -172,14 +180,18 @@ long mg_io_0006_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/mg_io_0006.pgc" +#line 75 "app/dbio/mg_io_0006.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0006.pgc" - long h_sum ; +#line 76 "app/dbio/mg_io_0006.pgc" + long h_max ; + +#line 77 "app/dbio/mg_io_0006.pgc" + long h_min ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0006.pgc" +#line 78 "app/dbio/mg_io_0006.pgc" if (!biz_date) @@ -188,17 +200,20 @@ long mg_io_0006_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0006_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( max ( appr_amt ) , 0 ) , coalesce ( min ( appr_amt ) , 0 ) from mg_io_0006_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0006.pgc" +#line 89 "app/dbio/mg_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0006_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/mg_io_0006.pgc b/app/dbio/mg_io_0006.pgc index 7c2c84b..a647699 100644 --- a/app/dbio/mg_io_0006.pgc +++ b/app/dbio/mg_io_0006.pgc @@ -16,6 +16,7 @@ int mg_io_0006_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int mg_io_0006_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mg_io_0006_t - WHERE key = :h_key; + EXEC SQL SELECT max(appr_amt) + INTO :h_amount :h_ind + FROM mg_io_0006_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int mg_io_0006_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0006_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -54,8 +57,8 @@ int mg_io_0006_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE mg_io_0006_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET fee_amt = :h_amount, vat_amt = :h_amount / 10, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0006_touch"); @@ -70,7 +73,8 @@ long mg_io_0006_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_max; + long h_min; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +83,15 @@ long mg_io_0006_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mg_io_0006_t + EXEC SQL SELECT coalesce(max(appr_amt), 0), coalesce(min(appr_amt), 0) + INTO :h_max, :h_min + FROM mg_io_0006_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0006_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/mg_io_0007.c b/app/dbio/mg_io_0007.c index 71b8431..c47c8a7 100644 --- a/app/dbio/mg_io_0007.c +++ b/app/dbio/mg_io_0007.c @@ -110,12 +110,12 @@ int mg_io_0007_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0007_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select net_amt from mg_io_0007_t where mcht_no in ( select mcht_no from mg_io_0007_map_t where grp_key = $1 )", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0007.pgc" +#line 31 "app/dbio/mg_io_0007.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int mg_io_0007_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0007.pgc" +#line 46 "app/dbio/mg_io_0007.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0007.pgc" +#line 47 "app/dbio/mg_io_0007.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0007.pgc" +#line 48 "app/dbio/mg_io_0007.pgc" if (!key) @@ -150,12 +150,12 @@ int mg_io_0007_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0007_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0007_t set status_cd = case when $1 > 0 then '00' else '99' end , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0007.pgc" +#line 60 "app/dbio/mg_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long mg_io_0007_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0007.pgc" +#line 74 "app/dbio/mg_io_0007.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0007.pgc" +#line 75 "app/dbio/mg_io_0007.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0007.pgc" +#line 76 "app/dbio/mg_io_0007.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long mg_io_0007_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0007_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . appr_amt ) , 0 ) from mg_io_0007_dtl_t d join mg_io_0007_t h on h . mcht_no = d . mcht_no where d . biz_date = $1 and h . status_cd = '00'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0007.pgc" +#line 88 "app/dbio/mg_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long mg_io_0007_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0007.pgc b/app/dbio/mg_io_0007.pgc index f1678b3..29bf1aa 100644 --- a/app/dbio/mg_io_0007.pgc +++ b/app/dbio/mg_io_0007.pgc @@ -24,10 +24,11 @@ int mg_io_0007_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT net_amt INTO :h_amount FROM mg_io_0007_t - WHERE key = :h_key; + WHERE mcht_no IN + (SELECT mcht_no FROM mg_io_0007_map_t WHERE grp_key = :h_key); if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,9 @@ int mg_io_0007_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE mg_io_0007_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET status_cd = CASE WHEN :h_amount > 0 THEN '00' ELSE '99' END, + upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0007_touch"); @@ -79,10 +81,11 @@ long mg_io_0007_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.appr_amt), 0) INTO :h_sum - FROM mg_io_0007_t - WHERE biz_date = :h_biz_date; + FROM mg_io_0007_dtl_t d + JOIN mg_io_0007_t h ON h.mcht_no = d.mcht_no + WHERE d.biz_date = :h_biz_date AND h.status_cd = '00'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0007_total"); @@ -90,3 +93,4 @@ long mg_io_0007_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0008.c b/app/dbio/mg_io_0008.c index e7ff1a4..7805b94 100644 --- a/app/dbio/mg_io_0008.c +++ b/app/dbio/mg_io_0008.c @@ -110,20 +110,43 @@ int mg_io_0008_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0008_t where key = $1 ", + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cur_mg_io_0008_f cursor for select appr_amt from mg_io_0008_dtl_t where mcht_no = $1 order by seq desc */ +#line 29 "app/dbio/mg_io_0008.pgc" + +#line 29 "app/dbio/mg_io_0008.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_mg_io_0008_f cursor for select appr_amt from mg_io_0008_dtl_t where mcht_no = $1 order by seq desc", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 30 "app/dbio/mg_io_0008.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0008_fetch"); return TX_EDB; } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_mg_io_0008_f", ECPGt_EOIT, + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 35 "app/dbio/mg_io_0008.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_io_0008_f", ECPGt_EOIT, ECPGt_EORT);} +#line 37 "app/dbio/mg_io_0008.pgc" + + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0008_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_io_0008_f", ECPGt_EOIT, ECPGt_EORT);} +#line 42 "app/dbio/mg_io_0008.pgc" + + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_io_0008_f", ECPGt_EOIT, ECPGt_EORT);} +#line 45 "app/dbio/mg_io_0008.pgc" + + *out_amount = h_amount; return TX_OK; } @@ -134,13 +157,13 @@ int mg_io_0008_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0008.pgc" +#line 54 "app/dbio/mg_io_0008.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0008.pgc" +#line 55 "app/dbio/mg_io_0008.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0008.pgc" +#line 56 "app/dbio/mg_io_0008.pgc" if (!key) @@ -150,12 +173,12 @@ int mg_io_0008_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0008_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0008_acc_t set accum_amt = accum_amt + $1 , cnt = cnt + 1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0008.pgc" +#line 67 "app/dbio/mg_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +196,13 @@ long mg_io_0008_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0008.pgc" +#line 81 "app/dbio/mg_io_0008.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0008.pgc" - long h_sum ; +#line 82 "app/dbio/mg_io_0008.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0008.pgc" +#line 83 "app/dbio/mg_io_0008.pgc" if (!biz_date) @@ -188,17 +211,18 @@ long mg_io_0008_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0008_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct mcht_no ) from mg_io_0008_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0008.pgc" +#line 94 "app/dbio/mg_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0008_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/mg_io_0008.pgc b/app/dbio/mg_io_0008.pgc index e8d7a5f..ff796f7 100644 --- a/app/dbio/mg_io_0008.pgc +++ b/app/dbio/mg_io_0008.pgc @@ -24,17 +24,26 @@ int mg_io_0008_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mg_io_0008_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL DECLARE cur_mg_io_0008_f CURSOR FOR + SELECT appr_amt FROM mg_io_0008_dtl_t + WHERE mcht_no = :h_key ORDER BY seq DESC; + EXEC SQL OPEN cur_mg_io_0008_f; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0008_fetch"); return TX_EDB; } + EXEC SQL FETCH cur_mg_io_0008_f INTO :h_amount; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE cur_mg_io_0008_f; + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0008_fetch"); + EXEC SQL CLOSE cur_mg_io_0008_f; + return TX_EDB; + } + EXEC SQL CLOSE cur_mg_io_0008_f; + *out_amount = h_amount; return TX_OK; } @@ -53,9 +62,9 @@ int mg_io_0008_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE mg_io_0008_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE mg_io_0008_acc_t + SET accum_amt = accum_amt + :h_amount, cnt = cnt + 1, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0008_touch"); @@ -70,7 +79,7 @@ long mg_io_0008_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +88,15 @@ long mg_io_0008_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mg_io_0008_t + EXEC SQL SELECT count(DISTINCT mcht_no) + INTO :h_cnt + FROM mg_io_0008_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0008_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/mg_io_0009.c b/app/dbio/mg_io_0009.c index 6bb98a3..f2d321c 100644 --- a/app/dbio/mg_io_0009.c +++ b/app/dbio/mg_io_0009.c @@ -110,12 +110,12 @@ int mg_io_0009_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0009_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when status_cd = '00' then appr_amt else 0 end from mg_io_0009_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0009.pgc" +#line 31 "app/dbio/mg_io_0009.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int mg_io_0009_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0009.pgc" +#line 46 "app/dbio/mg_io_0009.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0009.pgc" +#line 47 "app/dbio/mg_io_0009.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0009.pgc" +#line 48 "app/dbio/mg_io_0009.pgc" if (!key) @@ -150,10 +150,10 @@ int mg_io_0009_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0009_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from mg_io_0009_bal_t where acct_no = $1 and bal_amt <= $2 ", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} #line 58 "app/dbio/mg_io_0009.pgc" @@ -188,12 +188,12 @@ long mg_io_0009_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0009_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( cancel_amt ) , 0 ) from mg_io_0009_t where biz_date = $1 and status_cd = '90' and cancel_yn = 'Y'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0009.pgc" +#line 86 "app/dbio/mg_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long mg_io_0009_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0009.pgc b/app/dbio/mg_io_0009.pgc index 736ec90..68ed082 100644 --- a/app/dbio/mg_io_0009.pgc +++ b/app/dbio/mg_io_0009.pgc @@ -24,10 +24,11 @@ int mg_io_0009_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT + CASE WHEN status_cd = '00' THEN appr_amt ELSE 0 END INTO :h_amount FROM mg_io_0009_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,8 @@ int mg_io_0009_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE mg_io_0009_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM mg_io_0009_bal_t + WHERE acct_no = :h_key AND bal_amt <= :h_amount; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0009_touch"); @@ -79,10 +79,11 @@ long mg_io_0009_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(cancel_amt), 0) INTO :h_sum FROM mg_io_0009_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + AND status_cd = '90' AND cancel_yn = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0009_total"); @@ -90,3 +91,4 @@ long mg_io_0009_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0010.c b/app/dbio/mg_io_0010.c index e52ddcd..113504b 100644 --- a/app/dbio/mg_io_0010.c +++ b/app/dbio/mg_io_0010.c @@ -110,7 +110,7 @@ int mg_io_0010_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0010_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt from mg_io_0010_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), @@ -150,20 +150,29 @@ int mg_io_0010_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0010_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0010_t set req_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/mg_io_0010.pgc" + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0010_touch"); + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_io_0010_hist_t ( mcht_no , req_amt , reg_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 64 "app/dbio/mg_io_0010.pgc" + if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0010_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,13 +182,13 @@ long mg_io_0010_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0010.pgc" +#line 76 "app/dbio/mg_io_0010.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0010.pgc" +#line 77 "app/dbio/mg_io_0010.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0010.pgc" +#line 78 "app/dbio/mg_io_0010.pgc" if (!biz_date) @@ -188,12 +197,12 @@ long mg_io_0010_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0010_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( recon_amt ) , 0 ) from mg_io_0010_sum_t where biz_date in ( select biz_date from mg_io_0010_map_t where biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0010.pgc" +#line 90 "app/dbio/mg_io_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +211,4 @@ long mg_io_0010_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0010.pgc b/app/dbio/mg_io_0010.pgc index 7b7f435..adec309 100644 --- a/app/dbio/mg_io_0010.pgc +++ b/app/dbio/mg_io_0010.pgc @@ -24,10 +24,10 @@ int mg_io_0010_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT appr_amt INTO :h_amount FROM mg_io_0010_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,15 +54,19 @@ int mg_io_0010_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE mg_io_0010_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET req_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0010_touch"); + return TX_EDB; + } + EXEC SQL INSERT INTO mg_io_0010_hist_t (mcht_no, req_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0010_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -79,10 +83,11 @@ long mg_io_0010_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(recon_amt), 0) INTO :h_sum - FROM mg_io_0010_t - WHERE biz_date = :h_biz_date; + FROM mg_io_0010_sum_t + WHERE biz_date IN + (SELECT biz_date FROM mg_io_0010_map_t WHERE biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0010_total"); @@ -90,3 +95,4 @@ long mg_io_0010_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0011.c b/app/dbio/mg_io_0011.c index 3d1c834..692c729 100644 --- a/app/dbio/mg_io_0011.c +++ b/app/dbio/mg_io_0011.c @@ -94,14 +94,22 @@ int mg_io_0011_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + + #line 17 "app/dbio/mg_io_0011.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/mg_io_0011.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_appr ; + #line 19 "app/dbio/mg_io_0011.pgc" + long h_fee ; + +#line 20 "app/dbio/mg_io_0011.pgc" + long h_vat ; +/* exec sql end declare section */ +#line 21 "app/dbio/mg_io_0011.pgc" if (!key || !out_amount) @@ -110,12 +118,16 @@ int mg_io_0011_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0011_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt , fee_amt , vat_amt from mg_io_0011_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_appr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_vat),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0011.pgc" +#line 32 "app/dbio/mg_io_0011.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +136,7 @@ int mg_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -134,13 +146,13 @@ int mg_io_0011_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0011.pgc" +#line 47 "app/dbio/mg_io_0011.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0011.pgc" +#line 48 "app/dbio/mg_io_0011.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0011.pgc" +#line 49 "app/dbio/mg_io_0011.pgc" if (!key) @@ -150,12 +162,12 @@ int mg_io_0011_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0011_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0011_t set appr_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0011.pgc" +#line 60 "app/dbio/mg_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +185,13 @@ long mg_io_0011_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0011.pgc" +#line 74 "app/dbio/mg_io_0011.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0011.pgc" - long h_sum ; +#line 75 "app/dbio/mg_io_0011.pgc" + long h_flag ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0011.pgc" +#line 76 "app/dbio/mg_io_0011.pgc" if (!biz_date) @@ -188,17 +200,18 @@ long mg_io_0011_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0011_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mg_io_0011_t where exists ( select 1 from mg_io_0011_dtl_t d where d . biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0011.pgc" +#line 89 "app/dbio/mg_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0011_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/mg_io_0011.pgc b/app/dbio/mg_io_0011.pgc index 2da756e..ceab25c 100644 --- a/app/dbio/mg_io_0011.pgc +++ b/app/dbio/mg_io_0011.pgc @@ -15,7 +15,9 @@ int mg_io_0011_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; - long h_amount; + long h_appr; + long h_fee; + long h_vat; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +26,10 @@ int mg_io_0011_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mg_io_0011_t - WHERE key = :h_key; + EXEC SQL SELECT appr_amt, fee_amt, vat_amt + INTO :h_appr, :h_fee, :h_vat + FROM mg_io_0011_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,7 +37,7 @@ int mg_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -54,8 +56,8 @@ int mg_io_0011_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE mg_io_0011_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET appr_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0011_touch"); @@ -70,7 +72,7 @@ long mg_io_0011_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_flag; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +81,17 @@ long mg_io_0011_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_flag FROM mg_io_0011_t - WHERE biz_date = :h_biz_date; + WHERE EXISTS + (SELECT 1 FROM mg_io_0011_dtl_t d + WHERE d.biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0011_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/mg_io_0012.c b/app/dbio/mg_io_0012.c index 1b32ffc..05e7d91 100644 --- a/app/dbio/mg_io_0012.c +++ b/app/dbio/mg_io_0012.c @@ -110,12 +110,12 @@ int mg_io_0012_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0012_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select h . net_amt from mg_io_0012_t h join mg_io_0012_map_t m on m . mcht_no = h . mcht_no where h . mcht_no = $1 and m . use_yn = 'Y'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0012.pgc" +#line 31 "app/dbio/mg_io_0012.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int mg_io_0012_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0012.pgc" +#line 46 "app/dbio/mg_io_0012.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0012.pgc" +#line 47 "app/dbio/mg_io_0012.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0012.pgc" +#line 48 "app/dbio/mg_io_0012.pgc" if (!key) @@ -150,12 +150,12 @@ int mg_io_0012_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0012_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0012_t set net_amt = $1 , upd_ts = now ( ) where mcht_no = $2 and status_cd = '00' and appr_amt > 0", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0012.pgc" +#line 59 "app/dbio/mg_io_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long mg_io_0012_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0012.pgc" +#line 73 "app/dbio/mg_io_0012.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0012.pgc" +#line 74 "app/dbio/mg_io_0012.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0012.pgc" +#line 75 "app/dbio/mg_io_0012.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long mg_io_0012_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0012_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( appr_amt ) , 0 ) from mg_io_0012_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0012.pgc" +#line 86 "app/dbio/mg_io_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long mg_io_0012_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0012.pgc b/app/dbio/mg_io_0012.pgc index 5c697d4..8869ffd 100644 --- a/app/dbio/mg_io_0012.pgc +++ b/app/dbio/mg_io_0012.pgc @@ -24,10 +24,11 @@ int mg_io_0012_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT h.net_amt INTO :h_amount - FROM mg_io_0012_t - WHERE key = :h_key; + FROM mg_io_0012_t h + JOIN mg_io_0012_map_t m ON m.mcht_no = h.mcht_no + WHERE h.mcht_no = :h_key AND m.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,8 @@ int mg_io_0012_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE mg_io_0012_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET net_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key AND status_cd = '00' AND appr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0012_touch"); @@ -79,7 +80,7 @@ long mg_io_0012_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(appr_amt), 0) INTO :h_sum FROM mg_io_0012_t WHERE biz_date = :h_biz_date; @@ -90,3 +91,4 @@ long mg_io_0012_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0013.c b/app/dbio/mg_io_0013.c index 489d1a0..1110469 100644 --- a/app/dbio/mg_io_0013.c +++ b/app/dbio/mg_io_0013.c @@ -94,14 +94,18 @@ int mg_io_0013_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/mg_io_0013.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/mg_io_0013.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/mg_io_0013.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/mg_io_0013.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int mg_io_0013_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0013_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select bal_amt from mg_io_0013_bal_t where acct_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0013.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/mg_io_0013.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int mg_io_0013_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0013_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int mg_io_0013_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0013.pgc" +#line 48 "app/dbio/mg_io_0013.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0013.pgc" +#line 49 "app/dbio/mg_io_0013.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0013.pgc" +#line 50 "app/dbio/mg_io_0013.pgc" if (!key) @@ -150,20 +156,18 @@ int mg_io_0013_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0013_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_io_0013_log_t ( mcht_no , appr_amt , reg_ts ) values ( $1 , $2 , now ( ) )", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0013.pgc" +#line 60 "app/dbio/mg_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -177,7 +181,7 @@ long mg_io_0013_total(const char *biz_date) char h_biz_date [ 9 ] ; #line 73 "app/dbio/mg_io_0013.pgc" - long h_sum ; + long h_cnt ; /* exec sql end declare section */ #line 74 "app/dbio/mg_io_0013.pgc" @@ -188,10 +192,10 @@ long mg_io_0013_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0013_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mg_io_0013_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 85 "app/dbio/mg_io_0013.pgc" @@ -200,5 +204,6 @@ long mg_io_0013_total(const char *biz_date) TX_DBIO_LOG_ERR("mg_io_0013_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/mg_io_0013.pgc b/app/dbio/mg_io_0013.pgc index e7ff88b..63e3809 100644 --- a/app/dbio/mg_io_0013.pgc +++ b/app/dbio/mg_io_0013.pgc @@ -16,6 +16,7 @@ int mg_io_0013_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int mg_io_0013_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mg_io_0013_t - WHERE key = :h_key; + EXEC SQL SELECT bal_amt + INTO :h_amount :h_ind + FROM mg_io_0013_bal_t + WHERE acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int mg_io_0013_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0013_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -53,16 +56,13 @@ int mg_io_0013_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE mg_io_0013_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL INSERT INTO mg_io_0013_log_t (mcht_no, appr_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -70,7 +70,7 @@ long mg_io_0013_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,8 +79,8 @@ long mg_io_0013_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_cnt FROM mg_io_0013_t WHERE biz_date = :h_biz_date; @@ -88,5 +88,6 @@ long mg_io_0013_total(const char *biz_date) TX_DBIO_LOG_ERR("mg_io_0013_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/mg_io_0014.c b/app/dbio/mg_io_0014.c index 76e8f8e..438df4a 100644 --- a/app/dbio/mg_io_0014.c +++ b/app/dbio/mg_io_0014.c @@ -110,12 +110,12 @@ int mg_io_0014_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0014_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select req_amt from mg_io_0014_t where mcht_no = $1 and status_cd = '00' and cancel_yn = 'N'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0014.pgc" +#line 31 "app/dbio/mg_io_0014.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int mg_io_0014_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0014.pgc" +#line 46 "app/dbio/mg_io_0014.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0014.pgc" +#line 47 "app/dbio/mg_io_0014.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0014.pgc" +#line 48 "app/dbio/mg_io_0014.pgc" if (!key) @@ -150,20 +150,31 @@ int mg_io_0014_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0014_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0014_bal_t set bal_amt = $1 , upd_ts = now ( ) where acct_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0014.pgc" +#line 59 "app/dbio/mg_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0014_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_io_0014_bal_t ( acct_no , bal_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 67 "app/dbio/mg_io_0014.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0014_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -172,14 +183,18 @@ long mg_io_0014_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/mg_io_0014.pgc" +#line 79 "app/dbio/mg_io_0014.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0014.pgc" - long h_sum ; +#line 80 "app/dbio/mg_io_0014.pgc" + long h_avg ; + +#line 81 "app/dbio/mg_io_0014.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0014.pgc" +#line 82 "app/dbio/mg_io_0014.pgc" if (!biz_date) @@ -188,17 +203,20 @@ long mg_io_0014_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0014_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select avg ( appr_amt ) from mg_io_0014_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0014.pgc" + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 93 "app/dbio/mg_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0014_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/mg_io_0014.pgc b/app/dbio/mg_io_0014.pgc index 990448b..4684deb 100644 --- a/app/dbio/mg_io_0014.pgc +++ b/app/dbio/mg_io_0014.pgc @@ -24,10 +24,11 @@ int mg_io_0014_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT req_amt INTO :h_amount FROM mg_io_0014_t - WHERE key = :h_key; + WHERE mcht_no = :h_key AND status_cd = '00' + AND cancel_yn = 'N'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,16 +54,22 @@ int mg_io_0014_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE mg_io_0014_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE mg_io_0014_bal_t + SET bal_amt = :h_amount, upd_ts = now() + WHERE acct_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0014_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + EXEC SQL INSERT INTO mg_io_0014_bal_t (acct_no, bal_amt, upd_ts) + VALUES (:h_key, :h_amount, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0014_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -70,7 +77,8 @@ long mg_io_0014_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_avg; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +87,17 @@ long mg_io_0014_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mg_io_0014_t + EXEC SQL SELECT avg(appr_amt) + INTO :h_avg :h_ind + FROM mg_io_0014_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0014_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/mg_io_0015.c b/app/dbio/mg_io_0015.c index 34d604e..2bd9705 100644 --- a/app/dbio/mg_io_0015.c +++ b/app/dbio/mg_io_0015.c @@ -94,14 +94,18 @@ int mg_io_0015_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/mg_io_0015.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/mg_io_0015.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/mg_io_0015.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/mg_io_0015.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int mg_io_0015_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0015_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( appr_amt ) from mg_io_0015_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0015.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/mg_io_0015.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int mg_io_0015_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0015_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int mg_io_0015_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0015.pgc" +#line 48 "app/dbio/mg_io_0015.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0015.pgc" +#line 49 "app/dbio/mg_io_0015.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0015.pgc" +#line 50 "app/dbio/mg_io_0015.pgc" if (!key) @@ -150,12 +156,10 @@ int mg_io_0015_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0015_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from mg_io_0015_tmp_t where ref_key = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0015.pgc" +#line 60 "app/dbio/mg_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +177,13 @@ long mg_io_0015_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0015.pgc" +#line 74 "app/dbio/mg_io_0015.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0015.pgc" +#line 75 "app/dbio/mg_io_0015.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0015.pgc" +#line 76 "app/dbio/mg_io_0015.pgc" if (!biz_date) @@ -188,17 +192,20 @@ long mg_io_0015_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0015_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( net_amt ) , 0 ) from mg_io_0015_t where biz_date = $1 group by biz_date having sum ( net_amt ) > 0 limit 1", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0015.pgc" +#line 90 "app/dbio/mg_io_0015.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0015_total"); return -1; } return h_sum; } + diff --git a/app/dbio/mg_io_0015.pgc b/app/dbio/mg_io_0015.pgc index 0b35522..c96af53 100644 --- a/app/dbio/mg_io_0015.pgc +++ b/app/dbio/mg_io_0015.pgc @@ -16,6 +16,7 @@ int mg_io_0015_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int mg_io_0015_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mg_io_0015_t - WHERE key = :h_key; + EXEC SQL SELECT max(appr_amt) + INTO :h_amount :h_ind + FROM mg_io_0015_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int mg_io_0015_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0015_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -53,9 +56,8 @@ int mg_io_0015_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE mg_io_0015_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM mg_io_0015_tmp_t + WHERE ref_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0015_touch"); @@ -79,14 +81,20 @@ long mg_io_0015_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(net_amt), 0) INTO :h_sum FROM mg_io_0015_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + GROUP BY biz_date + HAVING sum(net_amt) > 0 + LIMIT 1; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0015_total"); return -1; } return h_sum; } + diff --git a/app/dbio/mg_io_0016.c b/app/dbio/mg_io_0016.c index 99b5a97..d4cf06a 100644 --- a/app/dbio/mg_io_0016.c +++ b/app/dbio/mg_io_0016.c @@ -110,12 +110,12 @@ int mg_io_0016_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0016_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select net_amt from mg_io_0016_t where mcht_no in ( select mcht_no from mg_io_0016_map_t where grp_key = $1 )", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0016.pgc" +#line 31 "app/dbio/mg_io_0016.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int mg_io_0016_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0016.pgc" +#line 46 "app/dbio/mg_io_0016.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0016.pgc" +#line 47 "app/dbio/mg_io_0016.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0016.pgc" +#line 48 "app/dbio/mg_io_0016.pgc" if (!key) @@ -150,12 +150,14 @@ int mg_io_0016_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0016_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0016_t set fee_amt = $1 , vat_amt = $2 / 10 , upd_ts = now ( ) where mcht_no = $3 ", + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + 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_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0016.pgc" +#line 59 "app/dbio/mg_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -172,14 +174,18 @@ long mg_io_0016_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/mg_io_0016.pgc" +#line 73 "app/dbio/mg_io_0016.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0016.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/mg_io_0016.pgc" + long h_row ; + +#line 75 "app/dbio/mg_io_0016.pgc" + long acc = 0 ; +/* exec sql end declare section */ +#line 76 "app/dbio/mg_io_0016.pgc" if (!biz_date) @@ -188,17 +194,42 @@ long mg_io_0016_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0016_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGset_var( 0, ( h_biz_date ), __LINE__);\ + /* declare cur_mg_io_0016_t cursor for select net_amt from mg_io_0016_sum_t where biz_date = $1 */ #line 85 "app/dbio/mg_io_0016.pgc" +#line 85 "app/dbio/mg_io_0016.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_mg_io_0016_t cursor for select net_amt from mg_io_0016_sum_t where biz_date = $1 ", + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 86 "app/dbio/mg_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0016_total"); return -1; } - return h_sum; + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_mg_io_0016_t", ECPGt_EOIT, + ECPGt_long,&(h_row),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 92 "app/dbio/mg_io_0016.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0016_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_io_0016_t", ECPGt_EOIT, ECPGt_EORT);} +#line 97 "app/dbio/mg_io_0016.pgc" + + return -1; + } + acc += h_row; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_io_0016_t", ECPGt_EOIT, ECPGt_EORT);} +#line 102 "app/dbio/mg_io_0016.pgc" + + + return acc; } + diff --git a/app/dbio/mg_io_0016.pgc b/app/dbio/mg_io_0016.pgc index 7ee0ccf..8fd70fb 100644 --- a/app/dbio/mg_io_0016.pgc +++ b/app/dbio/mg_io_0016.pgc @@ -24,10 +24,11 @@ int mg_io_0016_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT net_amt INTO :h_amount FROM mg_io_0016_t - WHERE key = :h_key; + WHERE mcht_no IN + (SELECT mcht_no FROM mg_io_0016_map_t WHERE grp_key = :h_key); if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,8 @@ int mg_io_0016_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE mg_io_0016_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET fee_amt = :h_amount, vat_amt = :h_amount / 10, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0016_touch"); @@ -70,7 +71,8 @@ long mg_io_0016_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_row; + long acc = 0; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +81,26 @@ long mg_io_0016_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mg_io_0016_t - WHERE biz_date = :h_biz_date; - + EXEC SQL DECLARE cur_mg_io_0016_t CURSOR FOR + SELECT net_amt FROM mg_io_0016_sum_t WHERE biz_date = :h_biz_date; + EXEC SQL OPEN cur_mg_io_0016_t; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0016_total"); return -1; } - return h_sum; + for (;;) { + EXEC SQL FETCH cur_mg_io_0016_t INTO :h_row; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0016_total"); + EXEC SQL CLOSE cur_mg_io_0016_t; + return -1; + } + acc += h_row; + } + EXEC SQL CLOSE cur_mg_io_0016_t; + + return acc; } + diff --git a/app/dbio/mg_io_0017.c b/app/dbio/mg_io_0017.c index 67378e2..d361550 100644 --- a/app/dbio/mg_io_0017.c +++ b/app/dbio/mg_io_0017.c @@ -110,20 +110,43 @@ int mg_io_0017_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0017_t where key = $1 ", + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cur_mg_io_0017_f cursor for select appr_amt from mg_io_0017_dtl_t where mcht_no = $1 order by seq desc */ +#line 29 "app/dbio/mg_io_0017.pgc" + +#line 29 "app/dbio/mg_io_0017.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_mg_io_0017_f cursor for select appr_amt from mg_io_0017_dtl_t where mcht_no = $1 order by seq desc", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 30 "app/dbio/mg_io_0017.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0017_fetch"); return TX_EDB; } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_mg_io_0017_f", ECPGt_EOIT, + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 35 "app/dbio/mg_io_0017.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_io_0017_f", ECPGt_EOIT, ECPGt_EORT);} +#line 37 "app/dbio/mg_io_0017.pgc" + + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0017_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_io_0017_f", ECPGt_EOIT, ECPGt_EORT);} +#line 42 "app/dbio/mg_io_0017.pgc" + + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_io_0017_f", ECPGt_EOIT, ECPGt_EORT);} +#line 45 "app/dbio/mg_io_0017.pgc" + + *out_amount = h_amount; return TX_OK; } @@ -134,13 +157,13 @@ int mg_io_0017_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0017.pgc" +#line 54 "app/dbio/mg_io_0017.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0017.pgc" +#line 55 "app/dbio/mg_io_0017.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0017.pgc" +#line 56 "app/dbio/mg_io_0017.pgc" if (!key) @@ -150,12 +173,12 @@ int mg_io_0017_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0017_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0017_t set status_cd = case when $1 > 0 then '00' else '99' end , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0017.pgc" +#line 68 "app/dbio/mg_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -172,14 +195,18 @@ long mg_io_0017_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/mg_io_0017.pgc" +#line 82 "app/dbio/mg_io_0017.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0017.pgc" - long h_sum ; +#line 83 "app/dbio/mg_io_0017.pgc" + long h_max ; + +#line 84 "app/dbio/mg_io_0017.pgc" + long h_min ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0017.pgc" +#line 85 "app/dbio/mg_io_0017.pgc" if (!biz_date) @@ -188,17 +215,20 @@ long mg_io_0017_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0017_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( max ( appr_amt ) , 0 ) , coalesce ( min ( appr_amt ) , 0 ) from mg_io_0017_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0017.pgc" +#line 96 "app/dbio/mg_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0017_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/mg_io_0017.pgc b/app/dbio/mg_io_0017.pgc index 7116aeb..662bff0 100644 --- a/app/dbio/mg_io_0017.pgc +++ b/app/dbio/mg_io_0017.pgc @@ -24,17 +24,26 @@ int mg_io_0017_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mg_io_0017_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL DECLARE cur_mg_io_0017_f CURSOR FOR + SELECT appr_amt FROM mg_io_0017_dtl_t + WHERE mcht_no = :h_key ORDER BY seq DESC; + EXEC SQL OPEN cur_mg_io_0017_f; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0017_fetch"); return TX_EDB; } + EXEC SQL FETCH cur_mg_io_0017_f INTO :h_amount; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE cur_mg_io_0017_f; + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0017_fetch"); + EXEC SQL CLOSE cur_mg_io_0017_f; + return TX_EDB; + } + EXEC SQL CLOSE cur_mg_io_0017_f; + *out_amount = h_amount; return TX_OK; } @@ -54,8 +63,9 @@ int mg_io_0017_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE mg_io_0017_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET status_cd = CASE WHEN :h_amount > 0 THEN '00' ELSE '99' END, + upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0017_touch"); @@ -70,7 +80,8 @@ long mg_io_0017_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_max; + long h_min; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +90,15 @@ long mg_io_0017_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mg_io_0017_t + EXEC SQL SELECT coalesce(max(appr_amt), 0), coalesce(min(appr_amt), 0) + INTO :h_max, :h_min + FROM mg_io_0017_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0017_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/mg_io_0018.c b/app/dbio/mg_io_0018.c index 62e59a6..05c5c1c 100644 --- a/app/dbio/mg_io_0018.c +++ b/app/dbio/mg_io_0018.c @@ -110,12 +110,12 @@ int mg_io_0018_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0018_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when status_cd = '00' then appr_amt else 0 end from mg_io_0018_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0018.pgc" +#line 31 "app/dbio/mg_io_0018.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int mg_io_0018_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0018.pgc" +#line 46 "app/dbio/mg_io_0018.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0018.pgc" +#line 47 "app/dbio/mg_io_0018.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0018.pgc" +#line 48 "app/dbio/mg_io_0018.pgc" if (!key) @@ -150,12 +150,12 @@ int mg_io_0018_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0018_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0018_acc_t set accum_amt = accum_amt + $1 , cnt = cnt + 1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0018.pgc" +#line 59 "app/dbio/mg_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long mg_io_0018_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0018.pgc" +#line 73 "app/dbio/mg_io_0018.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0018.pgc" +#line 74 "app/dbio/mg_io_0018.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0018.pgc" +#line 75 "app/dbio/mg_io_0018.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long mg_io_0018_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0018_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . appr_amt ) , 0 ) from mg_io_0018_dtl_t d join mg_io_0018_t h on h . mcht_no = d . mcht_no where d . biz_date = $1 and h . status_cd = '00'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0018.pgc" +#line 87 "app/dbio/mg_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long mg_io_0018_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0018.pgc b/app/dbio/mg_io_0018.pgc index 7909888..9d46765 100644 --- a/app/dbio/mg_io_0018.pgc +++ b/app/dbio/mg_io_0018.pgc @@ -24,10 +24,11 @@ int mg_io_0018_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT + CASE WHEN status_cd = '00' THEN appr_amt ELSE 0 END INTO :h_amount FROM mg_io_0018_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,9 @@ int mg_io_0018_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE mg_io_0018_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE mg_io_0018_acc_t + SET accum_amt = accum_amt + :h_amount, cnt = cnt + 1, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0018_touch"); @@ -79,10 +80,11 @@ long mg_io_0018_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.appr_amt), 0) INTO :h_sum - FROM mg_io_0018_t - WHERE biz_date = :h_biz_date; + FROM mg_io_0018_dtl_t d + JOIN mg_io_0018_t h ON h.mcht_no = d.mcht_no + WHERE d.biz_date = :h_biz_date AND h.status_cd = '00'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0018_total"); @@ -90,3 +92,4 @@ long mg_io_0018_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0019.c b/app/dbio/mg_io_0019.c index bae3b53..6cecea5 100644 --- a/app/dbio/mg_io_0019.c +++ b/app/dbio/mg_io_0019.c @@ -110,7 +110,7 @@ int mg_io_0019_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0019_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt from mg_io_0019_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), @@ -150,12 +150,12 @@ int mg_io_0019_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0019_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from mg_io_0019_bal_t where acct_no = $1 and bal_amt <= $2 ", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0019.pgc" +#line 57 "app/dbio/mg_io_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long mg_io_0019_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0019.pgc" +#line 71 "app/dbio/mg_io_0019.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0019.pgc" - long h_sum ; +#line 72 "app/dbio/mg_io_0019.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0019.pgc" +#line 73 "app/dbio/mg_io_0019.pgc" if (!biz_date) @@ -188,17 +188,18 @@ long mg_io_0019_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0019_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct mcht_no ) from mg_io_0019_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0019.pgc" +#line 84 "app/dbio/mg_io_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0019_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/mg_io_0019.pgc b/app/dbio/mg_io_0019.pgc index 896ffbc..4300b52 100644 --- a/app/dbio/mg_io_0019.pgc +++ b/app/dbio/mg_io_0019.pgc @@ -24,10 +24,10 @@ int mg_io_0019_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT appr_amt INTO :h_amount FROM mg_io_0019_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +53,8 @@ int mg_io_0019_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE mg_io_0019_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM mg_io_0019_bal_t + WHERE acct_no = :h_key AND bal_amt <= :h_amount; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0019_touch"); @@ -70,7 +69,7 @@ long mg_io_0019_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +78,15 @@ long mg_io_0019_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mg_io_0019_t + EXEC SQL SELECT count(DISTINCT mcht_no) + INTO :h_cnt + FROM mg_io_0019_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0019_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/mg_io_0020.c b/app/dbio/mg_io_0020.c index 0922a24..644c0d6 100644 --- a/app/dbio/mg_io_0020.c +++ b/app/dbio/mg_io_0020.c @@ -94,14 +94,22 @@ int mg_io_0020_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + + #line 17 "app/dbio/mg_io_0020.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/mg_io_0020.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_appr ; + #line 19 "app/dbio/mg_io_0020.pgc" + long h_fee ; + +#line 20 "app/dbio/mg_io_0020.pgc" + long h_vat ; +/* exec sql end declare section */ +#line 21 "app/dbio/mg_io_0020.pgc" if (!key || !out_amount) @@ -110,12 +118,16 @@ int mg_io_0020_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0020_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt , fee_amt , vat_amt from mg_io_0020_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_appr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_vat),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0020.pgc" +#line 32 "app/dbio/mg_io_0020.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +136,7 @@ int mg_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -134,13 +146,13 @@ int mg_io_0020_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0020.pgc" +#line 47 "app/dbio/mg_io_0020.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0020.pgc" +#line 48 "app/dbio/mg_io_0020.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0020.pgc" +#line 49 "app/dbio/mg_io_0020.pgc" if (!key) @@ -150,20 +162,29 @@ int mg_io_0020_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0020_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0020_t set req_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0020.pgc" +#line 60 "app/dbio/mg_io_0020.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0020_touch"); + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_io_0020_hist_t ( mcht_no , req_amt , reg_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 66 "app/dbio/mg_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,13 +194,13 @@ long mg_io_0020_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0020.pgc" +#line 78 "app/dbio/mg_io_0020.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0020.pgc" +#line 79 "app/dbio/mg_io_0020.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0020.pgc" +#line 80 "app/dbio/mg_io_0020.pgc" if (!biz_date) @@ -188,12 +209,12 @@ long mg_io_0020_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0020_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( cancel_amt ) , 0 ) from mg_io_0020_t where biz_date = $1 and status_cd = '90' and cancel_yn = 'Y'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0020.pgc" +#line 92 "app/dbio/mg_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +223,4 @@ long mg_io_0020_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0020.pgc b/app/dbio/mg_io_0020.pgc index 1dc3df4..8dfdb47 100644 --- a/app/dbio/mg_io_0020.pgc +++ b/app/dbio/mg_io_0020.pgc @@ -15,7 +15,9 @@ int mg_io_0020_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; - long h_amount; + long h_appr; + long h_fee; + long h_vat; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +26,10 @@ int mg_io_0020_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mg_io_0020_t - WHERE key = :h_key; + EXEC SQL SELECT appr_amt, fee_amt, vat_amt + INTO :h_appr, :h_fee, :h_vat + FROM mg_io_0020_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,7 +37,7 @@ int mg_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -54,15 +56,19 @@ int mg_io_0020_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE mg_io_0020_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET req_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0020_touch"); + return TX_EDB; + } + EXEC SQL INSERT INTO mg_io_0020_hist_t (mcht_no, req_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -79,10 +85,11 @@ long mg_io_0020_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(cancel_amt), 0) INTO :h_sum FROM mg_io_0020_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + AND status_cd = '90' AND cancel_yn = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0020_total"); @@ -90,3 +97,4 @@ long mg_io_0020_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0021.c b/app/dbio/mg_io_0021.c index f969865..5d14ee6 100644 --- a/app/dbio/mg_io_0021.c +++ b/app/dbio/mg_io_0021.c @@ -110,12 +110,12 @@ int mg_io_0021_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0021_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select h . net_amt from mg_io_0021_t h join mg_io_0021_map_t m on m . mcht_no = h . mcht_no where h . mcht_no = $1 and m . use_yn = 'Y'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0021.pgc" +#line 31 "app/dbio/mg_io_0021.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int mg_io_0021_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0021.pgc" +#line 46 "app/dbio/mg_io_0021.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0021.pgc" +#line 47 "app/dbio/mg_io_0021.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0021.pgc" +#line 48 "app/dbio/mg_io_0021.pgc" if (!key) @@ -150,12 +150,12 @@ int mg_io_0021_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0021_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0021_t set appr_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0021.pgc" +#line 59 "app/dbio/mg_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long mg_io_0021_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0021.pgc" +#line 73 "app/dbio/mg_io_0021.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0021.pgc" +#line 74 "app/dbio/mg_io_0021.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0021.pgc" +#line 75 "app/dbio/mg_io_0021.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long mg_io_0021_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0021_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( recon_amt ) , 0 ) from mg_io_0021_sum_t where biz_date in ( select biz_date from mg_io_0021_map_t where biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0021.pgc" +#line 87 "app/dbio/mg_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long mg_io_0021_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0021.pgc b/app/dbio/mg_io_0021.pgc index 5704897..350fb37 100644 --- a/app/dbio/mg_io_0021.pgc +++ b/app/dbio/mg_io_0021.pgc @@ -24,10 +24,11 @@ int mg_io_0021_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT h.net_amt INTO :h_amount - FROM mg_io_0021_t - WHERE key = :h_key; + FROM mg_io_0021_t h + JOIN mg_io_0021_map_t m ON m.mcht_no = h.mcht_no + WHERE h.mcht_no = :h_key AND m.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,8 @@ int mg_io_0021_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE mg_io_0021_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET appr_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0021_touch"); @@ -79,10 +80,11 @@ long mg_io_0021_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(recon_amt), 0) INTO :h_sum - FROM mg_io_0021_t - WHERE biz_date = :h_biz_date; + FROM mg_io_0021_sum_t + WHERE biz_date IN + (SELECT biz_date FROM mg_io_0021_map_t WHERE biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0021_total"); @@ -90,3 +92,4 @@ long mg_io_0021_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0022.c b/app/dbio/mg_io_0022.c index 0243b41..4547dfa 100644 --- a/app/dbio/mg_io_0022.c +++ b/app/dbio/mg_io_0022.c @@ -94,14 +94,18 @@ int mg_io_0022_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/mg_io_0022.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/mg_io_0022.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/mg_io_0022.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/mg_io_0022.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int mg_io_0022_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0022_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select bal_amt from mg_io_0022_bal_t where acct_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0022.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/mg_io_0022.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int mg_io_0022_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0022_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int mg_io_0022_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0022.pgc" +#line 48 "app/dbio/mg_io_0022.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0022.pgc" +#line 49 "app/dbio/mg_io_0022.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0022.pgc" +#line 50 "app/dbio/mg_io_0022.pgc" if (!key) @@ -150,12 +156,12 @@ int mg_io_0022_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0022_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0022_t set net_amt = $1 , upd_ts = now ( ) where mcht_no = $2 and status_cd = '00' and appr_amt > 0", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0022.pgc" +#line 61 "app/dbio/mg_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +179,13 @@ long mg_io_0022_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0022.pgc" +#line 75 "app/dbio/mg_io_0022.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0022.pgc" - long h_sum ; +#line 76 "app/dbio/mg_io_0022.pgc" + long h_flag ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0022.pgc" +#line 77 "app/dbio/mg_io_0022.pgc" if (!biz_date) @@ -188,17 +194,18 @@ long mg_io_0022_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0022_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mg_io_0022_t where exists ( select 1 from mg_io_0022_dtl_t d where d . biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0022.pgc" +#line 90 "app/dbio/mg_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0022_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/mg_io_0022.pgc b/app/dbio/mg_io_0022.pgc index b6ca3eb..a27b0e3 100644 --- a/app/dbio/mg_io_0022.pgc +++ b/app/dbio/mg_io_0022.pgc @@ -16,6 +16,7 @@ int mg_io_0022_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int mg_io_0022_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mg_io_0022_t - WHERE key = :h_key; + EXEC SQL SELECT bal_amt + INTO :h_amount :h_ind + FROM mg_io_0022_bal_t + WHERE acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int mg_io_0022_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0022_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -54,8 +57,8 @@ int mg_io_0022_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE mg_io_0022_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET net_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key AND status_cd = '00' AND appr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0022_touch"); @@ -70,7 +73,7 @@ long mg_io_0022_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_flag; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +82,17 @@ long mg_io_0022_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_flag FROM mg_io_0022_t - WHERE biz_date = :h_biz_date; + WHERE EXISTS + (SELECT 1 FROM mg_io_0022_dtl_t d + WHERE d.biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0022_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/mg_io_0023.c b/app/dbio/mg_io_0023.c index 7b9f380..5064e1d 100644 --- a/app/dbio/mg_io_0023.c +++ b/app/dbio/mg_io_0023.c @@ -110,12 +110,12 @@ int mg_io_0023_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0023_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select req_amt from mg_io_0023_t where mcht_no = $1 and status_cd = '00' and cancel_yn = 'N'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0023.pgc" +#line 31 "app/dbio/mg_io_0023.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int mg_io_0023_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0023.pgc" +#line 46 "app/dbio/mg_io_0023.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0023.pgc" +#line 47 "app/dbio/mg_io_0023.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0023.pgc" +#line 48 "app/dbio/mg_io_0023.pgc" if (!key) @@ -150,10 +150,10 @@ int mg_io_0023_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0023_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_io_0023_log_t ( mcht_no , appr_amt , reg_ts ) values ( $1 , $2 , now ( ) )", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} #line 58 "app/dbio/mg_io_0023.pgc" @@ -162,8 +162,6 @@ int mg_io_0023_touch(const char *key, long amount) TX_DBIO_LOG_ERR("mg_io_0023_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,13 +171,13 @@ long mg_io_0023_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0023.pgc" +#line 70 "app/dbio/mg_io_0023.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0023.pgc" +#line 71 "app/dbio/mg_io_0023.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0023.pgc" +#line 72 "app/dbio/mg_io_0023.pgc" if (!biz_date) @@ -188,12 +186,12 @@ long mg_io_0023_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0023_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( appr_amt ) , 0 ) from mg_io_0023_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0023.pgc" +#line 83 "app/dbio/mg_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +200,4 @@ long mg_io_0023_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0023.pgc b/app/dbio/mg_io_0023.pgc index bcba494..f08c0b7 100644 --- a/app/dbio/mg_io_0023.pgc +++ b/app/dbio/mg_io_0023.pgc @@ -24,10 +24,11 @@ int mg_io_0023_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT req_amt INTO :h_amount FROM mg_io_0023_t - WHERE key = :h_key; + WHERE mcht_no = :h_key AND status_cd = '00' + AND cancel_yn = 'N'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,16 +54,13 @@ int mg_io_0023_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE mg_io_0023_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL INSERT INTO mg_io_0023_log_t (mcht_no, appr_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0023_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -79,7 +77,7 @@ long mg_io_0023_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(appr_amt), 0) INTO :h_sum FROM mg_io_0023_t WHERE biz_date = :h_biz_date; @@ -90,3 +88,4 @@ long mg_io_0023_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/mg_io_0024.c b/app/dbio/mg_io_0024.c index 244b022..0e24de9 100644 --- a/app/dbio/mg_io_0024.c +++ b/app/dbio/mg_io_0024.c @@ -94,14 +94,18 @@ int mg_io_0024_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/mg_io_0024.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/mg_io_0024.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/mg_io_0024.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/mg_io_0024.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int mg_io_0024_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0024_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( appr_amt ) from mg_io_0024_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0024.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/mg_io_0024.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int mg_io_0024_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0024_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int mg_io_0024_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0024.pgc" +#line 48 "app/dbio/mg_io_0024.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0024.pgc" +#line 49 "app/dbio/mg_io_0024.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0024.pgc" +#line 50 "app/dbio/mg_io_0024.pgc" if (!key) @@ -150,20 +156,31 @@ int mg_io_0024_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0024_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0024_bal_t set bal_amt = $1 , upd_ts = now ( ) where acct_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0024.pgc" +#line 61 "app/dbio/mg_io_0024.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0024_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_io_0024_bal_t ( acct_no , bal_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 69 "app/dbio/mg_io_0024.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0024_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -173,13 +190,13 @@ long mg_io_0024_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0024.pgc" +#line 81 "app/dbio/mg_io_0024.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0024.pgc" - long h_sum ; +#line 82 "app/dbio/mg_io_0024.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0024.pgc" +#line 83 "app/dbio/mg_io_0024.pgc" if (!biz_date) @@ -188,17 +205,18 @@ long mg_io_0024_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0024_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mg_io_0024_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0024.pgc" +#line 94 "app/dbio/mg_io_0024.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0024_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/mg_io_0024.pgc b/app/dbio/mg_io_0024.pgc index a4553d0..ef48ae4 100644 --- a/app/dbio/mg_io_0024.pgc +++ b/app/dbio/mg_io_0024.pgc @@ -16,6 +16,7 @@ int mg_io_0024_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int mg_io_0024_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mg_io_0024_t - WHERE key = :h_key; + EXEC SQL SELECT max(appr_amt) + INTO :h_amount :h_ind + FROM mg_io_0024_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int mg_io_0024_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mg_io_0024_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -53,16 +56,22 @@ int mg_io_0024_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE mg_io_0024_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE mg_io_0024_bal_t + SET bal_amt = :h_amount, upd_ts = now() + WHERE acct_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0024_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + EXEC SQL INSERT INTO mg_io_0024_bal_t (acct_no, bal_amt, upd_ts) + VALUES (:h_key, :h_amount, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0024_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -70,7 +79,7 @@ long mg_io_0024_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,8 +88,8 @@ long mg_io_0024_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_cnt FROM mg_io_0024_t WHERE biz_date = :h_biz_date; @@ -88,5 +97,6 @@ long mg_io_0024_total(const char *biz_date) TX_DBIO_LOG_ERR("mg_io_0024_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/mg_io_0025.c b/app/dbio/mg_io_0025.c index 4481cfd..1686d51 100644 --- a/app/dbio/mg_io_0025.c +++ b/app/dbio/mg_io_0025.c @@ -110,12 +110,12 @@ int mg_io_0025_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0025_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select net_amt from mg_io_0025_t where mcht_no in ( select mcht_no from mg_io_0025_map_t where grp_key = $1 )", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0025.pgc" +#line 31 "app/dbio/mg_io_0025.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int mg_io_0025_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0025.pgc" +#line 46 "app/dbio/mg_io_0025.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0025.pgc" +#line 47 "app/dbio/mg_io_0025.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0025.pgc" +#line 48 "app/dbio/mg_io_0025.pgc" if (!key) @@ -150,9 +150,7 @@ int mg_io_0025_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0025_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from mg_io_0025_tmp_t where ref_key = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/mg_io_0025.pgc" @@ -172,14 +170,18 @@ long mg_io_0025_total(const char *biz_date) /* exec sql begin declare section */ + #line 72 "app/dbio/mg_io_0025.pgc" char h_biz_date [ 9 ] ; #line 73 "app/dbio/mg_io_0025.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_avg ; + #line 74 "app/dbio/mg_io_0025.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 75 "app/dbio/mg_io_0025.pgc" if (!biz_date) @@ -188,17 +190,20 @@ long mg_io_0025_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0025_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select avg ( appr_amt ) from mg_io_0025_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0025.pgc" + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 86 "app/dbio/mg_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0025_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/mg_io_0025.pgc b/app/dbio/mg_io_0025.pgc index 907df41..5e95dd9 100644 --- a/app/dbio/mg_io_0025.pgc +++ b/app/dbio/mg_io_0025.pgc @@ -24,10 +24,11 @@ int mg_io_0025_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT net_amt INTO :h_amount FROM mg_io_0025_t - WHERE key = :h_key; + WHERE mcht_no IN + (SELECT mcht_no FROM mg_io_0025_map_t WHERE grp_key = :h_key); if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,8 @@ int mg_io_0025_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE mg_io_0025_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM mg_io_0025_tmp_t + WHERE ref_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0025_touch"); @@ -70,7 +70,8 @@ long mg_io_0025_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_avg; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +80,17 @@ long mg_io_0025_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mg_io_0025_t + EXEC SQL SELECT avg(appr_amt) + INTO :h_avg :h_ind + FROM mg_io_0025_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0025_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/mg_io_0026.c b/app/dbio/mg_io_0026.c index 3c0a179..7ffcb1f 100644 --- a/app/dbio/mg_io_0026.c +++ b/app/dbio/mg_io_0026.c @@ -110,20 +110,43 @@ int mg_io_0026_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0026_t where key = $1 ", + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cur_mg_io_0026_f cursor for select appr_amt from mg_io_0026_dtl_t where mcht_no = $1 order by seq desc */ +#line 29 "app/dbio/mg_io_0026.pgc" + +#line 29 "app/dbio/mg_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_mg_io_0026_f cursor for select appr_amt from mg_io_0026_dtl_t where mcht_no = $1 order by seq desc", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 30 "app/dbio/mg_io_0026.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0026_fetch"); return TX_EDB; } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_mg_io_0026_f", ECPGt_EOIT, + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 35 "app/dbio/mg_io_0026.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_io_0026_f", ECPGt_EOIT, ECPGt_EORT);} +#line 37 "app/dbio/mg_io_0026.pgc" + + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0026_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_io_0026_f", ECPGt_EOIT, ECPGt_EORT);} +#line 42 "app/dbio/mg_io_0026.pgc" + + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_io_0026_f", ECPGt_EOIT, ECPGt_EORT);} +#line 45 "app/dbio/mg_io_0026.pgc" + + *out_amount = h_amount; return TX_OK; } @@ -134,13 +157,13 @@ int mg_io_0026_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0026.pgc" +#line 54 "app/dbio/mg_io_0026.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0026.pgc" +#line 55 "app/dbio/mg_io_0026.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0026.pgc" +#line 56 "app/dbio/mg_io_0026.pgc" if (!key) @@ -150,12 +173,14 @@ int mg_io_0026_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0026_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0026_t set fee_amt = $1 , vat_amt = $2 / 10 , upd_ts = now ( ) where mcht_no = $3 ", + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + 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_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0026.pgc" +#line 67 "app/dbio/mg_io_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +198,13 @@ long mg_io_0026_total(const char *biz_date) -#line 72 "app/dbio/mg_io_0026.pgc" +#line 81 "app/dbio/mg_io_0026.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0026.pgc" +#line 82 "app/dbio/mg_io_0026.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0026.pgc" +#line 83 "app/dbio/mg_io_0026.pgc" if (!biz_date) @@ -188,17 +213,20 @@ long mg_io_0026_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0026_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( net_amt ) , 0 ) from mg_io_0026_t where biz_date = $1 group by biz_date having sum ( net_amt ) > 0 limit 1", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0026.pgc" +#line 97 "app/dbio/mg_io_0026.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0026_total"); return -1; } return h_sum; } + diff --git a/app/dbio/mg_io_0026.pgc b/app/dbio/mg_io_0026.pgc index c09d201..0b29d16 100644 --- a/app/dbio/mg_io_0026.pgc +++ b/app/dbio/mg_io_0026.pgc @@ -24,17 +24,26 @@ int mg_io_0026_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mg_io_0026_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL DECLARE cur_mg_io_0026_f CURSOR FOR + SELECT appr_amt FROM mg_io_0026_dtl_t + WHERE mcht_no = :h_key ORDER BY seq DESC; + EXEC SQL OPEN cur_mg_io_0026_f; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0026_fetch"); return TX_EDB; } + EXEC SQL FETCH cur_mg_io_0026_f INTO :h_amount; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE cur_mg_io_0026_f; + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0026_fetch"); + EXEC SQL CLOSE cur_mg_io_0026_f; + return TX_EDB; + } + EXEC SQL CLOSE cur_mg_io_0026_f; + *out_amount = h_amount; return TX_OK; } @@ -54,8 +63,8 @@ int mg_io_0026_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE mg_io_0026_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET fee_amt = :h_amount, vat_amt = :h_amount / 10, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0026_touch"); @@ -79,14 +88,20 @@ long mg_io_0026_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(net_amt), 0) INTO :h_sum FROM mg_io_0026_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + GROUP BY biz_date + HAVING sum(net_amt) > 0 + LIMIT 1; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0026_total"); return -1; } return h_sum; } + diff --git a/app/dbio/mg_io_0027.c b/app/dbio/mg_io_0027.c index dcdb6e8..63c9a04 100644 --- a/app/dbio/mg_io_0027.c +++ b/app/dbio/mg_io_0027.c @@ -110,12 +110,12 @@ int mg_io_0027_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mg_io_0027_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when status_cd = '00' then appr_amt else 0 end from mg_io_0027_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mg_io_0027.pgc" +#line 31 "app/dbio/mg_io_0027.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int mg_io_0027_touch(const char *key, long amount) -#line 45 "app/dbio/mg_io_0027.pgc" +#line 46 "app/dbio/mg_io_0027.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/mg_io_0027.pgc" +#line 47 "app/dbio/mg_io_0027.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/mg_io_0027.pgc" +#line 48 "app/dbio/mg_io_0027.pgc" if (!key) @@ -150,12 +150,12 @@ int mg_io_0027_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0027_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_io_0027_t set status_cd = case when $1 > 0 then '00' else '99' end , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mg_io_0027.pgc" +#line 60 "app/dbio/mg_io_0027.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -172,14 +172,18 @@ long mg_io_0027_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/mg_io_0027.pgc" +#line 74 "app/dbio/mg_io_0027.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/mg_io_0027.pgc" - long h_sum ; +#line 75 "app/dbio/mg_io_0027.pgc" + long h_row ; + +#line 76 "app/dbio/mg_io_0027.pgc" + long acc = 0 ; /* exec sql end declare section */ -#line 74 "app/dbio/mg_io_0027.pgc" +#line 77 "app/dbio/mg_io_0027.pgc" if (!biz_date) @@ -188,17 +192,42 @@ long mg_io_0027_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mg_io_0027_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mg_io_0027.pgc" + ECPGset_var( 0, ( h_biz_date ), __LINE__);\ + /* declare cur_mg_io_0027_t cursor for select net_amt from mg_io_0027_sum_t where biz_date = $1 */ +#line 86 "app/dbio/mg_io_0027.pgc" +#line 86 "app/dbio/mg_io_0027.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_mg_io_0027_t cursor for select net_amt from mg_io_0027_sum_t where biz_date = $1 ", + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 87 "app/dbio/mg_io_0027.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0027_total"); return -1; } - return h_sum; + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_mg_io_0027_t", ECPGt_EOIT, + ECPGt_long,&(h_row),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 93 "app/dbio/mg_io_0027.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0027_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_io_0027_t", ECPGt_EOIT, ECPGt_EORT);} +#line 98 "app/dbio/mg_io_0027.pgc" + + return -1; + } + acc += h_row; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_mg_io_0027_t", ECPGt_EOIT, ECPGt_EORT);} +#line 103 "app/dbio/mg_io_0027.pgc" + + + return acc; } + diff --git a/app/dbio/mg_io_0027.pgc b/app/dbio/mg_io_0027.pgc index c5dda95..c8c25d7 100644 --- a/app/dbio/mg_io_0027.pgc +++ b/app/dbio/mg_io_0027.pgc @@ -24,10 +24,11 @@ int mg_io_0027_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT + CASE WHEN status_cd = '00' THEN appr_amt ELSE 0 END INTO :h_amount FROM mg_io_0027_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,9 @@ int mg_io_0027_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE mg_io_0027_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET status_cd = CASE WHEN :h_amount > 0 THEN '00' ELSE '99' END, + upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0027_touch"); @@ -70,7 +72,8 @@ long mg_io_0027_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_row; + long acc = 0; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +82,26 @@ long mg_io_0027_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mg_io_0027_t - WHERE biz_date = :h_biz_date; - + EXEC SQL DECLARE cur_mg_io_0027_t CURSOR FOR + SELECT net_amt FROM mg_io_0027_sum_t WHERE biz_date = :h_biz_date; + EXEC SQL OPEN cur_mg_io_0027_t; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mg_io_0027_total"); return -1; } - return h_sum; + for (;;) { + EXEC SQL FETCH cur_mg_io_0027_t INTO :h_row; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mg_io_0027_total"); + EXEC SQL CLOSE cur_mg_io_0027_t; + return -1; + } + acc += h_row; + } + EXEC SQL CLOSE cur_mg_io_0027_t; + + return acc; } + diff --git a/app/dbio/mm_io_0001.c b/app/dbio/mm_io_0001.c index 82de62a..990cac8 100644 --- a/app/dbio/mm_io_0001.c +++ b/app/dbio/mm_io_0001.c @@ -96,26 +96,25 @@ int mm_io_0001_fetch(const char *key, long *out_amount) #line 17 "app/dbio/mm_io_0001.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0001.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/mm_io_0001.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0001_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . balance ) , 0 ) from mst_account a join mst_acct_bal b on a . acct_no = b . acct_no where a . acct_no = $1 and b . status_cd = 'Y'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0001.pgc" +#line 31 "app/dbio/mm_io_0001.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int mm_io_0001_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0001_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -134,29 +133,27 @@ int mm_io_0001_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0001.pgc" - char h_key [ 16 ] ; - #line 46 "app/dbio/mm_io_0001.pgc" - long h_amount ; -/* exec sql end declare section */ + char h_key [ 20 ] ; + #line 47 "app/dbio/mm_io_0001.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 48 "app/dbio/mm_io_0001.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0001_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mst_account set balance = $1 , upd_ts = now ( ) where acct_no = $2 and status_cd = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0001.pgc" - +#line 59 "app/dbio/mm_io_0001.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0001_touch"); @@ -174,7 +171,7 @@ long mm_io_0001_total(const char *biz_date) #line 72 "app/dbio/mm_io_0001.pgc" - char h_biz_date [ 9 ] ; + char h_bd [ 9 ] ; #line 73 "app/dbio/mm_io_0001.pgc" long h_sum ; @@ -184,17 +181,15 @@ long mm_io_0001_total(const char *biz_date) if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0001_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( balance ) , 0 ) from mst_account where biz_date = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0001.pgc" - +#line 84 "app/dbio/mm_io_0001.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0001_total"); diff --git a/app/dbio/mm_io_0001.pgc b/app/dbio/mm_io_0001.pgc index 4a3a7bf..ed31f44 100644 --- a/app/dbio/mm_io_0001.pgc +++ b/app/dbio/mm_io_0001.pgc @@ -14,20 +14,21 @@ EXEC SQL INCLUDE sqlca; int mm_io_0001_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0001_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(a.balance), 0) + INTO :h_amt + FROM mst_account a + JOIN mst_acct_bal b ON a.acct_no = b.acct_no + WHERE a.acct_no = :h_key + AND b.status_cd = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +36,27 @@ int mm_io_0001_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0001_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int mm_io_0001_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0001_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE mst_account + SET balance = :h_amt, upd_ts = now() + WHERE acct_no = :h_key + AND status_cd = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0001_touch"); return TX_EDB; @@ -69,21 +69,19 @@ int mm_io_0001_touch(const char *key, long amount) long mm_io_0001_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(balance), 0) INTO :h_sum - FROM mm_io_0001_t - WHERE biz_date = :h_biz_date; - + FROM mst_account + WHERE biz_date = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0001_total"); return -1; diff --git a/app/dbio/mm_io_0002.c b/app/dbio/mm_io_0002.c index 98cb41d..95e5ab5 100644 --- a/app/dbio/mm_io_0002.c +++ b/app/dbio/mm_io_0002.c @@ -94,37 +94,51 @@ int mm_io_0002_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/mm_io_0002.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0002.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/mm_io_0002.pgc" + int h_cnt ; +/* exec sql end declare section */ +#line 20 "app/dbio/mm_io_0002.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0002_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mst_acct_bal where cust_id = $1 and amount > 0", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_int,&(h_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0002.pgc" +#line 31 "app/dbio/mm_io_0002.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mst_acct_bal where cust_id = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 42 "app/dbio/mm_io_0002.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0002_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +148,27 @@ int mm_io_0002_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0002.pgc" - char h_key [ 16 ] ; +#line 54 "app/dbio/mm_io_0002.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0002.pgc" - long h_amount ; +#line 55 "app/dbio/mm_io_0002.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0002.pgc" +#line 56 "app/dbio/mm_io_0002.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0002_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mst_acct_bal set amount = $1 , upd_ts = now ( ) where cust_id = $2 and use_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0002.pgc" - +#line 67 "app/dbio/mm_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0002_touch"); @@ -173,32 +185,30 @@ long mm_io_0002_total(const char *biz_date) -#line 72 "app/dbio/mm_io_0002.pgc" - char h_biz_date [ 9 ] ; +#line 80 "app/dbio/mm_io_0002.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0002.pgc" - long h_sum ; +#line 81 "app/dbio/mm_io_0002.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0002.pgc" +#line 82 "app/dbio/mm_io_0002.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0002_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mst_customer where base_dt = $1 and amount <> 0", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0002.pgc" - +#line 93 "app/dbio/mm_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/mm_io_0002.pgc b/app/dbio/mm_io_0002.pgc index 04ecd33..b356f10 100644 --- a/app/dbio/mm_io_0002.pgc +++ b/app/dbio/mm_io_0002.pgc @@ -14,49 +14,57 @@ EXEC SQL INCLUDE sqlca; int mm_io_0002_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + int h_cnt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0002_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM mst_acct_bal + WHERE cust_id = :h_key + AND amount > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + EXEC SQL SELECT amount + INTO :h_amt + FROM mst_acct_bal + WHERE cust_id = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0002_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } int mm_io_0002_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0002_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE mst_acct_bal + SET amount = :h_amt, upd_ts = now() + WHERE cust_id = :h_key + AND use_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0002_touch"); return TX_EDB; @@ -69,24 +77,23 @@ int mm_io_0002_touch(const char *key, long amount) long mm_io_0002_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0002_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM mst_customer + WHERE base_dt = :h_bd + AND amount <> 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/mm_io_0003.c b/app/dbio/mm_io_0003.c index c721fb4..a08b2f7 100644 --- a/app/dbio/mm_io_0003.c +++ b/app/dbio/mm_io_0003.c @@ -92,39 +92,45 @@ struct sqlca_t *ECPGget_sqlca(void); int mm_io_0003_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ - + + #line 17 "app/dbio/mm_io_0003.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0003.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/mm_io_0003.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/mm_io_0003.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0003_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( credit_lim ) from mst_deposit where prod_cd = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/mm_io_0003.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0003_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +140,27 @@ int mm_io_0003_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0003.pgc" - char h_key [ 16 ] ; +#line 48 "app/dbio/mm_io_0003.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0003.pgc" - long h_amount ; +#line 49 "app/dbio/mm_io_0003.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0003.pgc" +#line 50 "app/dbio/mm_io_0003.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0003_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mst_product set credit_lim = $1 , upd_ts = now ( ) where prod_cd = $2 and block_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0003.pgc" - +#line 61 "app/dbio/mm_io_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0003_touch"); @@ -172,33 +176,62 @@ long mm_io_0003_total(const char *biz_date) /* exec sql begin declare section */ + + -#line 72 "app/dbio/mm_io_0003.pgc" - char h_biz_date [ 9 ] ; - -#line 73 "app/dbio/mm_io_0003.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/mm_io_0003.pgc" + char h_bd [ 9 ] ; + +#line 75 "app/dbio/mm_io_0003.pgc" + char h_grp [ 20 ] ; + +#line 76 "app/dbio/mm_io_0003.pgc" + long h_sub ; + +#line 77 "app/dbio/mm_io_0003.pgc" + long h_tot ; +/* exec sql end declare section */ +#line 78 "app/dbio/mm_io_0003.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + ECPGset_var( 0, ( h_bd ), __LINE__);\ + /* declare mm_io_0003_total_gc cursor for select dept_cd , coalesce ( sum ( credit_lim ) , 0 ) from mst_product where reg_dt = $1 group by dept_cd order by dept_cd */ +#line 91 "app/dbio/mm_io_0003.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0003_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), +#line 91 "app/dbio/mm_io_0003.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mm_io_0003_total_gc cursor for select dept_cd , coalesce ( sum ( credit_lim ) , 0 ) from mst_product where reg_dt = $1 group by dept_cd order by dept_cd", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 92 "app/dbio/mm_io_0003.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mm_io_0003_total_gc", ECPGt_EOIT, + ECPGt_char,(h_grp),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sub),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0003.pgc" +#line 94 "app/dbio/mm_io_0003.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0003_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0003_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 99 "app/dbio/mm_io_0003.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0003_total"); - return -1; + return -1; + } + h_tot += h_sub; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0003_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 104 "app/dbio/mm_io_0003.pgc" + + return h_tot; } diff --git a/app/dbio/mm_io_0003.pgc b/app/dbio/mm_io_0003.pgc index b16f9cf..f4d9846 100644 --- a/app/dbio/mm_io_0003.pgc +++ b/app/dbio/mm_io_0003.pgc @@ -14,49 +14,51 @@ EXEC SQL INCLUDE sqlca; int mm_io_0003_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0003_t - WHERE key = :h_key; - + EXEC SQL SELECT max(credit_lim) + INTO :h_amt:h_ind + FROM mst_deposit + WHERE prod_cd = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0003_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } int mm_io_0003_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0003_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE mst_product + SET credit_lim = :h_amt, upd_ts = now() + WHERE prod_cd = :h_key + AND block_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0003_touch"); return TX_EDB; @@ -69,24 +71,36 @@ int mm_io_0003_touch(const char *key, long amount) long mm_io_0003_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + char h_grp[20]; + long h_sub; + long h_tot; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0003_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0003_total"); - return -1; + EXEC SQL DECLARE mm_io_0003_total_gc CURSOR FOR + SELECT dept_cd, coalesce(sum(credit_lim), 0) + FROM mst_product + WHERE reg_dt = :h_bd + GROUP BY dept_cd + ORDER BY dept_cd; + EXEC SQL OPEN mm_io_0003_total_gc; + for (;;) { + EXEC SQL FETCH mm_io_0003_total_gc INTO :h_grp, :h_sub; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0003_total"); + EXEC SQL CLOSE mm_io_0003_total_gc; + return -1; + } + h_tot += h_sub; } - return h_sum; + EXEC SQL CLOSE mm_io_0003_total_gc; + return h_tot; } diff --git a/app/dbio/mm_io_0004.c b/app/dbio/mm_io_0004.c index b36fa1a..96c6169 100644 --- a/app/dbio/mm_io_0004.c +++ b/app/dbio/mm_io_0004.c @@ -94,37 +94,58 @@ int mm_io_0004_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/mm_io_0004.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0004.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/mm_io_0004.pgc" + long h_acc ; +/* exec sql end declare section */ +#line 20 "app/dbio/mm_io_0004.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0004_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare mm_io_0004_fetch_cur cursor for select avail_amt from mst_loan where card_no = $1 order by biz_date */ +#line 31 "app/dbio/mm_io_0004.pgc" + +#line 31 "app/dbio/mm_io_0004.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mm_io_0004_fetch_cur cursor for select avail_amt from mst_loan where card_no = $1 order by biz_date", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 32 "app/dbio/mm_io_0004.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mm_io_0004_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0004.pgc" +#line 34 "app/dbio/mm_io_0004.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0004_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0004_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 39 "app/dbio/mm_io_0004.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0004_fetch"); - return TX_EDB; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0004_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 44 "app/dbio/mm_io_0004.pgc" + + *out_amount = h_acc; return TX_OK; } @@ -134,29 +155,27 @@ int mm_io_0004_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0004.pgc" - char h_key [ 16 ] ; +#line 52 "app/dbio/mm_io_0004.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0004.pgc" - long h_amount ; +#line 53 "app/dbio/mm_io_0004.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0004.pgc" +#line 54 "app/dbio/mm_io_0004.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0004_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mst_customer set avail_amt = $1 , upd_ts = now ( ) where card_no = $2 and status_cd = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0004.pgc" - +#line 65 "app/dbio/mm_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0004_touch"); @@ -173,28 +192,26 @@ long mm_io_0004_total(const char *biz_date) -#line 72 "app/dbio/mm_io_0004.pgc" - char h_biz_date [ 9 ] ; +#line 78 "app/dbio/mm_io_0004.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0004.pgc" +#line 79 "app/dbio/mm_io_0004.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0004.pgc" +#line 80 "app/dbio/mm_io_0004.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0004_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . avail_amt ) , 0 ) from mst_loan d join mst_customer m on d . card_no = m . card_no where d . biz_date = $1 and m . status_cd = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0004.pgc" - +#line 92 "app/dbio/mm_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0004_total"); diff --git a/app/dbio/mm_io_0004.pgc b/app/dbio/mm_io_0004.pgc index 8d122a8..9472845 100644 --- a/app/dbio/mm_io_0004.pgc +++ b/app/dbio/mm_io_0004.pgc @@ -14,49 +14,55 @@ EXEC SQL INCLUDE sqlca; int mm_io_0004_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + long h_acc; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0004_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0004_fetch"); - return TX_EDB; + EXEC SQL DECLARE mm_io_0004_fetch_cur CURSOR FOR + SELECT avail_amt FROM mst_loan + WHERE card_no = :h_key + ORDER BY biz_date; + EXEC SQL OPEN mm_io_0004_fetch_cur; + for (;;) { + EXEC SQL FETCH mm_io_0004_fetch_cur INTO :h_amt; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0004_fetch"); + EXEC SQL CLOSE mm_io_0004_fetch_cur; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + EXEC SQL CLOSE mm_io_0004_fetch_cur; + *out_amount = h_acc; return TX_OK; } int mm_io_0004_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0004_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE mst_customer + SET avail_amt = :h_amt, upd_ts = now() + WHERE card_no = :h_key + AND status_cd = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0004_touch"); return TX_EDB; @@ -69,21 +75,21 @@ int mm_io_0004_touch(const char *key, long amount) long mm_io_0004_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.avail_amt), 0) INTO :h_sum - FROM mm_io_0004_t - WHERE biz_date = :h_biz_date; - + FROM mst_loan d + JOIN mst_customer m ON d.card_no = m.card_no + WHERE d.biz_date = :h_bd + AND m.status_cd = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0004_total"); return -1; diff --git a/app/dbio/mm_io_0005.c b/app/dbio/mm_io_0005.c index effc998..d3e3e3a 100644 --- a/app/dbio/mm_io_0005.c +++ b/app/dbio/mm_io_0005.c @@ -96,27 +96,25 @@ int mm_io_0005_fetch(const char *key, long *out_amount) #line 17 "app/dbio/mm_io_0005.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0005.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/mm_io_0005.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0005_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( m . prin_bal , 0 ) - ( select coalesce ( sum ( h . prin_bal ) , 0 ) from mst_card h where h . acct_no = m . acct_no ) from mst_deposit m where m . acct_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0005.pgc" - +#line 31 "app/dbio/mm_io_0005.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +122,7 @@ int mm_io_0005_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0005_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -135,29 +133,27 @@ int mm_io_0005_touch(const char *key, long amount) #line 45 "app/dbio/mm_io_0005.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 46 "app/dbio/mm_io_0005.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/mm_io_0005.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0005_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mst_deposit set prin_bal = $1 , upd_ts = now ( ) where acct_no = $2 and use_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/mm_io_0005.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0005_touch"); return TX_EDB; @@ -170,35 +166,39 @@ int mm_io_0005_touch(const char *key, long amount) long mm_io_0005_total(const char *biz_date) { /* exec sql begin declare section */ - + + +#line 71 "app/dbio/mm_io_0005.pgc" + char h_bd [ 9 ] ; + #line 72 "app/dbio/mm_io_0005.pgc" - char h_biz_date [ 9 ] ; + long h_max ; #line 73 "app/dbio/mm_io_0005.pgc" - long h_sum ; + short h_ind ; /* exec sql end declare section */ #line 74 "app/dbio/mm_io_0005.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0005_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( prin_bal ) from mst_loan where base_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0005.pgc" - + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 84 "app/dbio/mm_io_0005.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0005_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/mm_io_0005.pgc b/app/dbio/mm_io_0005.pgc index 933759e..b070b52 100644 --- a/app/dbio/mm_io_0005.pgc +++ b/app/dbio/mm_io_0005.pgc @@ -14,49 +14,48 @@ EXEC SQL INCLUDE sqlca; int mm_io_0005_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0005_t - WHERE key = :h_key; - + EXEC SQL SELECT coalesce(m.prin_bal, 0) + - (SELECT coalesce(sum(h.prin_bal), 0) + FROM mst_card h WHERE h.acct_no = m.acct_no) + INTO :h_amt + FROM mst_deposit m + WHERE m.acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0005_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int mm_io_0005_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0005_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE mst_deposit + SET prin_bal = :h_amt, upd_ts = now() + WHERE acct_no = :h_key + AND use_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0005_touch"); return TX_EDB; @@ -69,24 +68,25 @@ int mm_io_0005_touch(const char *key, long amount) long mm_io_0005_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0005_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT max(prin_bal) + INTO :h_max:h_ind + FROM mst_loan + WHERE base_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0005_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/mm_io_0006.c b/app/dbio/mm_io_0006.c index 7d65f72..5fdb700 100644 --- a/app/dbio/mm_io_0006.c +++ b/app/dbio/mm_io_0006.c @@ -92,31 +92,43 @@ struct sqlca_t *ECPGget_sqlca(void); int mm_io_0006_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ + + + #line 17 "app/dbio/mm_io_0006.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0006.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_min ; + #line 19 "app/dbio/mm_io_0006.pgc" + long h_max ; + +#line 20 "app/dbio/mm_io_0006.pgc" + short h_i1 ; + +#line 21 "app/dbio/mm_io_0006.pgc" + short h_i2 ; +/* exec sql end declare section */ +#line 22 "app/dbio/mm_io_0006.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0006_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( int_amt ) , max ( int_amt ) from mst_card where cust_id = $1 and block_yn <> 'D'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0006.pgc" - + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i1),(long)1,(long)1,sizeof(short), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i2),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 33 "app/dbio/mm_io_0006.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +136,9 @@ int mm_io_0006_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0006_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } @@ -134,29 +148,27 @@ int mm_io_0006_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0006.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/mm_io_0006.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0006.pgc" - long h_amount ; +#line 50 "app/dbio/mm_io_0006.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0006.pgc" +#line 51 "app/dbio/mm_io_0006.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0006_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mst_loan set int_amt = $1 , upd_ts = now ( ) where cust_id = $2 and block_yn = 'A'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0006.pgc" - +#line 62 "app/dbio/mm_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0006_touch"); @@ -173,32 +185,30 @@ long mm_io_0006_total(const char *biz_date) -#line 72 "app/dbio/mm_io_0006.pgc" - char h_biz_date [ 9 ] ; +#line 75 "app/dbio/mm_io_0006.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0006.pgc" - long h_sum ; +#line 76 "app/dbio/mm_io_0006.pgc" + long h_avg ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0006.pgc" +#line 77 "app/dbio/mm_io_0006.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0006_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( avg ( int_amt ) , 0 ) :: bigint from mst_loan where reg_dt = $1 and block_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0006.pgc" - +#line 88 "app/dbio/mm_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0006_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/mm_io_0006.pgc b/app/dbio/mm_io_0006.pgc index 66d8905..50691cb 100644 --- a/app/dbio/mm_io_0006.pgc +++ b/app/dbio/mm_io_0006.pgc @@ -14,49 +14,52 @@ EXEC SQL INCLUDE sqlca; int mm_io_0006_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_min; + long h_max; + short h_i1; + short h_i2; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0006_t - WHERE key = :h_key; - + EXEC SQL SELECT min(int_amt), max(int_amt) + INTO :h_min:h_i1, :h_max:h_i2 + FROM mst_card + WHERE cust_id = :h_key + AND block_yn <> 'D'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0006_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } int mm_io_0006_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0006_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE mst_loan + SET int_amt = :h_amt, upd_ts = now() + WHERE cust_id = :h_key + AND block_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0006_touch"); return TX_EDB; @@ -69,24 +72,23 @@ int mm_io_0006_touch(const char *key, long amount) long mm_io_0006_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_avg; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0006_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT coalesce(avg(int_amt), 0)::bigint + INTO :h_avg + FROM mst_loan + WHERE reg_dt = :h_bd + AND block_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0006_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/mm_io_0007.c b/app/dbio/mm_io_0007.c index 1f0a7cb..e8b4e70 100644 --- a/app/dbio/mm_io_0007.c +++ b/app/dbio/mm_io_0007.c @@ -96,26 +96,25 @@ int mm_io_0007_fetch(const char *key, long *out_amount) #line 17 "app/dbio/mm_io_0007.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0007.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/mm_io_0007.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0007_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . balance ) , 0 ) from mst_card a join mst_limit b on a . prod_cd = b . prod_cd where a . prod_cd = $1 and b . status_cd = 'Y'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0007.pgc" +#line 31 "app/dbio/mm_io_0007.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int mm_io_0007_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0007_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -134,36 +133,32 @@ int mm_io_0007_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0007.pgc" - char h_key [ 16 ] ; - #line 46 "app/dbio/mm_io_0007.pgc" - long h_amount ; -/* exec sql end declare section */ + char h_key [ 20 ] ; + #line 47 "app/dbio/mm_io_0007.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 48 "app/dbio/mm_io_0007.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0007_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mst_account ( prod_cd , balance , biz_date , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/mm_io_0007.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0007_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -172,33 +167,37 @@ long mm_io_0007_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/mm_io_0007.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/mm_io_0007.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0007.pgc" - long h_sum ; +#line 70 "app/dbio/mm_io_0007.pgc" + long h_dr ; + +#line 71 "app/dbio/mm_io_0007.pgc" + long h_cr ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0007.pgc" +#line 72 "app/dbio/mm_io_0007.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0007_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when status_cd = 'D' then balance else 0 end ) , 0 ) , coalesce ( sum ( case when status_cd = 'C' then balance else 0 end ) , 0 ) from mst_account where biz_date = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_dr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_cr),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0007.pgc" - +#line 84 "app/dbio/mm_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0007_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/mm_io_0007.pgc b/app/dbio/mm_io_0007.pgc index ad2c778..3400d06 100644 --- a/app/dbio/mm_io_0007.pgc +++ b/app/dbio/mm_io_0007.pgc @@ -14,20 +14,21 @@ EXEC SQL INCLUDE sqlca; int mm_io_0007_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0007_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(a.balance), 0) + INTO :h_amt + FROM mst_card a + JOIN mst_limit b ON a.prod_cd = b.prod_cd + WHERE a.prod_cd = :h_key + AND b.status_cd = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,58 +36,55 @@ int mm_io_0007_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0007_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int mm_io_0007_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0007_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO mst_account + (prod_cd, balance, biz_date, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0007_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long mm_io_0007_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_dr; + long h_cr; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0007_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT + coalesce(sum(CASE WHEN status_cd = 'D' THEN balance ELSE 0 END), 0), + coalesce(sum(CASE WHEN status_cd = 'C' THEN balance ELSE 0 END), 0) + INTO :h_dr, :h_cr + FROM mst_account + WHERE biz_date = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0007_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/mm_io_0008.c b/app/dbio/mm_io_0008.c index 0c2c830..a312865 100644 --- a/app/dbio/mm_io_0008.c +++ b/app/dbio/mm_io_0008.c @@ -94,37 +94,51 @@ int mm_io_0008_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/mm_io_0008.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0008.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/mm_io_0008.pgc" + int h_cnt ; +/* exec sql end declare section */ +#line 20 "app/dbio/mm_io_0008.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0008_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mst_limit where card_no = $1 and amount > 0", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_int,&(h_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0008.pgc" +#line 31 "app/dbio/mm_io_0008.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0008_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mst_limit where card_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 42 "app/dbio/mm_io_0008.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0008_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } @@ -134,36 +148,32 @@ int mm_io_0008_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0008.pgc" - char h_key [ 16 ] ; +#line 54 "app/dbio/mm_io_0008.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0008.pgc" - long h_amount ; +#line 55 "app/dbio/mm_io_0008.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0008.pgc" +#line 56 "app/dbio/mm_io_0008.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0008_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mst_acct_bal ( card_no , amount , base_dt , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0008.pgc" - +#line 66 "app/dbio/mm_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0008_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,28 +183,26 @@ long mm_io_0008_total(const char *biz_date) -#line 72 "app/dbio/mm_io_0008.pgc" - char h_biz_date [ 9 ] ; +#line 77 "app/dbio/mm_io_0008.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0008.pgc" +#line 78 "app/dbio/mm_io_0008.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0008.pgc" +#line 79 "app/dbio/mm_io_0008.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0008_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mst_limit where base_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0008.pgc" - +#line 89 "app/dbio/mm_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0008_total"); diff --git a/app/dbio/mm_io_0008.pgc b/app/dbio/mm_io_0008.pgc index 0fba807..509dd0e 100644 --- a/app/dbio/mm_io_0008.pgc +++ b/app/dbio/mm_io_0008.pgc @@ -14,76 +14,79 @@ EXEC SQL INCLUDE sqlca; int mm_io_0008_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + int h_cnt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0008_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM mst_limit + WHERE card_no = :h_key + AND amount > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0008_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + EXEC SQL SELECT amount + INTO :h_amt + FROM mst_limit + WHERE card_no = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0008_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } int mm_io_0008_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0008_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO mst_acct_bal + (card_no, amount, base_dt, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0008_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long mm_io_0008_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; - - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; EXEC SQL SELECT coalesce(sum(amount), 0) INTO :h_sum - FROM mm_io_0008_t - WHERE biz_date = :h_biz_date; - + FROM mst_limit + WHERE base_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0008_total"); return -1; diff --git a/app/dbio/mm_io_0009.c b/app/dbio/mm_io_0009.c index c26f64e..2dbe97d 100644 --- a/app/dbio/mm_io_0009.c +++ b/app/dbio/mm_io_0009.c @@ -92,39 +92,45 @@ struct sqlca_t *ECPGget_sqlca(void); int mm_io_0009_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ - + + #line 17 "app/dbio/mm_io_0009.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0009.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/mm_io_0009.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/mm_io_0009.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0009_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( credit_lim ) from mst_product where acct_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/mm_io_0009.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0009_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } @@ -134,36 +140,32 @@ int mm_io_0009_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0009.pgc" - char h_key [ 16 ] ; +#line 48 "app/dbio/mm_io_0009.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0009.pgc" - long h_amount ; +#line 49 "app/dbio/mm_io_0009.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0009.pgc" +#line 50 "app/dbio/mm_io_0009.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0009_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mst_product ( acct_no , credit_lim , reg_dt , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0009.pgc" - +#line 60 "app/dbio/mm_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0009_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,32 +175,30 @@ long mm_io_0009_total(const char *biz_date) -#line 72 "app/dbio/mm_io_0009.pgc" - char h_biz_date [ 9 ] ; +#line 71 "app/dbio/mm_io_0009.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0009.pgc" - long h_sum ; +#line 72 "app/dbio/mm_io_0009.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0009.pgc" +#line 73 "app/dbio/mm_io_0009.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0009_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mst_product where reg_dt = $1 and credit_lim <> 0", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0009.pgc" - +#line 84 "app/dbio/mm_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0009_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/mm_io_0009.pgc b/app/dbio/mm_io_0009.pgc index 7dba69b..cba4624 100644 --- a/app/dbio/mm_io_0009.pgc +++ b/app/dbio/mm_io_0009.pgc @@ -14,79 +14,77 @@ EXEC SQL INCLUDE sqlca; int mm_io_0009_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0009_t - WHERE key = :h_key; - + EXEC SQL SELECT max(credit_lim) + INTO :h_amt:h_ind + FROM mst_product + WHERE acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0009_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } int mm_io_0009_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0009_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO mst_product + (acct_no, credit_lim, reg_dt, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0009_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long mm_io_0009_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0009_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM mst_product + WHERE reg_dt = :h_bd + AND credit_lim <> 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0009_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/mm_io_0010.c b/app/dbio/mm_io_0010.c index f959177..832811c 100644 --- a/app/dbio/mm_io_0010.c +++ b/app/dbio/mm_io_0010.c @@ -94,37 +94,58 @@ int mm_io_0010_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/mm_io_0010.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0010.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/mm_io_0010.pgc" + long h_acc ; +/* exec sql end declare section */ +#line 20 "app/dbio/mm_io_0010.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0010_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare mm_io_0010_fetch_cur cursor for select avail_amt from mst_customer where cust_id = $1 order by biz_date */ +#line 31 "app/dbio/mm_io_0010.pgc" + +#line 31 "app/dbio/mm_io_0010.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mm_io_0010_fetch_cur cursor for select avail_amt from mst_customer where cust_id = $1 order by biz_date", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 32 "app/dbio/mm_io_0010.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mm_io_0010_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0010.pgc" +#line 34 "app/dbio/mm_io_0010.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0010_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0010_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 39 "app/dbio/mm_io_0010.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0010_fetch"); - return TX_EDB; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0010_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 44 "app/dbio/mm_io_0010.pgc" + + *out_amount = h_acc; return TX_OK; } @@ -134,36 +155,32 @@ int mm_io_0010_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0010.pgc" - char h_key [ 16 ] ; +#line 52 "app/dbio/mm_io_0010.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0010.pgc" - long h_amount ; +#line 53 "app/dbio/mm_io_0010.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0010.pgc" +#line 54 "app/dbio/mm_io_0010.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0010_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mst_customer ( cust_id , avail_amt , biz_date , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0010.pgc" - +#line 64 "app/dbio/mm_io_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0010_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -172,33 +189,62 @@ long mm_io_0010_total(const char *biz_date) /* exec sql begin declare section */ + + -#line 72 "app/dbio/mm_io_0010.pgc" - char h_biz_date [ 9 ] ; +#line 75 "app/dbio/mm_io_0010.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0010.pgc" - long h_sum ; +#line 76 "app/dbio/mm_io_0010.pgc" + char h_grp [ 20 ] ; + +#line 77 "app/dbio/mm_io_0010.pgc" + long h_sub ; + +#line 78 "app/dbio/mm_io_0010.pgc" + long h_tot ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0010.pgc" +#line 79 "app/dbio/mm_io_0010.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + ECPGset_var( 1, ( h_bd ), __LINE__);\ + /* declare mm_io_0010_total_gc cursor for select branch_cd , coalesce ( sum ( avail_amt ) , 0 ) from mst_acct_bal where biz_date = $1 group by branch_cd order by branch_cd */ +#line 92 "app/dbio/mm_io_0010.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0010_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), +#line 92 "app/dbio/mm_io_0010.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mm_io_0010_total_gc cursor for select branch_cd , coalesce ( sum ( avail_amt ) , 0 ) from mst_acct_bal where biz_date = $1 group by branch_cd order by branch_cd", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 93 "app/dbio/mm_io_0010.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mm_io_0010_total_gc", ECPGt_EOIT, + ECPGt_char,(h_grp),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sub),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0010.pgc" +#line 95 "app/dbio/mm_io_0010.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0010_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0010_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 100 "app/dbio/mm_io_0010.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0010_total"); - return -1; + return -1; + } + h_tot += h_sub; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0010_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 105 "app/dbio/mm_io_0010.pgc" + + return h_tot; } diff --git a/app/dbio/mm_io_0010.pgc b/app/dbio/mm_io_0010.pgc index df75183..a150db6 100644 --- a/app/dbio/mm_io_0010.pgc +++ b/app/dbio/mm_io_0010.pgc @@ -14,79 +14,94 @@ EXEC SQL INCLUDE sqlca; int mm_io_0010_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + long h_acc; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0010_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0010_fetch"); - return TX_EDB; + EXEC SQL DECLARE mm_io_0010_fetch_cur CURSOR FOR + SELECT avail_amt FROM mst_customer + WHERE cust_id = :h_key + ORDER BY biz_date; + EXEC SQL OPEN mm_io_0010_fetch_cur; + for (;;) { + EXEC SQL FETCH mm_io_0010_fetch_cur INTO :h_amt; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0010_fetch"); + EXEC SQL CLOSE mm_io_0010_fetch_cur; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + EXEC SQL CLOSE mm_io_0010_fetch_cur; + *out_amount = h_acc; return TX_OK; } int mm_io_0010_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0010_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO mst_customer + (cust_id, avail_amt, biz_date, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0010_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long mm_io_0010_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + char h_grp[20]; + long h_sub; + long h_tot; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0010_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0010_total"); - return -1; + EXEC SQL DECLARE mm_io_0010_total_gc CURSOR FOR + SELECT branch_cd, coalesce(sum(avail_amt), 0) + FROM mst_acct_bal + WHERE biz_date = :h_bd + GROUP BY branch_cd + ORDER BY branch_cd; + EXEC SQL OPEN mm_io_0010_total_gc; + for (;;) { + EXEC SQL FETCH mm_io_0010_total_gc INTO :h_grp, :h_sub; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0010_total"); + EXEC SQL CLOSE mm_io_0010_total_gc; + return -1; + } + h_tot += h_sub; } - return h_sum; + EXEC SQL CLOSE mm_io_0010_total_gc; + return h_tot; } diff --git a/app/dbio/mm_io_0011.c b/app/dbio/mm_io_0011.c index 59b5d36..dfee058 100644 --- a/app/dbio/mm_io_0011.c +++ b/app/dbio/mm_io_0011.c @@ -96,27 +96,25 @@ int mm_io_0011_fetch(const char *key, long *out_amount) #line 17 "app/dbio/mm_io_0011.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0011.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/mm_io_0011.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0011_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( m . prin_bal , 0 ) - ( select coalesce ( sum ( h . prin_bal ) , 0 ) from mst_deposit h where h . prod_cd = m . prod_cd ) from mst_product m where m . prod_cd = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0011.pgc" - +#line 31 "app/dbio/mm_io_0011.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +122,7 @@ int mm_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -135,35 +133,31 @@ int mm_io_0011_touch(const char *key, long amount) #line 45 "app/dbio/mm_io_0011.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 46 "app/dbio/mm_io_0011.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/mm_io_0011.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0011_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mst_deposit ( prod_cd , prin_bal , base_dt , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0011.pgc" - +#line 57 "app/dbio/mm_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0011_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,28 +167,26 @@ long mm_io_0011_total(const char *biz_date) -#line 72 "app/dbio/mm_io_0011.pgc" - char h_biz_date [ 9 ] ; +#line 68 "app/dbio/mm_io_0011.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0011.pgc" +#line 69 "app/dbio/mm_io_0011.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0011.pgc" +#line 70 "app/dbio/mm_io_0011.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0011_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . prin_bal ) , 0 ) from mst_deposit d join mst_product m on d . prod_cd = m . prod_cd where d . base_dt = $1 and m . use_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0011.pgc" - +#line 82 "app/dbio/mm_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0011_total"); diff --git a/app/dbio/mm_io_0011.pgc b/app/dbio/mm_io_0011.pgc index d5439b5..53cf51b 100644 --- a/app/dbio/mm_io_0011.pgc +++ b/app/dbio/mm_io_0011.pgc @@ -14,76 +14,72 @@ EXEC SQL INCLUDE sqlca; int mm_io_0011_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0011_t - WHERE key = :h_key; - + EXEC SQL SELECT coalesce(m.prin_bal, 0) + - (SELECT coalesce(sum(h.prin_bal), 0) + FROM mst_deposit h WHERE h.prod_cd = m.prod_cd) + INTO :h_amt + FROM mst_product m + WHERE m.prod_cd = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int mm_io_0011_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0011_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO mst_deposit + (prod_cd, prin_bal, base_dt, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0011_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long mm_io_0011_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.prin_bal), 0) INTO :h_sum - FROM mm_io_0011_t - WHERE biz_date = :h_biz_date; - + FROM mst_deposit d + JOIN mst_product m ON d.prod_cd = m.prod_cd + WHERE d.base_dt = :h_bd + AND m.use_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0011_total"); return -1; diff --git a/app/dbio/mm_io_0012.c b/app/dbio/mm_io_0012.c index 1fc3bbf..acadd81 100644 --- a/app/dbio/mm_io_0012.c +++ b/app/dbio/mm_io_0012.c @@ -92,31 +92,43 @@ struct sqlca_t *ECPGget_sqlca(void); int mm_io_0012_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ + + + #line 17 "app/dbio/mm_io_0012.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0012.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_min ; + #line 19 "app/dbio/mm_io_0012.pgc" + long h_max ; + +#line 20 "app/dbio/mm_io_0012.pgc" + short h_i1 ; + +#line 21 "app/dbio/mm_io_0012.pgc" + short h_i2 ; +/* exec sql end declare section */ +#line 22 "app/dbio/mm_io_0012.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0012_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( int_amt ) , max ( int_amt ) from mst_deposit where card_no = $1 and block_yn <> 'D'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0012.pgc" - + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i1),(long)1,(long)1,sizeof(short), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i2),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 33 "app/dbio/mm_io_0012.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +136,9 @@ int mm_io_0012_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0012_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } @@ -134,71 +148,71 @@ int mm_io_0012_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0012.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/mm_io_0012.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0012.pgc" - long h_amount ; +#line 50 "app/dbio/mm_io_0012.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0012.pgc" +#line 51 "app/dbio/mm_io_0012.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0012_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mst_loan ( card_no , int_amt , reg_dt , reg_ts ) values ( $1 , $2 , to_char ( now ( ) , 'YYYYMMDD' ) , now ( ) )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0012.pgc" - +#line 61 "app/dbio/mm_io_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0012_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long mm_io_0012_total(const char *biz_date) { /* exec sql begin declare section */ - + + #line 72 "app/dbio/mm_io_0012.pgc" - char h_biz_date [ 9 ] ; + char h_bd [ 9 ] ; #line 73 "app/dbio/mm_io_0012.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_max ; + #line 74 "app/dbio/mm_io_0012.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 75 "app/dbio/mm_io_0012.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0012_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( int_amt ) from mst_deposit where reg_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 85 "app/dbio/mm_io_0012.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0012_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/mm_io_0012.pgc b/app/dbio/mm_io_0012.pgc index 5bd8ae1..1c22445 100644 --- a/app/dbio/mm_io_0012.pgc +++ b/app/dbio/mm_io_0012.pgc @@ -14,79 +14,80 @@ EXEC SQL INCLUDE sqlca; int mm_io_0012_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_min; + long h_max; + short h_i1; + short h_i2; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0012_t - WHERE key = :h_key; - + EXEC SQL SELECT min(int_amt), max(int_amt) + INTO :h_min:h_i1, :h_max:h_i2 + FROM mst_deposit + WHERE card_no = :h_key + AND block_yn <> 'D'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0012_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } int mm_io_0012_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0012_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO mst_loan + (card_no, int_amt, reg_dt, reg_ts) + VALUES (:h_key, :h_amt, to_char(now(), 'YYYYMMDD'), now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0012_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long mm_io_0012_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0012_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT max(int_amt) + INTO :h_max:h_ind + FROM mst_deposit + WHERE reg_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0012_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/mm_io_0013.c b/app/dbio/mm_io_0013.c index 2b066de..564f939 100644 --- a/app/dbio/mm_io_0013.c +++ b/app/dbio/mm_io_0013.c @@ -96,26 +96,25 @@ int mm_io_0013_fetch(const char *key, long *out_amount) #line 17 "app/dbio/mm_io_0013.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0013.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/mm_io_0013.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0013_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . balance ) , 0 ) from mst_deposit a join mst_loan b on a . acct_no = b . acct_no where a . acct_no = $1 and b . status_cd = 'Y'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0013.pgc" +#line 31 "app/dbio/mm_io_0013.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int mm_io_0013_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0013_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -134,29 +133,27 @@ int mm_io_0013_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0013.pgc" - char h_key [ 16 ] ; - #line 46 "app/dbio/mm_io_0013.pgc" - long h_amount ; -/* exec sql end declare section */ + char h_key [ 20 ] ; + #line 47 "app/dbio/mm_io_0013.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 48 "app/dbio/mm_io_0013.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0013_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mst_deposit ( acct_no , balance , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( acct_no ) do update set balance = mst_deposit . balance + EXCLUDED . balance , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0013.pgc" - +#line 60 "app/dbio/mm_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0013_touch"); @@ -173,32 +170,30 @@ long mm_io_0013_total(const char *biz_date) -#line 72 "app/dbio/mm_io_0013.pgc" - char h_biz_date [ 9 ] ; - #line 73 "app/dbio/mm_io_0013.pgc" - long h_sum ; -/* exec sql end declare section */ + char h_bd [ 9 ] ; + #line 74 "app/dbio/mm_io_0013.pgc" + long h_avg ; +/* exec sql end declare section */ +#line 75 "app/dbio/mm_io_0013.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0013_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( avg ( balance ) , 0 ) :: bigint from mst_deposit where biz_date = $1 and status_cd = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0013.pgc" - +#line 86 "app/dbio/mm_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0013_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/mm_io_0013.pgc b/app/dbio/mm_io_0013.pgc index 0b83ce2..112916a 100644 --- a/app/dbio/mm_io_0013.pgc +++ b/app/dbio/mm_io_0013.pgc @@ -14,20 +14,21 @@ EXEC SQL INCLUDE sqlca; int mm_io_0013_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0013_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(a.balance), 0) + INTO :h_amt + FROM mst_deposit a + JOIN mst_loan b ON a.acct_no = b.acct_no + WHERE a.acct_no = :h_key + AND b.status_cd = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +36,28 @@ int mm_io_0013_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0013_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int mm_io_0013_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0013_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO mst_deposit (acct_no, balance, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (acct_no) + DO UPDATE SET balance = mst_deposit.balance + EXCLUDED.balance, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0013_touch"); return TX_EDB; @@ -69,24 +70,23 @@ int mm_io_0013_touch(const char *key, long amount) long mm_io_0013_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_avg; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0013_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT coalesce(avg(balance), 0)::bigint + INTO :h_avg + FROM mst_deposit + WHERE biz_date = :h_bd + AND status_cd = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0013_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/mm_io_0014.c b/app/dbio/mm_io_0014.c index d3538e3..34dfc97 100644 --- a/app/dbio/mm_io_0014.c +++ b/app/dbio/mm_io_0014.c @@ -94,37 +94,51 @@ int mm_io_0014_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/mm_io_0014.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0014.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/mm_io_0014.pgc" + int h_cnt ; +/* exec sql end declare section */ +#line 20 "app/dbio/mm_io_0014.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0014_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mst_loan where cust_id = $1 and amount > 0", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_int,&(h_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0014.pgc" +#line 31 "app/dbio/mm_io_0014.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0014_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mst_loan where cust_id = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 42 "app/dbio/mm_io_0014.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0014_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +148,27 @@ int mm_io_0014_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0014.pgc" - char h_key [ 16 ] ; +#line 54 "app/dbio/mm_io_0014.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0014.pgc" - long h_amount ; +#line 55 "app/dbio/mm_io_0014.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0014.pgc" +#line 56 "app/dbio/mm_io_0014.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0014_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mst_loan ( cust_id , amount , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( cust_id ) do update set amount = mst_loan . amount + EXCLUDED . amount , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0014.pgc" - +#line 68 "app/dbio/mm_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0014_touch"); @@ -172,33 +184,37 @@ long mm_io_0014_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/mm_io_0014.pgc" - char h_biz_date [ 9 ] ; +#line 81 "app/dbio/mm_io_0014.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0014.pgc" - long h_sum ; +#line 82 "app/dbio/mm_io_0014.pgc" + long h_dr ; + +#line 83 "app/dbio/mm_io_0014.pgc" + long h_cr ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0014.pgc" +#line 84 "app/dbio/mm_io_0014.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0014_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when use_yn = 'D' then amount else 0 end ) , 0 ) , coalesce ( sum ( case when use_yn = 'C' then amount else 0 end ) , 0 ) from mst_limit where base_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_dr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_cr),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0014.pgc" - +#line 96 "app/dbio/mm_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0014_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/mm_io_0014.pgc b/app/dbio/mm_io_0014.pgc index 668ddb2..c57dffa 100644 --- a/app/dbio/mm_io_0014.pgc +++ b/app/dbio/mm_io_0014.pgc @@ -14,49 +14,58 @@ EXEC SQL INCLUDE sqlca; int mm_io_0014_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + int h_cnt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0014_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM mst_loan + WHERE cust_id = :h_key + AND amount > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0014_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + EXEC SQL SELECT amount + INTO :h_amt + FROM mst_loan + WHERE cust_id = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0014_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } int mm_io_0014_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0014_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO mst_loan (cust_id, amount, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (cust_id) + DO UPDATE SET amount = mst_loan.amount + EXCLUDED.amount, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0014_touch"); return TX_EDB; @@ -69,24 +78,25 @@ int mm_io_0014_touch(const char *key, long amount) long mm_io_0014_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_dr; + long h_cr; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0014_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT + coalesce(sum(CASE WHEN use_yn = 'D' THEN amount ELSE 0 END), 0), + coalesce(sum(CASE WHEN use_yn = 'C' THEN amount ELSE 0 END), 0) + INTO :h_dr, :h_cr + FROM mst_limit + WHERE base_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0014_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/mm_io_0015.c b/app/dbio/mm_io_0015.c index e84f8fe..db9924a 100644 --- a/app/dbio/mm_io_0015.c +++ b/app/dbio/mm_io_0015.c @@ -92,39 +92,45 @@ struct sqlca_t *ECPGget_sqlca(void); int mm_io_0015_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ - + + #line 17 "app/dbio/mm_io_0015.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0015.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/mm_io_0015.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/mm_io_0015.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0015_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( credit_lim ) from mst_account where prod_cd = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/mm_io_0015.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0015_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +140,27 @@ int mm_io_0015_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0015.pgc" - char h_key [ 16 ] ; +#line 48 "app/dbio/mm_io_0015.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0015.pgc" - long h_amount ; +#line 49 "app/dbio/mm_io_0015.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0015.pgc" +#line 50 "app/dbio/mm_io_0015.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0015_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mst_card ( prod_cd , credit_lim , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( prod_cd ) do update set credit_lim = mst_card . credit_lim + EXCLUDED . credit_lim , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0015.pgc" - +#line 62 "app/dbio/mm_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0015_touch"); @@ -173,28 +177,26 @@ long mm_io_0015_total(const char *biz_date) -#line 72 "app/dbio/mm_io_0015.pgc" - char h_biz_date [ 9 ] ; +#line 75 "app/dbio/mm_io_0015.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0015.pgc" +#line 76 "app/dbio/mm_io_0015.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0015.pgc" +#line 77 "app/dbio/mm_io_0015.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0015_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( credit_lim ) , 0 ) from mst_card where reg_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0015.pgc" - +#line 87 "app/dbio/mm_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0015_total"); diff --git a/app/dbio/mm_io_0015.pgc b/app/dbio/mm_io_0015.pgc index e4291fc..d83689c 100644 --- a/app/dbio/mm_io_0015.pgc +++ b/app/dbio/mm_io_0015.pgc @@ -14,49 +14,52 @@ EXEC SQL INCLUDE sqlca; int mm_io_0015_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0015_t - WHERE key = :h_key; - + EXEC SQL SELECT max(credit_lim) + INTO :h_amt:h_ind + FROM mst_account + WHERE prod_cd = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0015_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } int mm_io_0015_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0015_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO mst_card (prod_cd, credit_lim, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (prod_cd) + DO UPDATE SET credit_lim = mst_card.credit_lim + EXCLUDED.credit_lim, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0015_touch"); return TX_EDB; @@ -69,21 +72,19 @@ int mm_io_0015_touch(const char *key, long amount) long mm_io_0015_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(credit_lim), 0) INTO :h_sum - FROM mm_io_0015_t - WHERE biz_date = :h_biz_date; - + FROM mst_card + WHERE reg_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0015_total"); return -1; diff --git a/app/dbio/mm_io_0016.c b/app/dbio/mm_io_0016.c index e4861a9..3a496dc 100644 --- a/app/dbio/mm_io_0016.c +++ b/app/dbio/mm_io_0016.c @@ -94,37 +94,58 @@ int mm_io_0016_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/mm_io_0016.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0016.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/mm_io_0016.pgc" + long h_acc ; +/* exec sql end declare section */ +#line 20 "app/dbio/mm_io_0016.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0016_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare mm_io_0016_fetch_cur cursor for select avail_amt from mst_acct_bal where card_no = $1 order by biz_date */ +#line 31 "app/dbio/mm_io_0016.pgc" + +#line 31 "app/dbio/mm_io_0016.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mm_io_0016_fetch_cur cursor for select avail_amt from mst_acct_bal where card_no = $1 order by biz_date", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 32 "app/dbio/mm_io_0016.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mm_io_0016_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0016.pgc" +#line 34 "app/dbio/mm_io_0016.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0016_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0016_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 39 "app/dbio/mm_io_0016.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0016_fetch"); - return TX_EDB; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0016_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 44 "app/dbio/mm_io_0016.pgc" + + *out_amount = h_acc; return TX_OK; } @@ -134,29 +155,27 @@ int mm_io_0016_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0016.pgc" - char h_key [ 16 ] ; +#line 52 "app/dbio/mm_io_0016.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0016.pgc" - long h_amount ; +#line 53 "app/dbio/mm_io_0016.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0016.pgc" +#line 54 "app/dbio/mm_io_0016.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0016_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mst_limit ( card_no , avail_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( card_no ) do update set avail_amt = mst_limit . avail_amt + EXCLUDED . avail_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0016.pgc" - +#line 66 "app/dbio/mm_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0016_touch"); @@ -173,32 +192,30 @@ long mm_io_0016_total(const char *biz_date) -#line 72 "app/dbio/mm_io_0016.pgc" - char h_biz_date [ 9 ] ; +#line 79 "app/dbio/mm_io_0016.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0016.pgc" - long h_sum ; +#line 80 "app/dbio/mm_io_0016.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0016.pgc" +#line 81 "app/dbio/mm_io_0016.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0016_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mst_acct_bal where biz_date = $1 and avail_amt <> 0", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0016.pgc" - +#line 92 "app/dbio/mm_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0016_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/mm_io_0016.pgc b/app/dbio/mm_io_0016.pgc index 269e302..1bbcede 100644 --- a/app/dbio/mm_io_0016.pgc +++ b/app/dbio/mm_io_0016.pgc @@ -14,49 +14,56 @@ EXEC SQL INCLUDE sqlca; int mm_io_0016_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + long h_acc; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0016_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0016_fetch"); - return TX_EDB; + EXEC SQL DECLARE mm_io_0016_fetch_cur CURSOR FOR + SELECT avail_amt FROM mst_acct_bal + WHERE card_no = :h_key + ORDER BY biz_date; + EXEC SQL OPEN mm_io_0016_fetch_cur; + for (;;) { + EXEC SQL FETCH mm_io_0016_fetch_cur INTO :h_amt; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0016_fetch"); + EXEC SQL CLOSE mm_io_0016_fetch_cur; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + EXEC SQL CLOSE mm_io_0016_fetch_cur; + *out_amount = h_acc; return TX_OK; } int mm_io_0016_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0016_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO mst_limit (card_no, avail_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (card_no) + DO UPDATE SET avail_amt = mst_limit.avail_amt + EXCLUDED.avail_amt, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0016_touch"); return TX_EDB; @@ -69,24 +76,23 @@ int mm_io_0016_touch(const char *key, long amount) long mm_io_0016_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0016_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM mst_acct_bal + WHERE biz_date = :h_bd + AND avail_amt <> 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0016_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/mm_io_0017.c b/app/dbio/mm_io_0017.c index 53cea74..c7ec287 100644 --- a/app/dbio/mm_io_0017.c +++ b/app/dbio/mm_io_0017.c @@ -96,27 +96,25 @@ int mm_io_0017_fetch(const char *key, long *out_amount) #line 17 "app/dbio/mm_io_0017.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0017.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/mm_io_0017.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0017_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( m . prin_bal , 0 ) - ( select coalesce ( sum ( h . prin_bal ) , 0 ) from mst_product h where h . acct_no = m . acct_no ) from mst_account m where m . acct_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0017.pgc" - +#line 31 "app/dbio/mm_io_0017.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +122,7 @@ int mm_io_0017_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0017_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -135,28 +133,26 @@ int mm_io_0017_touch(const char *key, long amount) #line 45 "app/dbio/mm_io_0017.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 46 "app/dbio/mm_io_0017.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/mm_io_0017.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0017_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mst_account ( acct_no , prin_bal , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( acct_no ) do update set prin_bal = mst_account . prin_bal + EXCLUDED . prin_bal , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0017.pgc" - +#line 59 "app/dbio/mm_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0017_touch"); @@ -172,33 +168,62 @@ long mm_io_0017_total(const char *biz_date) /* exec sql begin declare section */ + + #line 72 "app/dbio/mm_io_0017.pgc" - char h_biz_date [ 9 ] ; + char h_bd [ 9 ] ; #line 73 "app/dbio/mm_io_0017.pgc" - long h_sum ; -/* exec sql end declare section */ + char h_grp [ 20 ] ; + #line 74 "app/dbio/mm_io_0017.pgc" + long h_sub ; + +#line 75 "app/dbio/mm_io_0017.pgc" + long h_tot ; +/* exec sql end declare section */ +#line 76 "app/dbio/mm_io_0017.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + ECPGset_var( 0, ( h_bd ), __LINE__);\ + /* declare mm_io_0017_total_gc cursor for select cust_id , coalesce ( sum ( prin_bal ) , 0 ) from mst_account where base_dt = $1 group by cust_id order by cust_id */ +#line 89 "app/dbio/mm_io_0017.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0017_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), +#line 89 "app/dbio/mm_io_0017.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mm_io_0017_total_gc cursor for select cust_id , coalesce ( sum ( prin_bal ) , 0 ) from mst_account where base_dt = $1 group by cust_id order by cust_id", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 90 "app/dbio/mm_io_0017.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mm_io_0017_total_gc", ECPGt_EOIT, + ECPGt_char,(h_grp),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sub),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0017.pgc" +#line 92 "app/dbio/mm_io_0017.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0017_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0017_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 97 "app/dbio/mm_io_0017.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0017_total"); - return -1; + return -1; + } + h_tot += h_sub; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0017_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 102 "app/dbio/mm_io_0017.pgc" + + return h_tot; } diff --git a/app/dbio/mm_io_0017.pgc b/app/dbio/mm_io_0017.pgc index 79a3989..f4c6edb 100644 --- a/app/dbio/mm_io_0017.pgc +++ b/app/dbio/mm_io_0017.pgc @@ -14,49 +14,49 @@ EXEC SQL INCLUDE sqlca; int mm_io_0017_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0017_t - WHERE key = :h_key; - + EXEC SQL SELECT coalesce(m.prin_bal, 0) + - (SELECT coalesce(sum(h.prin_bal), 0) + FROM mst_product h WHERE h.acct_no = m.acct_no) + INTO :h_amt + FROM mst_account m + WHERE m.acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0017_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int mm_io_0017_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0017_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO mst_account (acct_no, prin_bal, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (acct_no) + DO UPDATE SET prin_bal = mst_account.prin_bal + EXCLUDED.prin_bal, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0017_touch"); return TX_EDB; @@ -69,24 +69,36 @@ int mm_io_0017_touch(const char *key, long amount) long mm_io_0017_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + char h_grp[20]; + long h_sub; + long h_tot; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0017_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0017_total"); - return -1; + EXEC SQL DECLARE mm_io_0017_total_gc CURSOR FOR + SELECT cust_id, coalesce(sum(prin_bal), 0) + FROM mst_account + WHERE base_dt = :h_bd + GROUP BY cust_id + ORDER BY cust_id; + EXEC SQL OPEN mm_io_0017_total_gc; + for (;;) { + EXEC SQL FETCH mm_io_0017_total_gc INTO :h_grp, :h_sub; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0017_total"); + EXEC SQL CLOSE mm_io_0017_total_gc; + return -1; + } + h_tot += h_sub; } - return h_sum; + EXEC SQL CLOSE mm_io_0017_total_gc; + return h_tot; } diff --git a/app/dbio/mm_io_0018.c b/app/dbio/mm_io_0018.c index 26efa2b..7ec7b7b 100644 --- a/app/dbio/mm_io_0018.c +++ b/app/dbio/mm_io_0018.c @@ -92,31 +92,43 @@ struct sqlca_t *ECPGget_sqlca(void); int mm_io_0018_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ + + + #line 17 "app/dbio/mm_io_0018.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0018.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_min ; + #line 19 "app/dbio/mm_io_0018.pgc" + long h_max ; + +#line 20 "app/dbio/mm_io_0018.pgc" + short h_i1 ; + +#line 21 "app/dbio/mm_io_0018.pgc" + short h_i2 ; +/* exec sql end declare section */ +#line 22 "app/dbio/mm_io_0018.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0018_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( int_amt ) , max ( int_amt ) from mst_product where cust_id = $1 and block_yn <> 'D'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0018.pgc" - + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i1),(long)1,(long)1,sizeof(short), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i2),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 33 "app/dbio/mm_io_0018.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +136,9 @@ int mm_io_0018_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0018_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } @@ -134,29 +148,27 @@ int mm_io_0018_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0018.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/mm_io_0018.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0018.pgc" - long h_amount ; +#line 50 "app/dbio/mm_io_0018.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0018.pgc" +#line 51 "app/dbio/mm_io_0018.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0018_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mst_acct_bal ( cust_id , int_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( cust_id ) do update set int_amt = mst_acct_bal . int_amt + EXCLUDED . int_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0018.pgc" - +#line 63 "app/dbio/mm_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0018_touch"); @@ -173,28 +185,26 @@ long mm_io_0018_total(const char *biz_date) -#line 72 "app/dbio/mm_io_0018.pgc" - char h_biz_date [ 9 ] ; +#line 76 "app/dbio/mm_io_0018.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0018.pgc" +#line 77 "app/dbio/mm_io_0018.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0018.pgc" +#line 78 "app/dbio/mm_io_0018.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0018_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . int_amt ) , 0 ) from mst_customer d join mst_acct_bal m on d . cust_id = m . cust_id where d . reg_dt = $1 and m . block_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0018.pgc" - +#line 90 "app/dbio/mm_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0018_total"); diff --git a/app/dbio/mm_io_0018.pgc b/app/dbio/mm_io_0018.pgc index 4546df9..23a5855 100644 --- a/app/dbio/mm_io_0018.pgc +++ b/app/dbio/mm_io_0018.pgc @@ -14,49 +14,53 @@ EXEC SQL INCLUDE sqlca; int mm_io_0018_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_min; + long h_max; + short h_i1; + short h_i2; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0018_t - WHERE key = :h_key; - + EXEC SQL SELECT min(int_amt), max(int_amt) + INTO :h_min:h_i1, :h_max:h_i2 + FROM mst_product + WHERE cust_id = :h_key + AND block_yn <> 'D'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0018_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } int mm_io_0018_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0018_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO mst_acct_bal (cust_id, int_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (cust_id) + DO UPDATE SET int_amt = mst_acct_bal.int_amt + EXCLUDED.int_amt, + upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0018_touch"); return TX_EDB; @@ -69,21 +73,21 @@ int mm_io_0018_touch(const char *key, long amount) long mm_io_0018_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.int_amt), 0) INTO :h_sum - FROM mm_io_0018_t - WHERE biz_date = :h_biz_date; - + FROM mst_customer d + JOIN mst_acct_bal m ON d.cust_id = m.cust_id + WHERE d.reg_dt = :h_bd + AND m.block_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0018_total"); return -1; diff --git a/app/dbio/mm_io_0019.c b/app/dbio/mm_io_0019.c index a02836a..4b31e20 100644 --- a/app/dbio/mm_io_0019.c +++ b/app/dbio/mm_io_0019.c @@ -96,26 +96,25 @@ int mm_io_0019_fetch(const char *key, long *out_amount) #line 17 "app/dbio/mm_io_0019.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0019.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/mm_io_0019.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0019_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . balance ) , 0 ) from mst_product a join mst_customer b on a . prod_cd = b . prod_cd where a . prod_cd = $1 and b . status_cd = 'Y'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0019.pgc" +#line 31 "app/dbio/mm_io_0019.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int mm_io_0019_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0019_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -134,71 +133,74 @@ int mm_io_0019_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0019.pgc" - char h_key [ 16 ] ; - #line 46 "app/dbio/mm_io_0019.pgc" - long h_amount ; -/* exec sql end declare section */ + char h_key [ 20 ] ; + #line 47 "app/dbio/mm_io_0019.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 48 "app/dbio/mm_io_0019.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0019_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from mst_deposit where prod_cd = $1 and balance < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/mm_io_0019.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0019_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "mm_io_0019_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long mm_io_0019_total(const char *biz_date) { /* exec sql begin declare section */ - + + #line 72 "app/dbio/mm_io_0019.pgc" - char h_biz_date [ 9 ] ; + char h_bd [ 9 ] ; #line 73 "app/dbio/mm_io_0019.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_max ; + #line 74 "app/dbio/mm_io_0019.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 75 "app/dbio/mm_io_0019.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0019_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( balance ) from mst_customer where biz_date = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 85 "app/dbio/mm_io_0019.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0019_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/mm_io_0019.pgc b/app/dbio/mm_io_0019.pgc index bc496f8..6772ce1 100644 --- a/app/dbio/mm_io_0019.pgc +++ b/app/dbio/mm_io_0019.pgc @@ -14,20 +14,21 @@ EXEC SQL INCLUDE sqlca; int mm_io_0019_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0019_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(a.balance), 0) + INTO :h_amt + FROM mst_product a + JOIN mst_customer b ON a.prod_cd = b.prod_cd + WHERE a.prod_cd = :h_key + AND b.status_cd = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,58 +36,58 @@ int mm_io_0019_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0019_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int mm_io_0019_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0019_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM mst_deposit + WHERE prod_cd = :h_key + AND balance < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0019_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "mm_io_0019_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long mm_io_0019_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0019_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT max(balance) + INTO :h_max:h_ind + FROM mst_customer + WHERE biz_date = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0019_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/mm_io_0020.c b/app/dbio/mm_io_0020.c index f981e06..9de081e 100644 --- a/app/dbio/mm_io_0020.c +++ b/app/dbio/mm_io_0020.c @@ -94,37 +94,51 @@ int mm_io_0020_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/mm_io_0020.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0020.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/mm_io_0020.pgc" + int h_cnt ; +/* exec sql end declare section */ +#line 20 "app/dbio/mm_io_0020.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0020_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mst_customer where card_no = $1 and amount > 0", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_int,&(h_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0020.pgc" +#line 31 "app/dbio/mm_io_0020.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mst_customer where card_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 42 "app/dbio/mm_io_0020.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0020_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +148,27 @@ int mm_io_0020_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0020.pgc" - char h_key [ 16 ] ; +#line 54 "app/dbio/mm_io_0020.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0020.pgc" - long h_amount ; +#line 55 "app/dbio/mm_io_0020.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0020.pgc" +#line 56 "app/dbio/mm_io_0020.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0020_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from mst_loan where card_no = $1 and amount < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0020.pgc" - +#line 66 "app/dbio/mm_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0020_touch"); @@ -164,6 +176,7 @@ int mm_io_0020_touch(const char *key, long amount) } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "mm_io_0020_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } @@ -173,32 +186,30 @@ long mm_io_0020_total(const char *biz_date) -#line 72 "app/dbio/mm_io_0020.pgc" - char h_biz_date [ 9 ] ; +#line 80 "app/dbio/mm_io_0020.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0020.pgc" - long h_sum ; +#line 81 "app/dbio/mm_io_0020.pgc" + long h_avg ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0020.pgc" +#line 82 "app/dbio/mm_io_0020.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0020_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( avg ( amount ) , 0 ) :: bigint from mst_customer where base_dt = $1 and use_yn = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0020.pgc" - +#line 93 "app/dbio/mm_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0020_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/mm_io_0020.pgc b/app/dbio/mm_io_0020.pgc index 5bd5224..461124f 100644 --- a/app/dbio/mm_io_0020.pgc +++ b/app/dbio/mm_io_0020.pgc @@ -14,79 +14,86 @@ EXEC SQL INCLUDE sqlca; int mm_io_0020_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + int h_cnt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0020_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM mst_customer + WHERE card_no = :h_key + AND amount > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + EXEC SQL SELECT amount + INTO :h_amt + FROM mst_customer + WHERE card_no = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0020_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } int mm_io_0020_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0020_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM mst_loan + WHERE card_no = :h_key + AND amount < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0020_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "mm_io_0020_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long mm_io_0020_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_avg; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0020_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT coalesce(avg(amount), 0)::bigint + INTO :h_avg + FROM mst_customer + WHERE base_dt = :h_bd + AND use_yn = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0020_total"); return -1; } - return h_sum; + return h_avg; } diff --git a/app/dbio/mm_io_0021.c b/app/dbio/mm_io_0021.c index 253ca9d..4fda708 100644 --- a/app/dbio/mm_io_0021.c +++ b/app/dbio/mm_io_0021.c @@ -92,39 +92,45 @@ struct sqlca_t *ECPGget_sqlca(void); int mm_io_0021_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ - + + #line 17 "app/dbio/mm_io_0021.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0021.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/mm_io_0021.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/mm_io_0021.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0021_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( credit_lim ) from mst_card where acct_no = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/mm_io_0021.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0021_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +140,27 @@ int mm_io_0021_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0021.pgc" - char h_key [ 16 ] ; +#line 48 "app/dbio/mm_io_0021.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0021.pgc" - long h_amount ; +#line 49 "app/dbio/mm_io_0021.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0021.pgc" +#line 50 "app/dbio/mm_io_0021.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0021_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from mst_card where acct_no = $1 and credit_lim < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0021.pgc" - +#line 60 "app/dbio/mm_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0021_touch"); @@ -164,6 +168,7 @@ int mm_io_0021_touch(const char *key, long amount) } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "mm_io_0021_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } @@ -172,33 +177,37 @@ long mm_io_0021_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/mm_io_0021.pgc" - char h_biz_date [ 9 ] ; - -#line 73 "app/dbio/mm_io_0021.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/mm_io_0021.pgc" + char h_bd [ 9 ] ; + +#line 75 "app/dbio/mm_io_0021.pgc" + long h_dr ; + +#line 76 "app/dbio/mm_io_0021.pgc" + long h_cr ; +/* exec sql end declare section */ +#line 77 "app/dbio/mm_io_0021.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0021_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when block_yn = 'D' then credit_lim else 0 end ) , 0 ) , coalesce ( sum ( case when block_yn = 'C' then credit_lim else 0 end ) , 0 ) from mst_card where reg_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_dr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_cr),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0021.pgc" - +#line 89 "app/dbio/mm_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0021_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/mm_io_0021.pgc b/app/dbio/mm_io_0021.pgc index 5b67001..37d9668 100644 --- a/app/dbio/mm_io_0021.pgc +++ b/app/dbio/mm_io_0021.pgc @@ -14,79 +14,82 @@ EXEC SQL INCLUDE sqlca; int mm_io_0021_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0021_t - WHERE key = :h_key; - + EXEC SQL SELECT max(credit_lim) + INTO :h_amt:h_ind + FROM mst_card + WHERE acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0021_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) { + *out_amount = 0; + return TX_ENOENT; + } + *out_amount = h_amt; return TX_OK; } int mm_io_0021_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0021_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM mst_card + WHERE acct_no = :h_key + AND credit_lim < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0021_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "mm_io_0021_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long mm_io_0021_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_dr; + long h_cr; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0021_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT + coalesce(sum(CASE WHEN block_yn = 'D' THEN credit_lim ELSE 0 END), 0), + coalesce(sum(CASE WHEN block_yn = 'C' THEN credit_lim ELSE 0 END), 0) + INTO :h_dr, :h_cr + FROM mst_card + WHERE reg_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0021_total"); return -1; } - return h_sum; + return h_dr - h_cr; } diff --git a/app/dbio/mm_io_0022.c b/app/dbio/mm_io_0022.c index 5929e3c..ddcddc5 100644 --- a/app/dbio/mm_io_0022.c +++ b/app/dbio/mm_io_0022.c @@ -94,37 +94,58 @@ int mm_io_0022_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/mm_io_0022.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0022.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/mm_io_0022.pgc" + long h_acc ; +/* exec sql end declare section */ +#line 20 "app/dbio/mm_io_0022.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0022_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare mm_io_0022_fetch_cur cursor for select avail_amt from mst_limit where cust_id = $1 order by biz_date */ +#line 31 "app/dbio/mm_io_0022.pgc" + +#line 31 "app/dbio/mm_io_0022.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mm_io_0022_fetch_cur cursor for select avail_amt from mst_limit where cust_id = $1 order by biz_date", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 32 "app/dbio/mm_io_0022.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mm_io_0022_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0022.pgc" +#line 34 "app/dbio/mm_io_0022.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0022_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0022_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 39 "app/dbio/mm_io_0022.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0022_fetch"); - return TX_EDB; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0022_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 44 "app/dbio/mm_io_0022.pgc" + + *out_amount = h_acc; return TX_OK; } @@ -134,29 +155,27 @@ int mm_io_0022_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0022.pgc" - char h_key [ 16 ] ; +#line 52 "app/dbio/mm_io_0022.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0022.pgc" - long h_amount ; +#line 53 "app/dbio/mm_io_0022.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0022.pgc" +#line 54 "app/dbio/mm_io_0022.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0022_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from mst_limit where cust_id = $1 and avail_amt < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0022.pgc" - +#line 64 "app/dbio/mm_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0022_touch"); @@ -164,6 +183,7 @@ int mm_io_0022_touch(const char *key, long amount) } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "mm_io_0022_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } @@ -173,28 +193,26 @@ long mm_io_0022_total(const char *biz_date) -#line 72 "app/dbio/mm_io_0022.pgc" - char h_biz_date [ 9 ] ; +#line 78 "app/dbio/mm_io_0022.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0022.pgc" +#line 79 "app/dbio/mm_io_0022.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0022.pgc" +#line 80 "app/dbio/mm_io_0022.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0022_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( avail_amt ) , 0 ) from mst_loan where biz_date = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0022.pgc" - +#line 90 "app/dbio/mm_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0022_total"); diff --git a/app/dbio/mm_io_0022.pgc b/app/dbio/mm_io_0022.pgc index f691aa9..73686fc 100644 --- a/app/dbio/mm_io_0022.pgc +++ b/app/dbio/mm_io_0022.pgc @@ -14,76 +14,80 @@ EXEC SQL INCLUDE sqlca; int mm_io_0022_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + long h_acc; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + h_acc = 0; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0022_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0022_fetch"); - return TX_EDB; + EXEC SQL DECLARE mm_io_0022_fetch_cur CURSOR FOR + SELECT avail_amt FROM mst_limit + WHERE cust_id = :h_key + ORDER BY biz_date; + EXEC SQL OPEN mm_io_0022_fetch_cur; + for (;;) { + EXEC SQL FETCH mm_io_0022_fetch_cur INTO :h_amt; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0022_fetch"); + EXEC SQL CLOSE mm_io_0022_fetch_cur; + return TX_EDB; + } + h_acc += h_amt; } - *out_amount = h_amount; + EXEC SQL CLOSE mm_io_0022_fetch_cur; + *out_amount = h_acc; return TX_OK; } int mm_io_0022_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0022_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM mst_limit + WHERE cust_id = :h_key + AND avail_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0022_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "mm_io_0022_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long mm_io_0022_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(avail_amt), 0) INTO :h_sum - FROM mm_io_0022_t - WHERE biz_date = :h_biz_date; - + FROM mst_loan + WHERE biz_date = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0022_total"); return -1; diff --git a/app/dbio/mm_io_0023.c b/app/dbio/mm_io_0023.c index bbe9ff2..8d31bd1 100644 --- a/app/dbio/mm_io_0023.c +++ b/app/dbio/mm_io_0023.c @@ -96,27 +96,25 @@ int mm_io_0023_fetch(const char *key, long *out_amount) #line 17 "app/dbio/mm_io_0023.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0023.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/mm_io_0023.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0023_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( m . prin_bal , 0 ) - ( select coalesce ( sum ( h . prin_bal ) , 0 ) from mst_account h where h . prod_cd = m . prod_cd ) from mst_card m where m . prod_cd = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0023.pgc" - +#line 31 "app/dbio/mm_io_0023.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +122,7 @@ int mm_io_0023_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0023_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -135,28 +133,26 @@ int mm_io_0023_touch(const char *key, long amount) #line 45 "app/dbio/mm_io_0023.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 46 "app/dbio/mm_io_0023.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/mm_io_0023.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0023_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from mst_account where prod_cd = $1 and prin_bal < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0023.pgc" - +#line 57 "app/dbio/mm_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0023_touch"); @@ -164,6 +160,7 @@ int mm_io_0023_touch(const char *key, long amount) } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "mm_io_0023_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } @@ -173,32 +170,30 @@ long mm_io_0023_total(const char *biz_date) -#line 72 "app/dbio/mm_io_0023.pgc" - char h_biz_date [ 9 ] ; +#line 71 "app/dbio/mm_io_0023.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0023.pgc" - long h_sum ; +#line 72 "app/dbio/mm_io_0023.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0023.pgc" +#line 73 "app/dbio/mm_io_0023.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0023_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mst_account where base_dt = $1 and prin_bal <> 0", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0023.pgc" - +#line 84 "app/dbio/mm_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0023_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/mm_io_0023.pgc b/app/dbio/mm_io_0023.pgc index 687b35c..5f923dd 100644 --- a/app/dbio/mm_io_0023.pgc +++ b/app/dbio/mm_io_0023.pgc @@ -14,79 +14,77 @@ EXEC SQL INCLUDE sqlca; int mm_io_0023_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0023_t - WHERE key = :h_key; - + EXEC SQL SELECT coalesce(m.prin_bal, 0) + - (SELECT coalesce(sum(h.prin_bal), 0) + FROM mst_account h WHERE h.prod_cd = m.prod_cd) + INTO :h_amt + FROM mst_card m + WHERE m.prod_cd = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0023_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int mm_io_0023_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0023_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM mst_account + WHERE prod_cd = :h_key + AND prin_bal < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0023_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "mm_io_0023_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long mm_io_0023_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0023_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM mst_account + WHERE base_dt = :h_bd + AND prin_bal <> 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0023_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/mm_io_0024.c b/app/dbio/mm_io_0024.c index 94be67c..5580564 100644 --- a/app/dbio/mm_io_0024.c +++ b/app/dbio/mm_io_0024.c @@ -92,31 +92,43 @@ struct sqlca_t *ECPGget_sqlca(void); int mm_io_0024_fetch(const char *key, long *out_amount) { /* exec sql begin declare section */ + + + #line 17 "app/dbio/mm_io_0024.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0024.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_min ; + #line 19 "app/dbio/mm_io_0024.pgc" + long h_max ; + +#line 20 "app/dbio/mm_io_0024.pgc" + short h_i1 ; + +#line 21 "app/dbio/mm_io_0024.pgc" + short h_i2 ; +/* exec sql end declare section */ +#line 22 "app/dbio/mm_io_0024.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0024_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( int_amt ) , max ( int_amt ) from mst_account where card_no = $1 and block_yn <> 'D'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0024.pgc" - + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i1),(long)1,(long)1,sizeof(short), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_i2),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 33 "app/dbio/mm_io_0024.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -124,7 +136,9 @@ int mm_io_0024_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0024_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } @@ -134,29 +148,27 @@ int mm_io_0024_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0024.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/mm_io_0024.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0024.pgc" - long h_amount ; +#line 50 "app/dbio/mm_io_0024.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0024.pgc" +#line 51 "app/dbio/mm_io_0024.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0024_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from mst_acct_bal where card_no = $1 and int_amt < $2 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0024.pgc" - +#line 61 "app/dbio/mm_io_0024.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0024_touch"); @@ -164,6 +176,7 @@ int mm_io_0024_touch(const char *key, long amount) } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "mm_io_0024_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } @@ -172,33 +185,62 @@ long mm_io_0024_total(const char *biz_date) /* exec sql begin declare section */ + + -#line 72 "app/dbio/mm_io_0024.pgc" - char h_biz_date [ 9 ] ; +#line 75 "app/dbio/mm_io_0024.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0024.pgc" - long h_sum ; +#line 76 "app/dbio/mm_io_0024.pgc" + char h_grp [ 20 ] ; + +#line 77 "app/dbio/mm_io_0024.pgc" + long h_sub ; + +#line 78 "app/dbio/mm_io_0024.pgc" + long h_tot ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0024.pgc" +#line 79 "app/dbio/mm_io_0024.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + ECPGset_var( 0, ( h_bd ), __LINE__);\ + /* declare mm_io_0024_total_gc cursor for select prod_cd , coalesce ( sum ( int_amt ) , 0 ) from mst_limit where reg_dt = $1 group by prod_cd order by prod_cd */ +#line 92 "app/dbio/mm_io_0024.pgc" - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0024_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), +#line 92 "app/dbio/mm_io_0024.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mm_io_0024_total_gc cursor for select prod_cd , coalesce ( sum ( int_amt ) , 0 ) from mst_limit where reg_dt = $1 group by prod_cd order by prod_cd", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 93 "app/dbio/mm_io_0024.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mm_io_0024_total_gc", ECPGt_EOIT, + ECPGt_char,(h_grp),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sub),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0024.pgc" +#line 95 "app/dbio/mm_io_0024.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0024_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0024_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 100 "app/dbio/mm_io_0024.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0024_total"); - return -1; + return -1; + } + h_tot += h_sub; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mm_io_0024_total_gc", ECPGt_EOIT, ECPGt_EORT);} +#line 105 "app/dbio/mm_io_0024.pgc" + + return h_tot; } diff --git a/app/dbio/mm_io_0024.pgc b/app/dbio/mm_io_0024.pgc index 38d8ea9..637b7e1 100644 --- a/app/dbio/mm_io_0024.pgc +++ b/app/dbio/mm_io_0024.pgc @@ -14,79 +14,94 @@ EXEC SQL INCLUDE sqlca; int mm_io_0024_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_min; + long h_max; + short h_i1; + short h_i2; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0024_t - WHERE key = :h_key; - + EXEC SQL SELECT min(int_amt), max(int_amt) + INTO :h_min:h_i1, :h_max:h_i2 + FROM mst_account + WHERE card_no = :h_key + AND block_yn <> 'D'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0024_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_i1 < 0 || h_i2 < 0) + return TX_ENOENT; + *out_amount = h_max - h_min; return TX_OK; } int mm_io_0024_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0024_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM mst_acct_bal + WHERE card_no = :h_key + AND int_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0024_touch"); return TX_EDB; } if (sqlca.sqlerrd[2] == 0) return TX_ENOENT; + tx_log(TX_LOG_INFO, "mm_io_0024_touch 삭제 %ld건", (long)sqlca.sqlerrd[2]); return TX_OK; } long mm_io_0024_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + char h_grp[20]; + long h_sub; + long h_tot; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; + h_tot = 0; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0024_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("mm_io_0024_total"); - return -1; + EXEC SQL DECLARE mm_io_0024_total_gc CURSOR FOR + SELECT prod_cd, coalesce(sum(int_amt), 0) + FROM mst_limit + WHERE reg_dt = :h_bd + GROUP BY prod_cd + ORDER BY prod_cd; + EXEC SQL OPEN mm_io_0024_total_gc; + for (;;) { + EXEC SQL FETCH mm_io_0024_total_gc INTO :h_grp, :h_sub; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0024_total"); + EXEC SQL CLOSE mm_io_0024_total_gc; + return -1; + } + h_tot += h_sub; } - return h_sum; + EXEC SQL CLOSE mm_io_0024_total_gc; + return h_tot; } diff --git a/app/dbio/mm_io_0025.c b/app/dbio/mm_io_0025.c index a97174e..9c6d6b0 100644 --- a/app/dbio/mm_io_0025.c +++ b/app/dbio/mm_io_0025.c @@ -96,26 +96,25 @@ int mm_io_0025_fetch(const char *key, long *out_amount) #line 17 "app/dbio/mm_io_0025.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0025.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 19 "app/dbio/mm_io_0025.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0025_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . balance ) , 0 ) from mst_account a join mst_acct_bal b on a . acct_no = b . acct_no where a . acct_no = $1 and b . status_cd = 'Y'", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0025.pgc" +#line 31 "app/dbio/mm_io_0025.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int mm_io_0025_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0025_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } @@ -134,29 +133,27 @@ int mm_io_0025_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0025.pgc" - char h_key [ 16 ] ; - #line 46 "app/dbio/mm_io_0025.pgc" - long h_amount ; -/* exec sql end declare section */ + char h_key [ 20 ] ; + #line 47 "app/dbio/mm_io_0025.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 48 "app/dbio/mm_io_0025.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0025_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mst_acct_bal set balance = balance + $1 where cust_id in ( select cust_id from mst_account where acct_no = $2 )", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0025.pgc" - +#line 59 "app/dbio/mm_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0025_touch"); @@ -174,7 +171,7 @@ long mm_io_0025_total(const char *biz_date) #line 72 "app/dbio/mm_io_0025.pgc" - char h_biz_date [ 9 ] ; + char h_bd [ 9 ] ; #line 73 "app/dbio/mm_io_0025.pgc" long h_sum ; @@ -184,17 +181,15 @@ long mm_io_0025_total(const char *biz_date) if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0025_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . balance ) , 0 ) from mst_product d join mst_account m on d . acct_no = m . acct_no where d . biz_date = $1 and m . status_cd = 'A'", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0025.pgc" - +#line 86 "app/dbio/mm_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0025_total"); diff --git a/app/dbio/mm_io_0025.pgc b/app/dbio/mm_io_0025.pgc index c689a58..dd41eaf 100644 --- a/app/dbio/mm_io_0025.pgc +++ b/app/dbio/mm_io_0025.pgc @@ -14,20 +14,21 @@ EXEC SQL INCLUDE sqlca; int mm_io_0025_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0025_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(a.balance), 0) + INTO :h_amt + FROM mst_account a + JOIN mst_acct_bal b ON a.acct_no = b.acct_no + WHERE a.acct_no = :h_key + AND b.status_cd = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +36,27 @@ int mm_io_0025_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("mm_io_0025_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_amt; return TX_OK; } int mm_io_0025_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0025_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE mst_acct_bal + SET balance = balance + :h_amt + WHERE cust_id IN (SELECT cust_id FROM mst_account + WHERE acct_no = :h_key); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0025_touch"); return TX_EDB; @@ -69,21 +69,21 @@ int mm_io_0025_touch(const char *key, long amount) long mm_io_0025_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_bd[9]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.balance), 0) INTO :h_sum - FROM mm_io_0025_t - WHERE biz_date = :h_biz_date; - + FROM mst_product d + JOIN mst_account m ON d.acct_no = m.acct_no + WHERE d.biz_date = :h_bd + AND m.status_cd = 'A'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0025_total"); return -1; diff --git a/app/dbio/mm_io_0026.c b/app/dbio/mm_io_0026.c index da3ef18..d56f60d 100644 --- a/app/dbio/mm_io_0026.c +++ b/app/dbio/mm_io_0026.c @@ -94,37 +94,51 @@ int mm_io_0026_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/mm_io_0026.pgc" - char h_key [ 16 ] ; + char h_key [ 20 ] ; #line 18 "app/dbio/mm_io_0026.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_amt ; + #line 19 "app/dbio/mm_io_0026.pgc" + int h_cnt ; +/* exec sql end declare section */ +#line 20 "app/dbio/mm_io_0026.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mm_io_0026_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mst_acct_bal where cust_id = $1 and amount > 0", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_int,&(h_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/mm_io_0026.pgc" +#line 31 "app/dbio/mm_io_0026.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0026_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from mst_acct_bal where cust_id = $1 ", + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 42 "app/dbio/mm_io_0026.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0026_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } @@ -134,29 +148,27 @@ int mm_io_0026_touch(const char *key, long amount) -#line 45 "app/dbio/mm_io_0026.pgc" - char h_key [ 16 ] ; +#line 54 "app/dbio/mm_io_0026.pgc" + char h_key [ 20 ] ; -#line 46 "app/dbio/mm_io_0026.pgc" - long h_amount ; +#line 55 "app/dbio/mm_io_0026.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/mm_io_0026.pgc" +#line 56 "app/dbio/mm_io_0026.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mm_io_0026_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mst_product set amount = amount + $1 where branch_cd in ( select branch_cd from mst_acct_bal where cust_id = $2 )", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)20,(long)1,(20)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/mm_io_0026.pgc" - +#line 67 "app/dbio/mm_io_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0026_touch"); @@ -170,35 +182,39 @@ int mm_io_0026_touch(const char *key, long amount) long mm_io_0026_total(const char *biz_date) { /* exec sql begin declare section */ - + + -#line 72 "app/dbio/mm_io_0026.pgc" - char h_biz_date [ 9 ] ; +#line 80 "app/dbio/mm_io_0026.pgc" + char h_bd [ 9 ] ; -#line 73 "app/dbio/mm_io_0026.pgc" - long h_sum ; +#line 81 "app/dbio/mm_io_0026.pgc" + long h_max ; + +#line 82 "app/dbio/mm_io_0026.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/mm_io_0026.pgc" +#line 83 "app/dbio/mm_io_0026.pgc" if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from mm_io_0026_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( amount ) from mst_product where base_dt = $1 ", + ECPGt_char,(h_bd),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/mm_io_0026.pgc" - + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 93 "app/dbio/mm_io_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0026_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/mm_io_0026.pgc b/app/dbio/mm_io_0026.pgc index 5a49f7d..6d784b8 100644 --- a/app/dbio/mm_io_0026.pgc +++ b/app/dbio/mm_io_0026.pgc @@ -14,49 +14,57 @@ EXEC SQL INCLUDE sqlca; int mm_io_0026_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; + int h_cnt; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM mm_io_0026_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM mst_acct_bal + WHERE cust_id = :h_key + AND amount > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0026_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_cnt == 0) + return TX_ENOENT; + + EXEC SQL SELECT amount + INTO :h_amt + FROM mst_acct_bal + WHERE cust_id = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("mm_io_0026_fetch"); + return TX_EDB; + } + *out_amount = h_amt; return TX_OK; } int mm_io_0026_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[20]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE mm_io_0026_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE mst_product + SET amount = amount + :h_amt + WHERE branch_cd IN (SELECT branch_cd FROM mst_acct_bal + WHERE cust_id = :h_key); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0026_touch"); return TX_EDB; @@ -69,24 +77,25 @@ int mm_io_0026_touch(const char *key, long amount) long mm_io_0026_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_bd[9]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_bd, biz_date, sizeof(h_bd) - 1); + h_bd[sizeof(h_bd) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM mm_io_0026_t - WHERE biz_date = :h_biz_date; - + EXEC SQL SELECT max(amount) + INTO :h_max:h_ind + FROM mst_product + WHERE base_dt = :h_bd; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("mm_io_0026_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/py_io_0001.c b/app/dbio/py_io_0001.c index 2e00166..422431f 100644 --- a/app/dbio/py_io_0001.c +++ b/app/dbio/py_io_0001.c @@ -96,26 +96,25 @@ int py_io_0001_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0001.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0001.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0001.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0001_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select pay_amt from py_payout_dtl where payout_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/py_io_0001.pgc" +#line 29 "app/dbio/py_io_0001.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int py_io_0001_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0001_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int py_io_0001_touch(const char *key, long amount) -#line 45 "app/dbio/py_io_0001.pgc" - char h_key [ 16 ] ; +#line 44 "app/dbio/py_io_0001.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/py_io_0001.pgc" - long h_amount ; +#line 45 "app/dbio/py_io_0001.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/py_io_0001.pgc" +#line 46 "app/dbio/py_io_0001.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0001_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_payout_dtl set pay_amt = $1 , upd_ts = now ( ) where payout_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0001.pgc" - +#line 56 "app/dbio/py_io_0001.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0001_touch"); @@ -173,27 +170,26 @@ long py_io_0001_total(const char *biz_date) -#line 72 "app/dbio/py_io_0001.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/py_io_0001.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0001.pgc" +#line 70 "app/dbio/py_io_0001.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0001.pgc" +#line 71 "app/dbio/py_io_0001.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0001_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( pay_amt ) , 0 ) from py_payout_dtl where pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0001.pgc" +#line 81 "app/dbio/py_io_0001.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/py_io_0001.pgc b/app/dbio/py_io_0001.pgc index a47c3b3..349f4fa 100644 --- a/app/dbio/py_io_0001.pgc +++ b/app/dbio/py_io_0001.pgc @@ -14,20 +14,19 @@ EXEC SQL INCLUDE sqlca; int py_io_0001_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0001_t - WHERE key = :h_key; + EXEC SQL SELECT pay_amt + INTO :h_val + FROM py_payout_dtl + WHERE payout_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +34,26 @@ int py_io_0001_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0001_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int py_io_0001_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0001_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE py_payout_dtl + SET pay_amt = :h_amt, upd_ts = now() + WHERE payout_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0001_touch"); return TX_EDB; @@ -69,20 +66,19 @@ int py_io_0001_touch(const char *key, long amount) long py_io_0001_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(pay_amt), 0) INTO :h_sum - FROM py_io_0001_t - WHERE biz_date = :h_biz_date; + FROM py_payout_dtl + WHERE pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0001_total"); diff --git a/app/dbio/py_io_0002.c b/app/dbio/py_io_0002.c index fcd1cf1..3b3a6c0 100644 --- a/app/dbio/py_io_0002.c +++ b/app/dbio/py_io_0002.c @@ -94,27 +94,30 @@ int py_io_0002_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/py_io_0002.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0002.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/py_io_0002.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/py_io_0002.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0002_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select hold_amt from py_payout_dtl where payout_key = $1 and paid_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/py_io_0002.pgc" @@ -124,7 +127,7 @@ int py_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } @@ -135,28 +138,26 @@ int py_io_0002_touch(const char *key, long amount) #line 45 "app/dbio/py_io_0002.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/py_io_0002.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/py_io_0002.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0002_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_payout_dtl set pay_amt = $1 , paid_flag = 'Y' , upd_ts = now ( ) where payout_key = $2 and paid_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0002.pgc" - +#line 57 "app/dbio/py_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0002_touch"); @@ -173,32 +174,31 @@ long py_io_0002_total(const char *biz_date) -#line 72 "app/dbio/py_io_0002.pgc" - char h_biz_date [ 9 ] ; +#line 70 "app/dbio/py_io_0002.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0002.pgc" - long h_sum ; +#line 71 "app/dbio/py_io_0002.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0002.pgc" +#line 72 "app/dbio/py_io_0002.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0002_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from py_payout_dtl where pay_dt = $1 and paid_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0002.pgc" +#line 82 "app/dbio/py_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/py_io_0002.pgc b/app/dbio/py_io_0002.pgc index 6ae96a7..39773b9 100644 --- a/app/dbio/py_io_0002.pgc +++ b/app/dbio/py_io_0002.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int py_io_0002_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0002_t - WHERE key = :h_key; + EXEC SQL SELECT hold_amt + INTO :h_val:h_ind + FROM py_payout_dtl + WHERE payout_key = :h_key AND paid_flag = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +35,26 @@ int py_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } int py_io_0002_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0002_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE py_payout_dtl + SET pay_amt = :h_amt, paid_flag = 'Y', upd_ts = now() + WHERE payout_key = :h_key AND paid_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0002_touch"); return TX_EDB; @@ -69,24 +67,23 @@ int py_io_0002_touch(const char *key, long amount) long py_io_0002_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM py_io_0002_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM py_payout_dtl + WHERE pay_dt = :h_dt AND paid_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/py_io_0003.c b/app/dbio/py_io_0003.c index 8f0431c..4ae8f08 100644 --- a/app/dbio/py_io_0003.c +++ b/app/dbio/py_io_0003.c @@ -96,24 +96,23 @@ int py_io_0003_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0003.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0003.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0003.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0003_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a . pay_amt from py_payout_dtl a join py_payout_hold b on a . payout_key = b . payout_key where a . payout_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/py_io_0003.pgc" @@ -124,7 +123,7 @@ int py_io_0003_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0003_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -135,28 +134,28 @@ int py_io_0003_touch(const char *key, long amount) #line 45 "app/dbio/py_io_0003.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/py_io_0003.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/py_io_0003.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0003_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_payout_dtl set hold_amt = $1 where payout_key = $2 and pay_amt >= $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0003.pgc" - +#line 57 "app/dbio/py_io_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0003_touch"); @@ -172,33 +171,38 @@ long py_io_0003_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/py_io_0003.pgc" - char h_biz_date [ 9 ] ; +#line 70 "app/dbio/py_io_0003.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0003.pgc" - long h_sum ; +#line 71 "app/dbio/py_io_0003.pgc" + long h_max ; + +#line 72 "app/dbio/py_io_0003.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0003.pgc" +#line 73 "app/dbio/py_io_0003.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0003_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( pay_amt ) from py_payout_dtl where pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0003.pgc" + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 83 "app/dbio/py_io_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0003_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/py_io_0003.pgc b/app/dbio/py_io_0003.pgc index 9b31202..a261c9b 100644 --- a/app/dbio/py_io_0003.pgc +++ b/app/dbio/py_io_0003.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int py_io_0003_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0003_t - WHERE key = :h_key; + EXEC SQL SELECT a.pay_amt + INTO :h_val + FROM py_payout_dtl a + JOIN py_payout_hold b ON a.payout_key = b.payout_key + WHERE a.payout_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +35,26 @@ int py_io_0003_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0003_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int py_io_0003_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0003_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE py_payout_dtl + SET hold_amt = :h_amt + WHERE payout_key = :h_key AND pay_amt >= :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0003_touch"); return TX_EDB; @@ -69,24 +67,26 @@ int py_io_0003_touch(const char *key, long amount) long py_io_0003_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM py_io_0003_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(pay_amt) + INTO :h_max:h_ind + FROM py_payout_dtl + WHERE pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0003_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/py_io_0004.c b/app/dbio/py_io_0004.c index 733ef2f..347b3ce 100644 --- a/app/dbio/py_io_0004.c +++ b/app/dbio/py_io_0004.c @@ -96,35 +96,32 @@ int py_io_0004_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0004.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0004.pgc" - long h_amount ; + long h_flag ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0004.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0004_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when exists ( select 1 from py_payout_dtl where payout_key = $1 and paid_flag = 'N' ) then 1 else 0 end", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/py_io_0004.pgc" +#line 29 "app/dbio/py_io_0004.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0004_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } @@ -134,36 +131,32 @@ int py_io_0004_touch(const char *key, long amount) -#line 45 "app/dbio/py_io_0004.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/py_io_0004.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/py_io_0004.pgc" - long h_amount ; +#line 43 "app/dbio/py_io_0004.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/py_io_0004.pgc" +#line 44 "app/dbio/py_io_0004.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0004_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into py_payout_sum ( payout_key , pay_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0004.pgc" - +#line 53 "app/dbio/py_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,27 +166,26 @@ long py_io_0004_total(const char *biz_date) -#line 72 "app/dbio/py_io_0004.pgc" - char h_biz_date [ 9 ] ; +#line 64 "app/dbio/py_io_0004.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0004.pgc" +#line 65 "app/dbio/py_io_0004.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0004.pgc" +#line 66 "app/dbio/py_io_0004.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0004_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . pay_amt ) , 0 ) from py_payout_dtl a join py_payout_hold b on a . payout_key = b . payout_key where a . pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0004.pgc" +#line 77 "app/dbio/py_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/py_io_0004.pgc b/app/dbio/py_io_0004.pgc index 36785f1..44e34bf 100644 --- a/app/dbio/py_io_0004.pgc +++ b/app/dbio/py_io_0004.pgc @@ -14,75 +14,67 @@ EXEC SQL INCLUDE sqlca; int py_io_0004_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_flag; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0004_t - WHERE key = :h_key; + EXEC SQL SELECT CASE WHEN EXISTS ( + SELECT 1 FROM py_payout_dtl + WHERE payout_key = :h_key AND paid_flag = 'N') THEN 1 ELSE 0 END + INTO :h_flag; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0004_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } int py_io_0004_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0004_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO py_payout_sum (payout_key, pay_amt, upd_ts) + VALUES (:h_key, :h_amt, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long py_io_0004_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.pay_amt), 0) INTO :h_sum - FROM py_io_0004_t - WHERE biz_date = :h_biz_date; + FROM py_payout_dtl a + JOIN py_payout_hold b ON a.payout_key = b.payout_key + WHERE a.pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0004_total"); diff --git a/app/dbio/py_io_0005.c b/app/dbio/py_io_0005.c index 2ff658d..6d36302 100644 --- a/app/dbio/py_io_0005.c +++ b/app/dbio/py_io_0005.c @@ -94,37 +94,40 @@ int py_io_0005_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/py_io_0005.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0005.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/py_io_0005.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/py_io_0005.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0005_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( pay_amt ) from py_payout_dtl where payee_id = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/py_io_0005.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0005_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,35 +138,31 @@ int py_io_0005_touch(const char *key, long amount) #line 45 "app/dbio/py_io_0005.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/py_io_0005.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/py_io_0005.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0005_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into py_payout_dtl ( payout_key , pay_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( payout_key ) do update set pay_amt = excluded . pay_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/py_io_0005.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0005_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,32 +172,52 @@ long py_io_0005_total(const char *biz_date) -#line 72 "app/dbio/py_io_0005.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/py_io_0005.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0005.pgc" - long h_sum ; +#line 70 "app/dbio/py_io_0005.pgc" + long h_grp ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0005.pgc" +#line 71 "app/dbio/py_io_0005.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0005_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_dt ), __LINE__);\ + /* declare py_io_0005_total_cur cursor for select coalesce ( sum ( pay_amt ) , 0 ) from py_payout_dtl where pay_dt = $1 group by payee_id */ +#line 82 "app/dbio/py_io_0005.pgc" + +#line 82 "app/dbio/py_io_0005.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare py_io_0005_total_cur cursor for select coalesce ( sum ( pay_amt ) , 0 ) from py_payout_dtl where pay_dt = $1 group by payee_id", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 83 "app/dbio/py_io_0005.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch py_io_0005_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 85 "app/dbio/py_io_0005.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("py_io_0005_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0005_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 90 "app/dbio/py_io_0005.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("py_io_0005_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0005_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 95 "app/dbio/py_io_0005.pgc" + + return acc; } diff --git a/app/dbio/py_io_0005.pgc b/app/dbio/py_io_0005.pgc index 51a77ad..8fb92e1 100644 --- a/app/dbio/py_io_0005.pgc +++ b/app/dbio/py_io_0005.pgc @@ -14,79 +14,84 @@ EXEC SQL INCLUDE sqlca; int py_io_0005_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0005_t - WHERE key = :h_key; + EXEC SQL SELECT max(pay_amt) + INTO :h_val:h_ind + FROM py_payout_dtl + WHERE payee_id = :h_key; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0005_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int py_io_0005_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0005_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO py_payout_dtl (payout_key, pay_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (payout_key) + DO UPDATE SET pay_amt = excluded.pay_amt, upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0005_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long py_io_0005_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM py_io_0005_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("py_io_0005_total"); - return -1; + EXEC SQL DECLARE py_io_0005_total_cur CURSOR FOR + SELECT coalesce(sum(pay_amt), 0) FROM py_payout_dtl + WHERE pay_dt = :h_dt GROUP BY payee_id; + EXEC SQL OPEN py_io_0005_total_cur; + for (;;) { + EXEC SQL FETCH py_io_0005_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("py_io_0005_total"); + EXEC SQL CLOSE py_io_0005_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE py_io_0005_total_cur; + return acc; } diff --git a/app/dbio/py_io_0006.c b/app/dbio/py_io_0006.c index c74d5c2..74d9617 100644 --- a/app/dbio/py_io_0006.c +++ b/app/dbio/py_io_0006.c @@ -94,37 +94,40 @@ int py_io_0006_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/py_io_0006.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0006.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/py_io_0006.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/py_io_0006.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0006_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( pay_amt ) from py_payout_dtl where payee_id = $1 and paid_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/py_io_0006.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0006_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,24 @@ int py_io_0006_touch(const char *key, long amount) #line 45 "app/dbio/py_io_0006.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/py_io_0006.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/py_io_0006.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0006_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from py_payout_sum where payout_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0006.pgc" - +#line 56 "app/dbio/py_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0006_touch"); @@ -173,27 +172,26 @@ long py_io_0006_total(const char *biz_date) -#line 72 "app/dbio/py_io_0006.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/py_io_0006.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0006.pgc" +#line 70 "app/dbio/py_io_0006.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0006.pgc" +#line 71 "app/dbio/py_io_0006.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0006_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when paid_flag = 'Y' then pay_amt else 0 end ) , 0 ) from py_payout_dtl where pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0006.pgc" +#line 81 "app/dbio/py_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/py_io_0006.pgc b/app/dbio/py_io_0006.pgc index caf96a3..bb3af31 100644 --- a/app/dbio/py_io_0006.pgc +++ b/app/dbio/py_io_0006.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int py_io_0006_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0006_t - WHERE key = :h_key; + EXEC SQL SELECT min(pay_amt) + INTO :h_val:h_ind + FROM py_payout_dtl + WHERE payee_id = :h_key AND paid_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0006_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int py_io_0006_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0006_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM py_payout_sum + WHERE payout_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0006_touch"); return TX_EDB; @@ -69,20 +66,19 @@ int py_io_0006_touch(const char *key, long amount) long py_io_0006_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(CASE WHEN paid_flag = 'Y' THEN pay_amt ELSE 0 END), 0) INTO :h_sum - FROM py_io_0006_t - WHERE biz_date = :h_biz_date; + FROM py_payout_dtl + WHERE pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0006_total"); diff --git a/app/dbio/py_io_0007.c b/app/dbio/py_io_0007.c index a3447b3..4b441e1 100644 --- a/app/dbio/py_io_0007.c +++ b/app/dbio/py_io_0007.c @@ -96,35 +96,32 @@ int py_io_0007_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0007.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0007.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0007.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0007_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( pay_amt ) , 0 ) from py_payout_dtl where payee_id = $1 and paid_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/py_io_0007.pgc" +#line 29 "app/dbio/py_io_0007.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0007_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +131,27 @@ int py_io_0007_touch(const char *key, long amount) -#line 45 "app/dbio/py_io_0007.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/py_io_0007.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/py_io_0007.pgc" - long h_amount ; +#line 43 "app/dbio/py_io_0007.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/py_io_0007.pgc" +#line 44 "app/dbio/py_io_0007.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0007_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from py_payout_sum where payee_id = $1 and pay_amt < $2 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0007.pgc" - +#line 53 "app/dbio/py_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0007_touch"); @@ -173,32 +168,31 @@ long py_io_0007_total(const char *biz_date) -#line 72 "app/dbio/py_io_0007.pgc" - char h_biz_date [ 9 ] ; +#line 66 "app/dbio/py_io_0007.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0007.pgc" - long h_sum ; +#line 67 "app/dbio/py_io_0007.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0007.pgc" +#line 68 "app/dbio/py_io_0007.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0007_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct payee_id ) from py_payout_dtl where pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0007.pgc" +#line 78 "app/dbio/py_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0007_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/py_io_0007.pgc b/app/dbio/py_io_0007.pgc index 6079505..48850e9 100644 --- a/app/dbio/py_io_0007.pgc +++ b/app/dbio/py_io_0007.pgc @@ -14,49 +14,43 @@ EXEC SQL INCLUDE sqlca; int py_io_0007_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0007_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(pay_amt), 0) + INTO :h_val + FROM py_payout_dtl + WHERE payee_id = :h_key AND paid_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0007_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int py_io_0007_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0007_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM py_payout_sum + WHERE payee_id = :h_key AND pay_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0007_touch"); return TX_EDB; @@ -69,24 +63,23 @@ int py_io_0007_touch(const char *key, long amount) long py_io_0007_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM py_io_0007_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(distinct payee_id) + INTO :h_cnt + FROM py_payout_dtl + WHERE pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0007_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/py_io_0008.c b/app/dbio/py_io_0008.c index e9e303a..5eadfef 100644 --- a/app/dbio/py_io_0008.c +++ b/app/dbio/py_io_0008.c @@ -96,35 +96,53 @@ int py_io_0008_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0008.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0008.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0008.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0008_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare py_io_0008_fetch_cur cursor for select pay_amt from py_payout_dtl where payout_key = $1 order by pay_dt desc */ +#line 28 "app/dbio/py_io_0008.pgc" + +#line 28 "app/dbio/py_io_0008.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare py_io_0008_fetch_cur cursor for select pay_amt from py_payout_dtl where payout_key = $1 order by pay_dt desc", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 29 "app/dbio/py_io_0008.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch py_io_0008_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/py_io_0008.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0008_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 33 "app/dbio/py_io_0008.pgc" + return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0008_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0008_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 38 "app/dbio/py_io_0008.pgc" + return TX_EDB; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0008_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 41 "app/dbio/py_io_0008.pgc" + + *out_amount = h_val; return TX_OK; } @@ -134,29 +152,29 @@ int py_io_0008_touch(const char *key, long amount) -#line 45 "app/dbio/py_io_0008.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/py_io_0008.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/py_io_0008.pgc" - long h_amount ; +#line 50 "app/dbio/py_io_0008.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/py_io_0008.pgc" +#line 51 "app/dbio/py_io_0008.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0008_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_payout_dtl set pay_amt = pay_amt + $1 , paid_flag = case when pay_amt + $2 > 0 then 'Y' else 'N' end , upd_ts = now ( ) where payout_key = $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0008.pgc" - +#line 63 "app/dbio/py_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0008_touch"); @@ -173,27 +191,26 @@ long py_io_0008_total(const char *biz_date) -#line 72 "app/dbio/py_io_0008.pgc" - char h_biz_date [ 9 ] ; +#line 76 "app/dbio/py_io_0008.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0008.pgc" +#line 77 "app/dbio/py_io_0008.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0008.pgc" +#line 78 "app/dbio/py_io_0008.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0008_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( pay_amt ) , 0 ) from py_payout_dtl where pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0008.pgc" +#line 88 "app/dbio/py_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/py_io_0008.pgc b/app/dbio/py_io_0008.pgc index 11c5145..38ca2b1 100644 --- a/app/dbio/py_io_0008.pgc +++ b/app/dbio/py_io_0008.pgc @@ -14,49 +14,53 @@ EXEC SQL INCLUDE sqlca; int py_io_0008_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0008_t - WHERE key = :h_key; + EXEC SQL DECLARE py_io_0008_fetch_cur CURSOR FOR + SELECT pay_amt FROM py_payout_dtl + WHERE payout_key = :h_key ORDER BY pay_dt DESC; + EXEC SQL OPEN py_io_0008_fetch_cur; + EXEC SQL FETCH py_io_0008_fetch_cur INTO :h_val; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE py_io_0008_fetch_cur; return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0008_fetch"); + EXEC SQL CLOSE py_io_0008_fetch_cur; return TX_EDB; } - *out_amount = h_amount; + EXEC SQL CLOSE py_io_0008_fetch_cur; + *out_amount = h_val; return TX_OK; } int py_io_0008_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0008_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE py_payout_dtl + SET pay_amt = pay_amt + :h_amt, + paid_flag = CASE WHEN pay_amt + :h_amt > 0 THEN 'Y' ELSE 'N' END, + upd_ts = now() + WHERE payout_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0008_touch"); return TX_EDB; @@ -69,20 +73,19 @@ int py_io_0008_touch(const char *key, long amount) long py_io_0008_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(pay_amt), 0) INTO :h_sum - FROM py_io_0008_t - WHERE biz_date = :h_biz_date; + FROM py_payout_dtl + WHERE pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0008_total"); diff --git a/app/dbio/py_io_0009.c b/app/dbio/py_io_0009.c index f44f207..9622498 100644 --- a/app/dbio/py_io_0009.c +++ b/app/dbio/py_io_0009.c @@ -96,26 +96,25 @@ int py_io_0009_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0009.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0009.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0009.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0009_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select pay_amt from py_payout_dtl where payout_key in ( select payout_key from py_payout_hold where payee_id = $1 ) order by pay_amt desc limit 1", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/py_io_0009.pgc" +#line 32 "app/dbio/py_io_0009.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int py_io_0009_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0009_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int py_io_0009_touch(const char *key, long amount) -#line 45 "app/dbio/py_io_0009.pgc" - char h_key [ 16 ] ; - -#line 46 "app/dbio/py_io_0009.pgc" - long h_amount ; -/* exec sql end declare section */ #line 47 "app/dbio/py_io_0009.pgc" + char h_key [ 32 ] ; + +#line 48 "app/dbio/py_io_0009.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 49 "app/dbio/py_io_0009.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0009_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_payout_dtl set pay_amt = $1 , upd_ts = now ( ) where payout_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0009.pgc" - +#line 59 "app/dbio/py_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0009_touch"); @@ -174,31 +171,30 @@ long py_io_0009_total(const char *biz_date) #line 72 "app/dbio/py_io_0009.pgc" - char h_biz_date [ 9 ] ; + char h_dt [ 16 ] ; #line 73 "app/dbio/py_io_0009.pgc" - long h_sum ; + long h_cnt ; /* exec sql end declare section */ #line 74 "app/dbio/py_io_0009.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0009_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from py_payout_dtl where pay_dt = $1 and paid_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0009.pgc" +#line 84 "app/dbio/py_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0009_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/py_io_0009.pgc b/app/dbio/py_io_0009.pgc index 4df00d5..b189512 100644 --- a/app/dbio/py_io_0009.pgc +++ b/app/dbio/py_io_0009.pgc @@ -14,20 +14,22 @@ EXEC SQL INCLUDE sqlca; int py_io_0009_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0009_t - WHERE key = :h_key; + EXEC SQL SELECT pay_amt + INTO :h_val + FROM py_payout_dtl + WHERE payout_key IN ( + SELECT payout_key FROM py_payout_hold WHERE payee_id = :h_key) + ORDER BY pay_amt DESC + LIMIT 1; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +37,26 @@ int py_io_0009_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0009_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int py_io_0009_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0009_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE py_payout_dtl + SET pay_amt = :h_amt, upd_ts = now() + WHERE payout_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0009_touch"); return TX_EDB; @@ -69,24 +69,23 @@ int py_io_0009_touch(const char *key, long amount) long py_io_0009_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM py_io_0009_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM py_payout_dtl + WHERE pay_dt = :h_dt AND paid_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0009_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/py_io_0010.c b/app/dbio/py_io_0010.c index 378741b..2aa1b48 100644 --- a/app/dbio/py_io_0010.c +++ b/app/dbio/py_io_0010.c @@ -96,26 +96,25 @@ int py_io_0010_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0010.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0010.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0010.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0010_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select pay_amt from py_payout_dtl where payout_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/py_io_0010.pgc" +#line 29 "app/dbio/py_io_0010.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int py_io_0010_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0010_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int py_io_0010_touch(const char *key, long amount) -#line 45 "app/dbio/py_io_0010.pgc" - char h_key [ 16 ] ; +#line 44 "app/dbio/py_io_0010.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/py_io_0010.pgc" - long h_amount ; +#line 45 "app/dbio/py_io_0010.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/py_io_0010.pgc" +#line 46 "app/dbio/py_io_0010.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0010_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_payout_dtl set pay_amt = $1 , paid_flag = 'Y' , upd_ts = now ( ) where payout_key = $2 and paid_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0010.pgc" - +#line 56 "app/dbio/py_io_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0010_touch"); @@ -172,33 +169,38 @@ long py_io_0010_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/py_io_0010.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/py_io_0010.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0010.pgc" - long h_sum ; +#line 70 "app/dbio/py_io_0010.pgc" + long h_max ; + +#line 71 "app/dbio/py_io_0010.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0010.pgc" +#line 72 "app/dbio/py_io_0010.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0010_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( pay_amt ) from py_payout_dtl where pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0010.pgc" + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 82 "app/dbio/py_io_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0010_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/py_io_0010.pgc b/app/dbio/py_io_0010.pgc index cce2daa..5c2127d 100644 --- a/app/dbio/py_io_0010.pgc +++ b/app/dbio/py_io_0010.pgc @@ -14,20 +14,19 @@ EXEC SQL INCLUDE sqlca; int py_io_0010_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0010_t - WHERE key = :h_key; + EXEC SQL SELECT pay_amt + INTO :h_val + FROM py_payout_dtl + WHERE payout_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +34,26 @@ int py_io_0010_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0010_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int py_io_0010_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0010_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE py_payout_dtl + SET pay_amt = :h_amt, paid_flag = 'Y', upd_ts = now() + WHERE payout_key = :h_key AND paid_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0010_touch"); return TX_EDB; @@ -69,24 +66,26 @@ int py_io_0010_touch(const char *key, long amount) long py_io_0010_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM py_io_0010_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(pay_amt) + INTO :h_max:h_ind + FROM py_payout_dtl + WHERE pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0010_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/py_io_0011.c b/app/dbio/py_io_0011.c index c7fe52d..5ad4b1d 100644 --- a/app/dbio/py_io_0011.c +++ b/app/dbio/py_io_0011.c @@ -94,27 +94,30 @@ int py_io_0011_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/py_io_0011.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0011.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/py_io_0011.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/py_io_0011.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0011_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select hold_amt from py_payout_dtl where payout_key = $1 and paid_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/py_io_0011.pgc" @@ -124,7 +127,7 @@ int py_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } @@ -135,28 +138,28 @@ int py_io_0011_touch(const char *key, long amount) #line 45 "app/dbio/py_io_0011.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/py_io_0011.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/py_io_0011.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0011_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_payout_dtl set hold_amt = $1 where payout_key = $2 and pay_amt >= $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0011.pgc" - +#line 57 "app/dbio/py_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0011_touch"); @@ -173,27 +176,26 @@ long py_io_0011_total(const char *biz_date) -#line 72 "app/dbio/py_io_0011.pgc" - char h_biz_date [ 9 ] ; +#line 70 "app/dbio/py_io_0011.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0011.pgc" +#line 71 "app/dbio/py_io_0011.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0011.pgc" +#line 72 "app/dbio/py_io_0011.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0011_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . pay_amt ) , 0 ) from py_payout_dtl a join py_payout_hold b on a . payout_key = b . payout_key where a . pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0011.pgc" +#line 83 "app/dbio/py_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/py_io_0011.pgc b/app/dbio/py_io_0011.pgc index b27474d..331a266 100644 --- a/app/dbio/py_io_0011.pgc +++ b/app/dbio/py_io_0011.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int py_io_0011_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0011_t - WHERE key = :h_key; + EXEC SQL SELECT hold_amt + INTO :h_val:h_ind + FROM py_payout_dtl + WHERE payout_key = :h_key AND paid_flag = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +35,26 @@ int py_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } int py_io_0011_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0011_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE py_payout_dtl + SET hold_amt = :h_amt + WHERE payout_key = :h_key AND pay_amt >= :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0011_touch"); return TX_EDB; @@ -69,20 +67,20 @@ int py_io_0011_touch(const char *key, long amount) long py_io_0011_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.pay_amt), 0) INTO :h_sum - FROM py_io_0011_t - WHERE biz_date = :h_biz_date; + FROM py_payout_dtl a + JOIN py_payout_hold b ON a.payout_key = b.payout_key + WHERE a.pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0011_total"); diff --git a/app/dbio/py_io_0012.c b/app/dbio/py_io_0012.c index 92e0852..77dcd2d 100644 --- a/app/dbio/py_io_0012.c +++ b/app/dbio/py_io_0012.c @@ -96,24 +96,23 @@ int py_io_0012_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0012.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0012.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0012.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0012_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a . pay_amt from py_payout_dtl a join py_payout_hold b on a . payout_key = b . payout_key where a . payout_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/py_io_0012.pgc" @@ -124,7 +123,7 @@ int py_io_0012_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0012_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -135,35 +134,31 @@ int py_io_0012_touch(const char *key, long amount) #line 45 "app/dbio/py_io_0012.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/py_io_0012.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/py_io_0012.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0012_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into py_payout_sum ( payout_key , pay_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0012.pgc" - +#line 56 "app/dbio/py_io_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0012_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,32 +168,52 @@ long py_io_0012_total(const char *biz_date) -#line 72 "app/dbio/py_io_0012.pgc" - char h_biz_date [ 9 ] ; +#line 67 "app/dbio/py_io_0012.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0012.pgc" - long h_sum ; +#line 68 "app/dbio/py_io_0012.pgc" + long h_grp ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0012.pgc" +#line 69 "app/dbio/py_io_0012.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0012_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_dt ), __LINE__);\ + /* declare py_io_0012_total_cur cursor for select coalesce ( sum ( pay_amt ) , 0 ) from py_payout_dtl where pay_dt = $1 group by payee_id */ +#line 80 "app/dbio/py_io_0012.pgc" + +#line 80 "app/dbio/py_io_0012.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare py_io_0012_total_cur cursor for select coalesce ( sum ( pay_amt ) , 0 ) from py_payout_dtl where pay_dt = $1 group by payee_id", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 81 "app/dbio/py_io_0012.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch py_io_0012_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0012.pgc" +#line 83 "app/dbio/py_io_0012.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("py_io_0012_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0012_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 88 "app/dbio/py_io_0012.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("py_io_0012_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0012_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 93 "app/dbio/py_io_0012.pgc" + + return acc; } diff --git a/app/dbio/py_io_0012.pgc b/app/dbio/py_io_0012.pgc index ffe919e..2603c22 100644 --- a/app/dbio/py_io_0012.pgc +++ b/app/dbio/py_io_0012.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int py_io_0012_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0012_t - WHERE key = :h_key; + EXEC SQL SELECT a.pay_amt + INTO :h_val + FROM py_payout_dtl a + JOIN py_payout_hold b ON a.payout_key = b.payout_key + WHERE a.payout_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,58 +35,61 @@ int py_io_0012_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0012_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int py_io_0012_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0012_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO py_payout_sum (payout_key, pay_amt, upd_ts) + VALUES (:h_key, :h_amt, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0012_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long py_io_0012_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM py_io_0012_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("py_io_0012_total"); - return -1; + EXEC SQL DECLARE py_io_0012_total_cur CURSOR FOR + SELECT coalesce(sum(pay_amt), 0) FROM py_payout_dtl + WHERE pay_dt = :h_dt GROUP BY payee_id; + EXEC SQL OPEN py_io_0012_total_cur; + for (;;) { + EXEC SQL FETCH py_io_0012_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("py_io_0012_total"); + EXEC SQL CLOSE py_io_0012_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE py_io_0012_total_cur; + return acc; } diff --git a/app/dbio/py_io_0013.c b/app/dbio/py_io_0013.c index 23947e0..57ba208 100644 --- a/app/dbio/py_io_0013.c +++ b/app/dbio/py_io_0013.c @@ -96,35 +96,32 @@ int py_io_0013_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0013.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0013.pgc" - long h_amount ; + long h_flag ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0013.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0013_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when exists ( select 1 from py_payout_dtl where payout_key = $1 and paid_flag = 'N' ) then 1 else 0 end", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/py_io_0013.pgc" +#line 29 "app/dbio/py_io_0013.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0013_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } @@ -134,36 +131,32 @@ int py_io_0013_touch(const char *key, long amount) -#line 45 "app/dbio/py_io_0013.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/py_io_0013.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/py_io_0013.pgc" - long h_amount ; +#line 43 "app/dbio/py_io_0013.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/py_io_0013.pgc" +#line 44 "app/dbio/py_io_0013.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0013_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into py_payout_dtl ( payout_key , pay_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( payout_key ) do update set pay_amt = excluded . pay_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0013.pgc" - +#line 55 "app/dbio/py_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,27 +166,26 @@ long py_io_0013_total(const char *biz_date) -#line 72 "app/dbio/py_io_0013.pgc" - char h_biz_date [ 9 ] ; +#line 66 "app/dbio/py_io_0013.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0013.pgc" +#line 67 "app/dbio/py_io_0013.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0013.pgc" +#line 68 "app/dbio/py_io_0013.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0013_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when paid_flag = 'Y' then pay_amt else 0 end ) , 0 ) from py_payout_dtl where pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0013.pgc" +#line 78 "app/dbio/py_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/py_io_0013.pgc b/app/dbio/py_io_0013.pgc index 003ce3a..4c41e64 100644 --- a/app/dbio/py_io_0013.pgc +++ b/app/dbio/py_io_0013.pgc @@ -14,75 +14,68 @@ EXEC SQL INCLUDE sqlca; int py_io_0013_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_flag; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0013_t - WHERE key = :h_key; + EXEC SQL SELECT CASE WHEN EXISTS ( + SELECT 1 FROM py_payout_dtl + WHERE payout_key = :h_key AND paid_flag = 'N') THEN 1 ELSE 0 END + INTO :h_flag; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0013_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } int py_io_0013_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0013_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO py_payout_dtl (payout_key, pay_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (payout_key) + DO UPDATE SET pay_amt = excluded.pay_amt, upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long py_io_0013_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(CASE WHEN paid_flag = 'Y' THEN pay_amt ELSE 0 END), 0) INTO :h_sum - FROM py_io_0013_t - WHERE biz_date = :h_biz_date; + FROM py_payout_dtl + WHERE pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0013_total"); diff --git a/app/dbio/py_io_0014.c b/app/dbio/py_io_0014.c index 757df15..cbcc400 100644 --- a/app/dbio/py_io_0014.c +++ b/app/dbio/py_io_0014.c @@ -94,37 +94,40 @@ int py_io_0014_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/py_io_0014.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0014.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/py_io_0014.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/py_io_0014.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0014_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( pay_amt ) from py_payout_dtl where payee_id = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/py_io_0014.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0014_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,24 @@ int py_io_0014_touch(const char *key, long amount) #line 45 "app/dbio/py_io_0014.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/py_io_0014.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/py_io_0014.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0014_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from py_payout_sum where payout_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0014.pgc" - +#line 56 "app/dbio/py_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0014_touch"); @@ -173,32 +172,31 @@ long py_io_0014_total(const char *biz_date) -#line 72 "app/dbio/py_io_0014.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/py_io_0014.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0014.pgc" - long h_sum ; +#line 70 "app/dbio/py_io_0014.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0014.pgc" +#line 71 "app/dbio/py_io_0014.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0014_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct payee_id ) from py_payout_dtl where pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0014.pgc" +#line 81 "app/dbio/py_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0014_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/py_io_0014.pgc b/app/dbio/py_io_0014.pgc index 6d1dc20..27cfc56 100644 --- a/app/dbio/py_io_0014.pgc +++ b/app/dbio/py_io_0014.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int py_io_0014_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0014_t - WHERE key = :h_key; + EXEC SQL SELECT max(pay_amt) + INTO :h_val:h_ind + FROM py_payout_dtl + WHERE payee_id = :h_key; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0014_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int py_io_0014_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0014_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM py_payout_sum + WHERE payout_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0014_touch"); return TX_EDB; @@ -69,24 +66,23 @@ int py_io_0014_touch(const char *key, long amount) long py_io_0014_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM py_io_0014_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(distinct payee_id) + INTO :h_cnt + FROM py_payout_dtl + WHERE pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0014_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/py_io_0015.c b/app/dbio/py_io_0015.c index ec3c6ed..f325e14 100644 --- a/app/dbio/py_io_0015.c +++ b/app/dbio/py_io_0015.c @@ -94,37 +94,40 @@ int py_io_0015_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/py_io_0015.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0015.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/py_io_0015.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/py_io_0015.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0015_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( pay_amt ) from py_payout_dtl where payee_id = $1 and paid_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/py_io_0015.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0015_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,26 @@ int py_io_0015_touch(const char *key, long amount) #line 45 "app/dbio/py_io_0015.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/py_io_0015.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/py_io_0015.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0015_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from py_payout_sum where payee_id = $1 and pay_amt < $2 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0015.pgc" - +#line 56 "app/dbio/py_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0015_touch"); @@ -173,27 +174,26 @@ long py_io_0015_total(const char *biz_date) -#line 72 "app/dbio/py_io_0015.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/py_io_0015.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0015.pgc" +#line 70 "app/dbio/py_io_0015.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0015.pgc" +#line 71 "app/dbio/py_io_0015.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0015_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( pay_amt ) , 0 ) from py_payout_dtl where pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0015.pgc" +#line 81 "app/dbio/py_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/py_io_0015.pgc b/app/dbio/py_io_0015.pgc index 6feb03e..6907902 100644 --- a/app/dbio/py_io_0015.pgc +++ b/app/dbio/py_io_0015.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int py_io_0015_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0015_t - WHERE key = :h_key; + EXEC SQL SELECT min(pay_amt) + INTO :h_val:h_ind + FROM py_payout_dtl + WHERE payee_id = :h_key AND paid_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0015_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int py_io_0015_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0015_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM py_payout_sum + WHERE payee_id = :h_key AND pay_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0015_touch"); return TX_EDB; @@ -69,20 +66,19 @@ int py_io_0015_touch(const char *key, long amount) long py_io_0015_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(pay_amt), 0) INTO :h_sum - FROM py_io_0015_t - WHERE biz_date = :h_biz_date; + FROM py_payout_dtl + WHERE pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0015_total"); diff --git a/app/dbio/py_io_0016.c b/app/dbio/py_io_0016.c index 2963905..1072e73 100644 --- a/app/dbio/py_io_0016.c +++ b/app/dbio/py_io_0016.c @@ -96,35 +96,32 @@ int py_io_0016_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0016.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0016.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0016.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0016_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( pay_amt ) , 0 ) from py_payout_dtl where payee_id = $1 and paid_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/py_io_0016.pgc" +#line 29 "app/dbio/py_io_0016.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0016_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +131,29 @@ int py_io_0016_touch(const char *key, long amount) -#line 45 "app/dbio/py_io_0016.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/py_io_0016.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/py_io_0016.pgc" - long h_amount ; +#line 43 "app/dbio/py_io_0016.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/py_io_0016.pgc" +#line 44 "app/dbio/py_io_0016.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0016_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_payout_dtl set pay_amt = pay_amt + $1 , paid_flag = case when pay_amt + $2 > 0 then 'Y' else 'N' end , upd_ts = now ( ) where payout_key = $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0016.pgc" - +#line 56 "app/dbio/py_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0016_touch"); @@ -173,32 +170,31 @@ long py_io_0016_total(const char *biz_date) -#line 72 "app/dbio/py_io_0016.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/py_io_0016.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0016.pgc" - long h_sum ; +#line 70 "app/dbio/py_io_0016.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0016.pgc" +#line 71 "app/dbio/py_io_0016.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0016_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from py_payout_dtl where pay_dt = $1 and paid_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0016.pgc" +#line 81 "app/dbio/py_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0016_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/py_io_0016.pgc b/app/dbio/py_io_0016.pgc index e448e64..c984531 100644 --- a/app/dbio/py_io_0016.pgc +++ b/app/dbio/py_io_0016.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int py_io_0016_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0016_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(pay_amt), 0) + INTO :h_val + FROM py_payout_dtl + WHERE payee_id = :h_key AND paid_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0016_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int py_io_0016_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0016_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE py_payout_dtl + SET pay_amt = pay_amt + :h_amt, + paid_flag = CASE WHEN pay_amt + :h_amt > 0 THEN 'Y' ELSE 'N' END, + upd_ts = now() + WHERE payout_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0016_touch"); return TX_EDB; @@ -69,24 +66,23 @@ int py_io_0016_touch(const char *key, long amount) long py_io_0016_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM py_io_0016_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM py_payout_dtl + WHERE pay_dt = :h_dt AND paid_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0016_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/py_io_0017.c b/app/dbio/py_io_0017.c index e503f14..153fb31 100644 --- a/app/dbio/py_io_0017.c +++ b/app/dbio/py_io_0017.c @@ -96,35 +96,53 @@ int py_io_0017_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0017.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0017.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0017.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0017_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare py_io_0017_fetch_cur cursor for select pay_amt from py_payout_dtl where payout_key = $1 order by pay_dt desc */ +#line 28 "app/dbio/py_io_0017.pgc" + +#line 28 "app/dbio/py_io_0017.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare py_io_0017_fetch_cur cursor for select pay_amt from py_payout_dtl where payout_key = $1 order by pay_dt desc", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 29 "app/dbio/py_io_0017.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch py_io_0017_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/py_io_0017.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0017_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 33 "app/dbio/py_io_0017.pgc" + return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0017_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0017_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 38 "app/dbio/py_io_0017.pgc" + return TX_EDB; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0017_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 41 "app/dbio/py_io_0017.pgc" + + *out_amount = h_val; return TX_OK; } @@ -134,29 +152,27 @@ int py_io_0017_touch(const char *key, long amount) -#line 45 "app/dbio/py_io_0017.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/py_io_0017.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/py_io_0017.pgc" - long h_amount ; +#line 50 "app/dbio/py_io_0017.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/py_io_0017.pgc" +#line 51 "app/dbio/py_io_0017.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0017_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_payout_dtl set pay_amt = $1 , upd_ts = now ( ) where payout_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0017.pgc" - +#line 61 "app/dbio/py_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0017_touch"); @@ -172,33 +188,38 @@ long py_io_0017_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/py_io_0017.pgc" - char h_biz_date [ 9 ] ; - -#line 73 "app/dbio/py_io_0017.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/py_io_0017.pgc" + char h_dt [ 16 ] ; + +#line 75 "app/dbio/py_io_0017.pgc" + long h_max ; + +#line 76 "app/dbio/py_io_0017.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 77 "app/dbio/py_io_0017.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0017_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( pay_amt ) from py_payout_dtl where pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0017.pgc" + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 87 "app/dbio/py_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0017_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/py_io_0017.pgc b/app/dbio/py_io_0017.pgc index 93eb296..7fda89f 100644 --- a/app/dbio/py_io_0017.pgc +++ b/app/dbio/py_io_0017.pgc @@ -14,49 +14,51 @@ EXEC SQL INCLUDE sqlca; int py_io_0017_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0017_t - WHERE key = :h_key; + EXEC SQL DECLARE py_io_0017_fetch_cur CURSOR FOR + SELECT pay_amt FROM py_payout_dtl + WHERE payout_key = :h_key ORDER BY pay_dt DESC; + EXEC SQL OPEN py_io_0017_fetch_cur; + EXEC SQL FETCH py_io_0017_fetch_cur INTO :h_val; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE py_io_0017_fetch_cur; return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0017_fetch"); + EXEC SQL CLOSE py_io_0017_fetch_cur; return TX_EDB; } - *out_amount = h_amount; + EXEC SQL CLOSE py_io_0017_fetch_cur; + *out_amount = h_val; return TX_OK; } int py_io_0017_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0017_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE py_payout_dtl + SET pay_amt = :h_amt, upd_ts = now() + WHERE payout_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0017_touch"); return TX_EDB; @@ -69,24 +71,26 @@ int py_io_0017_touch(const char *key, long amount) long py_io_0017_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM py_io_0017_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(pay_amt) + INTO :h_max:h_ind + FROM py_payout_dtl + WHERE pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0017_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/py_io_0018.c b/app/dbio/py_io_0018.c index b206ab6..17e5af2 100644 --- a/app/dbio/py_io_0018.c +++ b/app/dbio/py_io_0018.c @@ -96,26 +96,25 @@ int py_io_0018_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0018.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0018.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0018.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0018_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select pay_amt from py_payout_dtl where payout_key in ( select payout_key from py_payout_hold where payee_id = $1 ) order by pay_amt desc limit 1", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/py_io_0018.pgc" +#line 32 "app/dbio/py_io_0018.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int py_io_0018_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0018_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int py_io_0018_touch(const char *key, long amount) -#line 45 "app/dbio/py_io_0018.pgc" - char h_key [ 16 ] ; - -#line 46 "app/dbio/py_io_0018.pgc" - long h_amount ; -/* exec sql end declare section */ #line 47 "app/dbio/py_io_0018.pgc" + char h_key [ 32 ] ; + +#line 48 "app/dbio/py_io_0018.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 49 "app/dbio/py_io_0018.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0018_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_payout_dtl set pay_amt = $1 , paid_flag = 'Y' , upd_ts = now ( ) where payout_key = $2 and paid_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0018.pgc" - +#line 59 "app/dbio/py_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0018_touch"); @@ -174,7 +171,7 @@ long py_io_0018_total(const char *biz_date) #line 72 "app/dbio/py_io_0018.pgc" - char h_biz_date [ 9 ] ; + char h_dt [ 16 ] ; #line 73 "app/dbio/py_io_0018.pgc" long h_sum ; @@ -184,12 +181,11 @@ long py_io_0018_total(const char *biz_date) if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0018_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . pay_amt ) , 0 ) from py_payout_dtl a join py_payout_hold b on a . payout_key = b . payout_key where a . pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} diff --git a/app/dbio/py_io_0018.pgc b/app/dbio/py_io_0018.pgc index a059cf6..22deb2c 100644 --- a/app/dbio/py_io_0018.pgc +++ b/app/dbio/py_io_0018.pgc @@ -14,20 +14,22 @@ EXEC SQL INCLUDE sqlca; int py_io_0018_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0018_t - WHERE key = :h_key; + EXEC SQL SELECT pay_amt + INTO :h_val + FROM py_payout_dtl + WHERE payout_key IN ( + SELECT payout_key FROM py_payout_hold WHERE payee_id = :h_key) + ORDER BY pay_amt DESC + LIMIT 1; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +37,26 @@ int py_io_0018_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0018_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int py_io_0018_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0018_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE py_payout_dtl + SET pay_amt = :h_amt, paid_flag = 'Y', upd_ts = now() + WHERE payout_key = :h_key AND paid_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0018_touch"); return TX_EDB; @@ -69,20 +69,20 @@ int py_io_0018_touch(const char *key, long amount) long py_io_0018_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.pay_amt), 0) INTO :h_sum - FROM py_io_0018_t - WHERE biz_date = :h_biz_date; + FROM py_payout_dtl a + JOIN py_payout_hold b ON a.payout_key = b.payout_key + WHERE a.pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0018_total"); diff --git a/app/dbio/py_io_0019.c b/app/dbio/py_io_0019.c index 6f4cac6..ba72d7c 100644 --- a/app/dbio/py_io_0019.c +++ b/app/dbio/py_io_0019.c @@ -96,26 +96,25 @@ int py_io_0019_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0019.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0019.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0019.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0019_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select pay_amt from py_payout_dtl where payout_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/py_io_0019.pgc" +#line 29 "app/dbio/py_io_0019.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int py_io_0019_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0019_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,29 @@ int py_io_0019_touch(const char *key, long amount) -#line 45 "app/dbio/py_io_0019.pgc" - char h_key [ 16 ] ; +#line 44 "app/dbio/py_io_0019.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/py_io_0019.pgc" - long h_amount ; +#line 45 "app/dbio/py_io_0019.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/py_io_0019.pgc" +#line 46 "app/dbio/py_io_0019.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0019_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_payout_dtl set hold_amt = $1 where payout_key = $2 and pay_amt >= $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0019.pgc" - +#line 56 "app/dbio/py_io_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0019_touch"); @@ -173,32 +172,52 @@ long py_io_0019_total(const char *biz_date) -#line 72 "app/dbio/py_io_0019.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/py_io_0019.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0019.pgc" - long h_sum ; +#line 70 "app/dbio/py_io_0019.pgc" + long h_grp ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0019.pgc" +#line 71 "app/dbio/py_io_0019.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0019_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_dt ), __LINE__);\ + /* declare py_io_0019_total_cur cursor for select coalesce ( sum ( pay_amt ) , 0 ) from py_payout_dtl where pay_dt = $1 group by payee_id */ +#line 82 "app/dbio/py_io_0019.pgc" + +#line 82 "app/dbio/py_io_0019.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare py_io_0019_total_cur cursor for select coalesce ( sum ( pay_amt ) , 0 ) from py_payout_dtl where pay_dt = $1 group by payee_id", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 83 "app/dbio/py_io_0019.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch py_io_0019_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 85 "app/dbio/py_io_0019.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("py_io_0019_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0019_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 90 "app/dbio/py_io_0019.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("py_io_0019_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0019_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 95 "app/dbio/py_io_0019.pgc" + + return acc; } diff --git a/app/dbio/py_io_0019.pgc b/app/dbio/py_io_0019.pgc index f5f495c..9c3ae21 100644 --- a/app/dbio/py_io_0019.pgc +++ b/app/dbio/py_io_0019.pgc @@ -14,20 +14,19 @@ EXEC SQL INCLUDE sqlca; int py_io_0019_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0019_t - WHERE key = :h_key; + EXEC SQL SELECT pay_amt + INTO :h_val + FROM py_payout_dtl + WHERE payout_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +34,26 @@ int py_io_0019_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0019_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int py_io_0019_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0019_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE py_payout_dtl + SET hold_amt = :h_amt + WHERE payout_key = :h_key AND pay_amt >= :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0019_touch"); return TX_EDB; @@ -69,24 +66,32 @@ int py_io_0019_touch(const char *key, long amount) long py_io_0019_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM py_io_0019_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("py_io_0019_total"); - return -1; + EXEC SQL DECLARE py_io_0019_total_cur CURSOR FOR + SELECT coalesce(sum(pay_amt), 0) FROM py_payout_dtl + WHERE pay_dt = :h_dt GROUP BY payee_id; + EXEC SQL OPEN py_io_0019_total_cur; + for (;;) { + EXEC SQL FETCH py_io_0019_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("py_io_0019_total"); + EXEC SQL CLOSE py_io_0019_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE py_io_0019_total_cur; + return acc; } diff --git a/app/dbio/py_io_0020.c b/app/dbio/py_io_0020.c index c847aac..8310ce1 100644 --- a/app/dbio/py_io_0020.c +++ b/app/dbio/py_io_0020.c @@ -94,27 +94,30 @@ int py_io_0020_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/py_io_0020.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0020.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/py_io_0020.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/py_io_0020.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0020_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select hold_amt from py_payout_dtl where payout_key = $1 and paid_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/py_io_0020.pgc" @@ -124,7 +127,7 @@ int py_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } @@ -135,35 +138,31 @@ int py_io_0020_touch(const char *key, long amount) #line 45 "app/dbio/py_io_0020.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/py_io_0020.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/py_io_0020.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0020_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into py_payout_sum ( payout_key , pay_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0020.pgc" - +#line 56 "app/dbio/py_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,27 +172,26 @@ long py_io_0020_total(const char *biz_date) -#line 72 "app/dbio/py_io_0020.pgc" - char h_biz_date [ 9 ] ; +#line 67 "app/dbio/py_io_0020.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0020.pgc" +#line 68 "app/dbio/py_io_0020.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0020.pgc" +#line 69 "app/dbio/py_io_0020.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0020_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when paid_flag = 'Y' then pay_amt else 0 end ) , 0 ) from py_payout_dtl where pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0020.pgc" +#line 79 "app/dbio/py_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/py_io_0020.pgc b/app/dbio/py_io_0020.pgc index 13d0bb7..47aff09 100644 --- a/app/dbio/py_io_0020.pgc +++ b/app/dbio/py_io_0020.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int py_io_0020_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0020_t - WHERE key = :h_key; + EXEC SQL SELECT hold_amt + INTO :h_val:h_ind + FROM py_payout_dtl + WHERE payout_key = :h_key AND paid_flag = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,54 +35,48 @@ int py_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } int py_io_0020_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0020_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO py_payout_sum (payout_key, pay_amt, upd_ts) + VALUES (:h_key, :h_amt, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long py_io_0020_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(CASE WHEN paid_flag = 'Y' THEN pay_amt ELSE 0 END), 0) INTO :h_sum - FROM py_io_0020_t - WHERE biz_date = :h_biz_date; + FROM py_payout_dtl + WHERE pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0020_total"); diff --git a/app/dbio/py_io_0021.c b/app/dbio/py_io_0021.c index 6755ea3..914e38d 100644 --- a/app/dbio/py_io_0021.c +++ b/app/dbio/py_io_0021.c @@ -96,24 +96,23 @@ int py_io_0021_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0021.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0021.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0021.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0021_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a . pay_amt from py_payout_dtl a join py_payout_hold b on a . payout_key = b . payout_key where a . payout_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/py_io_0021.pgc" @@ -124,7 +123,7 @@ int py_io_0021_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0021_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -135,35 +134,31 @@ int py_io_0021_touch(const char *key, long amount) #line 45 "app/dbio/py_io_0021.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/py_io_0021.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/py_io_0021.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0021_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into py_payout_dtl ( payout_key , pay_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( payout_key ) do update set pay_amt = excluded . pay_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/py_io_0021.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0021_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,32 +168,31 @@ long py_io_0021_total(const char *biz_date) -#line 72 "app/dbio/py_io_0021.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/py_io_0021.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0021.pgc" - long h_sum ; +#line 70 "app/dbio/py_io_0021.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0021.pgc" +#line 71 "app/dbio/py_io_0021.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0021_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct payee_id ) from py_payout_dtl where pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0021.pgc" +#line 81 "app/dbio/py_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0021_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/py_io_0021.pgc b/app/dbio/py_io_0021.pgc index e4b292c..15edd2d 100644 --- a/app/dbio/py_io_0021.pgc +++ b/app/dbio/py_io_0021.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int py_io_0021_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0021_t - WHERE key = :h_key; + EXEC SQL SELECT a.pay_amt + INTO :h_val + FROM py_payout_dtl a + JOIN py_payout_hold b ON a.payout_key = b.payout_key + WHERE a.payout_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,58 +35,54 @@ int py_io_0021_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("py_io_0021_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int py_io_0021_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0021_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO py_payout_dtl (payout_key, pay_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (payout_key) + DO UPDATE SET pay_amt = excluded.pay_amt, upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0021_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long py_io_0021_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM py_io_0021_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(distinct payee_id) + INTO :h_cnt + FROM py_payout_dtl + WHERE pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0021_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/py_io_0022.c b/app/dbio/py_io_0022.c index 94436db..bbf10bb 100644 --- a/app/dbio/py_io_0022.c +++ b/app/dbio/py_io_0022.c @@ -96,35 +96,32 @@ int py_io_0022_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0022.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0022.pgc" - long h_amount ; + long h_flag ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0022.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0022_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when exists ( select 1 from py_payout_dtl where payout_key = $1 and paid_flag = 'N' ) then 1 else 0 end", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/py_io_0022.pgc" +#line 29 "app/dbio/py_io_0022.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0022_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } @@ -134,29 +131,25 @@ int py_io_0022_touch(const char *key, long amount) -#line 45 "app/dbio/py_io_0022.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/py_io_0022.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/py_io_0022.pgc" - long h_amount ; +#line 43 "app/dbio/py_io_0022.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/py_io_0022.pgc" +#line 44 "app/dbio/py_io_0022.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0022_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from py_payout_sum where payout_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0022.pgc" - +#line 53 "app/dbio/py_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0022_touch"); @@ -173,27 +166,26 @@ long py_io_0022_total(const char *biz_date) -#line 72 "app/dbio/py_io_0022.pgc" - char h_biz_date [ 9 ] ; +#line 66 "app/dbio/py_io_0022.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0022.pgc" +#line 67 "app/dbio/py_io_0022.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0022.pgc" +#line 68 "app/dbio/py_io_0022.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0022_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( pay_amt ) , 0 ) from py_payout_dtl where pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0022.pgc" +#line 78 "app/dbio/py_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/py_io_0022.pgc b/app/dbio/py_io_0022.pgc index 2d72f31..14ba38d 100644 --- a/app/dbio/py_io_0022.pgc +++ b/app/dbio/py_io_0022.pgc @@ -14,49 +14,43 @@ EXEC SQL INCLUDE sqlca; int py_io_0022_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_flag; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0022_t - WHERE key = :h_key; + EXEC SQL SELECT CASE WHEN EXISTS ( + SELECT 1 FROM py_payout_dtl + WHERE payout_key = :h_key AND paid_flag = 'N') THEN 1 ELSE 0 END + INTO :h_flag; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0022_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } int py_io_0022_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0022_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM py_payout_sum + WHERE payout_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0022_touch"); return TX_EDB; @@ -69,20 +63,19 @@ int py_io_0022_touch(const char *key, long amount) long py_io_0022_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(pay_amt), 0) INTO :h_sum - FROM py_io_0022_t - WHERE biz_date = :h_biz_date; + FROM py_payout_dtl + WHERE pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0022_total"); diff --git a/app/dbio/py_io_0023.c b/app/dbio/py_io_0023.c index 51c54cf..888489f 100644 --- a/app/dbio/py_io_0023.c +++ b/app/dbio/py_io_0023.c @@ -94,37 +94,40 @@ int py_io_0023_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/py_io_0023.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0023.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/py_io_0023.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/py_io_0023.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0023_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( pay_amt ) from py_payout_dtl where payee_id = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/py_io_0023.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0023_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,26 @@ int py_io_0023_touch(const char *key, long amount) #line 45 "app/dbio/py_io_0023.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/py_io_0023.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/py_io_0023.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0023_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from py_payout_sum where payee_id = $1 and pay_amt < $2 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0023.pgc" - +#line 56 "app/dbio/py_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0023_touch"); @@ -173,32 +174,31 @@ long py_io_0023_total(const char *biz_date) -#line 72 "app/dbio/py_io_0023.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/py_io_0023.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0023.pgc" - long h_sum ; +#line 70 "app/dbio/py_io_0023.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0023.pgc" +#line 71 "app/dbio/py_io_0023.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0023_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from py_payout_dtl where pay_dt = $1 and paid_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0023.pgc" +#line 81 "app/dbio/py_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0023_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/py_io_0023.pgc b/app/dbio/py_io_0023.pgc index 08e7c63..30a5649 100644 --- a/app/dbio/py_io_0023.pgc +++ b/app/dbio/py_io_0023.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int py_io_0023_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0023_t - WHERE key = :h_key; + EXEC SQL SELECT max(pay_amt) + INTO :h_val:h_ind + FROM py_payout_dtl + WHERE payee_id = :h_key; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0023_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int py_io_0023_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0023_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM py_payout_sum + WHERE payee_id = :h_key AND pay_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0023_touch"); return TX_EDB; @@ -69,24 +66,23 @@ int py_io_0023_touch(const char *key, long amount) long py_io_0023_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM py_io_0023_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM py_payout_dtl + WHERE pay_dt = :h_dt AND paid_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0023_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/py_io_0024.c b/app/dbio/py_io_0024.c index 379ccd3..890f65f 100644 --- a/app/dbio/py_io_0024.c +++ b/app/dbio/py_io_0024.c @@ -94,37 +94,40 @@ int py_io_0024_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/py_io_0024.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0024.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/py_io_0024.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/py_io_0024.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0024_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( pay_amt ) from py_payout_dtl where payee_id = $1 and paid_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/py_io_0024.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0024_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,28 @@ int py_io_0024_touch(const char *key, long amount) #line 45 "app/dbio/py_io_0024.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/py_io_0024.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/py_io_0024.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0024_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_payout_dtl set pay_amt = pay_amt + $1 , paid_flag = case when pay_amt + $2 > 0 then 'Y' else 'N' end , upd_ts = now ( ) where payout_key = $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0024.pgc" - +#line 59 "app/dbio/py_io_0024.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0024_touch"); @@ -172,27 +175,30 @@ long py_io_0024_total(const char *biz_date) /* exec sql begin declare section */ + #line 72 "app/dbio/py_io_0024.pgc" - char h_biz_date [ 9 ] ; + char h_dt [ 16 ] ; #line 73 "app/dbio/py_io_0024.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_max ; + #line 74 "app/dbio/py_io_0024.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 75 "app/dbio/py_io_0024.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0024_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( pay_amt ) from py_payout_dtl where pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 85 "app/dbio/py_io_0024.pgc" @@ -200,5 +206,7 @@ long py_io_0024_total(const char *biz_date) TX_DBIO_LOG_ERR("py_io_0024_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/py_io_0024.pgc b/app/dbio/py_io_0024.pgc index d73a1f0..a8a8f04 100644 --- a/app/dbio/py_io_0024.pgc +++ b/app/dbio/py_io_0024.pgc @@ -14,49 +14,49 @@ EXEC SQL INCLUDE sqlca; int py_io_0024_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0024_t - WHERE key = :h_key; + EXEC SQL SELECT min(pay_amt) + INTO :h_val:h_ind + FROM py_payout_dtl + WHERE payee_id = :h_key AND paid_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0024_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int py_io_0024_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0024_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE py_payout_dtl + SET pay_amt = pay_amt + :h_amt, + paid_flag = CASE WHEN pay_amt + :h_amt > 0 THEN 'Y' ELSE 'N' END, + upd_ts = now() + WHERE payout_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0024_touch"); return TX_EDB; @@ -69,24 +69,26 @@ int py_io_0024_touch(const char *key, long amount) long py_io_0024_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM py_io_0024_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(pay_amt) + INTO :h_max:h_ind + FROM py_payout_dtl + WHERE pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0024_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/py_io_0025.c b/app/dbio/py_io_0025.c index b8e8f88..7ddc67f 100644 --- a/app/dbio/py_io_0025.c +++ b/app/dbio/py_io_0025.c @@ -96,35 +96,32 @@ int py_io_0025_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0025.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0025.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0025.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0025_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( pay_amt ) , 0 ) from py_payout_dtl where payee_id = $1 and paid_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/py_io_0025.pgc" +#line 29 "app/dbio/py_io_0025.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0025_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +131,27 @@ int py_io_0025_touch(const char *key, long amount) -#line 45 "app/dbio/py_io_0025.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/py_io_0025.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/py_io_0025.pgc" - long h_amount ; +#line 43 "app/dbio/py_io_0025.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/py_io_0025.pgc" +#line 44 "app/dbio/py_io_0025.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0025_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_payout_dtl set pay_amt = $1 , upd_ts = now ( ) where payout_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0025.pgc" - +#line 54 "app/dbio/py_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0025_touch"); @@ -173,27 +168,26 @@ long py_io_0025_total(const char *biz_date) -#line 72 "app/dbio/py_io_0025.pgc" - char h_biz_date [ 9 ] ; +#line 67 "app/dbio/py_io_0025.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/py_io_0025.pgc" +#line 68 "app/dbio/py_io_0025.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/py_io_0025.pgc" +#line 69 "app/dbio/py_io_0025.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0025_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . pay_amt ) , 0 ) from py_payout_dtl a join py_payout_hold b on a . payout_key = b . payout_key where a . pay_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0025.pgc" +#line 80 "app/dbio/py_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/py_io_0025.pgc b/app/dbio/py_io_0025.pgc index 81c7bcc..a96dd95 100644 --- a/app/dbio/py_io_0025.pgc +++ b/app/dbio/py_io_0025.pgc @@ -14,49 +14,44 @@ EXEC SQL INCLUDE sqlca; int py_io_0025_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0025_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(pay_amt), 0) + INTO :h_val + FROM py_payout_dtl + WHERE payee_id = :h_key AND paid_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0025_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int py_io_0025_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0025_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE py_payout_dtl + SET pay_amt = :h_amt, upd_ts = now() + WHERE payout_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0025_touch"); return TX_EDB; @@ -69,20 +64,20 @@ int py_io_0025_touch(const char *key, long amount) long py_io_0025_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.pay_amt), 0) INTO :h_sum - FROM py_io_0025_t - WHERE biz_date = :h_biz_date; + FROM py_payout_dtl a + JOIN py_payout_hold b ON a.payout_key = b.payout_key + WHERE a.pay_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0025_total"); diff --git a/app/dbio/py_io_0026.c b/app/dbio/py_io_0026.c index 9771319..cb91704 100644 --- a/app/dbio/py_io_0026.c +++ b/app/dbio/py_io_0026.c @@ -96,35 +96,53 @@ int py_io_0026_fetch(const char *key, long *out_amount) #line 17 "app/dbio/py_io_0026.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/py_io_0026.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/py_io_0026.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from py_io_0026_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare py_io_0026_fetch_cur cursor for select pay_amt from py_payout_dtl where payout_key = $1 order by pay_dt desc */ +#line 28 "app/dbio/py_io_0026.pgc" + +#line 28 "app/dbio/py_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare py_io_0026_fetch_cur cursor for select pay_amt from py_payout_dtl where payout_key = $1 order by pay_dt desc", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 29 "app/dbio/py_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch py_io_0026_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/py_io_0026.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0026_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 33 "app/dbio/py_io_0026.pgc" + return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0026_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0026_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 38 "app/dbio/py_io_0026.pgc" + return TX_EDB; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0026_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 41 "app/dbio/py_io_0026.pgc" + + *out_amount = h_val; return TX_OK; } @@ -134,29 +152,27 @@ int py_io_0026_touch(const char *key, long amount) -#line 45 "app/dbio/py_io_0026.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/py_io_0026.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/py_io_0026.pgc" - long h_amount ; +#line 50 "app/dbio/py_io_0026.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/py_io_0026.pgc" +#line 51 "app/dbio/py_io_0026.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_io_0026_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update py_payout_dtl set pay_amt = $1 , paid_flag = 'Y' , upd_ts = now ( ) where payout_key = $2 and paid_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/py_io_0026.pgc" - +#line 61 "app/dbio/py_io_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0026_touch"); @@ -173,32 +189,52 @@ long py_io_0026_total(const char *biz_date) -#line 72 "app/dbio/py_io_0026.pgc" - char h_biz_date [ 9 ] ; - -#line 73 "app/dbio/py_io_0026.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/py_io_0026.pgc" + char h_dt [ 16 ] ; + +#line 75 "app/dbio/py_io_0026.pgc" + long h_grp ; +/* exec sql end declare section */ +#line 76 "app/dbio/py_io_0026.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from py_io_0026_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 1, ( h_dt ), __LINE__);\ + /* declare py_io_0026_total_cur cursor for select coalesce ( sum ( pay_amt ) , 0 ) from py_payout_dtl where pay_dt = $1 group by payee_id */ +#line 87 "app/dbio/py_io_0026.pgc" + +#line 87 "app/dbio/py_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare py_io_0026_total_cur cursor for select coalesce ( sum ( pay_amt ) , 0 ) from py_payout_dtl where pay_dt = $1 group by payee_id", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 88 "app/dbio/py_io_0026.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch py_io_0026_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/py_io_0026.pgc" +#line 90 "app/dbio/py_io_0026.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("py_io_0026_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0026_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 95 "app/dbio/py_io_0026.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("py_io_0026_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close py_io_0026_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 100 "app/dbio/py_io_0026.pgc" + + return acc; } diff --git a/app/dbio/py_io_0026.pgc b/app/dbio/py_io_0026.pgc index ffcfa7c..de5ba12 100644 --- a/app/dbio/py_io_0026.pgc +++ b/app/dbio/py_io_0026.pgc @@ -14,49 +14,51 @@ EXEC SQL INCLUDE sqlca; int py_io_0026_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM py_io_0026_t - WHERE key = :h_key; + EXEC SQL DECLARE py_io_0026_fetch_cur CURSOR FOR + SELECT pay_amt FROM py_payout_dtl + WHERE payout_key = :h_key ORDER BY pay_dt DESC; + EXEC SQL OPEN py_io_0026_fetch_cur; + EXEC SQL FETCH py_io_0026_fetch_cur INTO :h_val; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE py_io_0026_fetch_cur; return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0026_fetch"); + EXEC SQL CLOSE py_io_0026_fetch_cur; return TX_EDB; } - *out_amount = h_amount; + EXEC SQL CLOSE py_io_0026_fetch_cur; + *out_amount = h_val; return TX_OK; } int py_io_0026_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE py_io_0026_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE py_payout_dtl + SET pay_amt = :h_amt, paid_flag = 'Y', upd_ts = now() + WHERE payout_key = :h_key AND paid_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("py_io_0026_touch"); return TX_EDB; @@ -69,24 +71,32 @@ int py_io_0026_touch(const char *key, long amount) long py_io_0026_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM py_io_0026_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("py_io_0026_total"); - return -1; + EXEC SQL DECLARE py_io_0026_total_cur CURSOR FOR + SELECT coalesce(sum(pay_amt), 0) FROM py_payout_dtl + WHERE pay_dt = :h_dt GROUP BY payee_id; + EXEC SQL OPEN py_io_0026_total_cur; + for (;;) { + EXEC SQL FETCH py_io_0026_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("py_io_0026_total"); + EXEC SQL CLOSE py_io_0026_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE py_io_0026_total_cur; + return acc; } diff --git a/app/dbio/rc_io_0001.c b/app/dbio/rc_io_0001.c index 3a8fba9..7cb5886 100644 --- a/app/dbio/rc_io_0001.c +++ b/app/dbio/rc_io_0001.c @@ -110,7 +110,7 @@ int rc_io_0001_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0001_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt from rc_io_0001_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), @@ -150,7 +150,7 @@ int rc_io_0001_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0001_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0001_t set appr_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), @@ -188,7 +188,7 @@ long rc_io_0001_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0001_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( appr_amt ) , 0 ) from rc_io_0001_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), @@ -202,3 +202,4 @@ long rc_io_0001_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0001.pgc b/app/dbio/rc_io_0001.pgc index 4483622..f6683e7 100644 --- a/app/dbio/rc_io_0001.pgc +++ b/app/dbio/rc_io_0001.pgc @@ -24,10 +24,10 @@ int rc_io_0001_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT appr_amt INTO :h_amount FROM rc_io_0001_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +54,8 @@ int rc_io_0001_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE rc_io_0001_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET appr_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0001_touch"); @@ -79,7 +79,7 @@ long rc_io_0001_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(appr_amt), 0) INTO :h_sum FROM rc_io_0001_t WHERE biz_date = :h_biz_date; @@ -90,3 +90,4 @@ long rc_io_0001_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0002.c b/app/dbio/rc_io_0002.c index a099968..9d2841f 100644 --- a/app/dbio/rc_io_0002.c +++ b/app/dbio/rc_io_0002.c @@ -94,14 +94,22 @@ int rc_io_0002_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + + #line 17 "app/dbio/rc_io_0002.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/rc_io_0002.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_appr ; + #line 19 "app/dbio/rc_io_0002.pgc" + long h_fee ; + +#line 20 "app/dbio/rc_io_0002.pgc" + long h_vat ; +/* exec sql end declare section */ +#line 21 "app/dbio/rc_io_0002.pgc" if (!key || !out_amount) @@ -110,12 +118,16 @@ int rc_io_0002_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0002_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt , fee_amt , vat_amt from rc_io_0002_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_appr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_vat),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0002.pgc" +#line 32 "app/dbio/rc_io_0002.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +136,7 @@ int rc_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -134,13 +146,13 @@ int rc_io_0002_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0002.pgc" +#line 47 "app/dbio/rc_io_0002.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0002.pgc" +#line 48 "app/dbio/rc_io_0002.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0002.pgc" +#line 49 "app/dbio/rc_io_0002.pgc" if (!key) @@ -150,12 +162,12 @@ int rc_io_0002_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0002_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0002_t set net_amt = $1 , upd_ts = now ( ) where mcht_no = $2 and status_cd = '00' and appr_amt > 0", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0002.pgc" +#line 60 "app/dbio/rc_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +185,13 @@ long rc_io_0002_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0002.pgc" +#line 74 "app/dbio/rc_io_0002.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0002.pgc" - long h_sum ; +#line 75 "app/dbio/rc_io_0002.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0002.pgc" +#line 76 "app/dbio/rc_io_0002.pgc" if (!biz_date) @@ -188,17 +200,18 @@ long rc_io_0002_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0002_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from rc_io_0002_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0002.pgc" +#line 87 "app/dbio/rc_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/rc_io_0002.pgc b/app/dbio/rc_io_0002.pgc index 921332c..127c7f2 100644 --- a/app/dbio/rc_io_0002.pgc +++ b/app/dbio/rc_io_0002.pgc @@ -15,7 +15,9 @@ int rc_io_0002_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; - long h_amount; + long h_appr; + long h_fee; + long h_vat; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +26,10 @@ int rc_io_0002_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM rc_io_0002_t - WHERE key = :h_key; + EXEC SQL SELECT appr_amt, fee_amt, vat_amt + INTO :h_appr, :h_fee, :h_vat + FROM rc_io_0002_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,7 +37,7 @@ int rc_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -54,8 +56,8 @@ int rc_io_0002_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE rc_io_0002_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET net_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key AND status_cd = '00' AND appr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0002_touch"); @@ -70,7 +72,7 @@ long rc_io_0002_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,8 +81,8 @@ long rc_io_0002_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_cnt FROM rc_io_0002_t WHERE biz_date = :h_biz_date; @@ -88,5 +90,6 @@ long rc_io_0002_total(const char *biz_date) TX_DBIO_LOG_ERR("rc_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/rc_io_0003.c b/app/dbio/rc_io_0003.c index 8c0e18a..040b80a 100644 --- a/app/dbio/rc_io_0003.c +++ b/app/dbio/rc_io_0003.c @@ -110,12 +110,12 @@ int rc_io_0003_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0003_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select h . net_amt from rc_io_0003_t h join rc_io_0003_map_t m on m . mcht_no = h . mcht_no where h . mcht_no = $1 and m . use_yn = 'Y'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0003.pgc" +#line 31 "app/dbio/rc_io_0003.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int rc_io_0003_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0003.pgc" +#line 46 "app/dbio/rc_io_0003.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0003.pgc" +#line 47 "app/dbio/rc_io_0003.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0003.pgc" +#line 48 "app/dbio/rc_io_0003.pgc" if (!key) @@ -150,10 +150,10 @@ int rc_io_0003_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0003_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_io_0003_log_t ( mcht_no , appr_amt , reg_ts ) values ( $1 , $2 , now ( ) )", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} #line 58 "app/dbio/rc_io_0003.pgc" @@ -162,8 +162,6 @@ int rc_io_0003_touch(const char *key, long amount) TX_DBIO_LOG_ERR("rc_io_0003_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -172,14 +170,18 @@ long rc_io_0003_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/rc_io_0003.pgc" +#line 70 "app/dbio/rc_io_0003.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0003.pgc" - long h_sum ; +#line 71 "app/dbio/rc_io_0003.pgc" + long h_avg ; + +#line 72 "app/dbio/rc_io_0003.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0003.pgc" +#line 73 "app/dbio/rc_io_0003.pgc" if (!biz_date) @@ -188,17 +190,20 @@ long rc_io_0003_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0003_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select avg ( appr_amt ) from rc_io_0003_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0003.pgc" + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 84 "app/dbio/rc_io_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0003_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/rc_io_0003.pgc b/app/dbio/rc_io_0003.pgc index 59620bc..919624b 100644 --- a/app/dbio/rc_io_0003.pgc +++ b/app/dbio/rc_io_0003.pgc @@ -24,10 +24,11 @@ int rc_io_0003_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT h.net_amt INTO :h_amount - FROM rc_io_0003_t - WHERE key = :h_key; + FROM rc_io_0003_t h + JOIN rc_io_0003_map_t m ON m.mcht_no = h.mcht_no + WHERE h.mcht_no = :h_key AND m.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,16 +54,13 @@ int rc_io_0003_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE rc_io_0003_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL INSERT INTO rc_io_0003_log_t (mcht_no, appr_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0003_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -70,7 +68,8 @@ long rc_io_0003_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_avg; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +78,17 @@ long rc_io_0003_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM rc_io_0003_t + EXEC SQL SELECT avg(appr_amt) + INTO :h_avg :h_ind + FROM rc_io_0003_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0003_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/rc_io_0004.c b/app/dbio/rc_io_0004.c index 8b2a6d7..f8d0d60 100644 --- a/app/dbio/rc_io_0004.c +++ b/app/dbio/rc_io_0004.c @@ -94,14 +94,18 @@ int rc_io_0004_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/rc_io_0004.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/rc_io_0004.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/rc_io_0004.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/rc_io_0004.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int rc_io_0004_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0004_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select bal_amt from rc_io_0004_bal_t where acct_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0004.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/rc_io_0004.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int rc_io_0004_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0004_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int rc_io_0004_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0004.pgc" +#line 48 "app/dbio/rc_io_0004.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0004.pgc" +#line 49 "app/dbio/rc_io_0004.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0004.pgc" +#line 50 "app/dbio/rc_io_0004.pgc" if (!key) @@ -150,20 +156,31 @@ int rc_io_0004_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0004_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0004_bal_t set bal_amt = $1 , upd_ts = now ( ) where acct_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0004.pgc" +#line 61 "app/dbio/rc_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_io_0004_bal_t ( acct_no , bal_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 69 "app/dbio/rc_io_0004.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0004_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -173,13 +190,13 @@ long rc_io_0004_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0004.pgc" +#line 81 "app/dbio/rc_io_0004.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0004.pgc" +#line 82 "app/dbio/rc_io_0004.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0004.pgc" +#line 83 "app/dbio/rc_io_0004.pgc" if (!biz_date) @@ -188,17 +205,20 @@ long rc_io_0004_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0004_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( net_amt ) , 0 ) from rc_io_0004_t where biz_date = $1 group by biz_date having sum ( net_amt ) > 0 limit 1", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0004.pgc" +#line 97 "app/dbio/rc_io_0004.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0004_total"); return -1; } return h_sum; } + diff --git a/app/dbio/rc_io_0004.pgc b/app/dbio/rc_io_0004.pgc index 561d27f..8909a10 100644 --- a/app/dbio/rc_io_0004.pgc +++ b/app/dbio/rc_io_0004.pgc @@ -16,6 +16,7 @@ int rc_io_0004_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int rc_io_0004_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM rc_io_0004_t - WHERE key = :h_key; + EXEC SQL SELECT bal_amt + INTO :h_amount :h_ind + FROM rc_io_0004_bal_t + WHERE acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int rc_io_0004_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0004_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -53,16 +56,22 @@ int rc_io_0004_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE rc_io_0004_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE rc_io_0004_bal_t + SET bal_amt = :h_amount, upd_ts = now() + WHERE acct_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + EXEC SQL INSERT INTO rc_io_0004_bal_t (acct_no, bal_amt, upd_ts) + VALUES (:h_key, :h_amount, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0004_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -79,14 +88,20 @@ long rc_io_0004_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(net_amt), 0) INTO :h_sum FROM rc_io_0004_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + GROUP BY biz_date + HAVING sum(net_amt) > 0 + LIMIT 1; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0004_total"); return -1; } return h_sum; } + diff --git a/app/dbio/rc_io_0005.c b/app/dbio/rc_io_0005.c index 4f64adb..4901230 100644 --- a/app/dbio/rc_io_0005.c +++ b/app/dbio/rc_io_0005.c @@ -110,12 +110,12 @@ int rc_io_0005_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0005_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select req_amt from rc_io_0005_t where mcht_no = $1 and status_cd = '00' and cancel_yn = 'N'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0005.pgc" +#line 31 "app/dbio/rc_io_0005.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int rc_io_0005_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0005.pgc" +#line 46 "app/dbio/rc_io_0005.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0005.pgc" +#line 47 "app/dbio/rc_io_0005.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0005.pgc" +#line 48 "app/dbio/rc_io_0005.pgc" if (!key) @@ -150,9 +150,7 @@ int rc_io_0005_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0005_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from rc_io_0005_tmp_t where ref_key = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/rc_io_0005.pgc" @@ -172,14 +170,18 @@ long rc_io_0005_total(const char *biz_date) /* exec sql begin declare section */ + #line 72 "app/dbio/rc_io_0005.pgc" char h_biz_date [ 9 ] ; #line 73 "app/dbio/rc_io_0005.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_row ; + #line 74 "app/dbio/rc_io_0005.pgc" + long acc = 0 ; +/* exec sql end declare section */ +#line 75 "app/dbio/rc_io_0005.pgc" if (!biz_date) @@ -188,17 +190,42 @@ long rc_io_0005_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0005_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0005.pgc" + ECPGset_var( 0, ( h_biz_date ), __LINE__);\ + /* declare cur_rc_io_0005_t cursor for select net_amt from rc_io_0005_sum_t where biz_date = $1 */ +#line 84 "app/dbio/rc_io_0005.pgc" +#line 84 "app/dbio/rc_io_0005.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_rc_io_0005_t cursor for select net_amt from rc_io_0005_sum_t where biz_date = $1 ", + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 85 "app/dbio/rc_io_0005.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0005_total"); return -1; } - return h_sum; + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_rc_io_0005_t", ECPGt_EOIT, + ECPGt_long,&(h_row),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 91 "app/dbio/rc_io_0005.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0005_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_rc_io_0005_t", ECPGt_EOIT, ECPGt_EORT);} +#line 96 "app/dbio/rc_io_0005.pgc" + + return -1; + } + acc += h_row; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_rc_io_0005_t", ECPGt_EOIT, ECPGt_EORT);} +#line 101 "app/dbio/rc_io_0005.pgc" + + + return acc; } + diff --git a/app/dbio/rc_io_0005.pgc b/app/dbio/rc_io_0005.pgc index 3b06069..2f8ae91 100644 --- a/app/dbio/rc_io_0005.pgc +++ b/app/dbio/rc_io_0005.pgc @@ -24,10 +24,11 @@ int rc_io_0005_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT req_amt INTO :h_amount FROM rc_io_0005_t - WHERE key = :h_key; + WHERE mcht_no = :h_key AND status_cd = '00' + AND cancel_yn = 'N'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,8 @@ int rc_io_0005_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE rc_io_0005_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM rc_io_0005_tmp_t + WHERE ref_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0005_touch"); @@ -70,7 +70,8 @@ long rc_io_0005_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_row; + long acc = 0; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +80,26 @@ long rc_io_0005_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM rc_io_0005_t - WHERE biz_date = :h_biz_date; - + EXEC SQL DECLARE cur_rc_io_0005_t CURSOR FOR + SELECT net_amt FROM rc_io_0005_sum_t WHERE biz_date = :h_biz_date; + EXEC SQL OPEN cur_rc_io_0005_t; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0005_total"); return -1; } - return h_sum; + for (;;) { + EXEC SQL FETCH cur_rc_io_0005_t INTO :h_row; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0005_total"); + EXEC SQL CLOSE cur_rc_io_0005_t; + return -1; + } + acc += h_row; + } + EXEC SQL CLOSE cur_rc_io_0005_t; + + return acc; } + diff --git a/app/dbio/rc_io_0006.c b/app/dbio/rc_io_0006.c index 4053c61..7d9cf68 100644 --- a/app/dbio/rc_io_0006.c +++ b/app/dbio/rc_io_0006.c @@ -94,14 +94,18 @@ int rc_io_0006_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/rc_io_0006.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/rc_io_0006.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/rc_io_0006.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/rc_io_0006.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int rc_io_0006_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0006_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( appr_amt ) from rc_io_0006_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0006.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/rc_io_0006.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int rc_io_0006_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0006_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int rc_io_0006_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0006.pgc" +#line 48 "app/dbio/rc_io_0006.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0006.pgc" +#line 49 "app/dbio/rc_io_0006.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0006.pgc" +#line 50 "app/dbio/rc_io_0006.pgc" if (!key) @@ -150,12 +156,14 @@ int rc_io_0006_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0006_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0006_t set fee_amt = $1 , vat_amt = $2 / 10 , upd_ts = now ( ) where mcht_no = $3 ", + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + 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_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0006.pgc" +#line 61 "app/dbio/rc_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -172,14 +180,18 @@ long rc_io_0006_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/rc_io_0006.pgc" +#line 75 "app/dbio/rc_io_0006.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0006.pgc" - long h_sum ; +#line 76 "app/dbio/rc_io_0006.pgc" + long h_max ; + +#line 77 "app/dbio/rc_io_0006.pgc" + long h_min ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0006.pgc" +#line 78 "app/dbio/rc_io_0006.pgc" if (!biz_date) @@ -188,17 +200,20 @@ long rc_io_0006_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0006_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( max ( appr_amt ) , 0 ) , coalesce ( min ( appr_amt ) , 0 ) from rc_io_0006_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0006.pgc" +#line 89 "app/dbio/rc_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0006_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/rc_io_0006.pgc b/app/dbio/rc_io_0006.pgc index 42111c9..a866de4 100644 --- a/app/dbio/rc_io_0006.pgc +++ b/app/dbio/rc_io_0006.pgc @@ -16,6 +16,7 @@ int rc_io_0006_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int rc_io_0006_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM rc_io_0006_t - WHERE key = :h_key; + EXEC SQL SELECT max(appr_amt) + INTO :h_amount :h_ind + FROM rc_io_0006_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int rc_io_0006_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0006_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -54,8 +57,8 @@ int rc_io_0006_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE rc_io_0006_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET fee_amt = :h_amount, vat_amt = :h_amount / 10, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0006_touch"); @@ -70,7 +73,8 @@ long rc_io_0006_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_max; + long h_min; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +83,15 @@ long rc_io_0006_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM rc_io_0006_t + EXEC SQL SELECT coalesce(max(appr_amt), 0), coalesce(min(appr_amt), 0) + INTO :h_max, :h_min + FROM rc_io_0006_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0006_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/rc_io_0007.c b/app/dbio/rc_io_0007.c index 4dca71d..ff2cf59 100644 --- a/app/dbio/rc_io_0007.c +++ b/app/dbio/rc_io_0007.c @@ -110,12 +110,12 @@ int rc_io_0007_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0007_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select net_amt from rc_io_0007_t where mcht_no in ( select mcht_no from rc_io_0007_map_t where grp_key = $1 )", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0007.pgc" +#line 31 "app/dbio/rc_io_0007.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int rc_io_0007_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0007.pgc" +#line 46 "app/dbio/rc_io_0007.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0007.pgc" +#line 47 "app/dbio/rc_io_0007.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0007.pgc" +#line 48 "app/dbio/rc_io_0007.pgc" if (!key) @@ -150,12 +150,12 @@ int rc_io_0007_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0007_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0007_t set status_cd = case when $1 > 0 then '00' else '99' end , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0007.pgc" +#line 60 "app/dbio/rc_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long rc_io_0007_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0007.pgc" +#line 74 "app/dbio/rc_io_0007.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0007.pgc" +#line 75 "app/dbio/rc_io_0007.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0007.pgc" +#line 76 "app/dbio/rc_io_0007.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long rc_io_0007_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0007_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . appr_amt ) , 0 ) from rc_io_0007_dtl_t d join rc_io_0007_t h on h . mcht_no = d . mcht_no where d . biz_date = $1 and h . status_cd = '00'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0007.pgc" +#line 88 "app/dbio/rc_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long rc_io_0007_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0007.pgc b/app/dbio/rc_io_0007.pgc index c8adda4..f77d63b 100644 --- a/app/dbio/rc_io_0007.pgc +++ b/app/dbio/rc_io_0007.pgc @@ -24,10 +24,11 @@ int rc_io_0007_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT net_amt INTO :h_amount FROM rc_io_0007_t - WHERE key = :h_key; + WHERE mcht_no IN + (SELECT mcht_no FROM rc_io_0007_map_t WHERE grp_key = :h_key); if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,9 @@ int rc_io_0007_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE rc_io_0007_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET status_cd = CASE WHEN :h_amount > 0 THEN '00' ELSE '99' END, + upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0007_touch"); @@ -79,10 +81,11 @@ long rc_io_0007_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.appr_amt), 0) INTO :h_sum - FROM rc_io_0007_t - WHERE biz_date = :h_biz_date; + FROM rc_io_0007_dtl_t d + JOIN rc_io_0007_t h ON h.mcht_no = d.mcht_no + WHERE d.biz_date = :h_biz_date AND h.status_cd = '00'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0007_total"); @@ -90,3 +93,4 @@ long rc_io_0007_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0008.c b/app/dbio/rc_io_0008.c index 985b2c2..9a8215d 100644 --- a/app/dbio/rc_io_0008.c +++ b/app/dbio/rc_io_0008.c @@ -110,20 +110,43 @@ int rc_io_0008_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0008_t where key = $1 ", + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cur_rc_io_0008_f cursor for select appr_amt from rc_io_0008_dtl_t where mcht_no = $1 order by seq desc */ +#line 29 "app/dbio/rc_io_0008.pgc" + +#line 29 "app/dbio/rc_io_0008.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_rc_io_0008_f cursor for select appr_amt from rc_io_0008_dtl_t where mcht_no = $1 order by seq desc", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 30 "app/dbio/rc_io_0008.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0008_fetch"); return TX_EDB; } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_rc_io_0008_f", ECPGt_EOIT, + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 35 "app/dbio/rc_io_0008.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_rc_io_0008_f", ECPGt_EOIT, ECPGt_EORT);} +#line 37 "app/dbio/rc_io_0008.pgc" + + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0008_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_rc_io_0008_f", ECPGt_EOIT, ECPGt_EORT);} +#line 42 "app/dbio/rc_io_0008.pgc" + + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_rc_io_0008_f", ECPGt_EOIT, ECPGt_EORT);} +#line 45 "app/dbio/rc_io_0008.pgc" + + *out_amount = h_amount; return TX_OK; } @@ -134,13 +157,13 @@ int rc_io_0008_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0008.pgc" +#line 54 "app/dbio/rc_io_0008.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0008.pgc" +#line 55 "app/dbio/rc_io_0008.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0008.pgc" +#line 56 "app/dbio/rc_io_0008.pgc" if (!key) @@ -150,12 +173,12 @@ int rc_io_0008_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0008_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0008_acc_t set accum_amt = accum_amt + $1 , cnt = cnt + 1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0008.pgc" +#line 67 "app/dbio/rc_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +196,13 @@ long rc_io_0008_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0008.pgc" +#line 81 "app/dbio/rc_io_0008.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0008.pgc" - long h_sum ; +#line 82 "app/dbio/rc_io_0008.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0008.pgc" +#line 83 "app/dbio/rc_io_0008.pgc" if (!biz_date) @@ -188,17 +211,18 @@ long rc_io_0008_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0008_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct mcht_no ) from rc_io_0008_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0008.pgc" +#line 94 "app/dbio/rc_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0008_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/rc_io_0008.pgc b/app/dbio/rc_io_0008.pgc index 6c6594a..9c73cc0 100644 --- a/app/dbio/rc_io_0008.pgc +++ b/app/dbio/rc_io_0008.pgc @@ -24,17 +24,26 @@ int rc_io_0008_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM rc_io_0008_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL DECLARE cur_rc_io_0008_f CURSOR FOR + SELECT appr_amt FROM rc_io_0008_dtl_t + WHERE mcht_no = :h_key ORDER BY seq DESC; + EXEC SQL OPEN cur_rc_io_0008_f; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0008_fetch"); return TX_EDB; } + EXEC SQL FETCH cur_rc_io_0008_f INTO :h_amount; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE cur_rc_io_0008_f; + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0008_fetch"); + EXEC SQL CLOSE cur_rc_io_0008_f; + return TX_EDB; + } + EXEC SQL CLOSE cur_rc_io_0008_f; + *out_amount = h_amount; return TX_OK; } @@ -53,9 +62,9 @@ int rc_io_0008_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE rc_io_0008_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE rc_io_0008_acc_t + SET accum_amt = accum_amt + :h_amount, cnt = cnt + 1, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0008_touch"); @@ -70,7 +79,7 @@ long rc_io_0008_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +88,15 @@ long rc_io_0008_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM rc_io_0008_t + EXEC SQL SELECT count(DISTINCT mcht_no) + INTO :h_cnt + FROM rc_io_0008_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0008_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/rc_io_0009.c b/app/dbio/rc_io_0009.c index 5092e0d..013062f 100644 --- a/app/dbio/rc_io_0009.c +++ b/app/dbio/rc_io_0009.c @@ -110,12 +110,12 @@ int rc_io_0009_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0009_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when status_cd = '00' then appr_amt else 0 end from rc_io_0009_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0009.pgc" +#line 31 "app/dbio/rc_io_0009.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int rc_io_0009_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0009.pgc" +#line 46 "app/dbio/rc_io_0009.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0009.pgc" +#line 47 "app/dbio/rc_io_0009.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0009.pgc" +#line 48 "app/dbio/rc_io_0009.pgc" if (!key) @@ -150,10 +150,10 @@ int rc_io_0009_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0009_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from rc_io_0009_bal_t where acct_no = $1 and bal_amt <= $2 ", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} #line 58 "app/dbio/rc_io_0009.pgc" @@ -188,12 +188,12 @@ long rc_io_0009_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0009_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( cancel_amt ) , 0 ) from rc_io_0009_t where biz_date = $1 and status_cd = '90' and cancel_yn = 'Y'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0009.pgc" +#line 86 "app/dbio/rc_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long rc_io_0009_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0009.pgc b/app/dbio/rc_io_0009.pgc index e16d65f..9b39c3d 100644 --- a/app/dbio/rc_io_0009.pgc +++ b/app/dbio/rc_io_0009.pgc @@ -24,10 +24,11 @@ int rc_io_0009_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT + CASE WHEN status_cd = '00' THEN appr_amt ELSE 0 END INTO :h_amount FROM rc_io_0009_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,8 @@ int rc_io_0009_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE rc_io_0009_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM rc_io_0009_bal_t + WHERE acct_no = :h_key AND bal_amt <= :h_amount; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0009_touch"); @@ -79,10 +79,11 @@ long rc_io_0009_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(cancel_amt), 0) INTO :h_sum FROM rc_io_0009_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + AND status_cd = '90' AND cancel_yn = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0009_total"); @@ -90,3 +91,4 @@ long rc_io_0009_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0010.c b/app/dbio/rc_io_0010.c index c1b9ec0..053d84d 100644 --- a/app/dbio/rc_io_0010.c +++ b/app/dbio/rc_io_0010.c @@ -110,7 +110,7 @@ int rc_io_0010_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0010_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt from rc_io_0010_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), @@ -150,20 +150,29 @@ int rc_io_0010_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0010_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0010_t set req_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/rc_io_0010.pgc" + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0010_touch"); + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_io_0010_hist_t ( mcht_no , req_amt , reg_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 64 "app/dbio/rc_io_0010.pgc" + if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0010_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,13 +182,13 @@ long rc_io_0010_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0010.pgc" +#line 76 "app/dbio/rc_io_0010.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0010.pgc" +#line 77 "app/dbio/rc_io_0010.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0010.pgc" +#line 78 "app/dbio/rc_io_0010.pgc" if (!biz_date) @@ -188,12 +197,12 @@ long rc_io_0010_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0010_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( recon_amt ) , 0 ) from rc_io_0010_sum_t where biz_date in ( select biz_date from rc_io_0010_map_t where biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0010.pgc" +#line 90 "app/dbio/rc_io_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +211,4 @@ long rc_io_0010_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0010.pgc b/app/dbio/rc_io_0010.pgc index 903c600..b5fbec0 100644 --- a/app/dbio/rc_io_0010.pgc +++ b/app/dbio/rc_io_0010.pgc @@ -24,10 +24,10 @@ int rc_io_0010_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT appr_amt INTO :h_amount FROM rc_io_0010_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,15 +54,19 @@ int rc_io_0010_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE rc_io_0010_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET req_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0010_touch"); + return TX_EDB; + } + EXEC SQL INSERT INTO rc_io_0010_hist_t (mcht_no, req_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0010_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -79,10 +83,11 @@ long rc_io_0010_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(recon_amt), 0) INTO :h_sum - FROM rc_io_0010_t - WHERE biz_date = :h_biz_date; + FROM rc_io_0010_sum_t + WHERE biz_date IN + (SELECT biz_date FROM rc_io_0010_map_t WHERE biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0010_total"); @@ -90,3 +95,4 @@ long rc_io_0010_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0011.c b/app/dbio/rc_io_0011.c index 67006ef..502692d 100644 --- a/app/dbio/rc_io_0011.c +++ b/app/dbio/rc_io_0011.c @@ -94,14 +94,22 @@ int rc_io_0011_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + + #line 17 "app/dbio/rc_io_0011.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/rc_io_0011.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_appr ; + #line 19 "app/dbio/rc_io_0011.pgc" + long h_fee ; + +#line 20 "app/dbio/rc_io_0011.pgc" + long h_vat ; +/* exec sql end declare section */ +#line 21 "app/dbio/rc_io_0011.pgc" if (!key || !out_amount) @@ -110,12 +118,16 @@ int rc_io_0011_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0011_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt , fee_amt , vat_amt from rc_io_0011_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_appr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_vat),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0011.pgc" +#line 32 "app/dbio/rc_io_0011.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +136,7 @@ int rc_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -134,13 +146,13 @@ int rc_io_0011_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0011.pgc" +#line 47 "app/dbio/rc_io_0011.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0011.pgc" +#line 48 "app/dbio/rc_io_0011.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0011.pgc" +#line 49 "app/dbio/rc_io_0011.pgc" if (!key) @@ -150,12 +162,12 @@ int rc_io_0011_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0011_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0011_t set appr_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0011.pgc" +#line 60 "app/dbio/rc_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +185,13 @@ long rc_io_0011_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0011.pgc" +#line 74 "app/dbio/rc_io_0011.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0011.pgc" - long h_sum ; +#line 75 "app/dbio/rc_io_0011.pgc" + long h_flag ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0011.pgc" +#line 76 "app/dbio/rc_io_0011.pgc" if (!biz_date) @@ -188,17 +200,18 @@ long rc_io_0011_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0011_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from rc_io_0011_t where exists ( select 1 from rc_io_0011_dtl_t d where d . biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0011.pgc" +#line 89 "app/dbio/rc_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0011_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/rc_io_0011.pgc b/app/dbio/rc_io_0011.pgc index 9c86e9f..e6ed1db 100644 --- a/app/dbio/rc_io_0011.pgc +++ b/app/dbio/rc_io_0011.pgc @@ -15,7 +15,9 @@ int rc_io_0011_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; - long h_amount; + long h_appr; + long h_fee; + long h_vat; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +26,10 @@ int rc_io_0011_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM rc_io_0011_t - WHERE key = :h_key; + EXEC SQL SELECT appr_amt, fee_amt, vat_amt + INTO :h_appr, :h_fee, :h_vat + FROM rc_io_0011_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,7 +37,7 @@ int rc_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -54,8 +56,8 @@ int rc_io_0011_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE rc_io_0011_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET appr_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0011_touch"); @@ -70,7 +72,7 @@ long rc_io_0011_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_flag; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +81,17 @@ long rc_io_0011_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_flag FROM rc_io_0011_t - WHERE biz_date = :h_biz_date; + WHERE EXISTS + (SELECT 1 FROM rc_io_0011_dtl_t d + WHERE d.biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0011_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/rc_io_0012.c b/app/dbio/rc_io_0012.c index 5331760..ecdcb87 100644 --- a/app/dbio/rc_io_0012.c +++ b/app/dbio/rc_io_0012.c @@ -110,12 +110,12 @@ int rc_io_0012_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0012_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select h . net_amt from rc_io_0012_t h join rc_io_0012_map_t m on m . mcht_no = h . mcht_no where h . mcht_no = $1 and m . use_yn = 'Y'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0012.pgc" +#line 31 "app/dbio/rc_io_0012.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int rc_io_0012_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0012.pgc" +#line 46 "app/dbio/rc_io_0012.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0012.pgc" +#line 47 "app/dbio/rc_io_0012.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0012.pgc" +#line 48 "app/dbio/rc_io_0012.pgc" if (!key) @@ -150,12 +150,12 @@ int rc_io_0012_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0012_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0012_t set net_amt = $1 , upd_ts = now ( ) where mcht_no = $2 and status_cd = '00' and appr_amt > 0", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0012.pgc" +#line 59 "app/dbio/rc_io_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long rc_io_0012_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0012.pgc" +#line 73 "app/dbio/rc_io_0012.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0012.pgc" +#line 74 "app/dbio/rc_io_0012.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0012.pgc" +#line 75 "app/dbio/rc_io_0012.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long rc_io_0012_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0012_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( appr_amt ) , 0 ) from rc_io_0012_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0012.pgc" +#line 86 "app/dbio/rc_io_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long rc_io_0012_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0012.pgc b/app/dbio/rc_io_0012.pgc index 94739f0..03de013 100644 --- a/app/dbio/rc_io_0012.pgc +++ b/app/dbio/rc_io_0012.pgc @@ -24,10 +24,11 @@ int rc_io_0012_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT h.net_amt INTO :h_amount - FROM rc_io_0012_t - WHERE key = :h_key; + FROM rc_io_0012_t h + JOIN rc_io_0012_map_t m ON m.mcht_no = h.mcht_no + WHERE h.mcht_no = :h_key AND m.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,8 @@ int rc_io_0012_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE rc_io_0012_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET net_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key AND status_cd = '00' AND appr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0012_touch"); @@ -79,7 +80,7 @@ long rc_io_0012_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(appr_amt), 0) INTO :h_sum FROM rc_io_0012_t WHERE biz_date = :h_biz_date; @@ -90,3 +91,4 @@ long rc_io_0012_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0013.c b/app/dbio/rc_io_0013.c index 7f8724b..b38e14f 100644 --- a/app/dbio/rc_io_0013.c +++ b/app/dbio/rc_io_0013.c @@ -94,14 +94,18 @@ int rc_io_0013_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/rc_io_0013.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/rc_io_0013.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/rc_io_0013.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/rc_io_0013.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int rc_io_0013_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0013_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select bal_amt from rc_io_0013_bal_t where acct_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0013.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/rc_io_0013.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int rc_io_0013_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0013_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int rc_io_0013_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0013.pgc" +#line 48 "app/dbio/rc_io_0013.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0013.pgc" +#line 49 "app/dbio/rc_io_0013.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0013.pgc" +#line 50 "app/dbio/rc_io_0013.pgc" if (!key) @@ -150,20 +156,18 @@ int rc_io_0013_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0013_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_io_0013_log_t ( mcht_no , appr_amt , reg_ts ) values ( $1 , $2 , now ( ) )", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0013.pgc" +#line 60 "app/dbio/rc_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -177,7 +181,7 @@ long rc_io_0013_total(const char *biz_date) char h_biz_date [ 9 ] ; #line 73 "app/dbio/rc_io_0013.pgc" - long h_sum ; + long h_cnt ; /* exec sql end declare section */ #line 74 "app/dbio/rc_io_0013.pgc" @@ -188,10 +192,10 @@ long rc_io_0013_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0013_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from rc_io_0013_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 85 "app/dbio/rc_io_0013.pgc" @@ -200,5 +204,6 @@ long rc_io_0013_total(const char *biz_date) TX_DBIO_LOG_ERR("rc_io_0013_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/rc_io_0013.pgc b/app/dbio/rc_io_0013.pgc index 381b51a..b6af59f 100644 --- a/app/dbio/rc_io_0013.pgc +++ b/app/dbio/rc_io_0013.pgc @@ -16,6 +16,7 @@ int rc_io_0013_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int rc_io_0013_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM rc_io_0013_t - WHERE key = :h_key; + EXEC SQL SELECT bal_amt + INTO :h_amount :h_ind + FROM rc_io_0013_bal_t + WHERE acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int rc_io_0013_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0013_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -53,16 +56,13 @@ int rc_io_0013_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE rc_io_0013_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL INSERT INTO rc_io_0013_log_t (mcht_no, appr_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -70,7 +70,7 @@ long rc_io_0013_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,8 +79,8 @@ long rc_io_0013_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_cnt FROM rc_io_0013_t WHERE biz_date = :h_biz_date; @@ -88,5 +88,6 @@ long rc_io_0013_total(const char *biz_date) TX_DBIO_LOG_ERR("rc_io_0013_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/rc_io_0014.c b/app/dbio/rc_io_0014.c index c2918a3..92ce0c7 100644 --- a/app/dbio/rc_io_0014.c +++ b/app/dbio/rc_io_0014.c @@ -110,12 +110,12 @@ int rc_io_0014_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0014_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select req_amt from rc_io_0014_t where mcht_no = $1 and status_cd = '00' and cancel_yn = 'N'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0014.pgc" +#line 31 "app/dbio/rc_io_0014.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int rc_io_0014_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0014.pgc" +#line 46 "app/dbio/rc_io_0014.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0014.pgc" +#line 47 "app/dbio/rc_io_0014.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0014.pgc" +#line 48 "app/dbio/rc_io_0014.pgc" if (!key) @@ -150,20 +150,31 @@ int rc_io_0014_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0014_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0014_bal_t set bal_amt = $1 , upd_ts = now ( ) where acct_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0014.pgc" +#line 59 "app/dbio/rc_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0014_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_io_0014_bal_t ( acct_no , bal_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 67 "app/dbio/rc_io_0014.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0014_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -172,14 +183,18 @@ long rc_io_0014_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/rc_io_0014.pgc" +#line 79 "app/dbio/rc_io_0014.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0014.pgc" - long h_sum ; +#line 80 "app/dbio/rc_io_0014.pgc" + long h_avg ; + +#line 81 "app/dbio/rc_io_0014.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0014.pgc" +#line 82 "app/dbio/rc_io_0014.pgc" if (!biz_date) @@ -188,17 +203,20 @@ long rc_io_0014_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0014_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select avg ( appr_amt ) from rc_io_0014_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0014.pgc" + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 93 "app/dbio/rc_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0014_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/rc_io_0014.pgc b/app/dbio/rc_io_0014.pgc index 65dad6a..25d4da3 100644 --- a/app/dbio/rc_io_0014.pgc +++ b/app/dbio/rc_io_0014.pgc @@ -24,10 +24,11 @@ int rc_io_0014_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT req_amt INTO :h_amount FROM rc_io_0014_t - WHERE key = :h_key; + WHERE mcht_no = :h_key AND status_cd = '00' + AND cancel_yn = 'N'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,16 +54,22 @@ int rc_io_0014_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE rc_io_0014_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE rc_io_0014_bal_t + SET bal_amt = :h_amount, upd_ts = now() + WHERE acct_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0014_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + EXEC SQL INSERT INTO rc_io_0014_bal_t (acct_no, bal_amt, upd_ts) + VALUES (:h_key, :h_amount, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0014_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -70,7 +77,8 @@ long rc_io_0014_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_avg; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +87,17 @@ long rc_io_0014_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM rc_io_0014_t + EXEC SQL SELECT avg(appr_amt) + INTO :h_avg :h_ind + FROM rc_io_0014_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0014_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/rc_io_0015.c b/app/dbio/rc_io_0015.c index 2f8b213..6cf649d 100644 --- a/app/dbio/rc_io_0015.c +++ b/app/dbio/rc_io_0015.c @@ -94,14 +94,18 @@ int rc_io_0015_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/rc_io_0015.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/rc_io_0015.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/rc_io_0015.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/rc_io_0015.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int rc_io_0015_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0015_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( appr_amt ) from rc_io_0015_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0015.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/rc_io_0015.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int rc_io_0015_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0015_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int rc_io_0015_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0015.pgc" +#line 48 "app/dbio/rc_io_0015.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0015.pgc" +#line 49 "app/dbio/rc_io_0015.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0015.pgc" +#line 50 "app/dbio/rc_io_0015.pgc" if (!key) @@ -150,12 +156,10 @@ int rc_io_0015_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0015_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from rc_io_0015_tmp_t where ref_key = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0015.pgc" +#line 60 "app/dbio/rc_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +177,13 @@ long rc_io_0015_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0015.pgc" +#line 74 "app/dbio/rc_io_0015.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0015.pgc" +#line 75 "app/dbio/rc_io_0015.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0015.pgc" +#line 76 "app/dbio/rc_io_0015.pgc" if (!biz_date) @@ -188,17 +192,20 @@ long rc_io_0015_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0015_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( net_amt ) , 0 ) from rc_io_0015_t where biz_date = $1 group by biz_date having sum ( net_amt ) > 0 limit 1", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0015.pgc" +#line 90 "app/dbio/rc_io_0015.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0015_total"); return -1; } return h_sum; } + diff --git a/app/dbio/rc_io_0015.pgc b/app/dbio/rc_io_0015.pgc index d52e71d..d1b4726 100644 --- a/app/dbio/rc_io_0015.pgc +++ b/app/dbio/rc_io_0015.pgc @@ -16,6 +16,7 @@ int rc_io_0015_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int rc_io_0015_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM rc_io_0015_t - WHERE key = :h_key; + EXEC SQL SELECT max(appr_amt) + INTO :h_amount :h_ind + FROM rc_io_0015_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int rc_io_0015_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0015_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -53,9 +56,8 @@ int rc_io_0015_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE rc_io_0015_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM rc_io_0015_tmp_t + WHERE ref_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0015_touch"); @@ -79,14 +81,20 @@ long rc_io_0015_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(net_amt), 0) INTO :h_sum FROM rc_io_0015_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + GROUP BY biz_date + HAVING sum(net_amt) > 0 + LIMIT 1; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0015_total"); return -1; } return h_sum; } + diff --git a/app/dbio/rc_io_0016.c b/app/dbio/rc_io_0016.c index 488a988..0d14ea7 100644 --- a/app/dbio/rc_io_0016.c +++ b/app/dbio/rc_io_0016.c @@ -110,12 +110,12 @@ int rc_io_0016_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0016_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select net_amt from rc_io_0016_t where mcht_no in ( select mcht_no from rc_io_0016_map_t where grp_key = $1 )", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0016.pgc" +#line 31 "app/dbio/rc_io_0016.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int rc_io_0016_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0016.pgc" +#line 46 "app/dbio/rc_io_0016.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0016.pgc" +#line 47 "app/dbio/rc_io_0016.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0016.pgc" +#line 48 "app/dbio/rc_io_0016.pgc" if (!key) @@ -150,12 +150,14 @@ int rc_io_0016_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0016_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0016_t set fee_amt = $1 , vat_amt = $2 / 10 , upd_ts = now ( ) where mcht_no = $3 ", + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + 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_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0016.pgc" +#line 59 "app/dbio/rc_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -172,14 +174,18 @@ long rc_io_0016_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/rc_io_0016.pgc" +#line 73 "app/dbio/rc_io_0016.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0016.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/rc_io_0016.pgc" + long h_row ; + +#line 75 "app/dbio/rc_io_0016.pgc" + long acc = 0 ; +/* exec sql end declare section */ +#line 76 "app/dbio/rc_io_0016.pgc" if (!biz_date) @@ -188,17 +194,42 @@ long rc_io_0016_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0016_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGset_var( 0, ( h_biz_date ), __LINE__);\ + /* declare cur_rc_io_0016_t cursor for select net_amt from rc_io_0016_sum_t where biz_date = $1 */ #line 85 "app/dbio/rc_io_0016.pgc" +#line 85 "app/dbio/rc_io_0016.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_rc_io_0016_t cursor for select net_amt from rc_io_0016_sum_t where biz_date = $1 ", + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 86 "app/dbio/rc_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0016_total"); return -1; } - return h_sum; + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_rc_io_0016_t", ECPGt_EOIT, + ECPGt_long,&(h_row),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 92 "app/dbio/rc_io_0016.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0016_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_rc_io_0016_t", ECPGt_EOIT, ECPGt_EORT);} +#line 97 "app/dbio/rc_io_0016.pgc" + + return -1; + } + acc += h_row; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_rc_io_0016_t", ECPGt_EOIT, ECPGt_EORT);} +#line 102 "app/dbio/rc_io_0016.pgc" + + + return acc; } + diff --git a/app/dbio/rc_io_0016.pgc b/app/dbio/rc_io_0016.pgc index 2f687d4..d4603b0 100644 --- a/app/dbio/rc_io_0016.pgc +++ b/app/dbio/rc_io_0016.pgc @@ -24,10 +24,11 @@ int rc_io_0016_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT net_amt INTO :h_amount FROM rc_io_0016_t - WHERE key = :h_key; + WHERE mcht_no IN + (SELECT mcht_no FROM rc_io_0016_map_t WHERE grp_key = :h_key); if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,8 @@ int rc_io_0016_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE rc_io_0016_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET fee_amt = :h_amount, vat_amt = :h_amount / 10, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0016_touch"); @@ -70,7 +71,8 @@ long rc_io_0016_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_row; + long acc = 0; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +81,26 @@ long rc_io_0016_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM rc_io_0016_t - WHERE biz_date = :h_biz_date; - + EXEC SQL DECLARE cur_rc_io_0016_t CURSOR FOR + SELECT net_amt FROM rc_io_0016_sum_t WHERE biz_date = :h_biz_date; + EXEC SQL OPEN cur_rc_io_0016_t; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0016_total"); return -1; } - return h_sum; + for (;;) { + EXEC SQL FETCH cur_rc_io_0016_t INTO :h_row; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0016_total"); + EXEC SQL CLOSE cur_rc_io_0016_t; + return -1; + } + acc += h_row; + } + EXEC SQL CLOSE cur_rc_io_0016_t; + + return acc; } + diff --git a/app/dbio/rc_io_0017.c b/app/dbio/rc_io_0017.c index 711ef66..bd6b28b 100644 --- a/app/dbio/rc_io_0017.c +++ b/app/dbio/rc_io_0017.c @@ -110,20 +110,43 @@ int rc_io_0017_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0017_t where key = $1 ", + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cur_rc_io_0017_f cursor for select appr_amt from rc_io_0017_dtl_t where mcht_no = $1 order by seq desc */ +#line 29 "app/dbio/rc_io_0017.pgc" + +#line 29 "app/dbio/rc_io_0017.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_rc_io_0017_f cursor for select appr_amt from rc_io_0017_dtl_t where mcht_no = $1 order by seq desc", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 30 "app/dbio/rc_io_0017.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0017_fetch"); return TX_EDB; } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_rc_io_0017_f", ECPGt_EOIT, + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 35 "app/dbio/rc_io_0017.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_rc_io_0017_f", ECPGt_EOIT, ECPGt_EORT);} +#line 37 "app/dbio/rc_io_0017.pgc" + + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0017_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_rc_io_0017_f", ECPGt_EOIT, ECPGt_EORT);} +#line 42 "app/dbio/rc_io_0017.pgc" + + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_rc_io_0017_f", ECPGt_EOIT, ECPGt_EORT);} +#line 45 "app/dbio/rc_io_0017.pgc" + + *out_amount = h_amount; return TX_OK; } @@ -134,13 +157,13 @@ int rc_io_0017_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0017.pgc" +#line 54 "app/dbio/rc_io_0017.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0017.pgc" +#line 55 "app/dbio/rc_io_0017.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0017.pgc" +#line 56 "app/dbio/rc_io_0017.pgc" if (!key) @@ -150,12 +173,12 @@ int rc_io_0017_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0017_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0017_t set status_cd = case when $1 > 0 then '00' else '99' end , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0017.pgc" +#line 68 "app/dbio/rc_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -172,14 +195,18 @@ long rc_io_0017_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/rc_io_0017.pgc" +#line 82 "app/dbio/rc_io_0017.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0017.pgc" - long h_sum ; +#line 83 "app/dbio/rc_io_0017.pgc" + long h_max ; + +#line 84 "app/dbio/rc_io_0017.pgc" + long h_min ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0017.pgc" +#line 85 "app/dbio/rc_io_0017.pgc" if (!biz_date) @@ -188,17 +215,20 @@ long rc_io_0017_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0017_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( max ( appr_amt ) , 0 ) , coalesce ( min ( appr_amt ) , 0 ) from rc_io_0017_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_min),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0017.pgc" +#line 96 "app/dbio/rc_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0017_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/rc_io_0017.pgc b/app/dbio/rc_io_0017.pgc index d234a7e..d455bf2 100644 --- a/app/dbio/rc_io_0017.pgc +++ b/app/dbio/rc_io_0017.pgc @@ -24,17 +24,26 @@ int rc_io_0017_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM rc_io_0017_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL DECLARE cur_rc_io_0017_f CURSOR FOR + SELECT appr_amt FROM rc_io_0017_dtl_t + WHERE mcht_no = :h_key ORDER BY seq DESC; + EXEC SQL OPEN cur_rc_io_0017_f; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0017_fetch"); return TX_EDB; } + EXEC SQL FETCH cur_rc_io_0017_f INTO :h_amount; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE cur_rc_io_0017_f; + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0017_fetch"); + EXEC SQL CLOSE cur_rc_io_0017_f; + return TX_EDB; + } + EXEC SQL CLOSE cur_rc_io_0017_f; + *out_amount = h_amount; return TX_OK; } @@ -54,8 +63,9 @@ int rc_io_0017_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE rc_io_0017_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET status_cd = CASE WHEN :h_amount > 0 THEN '00' ELSE '99' END, + upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0017_touch"); @@ -70,7 +80,8 @@ long rc_io_0017_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_max; + long h_min; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +90,15 @@ long rc_io_0017_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM rc_io_0017_t + EXEC SQL SELECT coalesce(max(appr_amt), 0), coalesce(min(appr_amt), 0) + INTO :h_max, :h_min + FROM rc_io_0017_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0017_total"); return -1; } - return h_sum; + return h_max - h_min; } + diff --git a/app/dbio/rc_io_0018.c b/app/dbio/rc_io_0018.c index edc5cf9..ed7a334 100644 --- a/app/dbio/rc_io_0018.c +++ b/app/dbio/rc_io_0018.c @@ -110,12 +110,12 @@ int rc_io_0018_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0018_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when status_cd = '00' then appr_amt else 0 end from rc_io_0018_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0018.pgc" +#line 31 "app/dbio/rc_io_0018.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int rc_io_0018_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0018.pgc" +#line 46 "app/dbio/rc_io_0018.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0018.pgc" +#line 47 "app/dbio/rc_io_0018.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0018.pgc" +#line 48 "app/dbio/rc_io_0018.pgc" if (!key) @@ -150,12 +150,12 @@ int rc_io_0018_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0018_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0018_acc_t set accum_amt = accum_amt + $1 , cnt = cnt + 1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0018.pgc" +#line 59 "app/dbio/rc_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long rc_io_0018_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0018.pgc" +#line 73 "app/dbio/rc_io_0018.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0018.pgc" +#line 74 "app/dbio/rc_io_0018.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0018.pgc" +#line 75 "app/dbio/rc_io_0018.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long rc_io_0018_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0018_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( d . appr_amt ) , 0 ) from rc_io_0018_dtl_t d join rc_io_0018_t h on h . mcht_no = d . mcht_no where d . biz_date = $1 and h . status_cd = '00'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0018.pgc" +#line 87 "app/dbio/rc_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long rc_io_0018_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0018.pgc b/app/dbio/rc_io_0018.pgc index 1ac55c2..9b3d6e0 100644 --- a/app/dbio/rc_io_0018.pgc +++ b/app/dbio/rc_io_0018.pgc @@ -24,10 +24,11 @@ int rc_io_0018_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT + CASE WHEN status_cd = '00' THEN appr_amt ELSE 0 END INTO :h_amount FROM rc_io_0018_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,9 @@ int rc_io_0018_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE rc_io_0018_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE rc_io_0018_acc_t + SET accum_amt = accum_amt + :h_amount, cnt = cnt + 1, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0018_touch"); @@ -79,10 +80,11 @@ long rc_io_0018_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(d.appr_amt), 0) INTO :h_sum - FROM rc_io_0018_t - WHERE biz_date = :h_biz_date; + FROM rc_io_0018_dtl_t d + JOIN rc_io_0018_t h ON h.mcht_no = d.mcht_no + WHERE d.biz_date = :h_biz_date AND h.status_cd = '00'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0018_total"); @@ -90,3 +92,4 @@ long rc_io_0018_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0019.c b/app/dbio/rc_io_0019.c index 7e5317e..146dba5 100644 --- a/app/dbio/rc_io_0019.c +++ b/app/dbio/rc_io_0019.c @@ -110,7 +110,7 @@ int rc_io_0019_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0019_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt from rc_io_0019_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), @@ -150,12 +150,12 @@ int rc_io_0019_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0019_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from rc_io_0019_bal_t where acct_no = $1 and bal_amt <= $2 ", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0019.pgc" +#line 57 "app/dbio/rc_io_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long rc_io_0019_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0019.pgc" +#line 71 "app/dbio/rc_io_0019.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0019.pgc" - long h_sum ; +#line 72 "app/dbio/rc_io_0019.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0019.pgc" +#line 73 "app/dbio/rc_io_0019.pgc" if (!biz_date) @@ -188,17 +188,18 @@ long rc_io_0019_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0019_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct mcht_no ) from rc_io_0019_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0019.pgc" +#line 84 "app/dbio/rc_io_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0019_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/rc_io_0019.pgc b/app/dbio/rc_io_0019.pgc index 2014f97..ab7eb96 100644 --- a/app/dbio/rc_io_0019.pgc +++ b/app/dbio/rc_io_0019.pgc @@ -24,10 +24,10 @@ int rc_io_0019_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT appr_amt INTO :h_amount FROM rc_io_0019_t - WHERE key = :h_key; + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +53,8 @@ int rc_io_0019_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE rc_io_0019_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM rc_io_0019_bal_t + WHERE acct_no = :h_key AND bal_amt <= :h_amount; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0019_touch"); @@ -70,7 +69,7 @@ long rc_io_0019_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +78,15 @@ long rc_io_0019_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM rc_io_0019_t + EXEC SQL SELECT count(DISTINCT mcht_no) + INTO :h_cnt + FROM rc_io_0019_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0019_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/rc_io_0020.c b/app/dbio/rc_io_0020.c index a5b78c0..dcbce08 100644 --- a/app/dbio/rc_io_0020.c +++ b/app/dbio/rc_io_0020.c @@ -94,14 +94,22 @@ int rc_io_0020_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + + #line 17 "app/dbio/rc_io_0020.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/rc_io_0020.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_appr ; + #line 19 "app/dbio/rc_io_0020.pgc" + long h_fee ; + +#line 20 "app/dbio/rc_io_0020.pgc" + long h_vat ; +/* exec sql end declare section */ +#line 21 "app/dbio/rc_io_0020.pgc" if (!key || !out_amount) @@ -110,12 +118,16 @@ int rc_io_0020_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0020_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select appr_amt , fee_amt , vat_amt from rc_io_0020_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_appr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_vat),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0020.pgc" +#line 32 "app/dbio/rc_io_0020.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +136,7 @@ int rc_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -134,13 +146,13 @@ int rc_io_0020_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0020.pgc" +#line 47 "app/dbio/rc_io_0020.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0020.pgc" +#line 48 "app/dbio/rc_io_0020.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0020.pgc" +#line 49 "app/dbio/rc_io_0020.pgc" if (!key) @@ -150,20 +162,29 @@ int rc_io_0020_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0020_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0020_t set req_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0020.pgc" +#line 60 "app/dbio/rc_io_0020.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0020_touch"); + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_io_0020_hist_t ( mcht_no , req_amt , reg_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 66 "app/dbio/rc_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,13 +194,13 @@ long rc_io_0020_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0020.pgc" +#line 78 "app/dbio/rc_io_0020.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0020.pgc" +#line 79 "app/dbio/rc_io_0020.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0020.pgc" +#line 80 "app/dbio/rc_io_0020.pgc" if (!biz_date) @@ -188,12 +209,12 @@ long rc_io_0020_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0020_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( cancel_amt ) , 0 ) from rc_io_0020_t where biz_date = $1 and status_cd = '90' and cancel_yn = 'Y'", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0020.pgc" +#line 92 "app/dbio/rc_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +223,4 @@ long rc_io_0020_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0020.pgc b/app/dbio/rc_io_0020.pgc index 3499080..f412186 100644 --- a/app/dbio/rc_io_0020.pgc +++ b/app/dbio/rc_io_0020.pgc @@ -15,7 +15,9 @@ int rc_io_0020_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; - long h_amount; + long h_appr; + long h_fee; + long h_vat; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +26,10 @@ int rc_io_0020_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM rc_io_0020_t - WHERE key = :h_key; + EXEC SQL SELECT appr_amt, fee_amt, vat_amt + INTO :h_appr, :h_fee, :h_vat + FROM rc_io_0020_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,7 +37,7 @@ int rc_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_appr - h_fee - h_vat; return TX_OK; } @@ -54,15 +56,19 @@ int rc_io_0020_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE rc_io_0020_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET req_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0020_touch"); + return TX_EDB; + } + EXEC SQL INSERT INTO rc_io_0020_hist_t (mcht_no, req_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -79,10 +85,11 @@ long rc_io_0020_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(cancel_amt), 0) INTO :h_sum FROM rc_io_0020_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + AND status_cd = '90' AND cancel_yn = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0020_total"); @@ -90,3 +97,4 @@ long rc_io_0020_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0021.c b/app/dbio/rc_io_0021.c index 2308518..9569e55 100644 --- a/app/dbio/rc_io_0021.c +++ b/app/dbio/rc_io_0021.c @@ -110,12 +110,12 @@ int rc_io_0021_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0021_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select h . net_amt from rc_io_0021_t h join rc_io_0021_map_t m on m . mcht_no = h . mcht_no where h . mcht_no = $1 and m . use_yn = 'Y'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0021.pgc" +#line 31 "app/dbio/rc_io_0021.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int rc_io_0021_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0021.pgc" +#line 46 "app/dbio/rc_io_0021.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0021.pgc" +#line 47 "app/dbio/rc_io_0021.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0021.pgc" +#line 48 "app/dbio/rc_io_0021.pgc" if (!key) @@ -150,12 +150,12 @@ int rc_io_0021_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0021_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0021_t set appr_amt = $1 , upd_ts = now ( ) where mcht_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0021.pgc" +#line 59 "app/dbio/rc_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +173,13 @@ long rc_io_0021_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0021.pgc" +#line 73 "app/dbio/rc_io_0021.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0021.pgc" +#line 74 "app/dbio/rc_io_0021.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0021.pgc" +#line 75 "app/dbio/rc_io_0021.pgc" if (!biz_date) @@ -188,12 +188,12 @@ long rc_io_0021_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0021_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( recon_amt ) , 0 ) from rc_io_0021_sum_t where biz_date in ( select biz_date from rc_io_0021_map_t where biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0021.pgc" +#line 87 "app/dbio/rc_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +202,4 @@ long rc_io_0021_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0021.pgc b/app/dbio/rc_io_0021.pgc index 2fdbf0f..56c5e4e 100644 --- a/app/dbio/rc_io_0021.pgc +++ b/app/dbio/rc_io_0021.pgc @@ -24,10 +24,11 @@ int rc_io_0021_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT h.net_amt INTO :h_amount - FROM rc_io_0021_t - WHERE key = :h_key; + FROM rc_io_0021_t h + JOIN rc_io_0021_map_t m ON m.mcht_no = h.mcht_no + WHERE h.mcht_no = :h_key AND m.use_yn = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -54,8 +55,8 @@ int rc_io_0021_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE rc_io_0021_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET appr_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0021_touch"); @@ -79,10 +80,11 @@ long rc_io_0021_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(recon_amt), 0) INTO :h_sum - FROM rc_io_0021_t - WHERE biz_date = :h_biz_date; + FROM rc_io_0021_sum_t + WHERE biz_date IN + (SELECT biz_date FROM rc_io_0021_map_t WHERE biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0021_total"); @@ -90,3 +92,4 @@ long rc_io_0021_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0022.c b/app/dbio/rc_io_0022.c index 095f9cd..532e8ad 100644 --- a/app/dbio/rc_io_0022.c +++ b/app/dbio/rc_io_0022.c @@ -94,14 +94,18 @@ int rc_io_0022_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/rc_io_0022.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/rc_io_0022.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/rc_io_0022.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/rc_io_0022.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int rc_io_0022_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0022_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select bal_amt from rc_io_0022_bal_t where acct_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0022.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/rc_io_0022.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int rc_io_0022_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0022_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int rc_io_0022_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0022.pgc" +#line 48 "app/dbio/rc_io_0022.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0022.pgc" +#line 49 "app/dbio/rc_io_0022.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0022.pgc" +#line 50 "app/dbio/rc_io_0022.pgc" if (!key) @@ -150,12 +156,12 @@ int rc_io_0022_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0022_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0022_t set net_amt = $1 , upd_ts = now ( ) where mcht_no = $2 and status_cd = '00' and appr_amt > 0", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0022.pgc" +#line 61 "app/dbio/rc_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +179,13 @@ long rc_io_0022_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0022.pgc" +#line 75 "app/dbio/rc_io_0022.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0022.pgc" - long h_sum ; +#line 76 "app/dbio/rc_io_0022.pgc" + long h_flag ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0022.pgc" +#line 77 "app/dbio/rc_io_0022.pgc" if (!biz_date) @@ -188,17 +194,18 @@ long rc_io_0022_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0022_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from rc_io_0022_t where exists ( select 1 from rc_io_0022_dtl_t d where d . biz_date = $1 )", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0022.pgc" +#line 90 "app/dbio/rc_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0022_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/rc_io_0022.pgc b/app/dbio/rc_io_0022.pgc index b85eb5c..a7c4d7b 100644 --- a/app/dbio/rc_io_0022.pgc +++ b/app/dbio/rc_io_0022.pgc @@ -16,6 +16,7 @@ int rc_io_0022_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int rc_io_0022_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM rc_io_0022_t - WHERE key = :h_key; + EXEC SQL SELECT bal_amt + INTO :h_amount :h_ind + FROM rc_io_0022_bal_t + WHERE acct_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int rc_io_0022_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0022_fetch"); return TX_EDB; } + if (h_ind == -1) + h_amount = 0; *out_amount = h_amount; return TX_OK; } @@ -54,8 +57,8 @@ int rc_io_0022_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE rc_io_0022_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET net_amt = :h_amount, upd_ts = now() + WHERE mcht_no = :h_key AND status_cd = '00' AND appr_amt > 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0022_touch"); @@ -70,7 +73,7 @@ long rc_io_0022_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_flag; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +82,17 @@ long rc_io_0022_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_flag FROM rc_io_0022_t - WHERE biz_date = :h_biz_date; + WHERE EXISTS + (SELECT 1 FROM rc_io_0022_dtl_t d + WHERE d.biz_date = :h_biz_date); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0022_total"); return -1; } - return h_sum; + return h_flag > 0 ? 1 : 0; } + diff --git a/app/dbio/rc_io_0023.c b/app/dbio/rc_io_0023.c index e06570b..1472043 100644 --- a/app/dbio/rc_io_0023.c +++ b/app/dbio/rc_io_0023.c @@ -110,12 +110,12 @@ int rc_io_0023_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0023_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select req_amt from rc_io_0023_t where mcht_no = $1 and status_cd = '00' and cancel_yn = 'N'", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0023.pgc" +#line 31 "app/dbio/rc_io_0023.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int rc_io_0023_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0023.pgc" +#line 46 "app/dbio/rc_io_0023.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0023.pgc" +#line 47 "app/dbio/rc_io_0023.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0023.pgc" +#line 48 "app/dbio/rc_io_0023.pgc" if (!key) @@ -150,10 +150,10 @@ int rc_io_0023_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0023_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_io_0023_log_t ( mcht_no , appr_amt , reg_ts ) values ( $1 , $2 , now ( ) )", ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} #line 58 "app/dbio/rc_io_0023.pgc" @@ -162,8 +162,6 @@ int rc_io_0023_touch(const char *key, long amount) TX_DBIO_LOG_ERR("rc_io_0023_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,13 +171,13 @@ long rc_io_0023_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0023.pgc" +#line 70 "app/dbio/rc_io_0023.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0023.pgc" +#line 71 "app/dbio/rc_io_0023.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0023.pgc" +#line 72 "app/dbio/rc_io_0023.pgc" if (!biz_date) @@ -188,12 +186,12 @@ long rc_io_0023_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0023_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( appr_amt ) , 0 ) from rc_io_0023_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0023.pgc" +#line 83 "app/dbio/rc_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,3 +200,4 @@ long rc_io_0023_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0023.pgc b/app/dbio/rc_io_0023.pgc index 23ebd7b..0afddb6 100644 --- a/app/dbio/rc_io_0023.pgc +++ b/app/dbio/rc_io_0023.pgc @@ -24,10 +24,11 @@ int rc_io_0023_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT req_amt INTO :h_amount FROM rc_io_0023_t - WHERE key = :h_key; + WHERE mcht_no = :h_key AND status_cd = '00' + AND cancel_yn = 'N'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,16 +54,13 @@ int rc_io_0023_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE rc_io_0023_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL INSERT INTO rc_io_0023_log_t (mcht_no, appr_amt, reg_ts) + VALUES (:h_key, :h_amount, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0023_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -79,7 +77,7 @@ long rc_io_0023_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(appr_amt), 0) INTO :h_sum FROM rc_io_0023_t WHERE biz_date = :h_biz_date; @@ -90,3 +88,4 @@ long rc_io_0023_total(const char *biz_date) } return h_sum; } + diff --git a/app/dbio/rc_io_0024.c b/app/dbio/rc_io_0024.c index 8a8629f..8bfeb6a 100644 --- a/app/dbio/rc_io_0024.c +++ b/app/dbio/rc_io_0024.c @@ -94,14 +94,18 @@ int rc_io_0024_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/rc_io_0024.pgc" char h_key [ 16 ] ; #line 18 "app/dbio/rc_io_0024.pgc" long h_amount ; -/* exec sql end declare section */ + #line 19 "app/dbio/rc_io_0024.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/rc_io_0024.pgc" if (!key || !out_amount) @@ -110,12 +114,12 @@ int rc_io_0024_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0024_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( appr_amt ) from rc_io_0024_dtl_t where mcht_no = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0024.pgc" + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 31 "app/dbio/rc_io_0024.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,6 +128,8 @@ int rc_io_0024_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0024_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -134,13 +140,13 @@ int rc_io_0024_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0024.pgc" +#line 48 "app/dbio/rc_io_0024.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0024.pgc" +#line 49 "app/dbio/rc_io_0024.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0024.pgc" +#line 50 "app/dbio/rc_io_0024.pgc" if (!key) @@ -150,20 +156,31 @@ int rc_io_0024_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0024_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0024_bal_t set bal_amt = $1 , upd_ts = now ( ) where acct_no = $2 ", ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0024.pgc" +#line 61 "app/dbio/rc_io_0024.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0024_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_io_0024_bal_t ( acct_no , bal_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(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_EOIT, ECPGt_EORT);} +#line 69 "app/dbio/rc_io_0024.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0024_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -173,13 +190,13 @@ long rc_io_0024_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0024.pgc" +#line 81 "app/dbio/rc_io_0024.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0024.pgc" - long h_sum ; +#line 82 "app/dbio/rc_io_0024.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0024.pgc" +#line 83 "app/dbio/rc_io_0024.pgc" if (!biz_date) @@ -188,17 +205,18 @@ long rc_io_0024_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0024_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from rc_io_0024_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0024.pgc" +#line 94 "app/dbio/rc_io_0024.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0024_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/rc_io_0024.pgc b/app/dbio/rc_io_0024.pgc index 252474b..3bd08d4 100644 --- a/app/dbio/rc_io_0024.pgc +++ b/app/dbio/rc_io_0024.pgc @@ -16,6 +16,7 @@ int rc_io_0024_fetch(const char *key, long *out_amount) EXEC SQL BEGIN DECLARE SECTION; char h_key[16]; long h_amount; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) @@ -24,10 +25,10 @@ int rc_io_0024_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM rc_io_0024_t - WHERE key = :h_key; + EXEC SQL SELECT max(appr_amt) + INTO :h_amount :h_ind + FROM rc_io_0024_dtl_t + WHERE mcht_no = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,6 +36,8 @@ int rc_io_0024_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("rc_io_0024_fetch"); return TX_EDB; } + if (sqlca.sqlcode == TX_SQL_NOTFOUND || h_ind == -1) + return TX_ENOENT; *out_amount = h_amount; return TX_OK; } @@ -53,16 +56,22 @@ int rc_io_0024_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE rc_io_0024_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL UPDATE rc_io_0024_bal_t + SET bal_amt = :h_amount, upd_ts = now() + WHERE acct_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0024_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; + if (sqlca.sqlerrd[2] == 0) { + EXEC SQL INSERT INTO rc_io_0024_bal_t (acct_no, bal_amt, upd_ts) + VALUES (:h_key, :h_amount, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0024_touch"); + return TX_EDB; + } + } return TX_OK; } @@ -70,7 +79,7 @@ long rc_io_0024_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,8 +88,8 @@ long rc_io_0024_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum + EXEC SQL SELECT count(*) + INTO :h_cnt FROM rc_io_0024_t WHERE biz_date = :h_biz_date; @@ -88,5 +97,6 @@ long rc_io_0024_total(const char *biz_date) TX_DBIO_LOG_ERR("rc_io_0024_total"); return -1; } - return h_sum; + return h_cnt; } + diff --git a/app/dbio/rc_io_0025.c b/app/dbio/rc_io_0025.c index 0b8b08c..28313b7 100644 --- a/app/dbio/rc_io_0025.c +++ b/app/dbio/rc_io_0025.c @@ -110,12 +110,12 @@ int rc_io_0025_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0025_t where key = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select net_amt from rc_io_0025_t where mcht_no in ( select mcht_no from rc_io_0025_map_t where grp_key = $1 )", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/rc_io_0025.pgc" +#line 31 "app/dbio/rc_io_0025.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -134,13 +134,13 @@ int rc_io_0025_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0025.pgc" +#line 46 "app/dbio/rc_io_0025.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0025.pgc" +#line 47 "app/dbio/rc_io_0025.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0025.pgc" +#line 48 "app/dbio/rc_io_0025.pgc" if (!key) @@ -150,9 +150,7 @@ int rc_io_0025_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0025_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from rc_io_0025_tmp_t where ref_key = $1 ", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/rc_io_0025.pgc" @@ -172,14 +170,18 @@ long rc_io_0025_total(const char *biz_date) /* exec sql begin declare section */ + #line 72 "app/dbio/rc_io_0025.pgc" char h_biz_date [ 9 ] ; #line 73 "app/dbio/rc_io_0025.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_avg ; + #line 74 "app/dbio/rc_io_0025.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 75 "app/dbio/rc_io_0025.pgc" if (!biz_date) @@ -188,17 +190,20 @@ long rc_io_0025_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0025_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select avg ( appr_amt ) from rc_io_0025_dtl_t where biz_date = $1 ", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0025.pgc" + ECPGt_long,&(h_avg),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 86 "app/dbio/rc_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0025_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/rc_io_0025.pgc b/app/dbio/rc_io_0025.pgc index 7440dde..46ae638 100644 --- a/app/dbio/rc_io_0025.pgc +++ b/app/dbio/rc_io_0025.pgc @@ -24,10 +24,11 @@ int rc_io_0025_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount + EXEC SQL SELECT net_amt INTO :h_amount FROM rc_io_0025_t - WHERE key = :h_key; + WHERE mcht_no IN + (SELECT mcht_no FROM rc_io_0025_map_t WHERE grp_key = :h_key); if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -53,9 +54,8 @@ int rc_io_0025_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - EXEC SQL UPDATE rc_io_0025_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + EXEC SQL DELETE FROM rc_io_0025_tmp_t + WHERE ref_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0025_touch"); @@ -70,7 +70,8 @@ long rc_io_0025_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; char h_biz_date[9]; - long h_sum; + long h_avg; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) @@ -79,14 +80,17 @@ long rc_io_0025_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM rc_io_0025_t + EXEC SQL SELECT avg(appr_amt) + INTO :h_avg :h_ind + FROM rc_io_0025_dtl_t WHERE biz_date = :h_biz_date; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0025_total"); return -1; } - return h_sum; + if (h_ind == -1) + return 0; + return h_avg; } + diff --git a/app/dbio/rc_io_0026.c b/app/dbio/rc_io_0026.c index b9488bd..9b59749 100644 --- a/app/dbio/rc_io_0026.c +++ b/app/dbio/rc_io_0026.c @@ -110,20 +110,43 @@ int rc_io_0026_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from rc_io_0026_t where key = $1 ", + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare cur_rc_io_0026_f cursor for select appr_amt from rc_io_0026_dtl_t where mcht_no = $1 order by seq desc */ +#line 29 "app/dbio/rc_io_0026.pgc" + +#line 29 "app/dbio/rc_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur_rc_io_0026_f cursor for select appr_amt from rc_io_0026_dtl_t where mcht_no = $1 order by seq desc", ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 30 "app/dbio/rc_io_0026.pgc" - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0026_fetch"); return TX_EDB; } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur_rc_io_0026_f", ECPGt_EOIT, + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 35 "app/dbio/rc_io_0026.pgc" + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_rc_io_0026_f", ECPGt_EOIT, ECPGt_EORT);} +#line 37 "app/dbio/rc_io_0026.pgc" + + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0026_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_rc_io_0026_f", ECPGt_EOIT, ECPGt_EORT);} +#line 42 "app/dbio/rc_io_0026.pgc" + + return TX_EDB; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur_rc_io_0026_f", ECPGt_EOIT, ECPGt_EORT);} +#line 45 "app/dbio/rc_io_0026.pgc" + + *out_amount = h_amount; return TX_OK; } @@ -134,13 +157,13 @@ int rc_io_0026_touch(const char *key, long amount) -#line 45 "app/dbio/rc_io_0026.pgc" +#line 54 "app/dbio/rc_io_0026.pgc" char h_key [ 16 ] ; -#line 46 "app/dbio/rc_io_0026.pgc" +#line 55 "app/dbio/rc_io_0026.pgc" long h_amount ; /* exec sql end declare section */ -#line 47 "app/dbio/rc_io_0026.pgc" +#line 56 "app/dbio/rc_io_0026.pgc" if (!key) @@ -150,12 +173,14 @@ int rc_io_0026_touch(const char *key, long amount) h_key[sizeof(h_key) - 1] = '\0'; h_amount = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0026_t set amount = $1 , upd_ts = now ( ) where key = $2 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update rc_io_0026_t set fee_amt = $1 , vat_amt = $2 / 10 , upd_ts = now ( ) where mcht_no = $3 ", + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + 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_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/rc_io_0026.pgc" +#line 67 "app/dbio/rc_io_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,13 +198,13 @@ long rc_io_0026_total(const char *biz_date) -#line 72 "app/dbio/rc_io_0026.pgc" +#line 81 "app/dbio/rc_io_0026.pgc" char h_biz_date [ 9 ] ; -#line 73 "app/dbio/rc_io_0026.pgc" +#line 82 "app/dbio/rc_io_0026.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/rc_io_0026.pgc" +#line 83 "app/dbio/rc_io_0026.pgc" if (!biz_date) @@ -188,17 +213,20 @@ long rc_io_0026_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from rc_io_0026_t where biz_date = $1 ", + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( net_amt ) , 0 ) from rc_io_0026_t where biz_date = $1 group by biz_date having sum ( net_amt ) > 0 limit 1", ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/rc_io_0026.pgc" +#line 97 "app/dbio/rc_io_0026.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0026_total"); return -1; } return h_sum; } + diff --git a/app/dbio/rc_io_0026.pgc b/app/dbio/rc_io_0026.pgc index de958e3..1ce9b96 100644 --- a/app/dbio/rc_io_0026.pgc +++ b/app/dbio/rc_io_0026.pgc @@ -24,17 +24,26 @@ int rc_io_0026_fetch(const char *key, long *out_amount) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM rc_io_0026_t - WHERE key = :h_key; - - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; + EXEC SQL DECLARE cur_rc_io_0026_f CURSOR FOR + SELECT appr_amt FROM rc_io_0026_dtl_t + WHERE mcht_no = :h_key ORDER BY seq DESC; + EXEC SQL OPEN cur_rc_io_0026_f; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0026_fetch"); return TX_EDB; } + EXEC SQL FETCH cur_rc_io_0026_f INTO :h_amount; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE cur_rc_io_0026_f; + return TX_ENOENT; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("rc_io_0026_fetch"); + EXEC SQL CLOSE cur_rc_io_0026_f; + return TX_EDB; + } + EXEC SQL CLOSE cur_rc_io_0026_f; + *out_amount = h_amount; return TX_OK; } @@ -54,8 +63,8 @@ int rc_io_0026_touch(const char *key, long amount) h_amount = amount; EXEC SQL UPDATE rc_io_0026_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + SET fee_amt = :h_amount, vat_amt = :h_amount / 10, upd_ts = now() + WHERE mcht_no = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0026_touch"); @@ -79,14 +88,20 @@ long rc_io_0026_total(const char *biz_date) strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(net_amt), 0) INTO :h_sum FROM rc_io_0026_t - WHERE biz_date = :h_biz_date; + WHERE biz_date = :h_biz_date + GROUP BY biz_date + HAVING sum(net_amt) > 0 + LIMIT 1; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + return 0; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("rc_io_0026_total"); return -1; } return h_sum; } + diff --git a/app/dbio/st_io_0001.c b/app/dbio/st_io_0001.c index 2086e2d..a77e1fe 100644 --- a/app/dbio/st_io_0001.c +++ b/app/dbio/st_io_0001.c @@ -96,26 +96,25 @@ int st_io_0001_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0001.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0001.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0001.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0001_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select settle_amt from st_settle_dtl where settle_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/st_io_0001.pgc" +#line 29 "app/dbio/st_io_0001.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int st_io_0001_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0001_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int st_io_0001_touch(const char *key, long amount) -#line 45 "app/dbio/st_io_0001.pgc" - char h_key [ 16 ] ; +#line 44 "app/dbio/st_io_0001.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/st_io_0001.pgc" - long h_amount ; +#line 45 "app/dbio/st_io_0001.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/st_io_0001.pgc" +#line 46 "app/dbio/st_io_0001.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0001_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_settle_dtl set settle_amt = $1 , upd_ts = now ( ) where settle_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0001.pgc" - +#line 56 "app/dbio/st_io_0001.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0001_touch"); @@ -173,27 +170,26 @@ long st_io_0001_total(const char *biz_date) -#line 72 "app/dbio/st_io_0001.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/st_io_0001.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0001.pgc" +#line 70 "app/dbio/st_io_0001.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0001.pgc" +#line 71 "app/dbio/st_io_0001.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0001_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( settle_amt ) , 0 ) from st_settle_dtl where settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0001.pgc" +#line 81 "app/dbio/st_io_0001.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/st_io_0001.pgc b/app/dbio/st_io_0001.pgc index 40f74b2..1ff4daa 100644 --- a/app/dbio/st_io_0001.pgc +++ b/app/dbio/st_io_0001.pgc @@ -14,20 +14,19 @@ EXEC SQL INCLUDE sqlca; int st_io_0001_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0001_t - WHERE key = :h_key; + EXEC SQL SELECT settle_amt + INTO :h_val + FROM st_settle_dtl + WHERE settle_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +34,26 @@ int st_io_0001_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0001_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int st_io_0001_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0001_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE st_settle_dtl + SET settle_amt = :h_amt, upd_ts = now() + WHERE settle_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0001_touch"); return TX_EDB; @@ -69,20 +66,19 @@ int st_io_0001_touch(const char *key, long amount) long st_io_0001_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(settle_amt), 0) INTO :h_sum - FROM st_io_0001_t - WHERE biz_date = :h_biz_date; + FROM st_settle_dtl + WHERE settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0001_total"); diff --git a/app/dbio/st_io_0002.c b/app/dbio/st_io_0002.c index 436189e..41e2c77 100644 --- a/app/dbio/st_io_0002.c +++ b/app/dbio/st_io_0002.c @@ -94,27 +94,30 @@ int st_io_0002_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/st_io_0002.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0002.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/st_io_0002.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/st_io_0002.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0002_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select fee_amt from st_settle_dtl where settle_key = $1 and settle_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/st_io_0002.pgc" @@ -124,7 +127,7 @@ int st_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } @@ -135,28 +138,26 @@ int st_io_0002_touch(const char *key, long amount) #line 45 "app/dbio/st_io_0002.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/st_io_0002.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/st_io_0002.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0002_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_settle_dtl set settle_amt = $1 , settle_flag = 'Y' , upd_ts = now ( ) where settle_key = $2 and settle_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0002.pgc" - +#line 57 "app/dbio/st_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0002_touch"); @@ -173,32 +174,31 @@ long st_io_0002_total(const char *biz_date) -#line 72 "app/dbio/st_io_0002.pgc" - char h_biz_date [ 9 ] ; +#line 70 "app/dbio/st_io_0002.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0002.pgc" - long h_sum ; +#line 71 "app/dbio/st_io_0002.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0002.pgc" +#line 72 "app/dbio/st_io_0002.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0002_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from st_settle_dtl where settle_dt = $1 and settle_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0002.pgc" +#line 82 "app/dbio/st_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/st_io_0002.pgc b/app/dbio/st_io_0002.pgc index a4f03b0..2ac867c 100644 --- a/app/dbio/st_io_0002.pgc +++ b/app/dbio/st_io_0002.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int st_io_0002_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0002_t - WHERE key = :h_key; + EXEC SQL SELECT fee_amt + INTO :h_val:h_ind + FROM st_settle_dtl + WHERE settle_key = :h_key AND settle_flag = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +35,26 @@ int st_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } int st_io_0002_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0002_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE st_settle_dtl + SET settle_amt = :h_amt, settle_flag = 'Y', upd_ts = now() + WHERE settle_key = :h_key AND settle_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0002_touch"); return TX_EDB; @@ -69,24 +67,23 @@ int st_io_0002_touch(const char *key, long amount) long st_io_0002_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM st_io_0002_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM st_settle_dtl + WHERE settle_dt = :h_dt AND settle_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/st_io_0003.c b/app/dbio/st_io_0003.c index 0b01ac1..a6aa4b7 100644 --- a/app/dbio/st_io_0003.c +++ b/app/dbio/st_io_0003.c @@ -96,24 +96,23 @@ int st_io_0003_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0003.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0003.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0003.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0003_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a . settle_amt from st_settle_dtl a join st_settle_fee b on a . settle_key = b . settle_key where a . settle_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/st_io_0003.pgc" @@ -124,7 +123,7 @@ int st_io_0003_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0003_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -135,28 +134,28 @@ int st_io_0003_touch(const char *key, long amount) #line 45 "app/dbio/st_io_0003.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/st_io_0003.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/st_io_0003.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0003_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_settle_dtl set fee_amt = $1 where settle_key = $2 and settle_amt >= $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0003.pgc" - +#line 57 "app/dbio/st_io_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0003_touch"); @@ -172,33 +171,38 @@ long st_io_0003_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/st_io_0003.pgc" - char h_biz_date [ 9 ] ; +#line 70 "app/dbio/st_io_0003.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0003.pgc" - long h_sum ; +#line 71 "app/dbio/st_io_0003.pgc" + long h_max ; + +#line 72 "app/dbio/st_io_0003.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0003.pgc" +#line 73 "app/dbio/st_io_0003.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0003_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( settle_amt ) from st_settle_dtl where settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0003.pgc" + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 83 "app/dbio/st_io_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0003_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/st_io_0003.pgc b/app/dbio/st_io_0003.pgc index 01628d1..ed62fb3 100644 --- a/app/dbio/st_io_0003.pgc +++ b/app/dbio/st_io_0003.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int st_io_0003_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0003_t - WHERE key = :h_key; + EXEC SQL SELECT a.settle_amt + INTO :h_val + FROM st_settle_dtl a + JOIN st_settle_fee b ON a.settle_key = b.settle_key + WHERE a.settle_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +35,26 @@ int st_io_0003_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0003_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int st_io_0003_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0003_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE st_settle_dtl + SET fee_amt = :h_amt + WHERE settle_key = :h_key AND settle_amt >= :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0003_touch"); return TX_EDB; @@ -69,24 +67,26 @@ int st_io_0003_touch(const char *key, long amount) long st_io_0003_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM st_io_0003_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(settle_amt) + INTO :h_max:h_ind + FROM st_settle_dtl + WHERE settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0003_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/st_io_0004.c b/app/dbio/st_io_0004.c index 90ef738..c455fc2 100644 --- a/app/dbio/st_io_0004.c +++ b/app/dbio/st_io_0004.c @@ -96,35 +96,32 @@ int st_io_0004_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0004.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0004.pgc" - long h_amount ; + long h_flag ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0004.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0004_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when exists ( select 1 from st_settle_dtl where settle_key = $1 and settle_flag = 'N' ) then 1 else 0 end", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/st_io_0004.pgc" +#line 29 "app/dbio/st_io_0004.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0004_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } @@ -134,36 +131,32 @@ int st_io_0004_touch(const char *key, long amount) -#line 45 "app/dbio/st_io_0004.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/st_io_0004.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/st_io_0004.pgc" - long h_amount ; +#line 43 "app/dbio/st_io_0004.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/st_io_0004.pgc" +#line 44 "app/dbio/st_io_0004.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0004_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into st_settle_sum ( settle_key , settle_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0004.pgc" - +#line 53 "app/dbio/st_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,27 +166,26 @@ long st_io_0004_total(const char *biz_date) -#line 72 "app/dbio/st_io_0004.pgc" - char h_biz_date [ 9 ] ; +#line 64 "app/dbio/st_io_0004.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0004.pgc" +#line 65 "app/dbio/st_io_0004.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0004.pgc" +#line 66 "app/dbio/st_io_0004.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0004_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . settle_amt ) , 0 ) from st_settle_dtl a join st_settle_fee b on a . settle_key = b . settle_key where a . settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0004.pgc" +#line 77 "app/dbio/st_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/st_io_0004.pgc b/app/dbio/st_io_0004.pgc index aa83e9b..bea5d77 100644 --- a/app/dbio/st_io_0004.pgc +++ b/app/dbio/st_io_0004.pgc @@ -14,75 +14,67 @@ EXEC SQL INCLUDE sqlca; int st_io_0004_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_flag; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0004_t - WHERE key = :h_key; + EXEC SQL SELECT CASE WHEN EXISTS ( + SELECT 1 FROM st_settle_dtl + WHERE settle_key = :h_key AND settle_flag = 'N') THEN 1 ELSE 0 END + INTO :h_flag; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0004_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } int st_io_0004_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0004_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO st_settle_sum (settle_key, settle_amt, upd_ts) + VALUES (:h_key, :h_amt, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long st_io_0004_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.settle_amt), 0) INTO :h_sum - FROM st_io_0004_t - WHERE biz_date = :h_biz_date; + FROM st_settle_dtl a + JOIN st_settle_fee b ON a.settle_key = b.settle_key + WHERE a.settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0004_total"); diff --git a/app/dbio/st_io_0005.c b/app/dbio/st_io_0005.c index 12d3f76..484c818 100644 --- a/app/dbio/st_io_0005.c +++ b/app/dbio/st_io_0005.c @@ -94,37 +94,40 @@ int st_io_0005_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/st_io_0005.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0005.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/st_io_0005.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/st_io_0005.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0005_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( settle_amt ) from st_settle_dtl where merchant_id = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/st_io_0005.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0005_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,35 +138,31 @@ int st_io_0005_touch(const char *key, long amount) #line 45 "app/dbio/st_io_0005.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/st_io_0005.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/st_io_0005.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0005_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into st_settle_dtl ( settle_key , settle_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( settle_key ) do update set settle_amt = excluded . settle_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/st_io_0005.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0005_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,32 +172,52 @@ long st_io_0005_total(const char *biz_date) -#line 72 "app/dbio/st_io_0005.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/st_io_0005.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0005.pgc" - long h_sum ; +#line 70 "app/dbio/st_io_0005.pgc" + long h_grp ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0005.pgc" +#line 71 "app/dbio/st_io_0005.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0005_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_dt ), __LINE__);\ + /* declare st_io_0005_total_cur cursor for select coalesce ( sum ( settle_amt ) , 0 ) from st_settle_dtl where settle_dt = $1 group by merchant_id */ +#line 82 "app/dbio/st_io_0005.pgc" + +#line 82 "app/dbio/st_io_0005.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare st_io_0005_total_cur cursor for select coalesce ( sum ( settle_amt ) , 0 ) from st_settle_dtl where settle_dt = $1 group by merchant_id", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 83 "app/dbio/st_io_0005.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch st_io_0005_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 85 "app/dbio/st_io_0005.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("st_io_0005_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0005_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 90 "app/dbio/st_io_0005.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("st_io_0005_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0005_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 95 "app/dbio/st_io_0005.pgc" + + return acc; } diff --git a/app/dbio/st_io_0005.pgc b/app/dbio/st_io_0005.pgc index a02995b..9789c0b 100644 --- a/app/dbio/st_io_0005.pgc +++ b/app/dbio/st_io_0005.pgc @@ -14,79 +14,84 @@ EXEC SQL INCLUDE sqlca; int st_io_0005_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0005_t - WHERE key = :h_key; + EXEC SQL SELECT max(settle_amt) + INTO :h_val:h_ind + FROM st_settle_dtl + WHERE merchant_id = :h_key; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0005_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int st_io_0005_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0005_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO st_settle_dtl (settle_key, settle_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (settle_key) + DO UPDATE SET settle_amt = excluded.settle_amt, upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0005_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long st_io_0005_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM st_io_0005_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("st_io_0005_total"); - return -1; + EXEC SQL DECLARE st_io_0005_total_cur CURSOR FOR + SELECT coalesce(sum(settle_amt), 0) FROM st_settle_dtl + WHERE settle_dt = :h_dt GROUP BY merchant_id; + EXEC SQL OPEN st_io_0005_total_cur; + for (;;) { + EXEC SQL FETCH st_io_0005_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("st_io_0005_total"); + EXEC SQL CLOSE st_io_0005_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE st_io_0005_total_cur; + return acc; } diff --git a/app/dbio/st_io_0006.c b/app/dbio/st_io_0006.c index ae1d342..9cfcb06 100644 --- a/app/dbio/st_io_0006.c +++ b/app/dbio/st_io_0006.c @@ -94,37 +94,40 @@ int st_io_0006_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/st_io_0006.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0006.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/st_io_0006.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/st_io_0006.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0006_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( settle_amt ) from st_settle_dtl where merchant_id = $1 and settle_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/st_io_0006.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0006_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,24 @@ int st_io_0006_touch(const char *key, long amount) #line 45 "app/dbio/st_io_0006.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/st_io_0006.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/st_io_0006.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0006_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from st_settle_sum where settle_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0006.pgc" - +#line 56 "app/dbio/st_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0006_touch"); @@ -173,27 +172,26 @@ long st_io_0006_total(const char *biz_date) -#line 72 "app/dbio/st_io_0006.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/st_io_0006.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0006.pgc" +#line 70 "app/dbio/st_io_0006.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0006.pgc" +#line 71 "app/dbio/st_io_0006.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0006_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when settle_flag = 'Y' then settle_amt else 0 end ) , 0 ) from st_settle_dtl where settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0006.pgc" +#line 81 "app/dbio/st_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/st_io_0006.pgc b/app/dbio/st_io_0006.pgc index 3e23cb8..eb0cfda 100644 --- a/app/dbio/st_io_0006.pgc +++ b/app/dbio/st_io_0006.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int st_io_0006_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0006_t - WHERE key = :h_key; + EXEC SQL SELECT min(settle_amt) + INTO :h_val:h_ind + FROM st_settle_dtl + WHERE merchant_id = :h_key AND settle_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0006_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int st_io_0006_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0006_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM st_settle_sum + WHERE settle_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0006_touch"); return TX_EDB; @@ -69,20 +66,19 @@ int st_io_0006_touch(const char *key, long amount) long st_io_0006_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(CASE WHEN settle_flag = 'Y' THEN settle_amt ELSE 0 END), 0) INTO :h_sum - FROM st_io_0006_t - WHERE biz_date = :h_biz_date; + FROM st_settle_dtl + WHERE settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0006_total"); diff --git a/app/dbio/st_io_0007.c b/app/dbio/st_io_0007.c index eb09d4c..e29f826 100644 --- a/app/dbio/st_io_0007.c +++ b/app/dbio/st_io_0007.c @@ -96,35 +96,32 @@ int st_io_0007_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0007.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0007.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0007.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0007_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( settle_amt ) , 0 ) from st_settle_dtl where merchant_id = $1 and settle_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/st_io_0007.pgc" +#line 29 "app/dbio/st_io_0007.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0007_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +131,27 @@ int st_io_0007_touch(const char *key, long amount) -#line 45 "app/dbio/st_io_0007.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/st_io_0007.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/st_io_0007.pgc" - long h_amount ; +#line 43 "app/dbio/st_io_0007.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/st_io_0007.pgc" +#line 44 "app/dbio/st_io_0007.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0007_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from st_settle_sum where merchant_id = $1 and settle_amt < $2 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0007.pgc" - +#line 53 "app/dbio/st_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0007_touch"); @@ -173,32 +168,31 @@ long st_io_0007_total(const char *biz_date) -#line 72 "app/dbio/st_io_0007.pgc" - char h_biz_date [ 9 ] ; +#line 66 "app/dbio/st_io_0007.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0007.pgc" - long h_sum ; +#line 67 "app/dbio/st_io_0007.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0007.pgc" +#line 68 "app/dbio/st_io_0007.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0007_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct merchant_id ) from st_settle_dtl where settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0007.pgc" +#line 78 "app/dbio/st_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0007_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/st_io_0007.pgc b/app/dbio/st_io_0007.pgc index d4c0bb9..49abf1d 100644 --- a/app/dbio/st_io_0007.pgc +++ b/app/dbio/st_io_0007.pgc @@ -14,49 +14,43 @@ EXEC SQL INCLUDE sqlca; int st_io_0007_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0007_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(settle_amt), 0) + INTO :h_val + FROM st_settle_dtl + WHERE merchant_id = :h_key AND settle_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0007_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int st_io_0007_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0007_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM st_settle_sum + WHERE merchant_id = :h_key AND settle_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0007_touch"); return TX_EDB; @@ -69,24 +63,23 @@ int st_io_0007_touch(const char *key, long amount) long st_io_0007_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM st_io_0007_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(distinct merchant_id) + INTO :h_cnt + FROM st_settle_dtl + WHERE settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0007_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/st_io_0008.c b/app/dbio/st_io_0008.c index 6f908f6..0e76ec1 100644 --- a/app/dbio/st_io_0008.c +++ b/app/dbio/st_io_0008.c @@ -96,35 +96,53 @@ int st_io_0008_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0008.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0008.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0008.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0008_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare st_io_0008_fetch_cur cursor for select settle_amt from st_settle_dtl where settle_key = $1 order by settle_dt desc */ +#line 28 "app/dbio/st_io_0008.pgc" + +#line 28 "app/dbio/st_io_0008.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare st_io_0008_fetch_cur cursor for select settle_amt from st_settle_dtl where settle_key = $1 order by settle_dt desc", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 29 "app/dbio/st_io_0008.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch st_io_0008_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/st_io_0008.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0008_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 33 "app/dbio/st_io_0008.pgc" + return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0008_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0008_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 38 "app/dbio/st_io_0008.pgc" + return TX_EDB; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0008_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 41 "app/dbio/st_io_0008.pgc" + + *out_amount = h_val; return TX_OK; } @@ -134,29 +152,29 @@ int st_io_0008_touch(const char *key, long amount) -#line 45 "app/dbio/st_io_0008.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/st_io_0008.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/st_io_0008.pgc" - long h_amount ; +#line 50 "app/dbio/st_io_0008.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/st_io_0008.pgc" +#line 51 "app/dbio/st_io_0008.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0008_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_settle_dtl set settle_amt = settle_amt + $1 , settle_flag = case when settle_amt + $2 > 0 then 'Y' else 'N' end , upd_ts = now ( ) where settle_key = $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0008.pgc" - +#line 63 "app/dbio/st_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0008_touch"); @@ -173,27 +191,26 @@ long st_io_0008_total(const char *biz_date) -#line 72 "app/dbio/st_io_0008.pgc" - char h_biz_date [ 9 ] ; +#line 76 "app/dbio/st_io_0008.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0008.pgc" +#line 77 "app/dbio/st_io_0008.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0008.pgc" +#line 78 "app/dbio/st_io_0008.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0008_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( settle_amt ) , 0 ) from st_settle_dtl where settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0008.pgc" +#line 88 "app/dbio/st_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/st_io_0008.pgc b/app/dbio/st_io_0008.pgc index 16d1990..2e05b9f 100644 --- a/app/dbio/st_io_0008.pgc +++ b/app/dbio/st_io_0008.pgc @@ -14,49 +14,53 @@ EXEC SQL INCLUDE sqlca; int st_io_0008_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0008_t - WHERE key = :h_key; + EXEC SQL DECLARE st_io_0008_fetch_cur CURSOR FOR + SELECT settle_amt FROM st_settle_dtl + WHERE settle_key = :h_key ORDER BY settle_dt DESC; + EXEC SQL OPEN st_io_0008_fetch_cur; + EXEC SQL FETCH st_io_0008_fetch_cur INTO :h_val; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE st_io_0008_fetch_cur; return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0008_fetch"); + EXEC SQL CLOSE st_io_0008_fetch_cur; return TX_EDB; } - *out_amount = h_amount; + EXEC SQL CLOSE st_io_0008_fetch_cur; + *out_amount = h_val; return TX_OK; } int st_io_0008_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0008_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE st_settle_dtl + SET settle_amt = settle_amt + :h_amt, + settle_flag = CASE WHEN settle_amt + :h_amt > 0 THEN 'Y' ELSE 'N' END, + upd_ts = now() + WHERE settle_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0008_touch"); return TX_EDB; @@ -69,20 +73,19 @@ int st_io_0008_touch(const char *key, long amount) long st_io_0008_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(settle_amt), 0) INTO :h_sum - FROM st_io_0008_t - WHERE biz_date = :h_biz_date; + FROM st_settle_dtl + WHERE settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0008_total"); diff --git a/app/dbio/st_io_0009.c b/app/dbio/st_io_0009.c index 33f0b6c..f856aaf 100644 --- a/app/dbio/st_io_0009.c +++ b/app/dbio/st_io_0009.c @@ -96,26 +96,25 @@ int st_io_0009_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0009.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0009.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0009.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0009_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select settle_amt from st_settle_dtl where settle_key in ( select settle_key from st_settle_fee where merchant_id = $1 ) order by settle_amt desc limit 1", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/st_io_0009.pgc" +#line 32 "app/dbio/st_io_0009.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int st_io_0009_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0009_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int st_io_0009_touch(const char *key, long amount) -#line 45 "app/dbio/st_io_0009.pgc" - char h_key [ 16 ] ; - -#line 46 "app/dbio/st_io_0009.pgc" - long h_amount ; -/* exec sql end declare section */ #line 47 "app/dbio/st_io_0009.pgc" + char h_key [ 32 ] ; + +#line 48 "app/dbio/st_io_0009.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 49 "app/dbio/st_io_0009.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0009_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_settle_dtl set settle_amt = $1 , upd_ts = now ( ) where settle_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0009.pgc" - +#line 59 "app/dbio/st_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0009_touch"); @@ -174,31 +171,30 @@ long st_io_0009_total(const char *biz_date) #line 72 "app/dbio/st_io_0009.pgc" - char h_biz_date [ 9 ] ; + char h_dt [ 16 ] ; #line 73 "app/dbio/st_io_0009.pgc" - long h_sum ; + long h_cnt ; /* exec sql end declare section */ #line 74 "app/dbio/st_io_0009.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0009_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from st_settle_dtl where settle_dt = $1 and settle_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0009.pgc" +#line 84 "app/dbio/st_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0009_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/st_io_0009.pgc b/app/dbio/st_io_0009.pgc index 7af6331..8db46d9 100644 --- a/app/dbio/st_io_0009.pgc +++ b/app/dbio/st_io_0009.pgc @@ -14,20 +14,22 @@ EXEC SQL INCLUDE sqlca; int st_io_0009_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0009_t - WHERE key = :h_key; + EXEC SQL SELECT settle_amt + INTO :h_val + FROM st_settle_dtl + WHERE settle_key IN ( + SELECT settle_key FROM st_settle_fee WHERE merchant_id = :h_key) + ORDER BY settle_amt DESC + LIMIT 1; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +37,26 @@ int st_io_0009_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0009_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int st_io_0009_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0009_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE st_settle_dtl + SET settle_amt = :h_amt, upd_ts = now() + WHERE settle_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0009_touch"); return TX_EDB; @@ -69,24 +69,23 @@ int st_io_0009_touch(const char *key, long amount) long st_io_0009_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM st_io_0009_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM st_settle_dtl + WHERE settle_dt = :h_dt AND settle_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0009_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/st_io_0010.c b/app/dbio/st_io_0010.c index c91d065..e534437 100644 --- a/app/dbio/st_io_0010.c +++ b/app/dbio/st_io_0010.c @@ -96,26 +96,25 @@ int st_io_0010_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0010.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0010.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0010.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0010_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select settle_amt from st_settle_dtl where settle_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/st_io_0010.pgc" +#line 29 "app/dbio/st_io_0010.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int st_io_0010_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0010_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int st_io_0010_touch(const char *key, long amount) -#line 45 "app/dbio/st_io_0010.pgc" - char h_key [ 16 ] ; +#line 44 "app/dbio/st_io_0010.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/st_io_0010.pgc" - long h_amount ; +#line 45 "app/dbio/st_io_0010.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/st_io_0010.pgc" +#line 46 "app/dbio/st_io_0010.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0010_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_settle_dtl set settle_amt = $1 , settle_flag = 'Y' , upd_ts = now ( ) where settle_key = $2 and settle_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0010.pgc" - +#line 56 "app/dbio/st_io_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0010_touch"); @@ -172,33 +169,38 @@ long st_io_0010_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/st_io_0010.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/st_io_0010.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0010.pgc" - long h_sum ; +#line 70 "app/dbio/st_io_0010.pgc" + long h_max ; + +#line 71 "app/dbio/st_io_0010.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0010.pgc" +#line 72 "app/dbio/st_io_0010.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0010_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( settle_amt ) from st_settle_dtl where settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0010.pgc" + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 82 "app/dbio/st_io_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0010_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/st_io_0010.pgc b/app/dbio/st_io_0010.pgc index 0f2b80b..7f13470 100644 --- a/app/dbio/st_io_0010.pgc +++ b/app/dbio/st_io_0010.pgc @@ -14,20 +14,19 @@ EXEC SQL INCLUDE sqlca; int st_io_0010_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0010_t - WHERE key = :h_key; + EXEC SQL SELECT settle_amt + INTO :h_val + FROM st_settle_dtl + WHERE settle_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +34,26 @@ int st_io_0010_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0010_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int st_io_0010_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0010_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE st_settle_dtl + SET settle_amt = :h_amt, settle_flag = 'Y', upd_ts = now() + WHERE settle_key = :h_key AND settle_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0010_touch"); return TX_EDB; @@ -69,24 +66,26 @@ int st_io_0010_touch(const char *key, long amount) long st_io_0010_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM st_io_0010_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(settle_amt) + INTO :h_max:h_ind + FROM st_settle_dtl + WHERE settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0010_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/st_io_0011.c b/app/dbio/st_io_0011.c index 929621a..799d0f6 100644 --- a/app/dbio/st_io_0011.c +++ b/app/dbio/st_io_0011.c @@ -94,27 +94,30 @@ int st_io_0011_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/st_io_0011.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0011.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/st_io_0011.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/st_io_0011.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0011_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select fee_amt from st_settle_dtl where settle_key = $1 and settle_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/st_io_0011.pgc" @@ -124,7 +127,7 @@ int st_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } @@ -135,28 +138,28 @@ int st_io_0011_touch(const char *key, long amount) #line 45 "app/dbio/st_io_0011.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/st_io_0011.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/st_io_0011.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0011_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_settle_dtl set fee_amt = $1 where settle_key = $2 and settle_amt >= $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0011.pgc" - +#line 57 "app/dbio/st_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0011_touch"); @@ -173,27 +176,26 @@ long st_io_0011_total(const char *biz_date) -#line 72 "app/dbio/st_io_0011.pgc" - char h_biz_date [ 9 ] ; +#line 70 "app/dbio/st_io_0011.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0011.pgc" +#line 71 "app/dbio/st_io_0011.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0011.pgc" +#line 72 "app/dbio/st_io_0011.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0011_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . settle_amt ) , 0 ) from st_settle_dtl a join st_settle_fee b on a . settle_key = b . settle_key where a . settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0011.pgc" +#line 83 "app/dbio/st_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/st_io_0011.pgc b/app/dbio/st_io_0011.pgc index 6e71e03..ded0351 100644 --- a/app/dbio/st_io_0011.pgc +++ b/app/dbio/st_io_0011.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int st_io_0011_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0011_t - WHERE key = :h_key; + EXEC SQL SELECT fee_amt + INTO :h_val:h_ind + FROM st_settle_dtl + WHERE settle_key = :h_key AND settle_flag = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +35,26 @@ int st_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } int st_io_0011_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0011_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE st_settle_dtl + SET fee_amt = :h_amt + WHERE settle_key = :h_key AND settle_amt >= :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0011_touch"); return TX_EDB; @@ -69,20 +67,20 @@ int st_io_0011_touch(const char *key, long amount) long st_io_0011_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.settle_amt), 0) INTO :h_sum - FROM st_io_0011_t - WHERE biz_date = :h_biz_date; + FROM st_settle_dtl a + JOIN st_settle_fee b ON a.settle_key = b.settle_key + WHERE a.settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0011_total"); diff --git a/app/dbio/st_io_0012.c b/app/dbio/st_io_0012.c index 9a7713c..a0d9d25 100644 --- a/app/dbio/st_io_0012.c +++ b/app/dbio/st_io_0012.c @@ -96,24 +96,23 @@ int st_io_0012_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0012.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0012.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0012.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0012_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a . settle_amt from st_settle_dtl a join st_settle_fee b on a . settle_key = b . settle_key where a . settle_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/st_io_0012.pgc" @@ -124,7 +123,7 @@ int st_io_0012_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0012_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -135,35 +134,31 @@ int st_io_0012_touch(const char *key, long amount) #line 45 "app/dbio/st_io_0012.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/st_io_0012.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/st_io_0012.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0012_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into st_settle_sum ( settle_key , settle_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0012.pgc" - +#line 56 "app/dbio/st_io_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0012_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,32 +168,52 @@ long st_io_0012_total(const char *biz_date) -#line 72 "app/dbio/st_io_0012.pgc" - char h_biz_date [ 9 ] ; +#line 67 "app/dbio/st_io_0012.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0012.pgc" - long h_sum ; +#line 68 "app/dbio/st_io_0012.pgc" + long h_grp ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0012.pgc" +#line 69 "app/dbio/st_io_0012.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0012_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_dt ), __LINE__);\ + /* declare st_io_0012_total_cur cursor for select coalesce ( sum ( settle_amt ) , 0 ) from st_settle_dtl where settle_dt = $1 group by merchant_id */ +#line 80 "app/dbio/st_io_0012.pgc" + +#line 80 "app/dbio/st_io_0012.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare st_io_0012_total_cur cursor for select coalesce ( sum ( settle_amt ) , 0 ) from st_settle_dtl where settle_dt = $1 group by merchant_id", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 81 "app/dbio/st_io_0012.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch st_io_0012_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0012.pgc" +#line 83 "app/dbio/st_io_0012.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("st_io_0012_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0012_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 88 "app/dbio/st_io_0012.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("st_io_0012_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0012_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 93 "app/dbio/st_io_0012.pgc" + + return acc; } diff --git a/app/dbio/st_io_0012.pgc b/app/dbio/st_io_0012.pgc index 2d2122f..43c94d7 100644 --- a/app/dbio/st_io_0012.pgc +++ b/app/dbio/st_io_0012.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int st_io_0012_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0012_t - WHERE key = :h_key; + EXEC SQL SELECT a.settle_amt + INTO :h_val + FROM st_settle_dtl a + JOIN st_settle_fee b ON a.settle_key = b.settle_key + WHERE a.settle_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,58 +35,61 @@ int st_io_0012_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0012_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int st_io_0012_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0012_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO st_settle_sum (settle_key, settle_amt, upd_ts) + VALUES (:h_key, :h_amt, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0012_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long st_io_0012_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM st_io_0012_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("st_io_0012_total"); - return -1; + EXEC SQL DECLARE st_io_0012_total_cur CURSOR FOR + SELECT coalesce(sum(settle_amt), 0) FROM st_settle_dtl + WHERE settle_dt = :h_dt GROUP BY merchant_id; + EXEC SQL OPEN st_io_0012_total_cur; + for (;;) { + EXEC SQL FETCH st_io_0012_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("st_io_0012_total"); + EXEC SQL CLOSE st_io_0012_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE st_io_0012_total_cur; + return acc; } diff --git a/app/dbio/st_io_0013.c b/app/dbio/st_io_0013.c index aa5ead1..4d1104b 100644 --- a/app/dbio/st_io_0013.c +++ b/app/dbio/st_io_0013.c @@ -96,35 +96,32 @@ int st_io_0013_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0013.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0013.pgc" - long h_amount ; + long h_flag ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0013.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0013_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when exists ( select 1 from st_settle_dtl where settle_key = $1 and settle_flag = 'N' ) then 1 else 0 end", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/st_io_0013.pgc" +#line 29 "app/dbio/st_io_0013.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0013_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } @@ -134,36 +131,32 @@ int st_io_0013_touch(const char *key, long amount) -#line 45 "app/dbio/st_io_0013.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/st_io_0013.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/st_io_0013.pgc" - long h_amount ; +#line 43 "app/dbio/st_io_0013.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/st_io_0013.pgc" +#line 44 "app/dbio/st_io_0013.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0013_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into st_settle_dtl ( settle_key , settle_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( settle_key ) do update set settle_amt = excluded . settle_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0013.pgc" - +#line 55 "app/dbio/st_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,27 +166,26 @@ long st_io_0013_total(const char *biz_date) -#line 72 "app/dbio/st_io_0013.pgc" - char h_biz_date [ 9 ] ; +#line 66 "app/dbio/st_io_0013.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0013.pgc" +#line 67 "app/dbio/st_io_0013.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0013.pgc" +#line 68 "app/dbio/st_io_0013.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0013_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when settle_flag = 'Y' then settle_amt else 0 end ) , 0 ) from st_settle_dtl where settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0013.pgc" +#line 78 "app/dbio/st_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/st_io_0013.pgc b/app/dbio/st_io_0013.pgc index b833427..353dfad 100644 --- a/app/dbio/st_io_0013.pgc +++ b/app/dbio/st_io_0013.pgc @@ -14,75 +14,68 @@ EXEC SQL INCLUDE sqlca; int st_io_0013_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_flag; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0013_t - WHERE key = :h_key; + EXEC SQL SELECT CASE WHEN EXISTS ( + SELECT 1 FROM st_settle_dtl + WHERE settle_key = :h_key AND settle_flag = 'N') THEN 1 ELSE 0 END + INTO :h_flag; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0013_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } int st_io_0013_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0013_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO st_settle_dtl (settle_key, settle_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (settle_key) + DO UPDATE SET settle_amt = excluded.settle_amt, upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long st_io_0013_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(CASE WHEN settle_flag = 'Y' THEN settle_amt ELSE 0 END), 0) INTO :h_sum - FROM st_io_0013_t - WHERE biz_date = :h_biz_date; + FROM st_settle_dtl + WHERE settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0013_total"); diff --git a/app/dbio/st_io_0014.c b/app/dbio/st_io_0014.c index 8adf43a..fadc5c7 100644 --- a/app/dbio/st_io_0014.c +++ b/app/dbio/st_io_0014.c @@ -94,37 +94,40 @@ int st_io_0014_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/st_io_0014.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0014.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/st_io_0014.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/st_io_0014.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0014_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( settle_amt ) from st_settle_dtl where merchant_id = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/st_io_0014.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0014_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,24 @@ int st_io_0014_touch(const char *key, long amount) #line 45 "app/dbio/st_io_0014.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/st_io_0014.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/st_io_0014.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0014_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from st_settle_sum where settle_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0014.pgc" - +#line 56 "app/dbio/st_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0014_touch"); @@ -173,32 +172,31 @@ long st_io_0014_total(const char *biz_date) -#line 72 "app/dbio/st_io_0014.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/st_io_0014.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0014.pgc" - long h_sum ; +#line 70 "app/dbio/st_io_0014.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0014.pgc" +#line 71 "app/dbio/st_io_0014.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0014_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct merchant_id ) from st_settle_dtl where settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0014.pgc" +#line 81 "app/dbio/st_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0014_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/st_io_0014.pgc b/app/dbio/st_io_0014.pgc index 8afac14..6d1a932 100644 --- a/app/dbio/st_io_0014.pgc +++ b/app/dbio/st_io_0014.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int st_io_0014_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0014_t - WHERE key = :h_key; + EXEC SQL SELECT max(settle_amt) + INTO :h_val:h_ind + FROM st_settle_dtl + WHERE merchant_id = :h_key; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0014_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int st_io_0014_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0014_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM st_settle_sum + WHERE settle_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0014_touch"); return TX_EDB; @@ -69,24 +66,23 @@ int st_io_0014_touch(const char *key, long amount) long st_io_0014_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM st_io_0014_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(distinct merchant_id) + INTO :h_cnt + FROM st_settle_dtl + WHERE settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0014_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/st_io_0015.c b/app/dbio/st_io_0015.c index e1900c1..e932c6f 100644 --- a/app/dbio/st_io_0015.c +++ b/app/dbio/st_io_0015.c @@ -94,37 +94,40 @@ int st_io_0015_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/st_io_0015.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0015.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/st_io_0015.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/st_io_0015.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0015_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( settle_amt ) from st_settle_dtl where merchant_id = $1 and settle_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/st_io_0015.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0015_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,26 @@ int st_io_0015_touch(const char *key, long amount) #line 45 "app/dbio/st_io_0015.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/st_io_0015.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/st_io_0015.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0015_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from st_settle_sum where merchant_id = $1 and settle_amt < $2 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0015.pgc" - +#line 56 "app/dbio/st_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0015_touch"); @@ -173,27 +174,26 @@ long st_io_0015_total(const char *biz_date) -#line 72 "app/dbio/st_io_0015.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/st_io_0015.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0015.pgc" +#line 70 "app/dbio/st_io_0015.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0015.pgc" +#line 71 "app/dbio/st_io_0015.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0015_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( settle_amt ) , 0 ) from st_settle_dtl where settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0015.pgc" +#line 81 "app/dbio/st_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/st_io_0015.pgc b/app/dbio/st_io_0015.pgc index 78c3f59..fb3fd31 100644 --- a/app/dbio/st_io_0015.pgc +++ b/app/dbio/st_io_0015.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int st_io_0015_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0015_t - WHERE key = :h_key; + EXEC SQL SELECT min(settle_amt) + INTO :h_val:h_ind + FROM st_settle_dtl + WHERE merchant_id = :h_key AND settle_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0015_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int st_io_0015_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0015_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM st_settle_sum + WHERE merchant_id = :h_key AND settle_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0015_touch"); return TX_EDB; @@ -69,20 +66,19 @@ int st_io_0015_touch(const char *key, long amount) long st_io_0015_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(settle_amt), 0) INTO :h_sum - FROM st_io_0015_t - WHERE biz_date = :h_biz_date; + FROM st_settle_dtl + WHERE settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0015_total"); diff --git a/app/dbio/st_io_0016.c b/app/dbio/st_io_0016.c index 9016916..c6d7458 100644 --- a/app/dbio/st_io_0016.c +++ b/app/dbio/st_io_0016.c @@ -96,35 +96,32 @@ int st_io_0016_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0016.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0016.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0016.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0016_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( settle_amt ) , 0 ) from st_settle_dtl where merchant_id = $1 and settle_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/st_io_0016.pgc" +#line 29 "app/dbio/st_io_0016.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0016_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +131,29 @@ int st_io_0016_touch(const char *key, long amount) -#line 45 "app/dbio/st_io_0016.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/st_io_0016.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/st_io_0016.pgc" - long h_amount ; +#line 43 "app/dbio/st_io_0016.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/st_io_0016.pgc" +#line 44 "app/dbio/st_io_0016.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0016_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_settle_dtl set settle_amt = settle_amt + $1 , settle_flag = case when settle_amt + $2 > 0 then 'Y' else 'N' end , upd_ts = now ( ) where settle_key = $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0016.pgc" - +#line 56 "app/dbio/st_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0016_touch"); @@ -173,32 +170,31 @@ long st_io_0016_total(const char *biz_date) -#line 72 "app/dbio/st_io_0016.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/st_io_0016.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0016.pgc" - long h_sum ; +#line 70 "app/dbio/st_io_0016.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0016.pgc" +#line 71 "app/dbio/st_io_0016.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0016_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from st_settle_dtl where settle_dt = $1 and settle_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0016.pgc" +#line 81 "app/dbio/st_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0016_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/st_io_0016.pgc b/app/dbio/st_io_0016.pgc index 9f87959..b97d821 100644 --- a/app/dbio/st_io_0016.pgc +++ b/app/dbio/st_io_0016.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int st_io_0016_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0016_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(settle_amt), 0) + INTO :h_val + FROM st_settle_dtl + WHERE merchant_id = :h_key AND settle_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0016_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int st_io_0016_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0016_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE st_settle_dtl + SET settle_amt = settle_amt + :h_amt, + settle_flag = CASE WHEN settle_amt + :h_amt > 0 THEN 'Y' ELSE 'N' END, + upd_ts = now() + WHERE settle_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0016_touch"); return TX_EDB; @@ -69,24 +66,23 @@ int st_io_0016_touch(const char *key, long amount) long st_io_0016_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM st_io_0016_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM st_settle_dtl + WHERE settle_dt = :h_dt AND settle_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0016_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/st_io_0017.c b/app/dbio/st_io_0017.c index 3eaaec9..15911b1 100644 --- a/app/dbio/st_io_0017.c +++ b/app/dbio/st_io_0017.c @@ -96,35 +96,53 @@ int st_io_0017_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0017.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0017.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0017.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0017_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare st_io_0017_fetch_cur cursor for select settle_amt from st_settle_dtl where settle_key = $1 order by settle_dt desc */ +#line 28 "app/dbio/st_io_0017.pgc" + +#line 28 "app/dbio/st_io_0017.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare st_io_0017_fetch_cur cursor for select settle_amt from st_settle_dtl where settle_key = $1 order by settle_dt desc", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 29 "app/dbio/st_io_0017.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch st_io_0017_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/st_io_0017.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0017_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 33 "app/dbio/st_io_0017.pgc" + return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0017_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0017_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 38 "app/dbio/st_io_0017.pgc" + return TX_EDB; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0017_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 41 "app/dbio/st_io_0017.pgc" + + *out_amount = h_val; return TX_OK; } @@ -134,29 +152,27 @@ int st_io_0017_touch(const char *key, long amount) -#line 45 "app/dbio/st_io_0017.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/st_io_0017.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/st_io_0017.pgc" - long h_amount ; +#line 50 "app/dbio/st_io_0017.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/st_io_0017.pgc" +#line 51 "app/dbio/st_io_0017.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0017_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_settle_dtl set settle_amt = $1 , upd_ts = now ( ) where settle_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0017.pgc" - +#line 61 "app/dbio/st_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0017_touch"); @@ -172,33 +188,38 @@ long st_io_0017_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/st_io_0017.pgc" - char h_biz_date [ 9 ] ; - -#line 73 "app/dbio/st_io_0017.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/st_io_0017.pgc" + char h_dt [ 16 ] ; + +#line 75 "app/dbio/st_io_0017.pgc" + long h_max ; + +#line 76 "app/dbio/st_io_0017.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 77 "app/dbio/st_io_0017.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0017_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( settle_amt ) from st_settle_dtl where settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0017.pgc" + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 87 "app/dbio/st_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0017_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/st_io_0017.pgc b/app/dbio/st_io_0017.pgc index 1cfbeac..e51682d 100644 --- a/app/dbio/st_io_0017.pgc +++ b/app/dbio/st_io_0017.pgc @@ -14,49 +14,51 @@ EXEC SQL INCLUDE sqlca; int st_io_0017_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0017_t - WHERE key = :h_key; + EXEC SQL DECLARE st_io_0017_fetch_cur CURSOR FOR + SELECT settle_amt FROM st_settle_dtl + WHERE settle_key = :h_key ORDER BY settle_dt DESC; + EXEC SQL OPEN st_io_0017_fetch_cur; + EXEC SQL FETCH st_io_0017_fetch_cur INTO :h_val; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE st_io_0017_fetch_cur; return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0017_fetch"); + EXEC SQL CLOSE st_io_0017_fetch_cur; return TX_EDB; } - *out_amount = h_amount; + EXEC SQL CLOSE st_io_0017_fetch_cur; + *out_amount = h_val; return TX_OK; } int st_io_0017_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0017_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE st_settle_dtl + SET settle_amt = :h_amt, upd_ts = now() + WHERE settle_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0017_touch"); return TX_EDB; @@ -69,24 +71,26 @@ int st_io_0017_touch(const char *key, long amount) long st_io_0017_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM st_io_0017_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(settle_amt) + INTO :h_max:h_ind + FROM st_settle_dtl + WHERE settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0017_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/st_io_0018.c b/app/dbio/st_io_0018.c index f3fbaef..24de7ff 100644 --- a/app/dbio/st_io_0018.c +++ b/app/dbio/st_io_0018.c @@ -96,26 +96,25 @@ int st_io_0018_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0018.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0018.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0018.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0018_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select settle_amt from st_settle_dtl where settle_key in ( select settle_key from st_settle_fee where merchant_id = $1 ) order by settle_amt desc limit 1", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/st_io_0018.pgc" +#line 32 "app/dbio/st_io_0018.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int st_io_0018_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0018_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int st_io_0018_touch(const char *key, long amount) -#line 45 "app/dbio/st_io_0018.pgc" - char h_key [ 16 ] ; - -#line 46 "app/dbio/st_io_0018.pgc" - long h_amount ; -/* exec sql end declare section */ #line 47 "app/dbio/st_io_0018.pgc" + char h_key [ 32 ] ; + +#line 48 "app/dbio/st_io_0018.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 49 "app/dbio/st_io_0018.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0018_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_settle_dtl set settle_amt = $1 , settle_flag = 'Y' , upd_ts = now ( ) where settle_key = $2 and settle_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0018.pgc" - +#line 59 "app/dbio/st_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0018_touch"); @@ -174,7 +171,7 @@ long st_io_0018_total(const char *biz_date) #line 72 "app/dbio/st_io_0018.pgc" - char h_biz_date [ 9 ] ; + char h_dt [ 16 ] ; #line 73 "app/dbio/st_io_0018.pgc" long h_sum ; @@ -184,12 +181,11 @@ long st_io_0018_total(const char *biz_date) if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0018_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . settle_amt ) , 0 ) from st_settle_dtl a join st_settle_fee b on a . settle_key = b . settle_key where a . settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} diff --git a/app/dbio/st_io_0018.pgc b/app/dbio/st_io_0018.pgc index 67bcfe4..fe42b23 100644 --- a/app/dbio/st_io_0018.pgc +++ b/app/dbio/st_io_0018.pgc @@ -14,20 +14,22 @@ EXEC SQL INCLUDE sqlca; int st_io_0018_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0018_t - WHERE key = :h_key; + EXEC SQL SELECT settle_amt + INTO :h_val + FROM st_settle_dtl + WHERE settle_key IN ( + SELECT settle_key FROM st_settle_fee WHERE merchant_id = :h_key) + ORDER BY settle_amt DESC + LIMIT 1; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +37,26 @@ int st_io_0018_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0018_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int st_io_0018_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0018_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE st_settle_dtl + SET settle_amt = :h_amt, settle_flag = 'Y', upd_ts = now() + WHERE settle_key = :h_key AND settle_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0018_touch"); return TX_EDB; @@ -69,20 +69,20 @@ int st_io_0018_touch(const char *key, long amount) long st_io_0018_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.settle_amt), 0) INTO :h_sum - FROM st_io_0018_t - WHERE biz_date = :h_biz_date; + FROM st_settle_dtl a + JOIN st_settle_fee b ON a.settle_key = b.settle_key + WHERE a.settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0018_total"); diff --git a/app/dbio/st_io_0019.c b/app/dbio/st_io_0019.c index b233995..52debf8 100644 --- a/app/dbio/st_io_0019.c +++ b/app/dbio/st_io_0019.c @@ -96,26 +96,25 @@ int st_io_0019_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0019.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0019.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0019.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0019_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select settle_amt from st_settle_dtl where settle_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/st_io_0019.pgc" +#line 29 "app/dbio/st_io_0019.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int st_io_0019_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0019_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,29 @@ int st_io_0019_touch(const char *key, long amount) -#line 45 "app/dbio/st_io_0019.pgc" - char h_key [ 16 ] ; +#line 44 "app/dbio/st_io_0019.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/st_io_0019.pgc" - long h_amount ; +#line 45 "app/dbio/st_io_0019.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/st_io_0019.pgc" +#line 46 "app/dbio/st_io_0019.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0019_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_settle_dtl set fee_amt = $1 where settle_key = $2 and settle_amt >= $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0019.pgc" - +#line 56 "app/dbio/st_io_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0019_touch"); @@ -173,32 +172,52 @@ long st_io_0019_total(const char *biz_date) -#line 72 "app/dbio/st_io_0019.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/st_io_0019.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0019.pgc" - long h_sum ; +#line 70 "app/dbio/st_io_0019.pgc" + long h_grp ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0019.pgc" +#line 71 "app/dbio/st_io_0019.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0019_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_dt ), __LINE__);\ + /* declare st_io_0019_total_cur cursor for select coalesce ( sum ( settle_amt ) , 0 ) from st_settle_dtl where settle_dt = $1 group by merchant_id */ +#line 82 "app/dbio/st_io_0019.pgc" + +#line 82 "app/dbio/st_io_0019.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare st_io_0019_total_cur cursor for select coalesce ( sum ( settle_amt ) , 0 ) from st_settle_dtl where settle_dt = $1 group by merchant_id", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 83 "app/dbio/st_io_0019.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch st_io_0019_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 85 "app/dbio/st_io_0019.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("st_io_0019_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0019_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 90 "app/dbio/st_io_0019.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("st_io_0019_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0019_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 95 "app/dbio/st_io_0019.pgc" + + return acc; } diff --git a/app/dbio/st_io_0019.pgc b/app/dbio/st_io_0019.pgc index f85821b..eafc15f 100644 --- a/app/dbio/st_io_0019.pgc +++ b/app/dbio/st_io_0019.pgc @@ -14,20 +14,19 @@ EXEC SQL INCLUDE sqlca; int st_io_0019_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0019_t - WHERE key = :h_key; + EXEC SQL SELECT settle_amt + INTO :h_val + FROM st_settle_dtl + WHERE settle_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +34,26 @@ int st_io_0019_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0019_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int st_io_0019_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0019_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE st_settle_dtl + SET fee_amt = :h_amt + WHERE settle_key = :h_key AND settle_amt >= :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0019_touch"); return TX_EDB; @@ -69,24 +66,32 @@ int st_io_0019_touch(const char *key, long amount) long st_io_0019_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM st_io_0019_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("st_io_0019_total"); - return -1; + EXEC SQL DECLARE st_io_0019_total_cur CURSOR FOR + SELECT coalesce(sum(settle_amt), 0) FROM st_settle_dtl + WHERE settle_dt = :h_dt GROUP BY merchant_id; + EXEC SQL OPEN st_io_0019_total_cur; + for (;;) { + EXEC SQL FETCH st_io_0019_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("st_io_0019_total"); + EXEC SQL CLOSE st_io_0019_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE st_io_0019_total_cur; + return acc; } diff --git a/app/dbio/st_io_0020.c b/app/dbio/st_io_0020.c index eb10a27..645c289 100644 --- a/app/dbio/st_io_0020.c +++ b/app/dbio/st_io_0020.c @@ -94,27 +94,30 @@ int st_io_0020_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/st_io_0020.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0020.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/st_io_0020.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/st_io_0020.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0020_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select fee_amt from st_settle_dtl where settle_key = $1 and settle_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/st_io_0020.pgc" @@ -124,7 +127,7 @@ int st_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } @@ -135,35 +138,31 @@ int st_io_0020_touch(const char *key, long amount) #line 45 "app/dbio/st_io_0020.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/st_io_0020.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/st_io_0020.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0020_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into st_settle_sum ( settle_key , settle_amt , upd_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0020.pgc" - +#line 56 "app/dbio/st_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,27 +172,26 @@ long st_io_0020_total(const char *biz_date) -#line 72 "app/dbio/st_io_0020.pgc" - char h_biz_date [ 9 ] ; +#line 67 "app/dbio/st_io_0020.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0020.pgc" +#line 68 "app/dbio/st_io_0020.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0020.pgc" +#line 69 "app/dbio/st_io_0020.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0020_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when settle_flag = 'Y' then settle_amt else 0 end ) , 0 ) from st_settle_dtl where settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0020.pgc" +#line 79 "app/dbio/st_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/st_io_0020.pgc b/app/dbio/st_io_0020.pgc index eb2d075..5076c9a 100644 --- a/app/dbio/st_io_0020.pgc +++ b/app/dbio/st_io_0020.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int st_io_0020_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0020_t - WHERE key = :h_key; + EXEC SQL SELECT fee_amt + INTO :h_val:h_ind + FROM st_settle_dtl + WHERE settle_key = :h_key AND settle_flag = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,54 +35,48 @@ int st_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } int st_io_0020_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0020_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO st_settle_sum (settle_key, settle_amt, upd_ts) + VALUES (:h_key, :h_amt, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long st_io_0020_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(CASE WHEN settle_flag = 'Y' THEN settle_amt ELSE 0 END), 0) INTO :h_sum - FROM st_io_0020_t - WHERE biz_date = :h_biz_date; + FROM st_settle_dtl + WHERE settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0020_total"); diff --git a/app/dbio/st_io_0021.c b/app/dbio/st_io_0021.c index 348486a..e9cde01 100644 --- a/app/dbio/st_io_0021.c +++ b/app/dbio/st_io_0021.c @@ -96,24 +96,23 @@ int st_io_0021_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0021.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0021.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0021.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0021_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a . settle_amt from st_settle_dtl a join st_settle_fee b on a . settle_key = b . settle_key where a . settle_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/st_io_0021.pgc" @@ -124,7 +123,7 @@ int st_io_0021_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0021_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -135,35 +134,31 @@ int st_io_0021_touch(const char *key, long amount) #line 45 "app/dbio/st_io_0021.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/st_io_0021.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/st_io_0021.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0021_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into st_settle_dtl ( settle_key , settle_amt , upd_ts ) values ( $1 , $2 , now ( ) ) on conflict ( settle_key ) do update set settle_amt = excluded . settle_amt , upd_ts = now ( )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/st_io_0021.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0021_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,32 +168,31 @@ long st_io_0021_total(const char *biz_date) -#line 72 "app/dbio/st_io_0021.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/st_io_0021.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0021.pgc" - long h_sum ; +#line 70 "app/dbio/st_io_0021.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0021.pgc" +#line 71 "app/dbio/st_io_0021.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0021_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct merchant_id ) from st_settle_dtl where settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0021.pgc" +#line 81 "app/dbio/st_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0021_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/st_io_0021.pgc b/app/dbio/st_io_0021.pgc index c0d7b7f..93bcf74 100644 --- a/app/dbio/st_io_0021.pgc +++ b/app/dbio/st_io_0021.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int st_io_0021_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0021_t - WHERE key = :h_key; + EXEC SQL SELECT a.settle_amt + INTO :h_val + FROM st_settle_dtl a + JOIN st_settle_fee b ON a.settle_key = b.settle_key + WHERE a.settle_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,58 +35,54 @@ int st_io_0021_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("st_io_0021_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int st_io_0021_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0021_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO st_settle_dtl (settle_key, settle_amt, upd_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (settle_key) + DO UPDATE SET settle_amt = excluded.settle_amt, upd_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0021_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long st_io_0021_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM st_io_0021_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(distinct merchant_id) + INTO :h_cnt + FROM st_settle_dtl + WHERE settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0021_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/st_io_0022.c b/app/dbio/st_io_0022.c index e1eae18..b35bcb4 100644 --- a/app/dbio/st_io_0022.c +++ b/app/dbio/st_io_0022.c @@ -96,35 +96,32 @@ int st_io_0022_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0022.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0022.pgc" - long h_amount ; + long h_flag ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0022.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0022_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when exists ( select 1 from st_settle_dtl where settle_key = $1 and settle_flag = 'N' ) then 1 else 0 end", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/st_io_0022.pgc" +#line 29 "app/dbio/st_io_0022.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0022_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } @@ -134,29 +131,25 @@ int st_io_0022_touch(const char *key, long amount) -#line 45 "app/dbio/st_io_0022.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/st_io_0022.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/st_io_0022.pgc" - long h_amount ; +#line 43 "app/dbio/st_io_0022.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/st_io_0022.pgc" +#line 44 "app/dbio/st_io_0022.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0022_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from st_settle_sum where settle_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0022.pgc" - +#line 53 "app/dbio/st_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0022_touch"); @@ -173,27 +166,26 @@ long st_io_0022_total(const char *biz_date) -#line 72 "app/dbio/st_io_0022.pgc" - char h_biz_date [ 9 ] ; +#line 66 "app/dbio/st_io_0022.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0022.pgc" +#line 67 "app/dbio/st_io_0022.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0022.pgc" +#line 68 "app/dbio/st_io_0022.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0022_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( settle_amt ) , 0 ) from st_settle_dtl where settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0022.pgc" +#line 78 "app/dbio/st_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/st_io_0022.pgc b/app/dbio/st_io_0022.pgc index 7b64d59..07d86e9 100644 --- a/app/dbio/st_io_0022.pgc +++ b/app/dbio/st_io_0022.pgc @@ -14,49 +14,43 @@ EXEC SQL INCLUDE sqlca; int st_io_0022_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_flag; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0022_t - WHERE key = :h_key; + EXEC SQL SELECT CASE WHEN EXISTS ( + SELECT 1 FROM st_settle_dtl + WHERE settle_key = :h_key AND settle_flag = 'N') THEN 1 ELSE 0 END + INTO :h_flag; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0022_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } int st_io_0022_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0022_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM st_settle_sum + WHERE settle_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0022_touch"); return TX_EDB; @@ -69,20 +63,19 @@ int st_io_0022_touch(const char *key, long amount) long st_io_0022_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(settle_amt), 0) INTO :h_sum - FROM st_io_0022_t - WHERE biz_date = :h_biz_date; + FROM st_settle_dtl + WHERE settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0022_total"); diff --git a/app/dbio/st_io_0023.c b/app/dbio/st_io_0023.c index af61409..db71517 100644 --- a/app/dbio/st_io_0023.c +++ b/app/dbio/st_io_0023.c @@ -94,37 +94,40 @@ int st_io_0023_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/st_io_0023.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0023.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/st_io_0023.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/st_io_0023.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0023_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( settle_amt ) from st_settle_dtl where merchant_id = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/st_io_0023.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0023_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,26 @@ int st_io_0023_touch(const char *key, long amount) #line 45 "app/dbio/st_io_0023.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/st_io_0023.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/st_io_0023.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0023_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from st_settle_sum where merchant_id = $1 and settle_amt < $2 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0023.pgc" - +#line 56 "app/dbio/st_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0023_touch"); @@ -173,32 +174,31 @@ long st_io_0023_total(const char *biz_date) -#line 72 "app/dbio/st_io_0023.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/st_io_0023.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0023.pgc" - long h_sum ; +#line 70 "app/dbio/st_io_0023.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0023.pgc" +#line 71 "app/dbio/st_io_0023.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0023_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from st_settle_dtl where settle_dt = $1 and settle_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0023.pgc" +#line 81 "app/dbio/st_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0023_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/st_io_0023.pgc b/app/dbio/st_io_0023.pgc index 468d572..6572de3 100644 --- a/app/dbio/st_io_0023.pgc +++ b/app/dbio/st_io_0023.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int st_io_0023_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0023_t - WHERE key = :h_key; + EXEC SQL SELECT max(settle_amt) + INTO :h_val:h_ind + FROM st_settle_dtl + WHERE merchant_id = :h_key; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0023_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int st_io_0023_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0023_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM st_settle_sum + WHERE merchant_id = :h_key AND settle_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0023_touch"); return TX_EDB; @@ -69,24 +66,23 @@ int st_io_0023_touch(const char *key, long amount) long st_io_0023_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM st_io_0023_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM st_settle_dtl + WHERE settle_dt = :h_dt AND settle_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0023_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/st_io_0024.c b/app/dbio/st_io_0024.c index 6f94a9e..657779a 100644 --- a/app/dbio/st_io_0024.c +++ b/app/dbio/st_io_0024.c @@ -94,37 +94,40 @@ int st_io_0024_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/st_io_0024.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0024.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/st_io_0024.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/st_io_0024.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0024_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( settle_amt ) from st_settle_dtl where merchant_id = $1 and settle_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/st_io_0024.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0024_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,28 @@ int st_io_0024_touch(const char *key, long amount) #line 45 "app/dbio/st_io_0024.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/st_io_0024.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/st_io_0024.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0024_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_settle_dtl set settle_amt = settle_amt + $1 , settle_flag = case when settle_amt + $2 > 0 then 'Y' else 'N' end , upd_ts = now ( ) where settle_key = $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0024.pgc" - +#line 59 "app/dbio/st_io_0024.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0024_touch"); @@ -172,27 +175,30 @@ long st_io_0024_total(const char *biz_date) /* exec sql begin declare section */ + #line 72 "app/dbio/st_io_0024.pgc" - char h_biz_date [ 9 ] ; + char h_dt [ 16 ] ; #line 73 "app/dbio/st_io_0024.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_max ; + #line 74 "app/dbio/st_io_0024.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 75 "app/dbio/st_io_0024.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0024_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( settle_amt ) from st_settle_dtl where settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 85 "app/dbio/st_io_0024.pgc" @@ -200,5 +206,7 @@ long st_io_0024_total(const char *biz_date) TX_DBIO_LOG_ERR("st_io_0024_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/st_io_0024.pgc b/app/dbio/st_io_0024.pgc index c1f57b9..b2a213e 100644 --- a/app/dbio/st_io_0024.pgc +++ b/app/dbio/st_io_0024.pgc @@ -14,49 +14,49 @@ EXEC SQL INCLUDE sqlca; int st_io_0024_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0024_t - WHERE key = :h_key; + EXEC SQL SELECT min(settle_amt) + INTO :h_val:h_ind + FROM st_settle_dtl + WHERE merchant_id = :h_key AND settle_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0024_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int st_io_0024_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0024_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE st_settle_dtl + SET settle_amt = settle_amt + :h_amt, + settle_flag = CASE WHEN settle_amt + :h_amt > 0 THEN 'Y' ELSE 'N' END, + upd_ts = now() + WHERE settle_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0024_touch"); return TX_EDB; @@ -69,24 +69,26 @@ int st_io_0024_touch(const char *key, long amount) long st_io_0024_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM st_io_0024_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(settle_amt) + INTO :h_max:h_ind + FROM st_settle_dtl + WHERE settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0024_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/st_io_0025.c b/app/dbio/st_io_0025.c index 21ce098..5fb515d 100644 --- a/app/dbio/st_io_0025.c +++ b/app/dbio/st_io_0025.c @@ -96,35 +96,32 @@ int st_io_0025_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0025.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0025.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0025.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0025_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( settle_amt ) , 0 ) from st_settle_dtl where merchant_id = $1 and settle_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/st_io_0025.pgc" +#line 29 "app/dbio/st_io_0025.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0025_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +131,27 @@ int st_io_0025_touch(const char *key, long amount) -#line 45 "app/dbio/st_io_0025.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/st_io_0025.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/st_io_0025.pgc" - long h_amount ; +#line 43 "app/dbio/st_io_0025.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/st_io_0025.pgc" +#line 44 "app/dbio/st_io_0025.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0025_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_settle_dtl set settle_amt = $1 , upd_ts = now ( ) where settle_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0025.pgc" - +#line 54 "app/dbio/st_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0025_touch"); @@ -173,27 +168,26 @@ long st_io_0025_total(const char *biz_date) -#line 72 "app/dbio/st_io_0025.pgc" - char h_biz_date [ 9 ] ; +#line 67 "app/dbio/st_io_0025.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/st_io_0025.pgc" +#line 68 "app/dbio/st_io_0025.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/st_io_0025.pgc" +#line 69 "app/dbio/st_io_0025.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0025_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . settle_amt ) , 0 ) from st_settle_dtl a join st_settle_fee b on a . settle_key = b . settle_key where a . settle_dt = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0025.pgc" +#line 80 "app/dbio/st_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/st_io_0025.pgc b/app/dbio/st_io_0025.pgc index bd95ebb..cee035e 100644 --- a/app/dbio/st_io_0025.pgc +++ b/app/dbio/st_io_0025.pgc @@ -14,49 +14,44 @@ EXEC SQL INCLUDE sqlca; int st_io_0025_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0025_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(settle_amt), 0) + INTO :h_val + FROM st_settle_dtl + WHERE merchant_id = :h_key AND settle_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0025_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int st_io_0025_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0025_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE st_settle_dtl + SET settle_amt = :h_amt, upd_ts = now() + WHERE settle_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0025_touch"); return TX_EDB; @@ -69,20 +64,20 @@ int st_io_0025_touch(const char *key, long amount) long st_io_0025_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.settle_amt), 0) INTO :h_sum - FROM st_io_0025_t - WHERE biz_date = :h_biz_date; + FROM st_settle_dtl a + JOIN st_settle_fee b ON a.settle_key = b.settle_key + WHERE a.settle_dt = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0025_total"); diff --git a/app/dbio/st_io_0026.c b/app/dbio/st_io_0026.c index 2aa550e..2c167c6 100644 --- a/app/dbio/st_io_0026.c +++ b/app/dbio/st_io_0026.c @@ -96,35 +96,53 @@ int st_io_0026_fetch(const char *key, long *out_amount) #line 17 "app/dbio/st_io_0026.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/st_io_0026.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/st_io_0026.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_io_0026_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare st_io_0026_fetch_cur cursor for select settle_amt from st_settle_dtl where settle_key = $1 order by settle_dt desc */ +#line 28 "app/dbio/st_io_0026.pgc" + +#line 28 "app/dbio/st_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare st_io_0026_fetch_cur cursor for select settle_amt from st_settle_dtl where settle_key = $1 order by settle_dt desc", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 29 "app/dbio/st_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch st_io_0026_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/st_io_0026.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0026_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 33 "app/dbio/st_io_0026.pgc" + return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0026_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0026_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 38 "app/dbio/st_io_0026.pgc" + return TX_EDB; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0026_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 41 "app/dbio/st_io_0026.pgc" + + *out_amount = h_val; return TX_OK; } @@ -134,29 +152,27 @@ int st_io_0026_touch(const char *key, long amount) -#line 45 "app/dbio/st_io_0026.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/st_io_0026.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/st_io_0026.pgc" - long h_amount ; +#line 50 "app/dbio/st_io_0026.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/st_io_0026.pgc" +#line 51 "app/dbio/st_io_0026.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_io_0026_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_settle_dtl set settle_amt = $1 , settle_flag = 'Y' , upd_ts = now ( ) where settle_key = $2 and settle_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/st_io_0026.pgc" - +#line 61 "app/dbio/st_io_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0026_touch"); @@ -173,32 +189,52 @@ long st_io_0026_total(const char *biz_date) -#line 72 "app/dbio/st_io_0026.pgc" - char h_biz_date [ 9 ] ; - -#line 73 "app/dbio/st_io_0026.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/st_io_0026.pgc" + char h_dt [ 16 ] ; + +#line 75 "app/dbio/st_io_0026.pgc" + long h_grp ; +/* exec sql end declare section */ +#line 76 "app/dbio/st_io_0026.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from st_io_0026_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 1, ( h_dt ), __LINE__);\ + /* declare st_io_0026_total_cur cursor for select coalesce ( sum ( settle_amt ) , 0 ) from st_settle_dtl where settle_dt = $1 group by merchant_id */ +#line 87 "app/dbio/st_io_0026.pgc" + +#line 87 "app/dbio/st_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare st_io_0026_total_cur cursor for select coalesce ( sum ( settle_amt ) , 0 ) from st_settle_dtl where settle_dt = $1 group by merchant_id", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 88 "app/dbio/st_io_0026.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch st_io_0026_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/st_io_0026.pgc" +#line 90 "app/dbio/st_io_0026.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("st_io_0026_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0026_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 95 "app/dbio/st_io_0026.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("st_io_0026_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close st_io_0026_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 100 "app/dbio/st_io_0026.pgc" + + return acc; } diff --git a/app/dbio/st_io_0026.pgc b/app/dbio/st_io_0026.pgc index 4d6d4d4..ff986c6 100644 --- a/app/dbio/st_io_0026.pgc +++ b/app/dbio/st_io_0026.pgc @@ -14,49 +14,51 @@ EXEC SQL INCLUDE sqlca; int st_io_0026_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM st_io_0026_t - WHERE key = :h_key; + EXEC SQL DECLARE st_io_0026_fetch_cur CURSOR FOR + SELECT settle_amt FROM st_settle_dtl + WHERE settle_key = :h_key ORDER BY settle_dt DESC; + EXEC SQL OPEN st_io_0026_fetch_cur; + EXEC SQL FETCH st_io_0026_fetch_cur INTO :h_val; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE st_io_0026_fetch_cur; return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0026_fetch"); + EXEC SQL CLOSE st_io_0026_fetch_cur; return TX_EDB; } - *out_amount = h_amount; + EXEC SQL CLOSE st_io_0026_fetch_cur; + *out_amount = h_val; return TX_OK; } int st_io_0026_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE st_io_0026_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE st_settle_dtl + SET settle_amt = :h_amt, settle_flag = 'Y', upd_ts = now() + WHERE settle_key = :h_key AND settle_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("st_io_0026_touch"); return TX_EDB; @@ -69,24 +71,32 @@ int st_io_0026_touch(const char *key, long amount) long st_io_0026_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM st_io_0026_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("st_io_0026_total"); - return -1; + EXEC SQL DECLARE st_io_0026_total_cur CURSOR FOR + SELECT coalesce(sum(settle_amt), 0) FROM st_settle_dtl + WHERE settle_dt = :h_dt GROUP BY merchant_id; + EXEC SQL OPEN st_io_0026_total_cur; + for (;;) { + EXEC SQL FETCH st_io_0026_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("st_io_0026_total"); + EXEC SQL CLOSE st_io_0026_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE st_io_0026_total_cur; + return acc; } diff --git a/app/dbio/vl_io_0001.c b/app/dbio/vl_io_0001.c index 2db75e1..5cf3e7f 100644 --- a/app/dbio/vl_io_0001.c +++ b/app/dbio/vl_io_0001.c @@ -96,26 +96,25 @@ int vl_io_0001_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0001.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0001.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0001.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0001_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select recon_amt from vl_recon_ledger where recon_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/vl_io_0001.pgc" +#line 29 "app/dbio/vl_io_0001.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int vl_io_0001_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0001_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int vl_io_0001_touch(const char *key, long amount) -#line 45 "app/dbio/vl_io_0001.pgc" - char h_key [ 16 ] ; +#line 44 "app/dbio/vl_io_0001.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/vl_io_0001.pgc" - long h_amount ; +#line 45 "app/dbio/vl_io_0001.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/vl_io_0001.pgc" +#line 46 "app/dbio/vl_io_0001.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0001_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_recon_ledger set recon_amt = $1 , chk_ts = now ( ) where recon_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0001.pgc" - +#line 56 "app/dbio/vl_io_0001.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0001_touch"); @@ -173,27 +170,26 @@ long vl_io_0001_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0001.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/vl_io_0001.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0001.pgc" +#line 70 "app/dbio/vl_io_0001.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0001.pgc" +#line 71 "app/dbio/vl_io_0001.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0001_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( recon_amt ) , 0 ) from vl_recon_ledger where biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0001.pgc" +#line 81 "app/dbio/vl_io_0001.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/vl_io_0001.pgc b/app/dbio/vl_io_0001.pgc index aa92fb3..f757b59 100644 --- a/app/dbio/vl_io_0001.pgc +++ b/app/dbio/vl_io_0001.pgc @@ -14,20 +14,19 @@ EXEC SQL INCLUDE sqlca; int vl_io_0001_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0001_t - WHERE key = :h_key; + EXEC SQL SELECT recon_amt + INTO :h_val + FROM vl_recon_ledger + WHERE recon_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +34,26 @@ int vl_io_0001_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0001_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int vl_io_0001_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0001_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE vl_recon_ledger + SET recon_amt = :h_amt, chk_ts = now() + WHERE recon_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0001_touch"); return TX_EDB; @@ -69,20 +66,19 @@ int vl_io_0001_touch(const char *key, long amount) long vl_io_0001_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(recon_amt), 0) INTO :h_sum - FROM vl_io_0001_t - WHERE biz_date = :h_biz_date; + FROM vl_recon_ledger + WHERE biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0001_total"); diff --git a/app/dbio/vl_io_0002.c b/app/dbio/vl_io_0002.c index 86431a3..1f8790c 100644 --- a/app/dbio/vl_io_0002.c +++ b/app/dbio/vl_io_0002.c @@ -94,27 +94,30 @@ int vl_io_0002_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/vl_io_0002.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0002.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/vl_io_0002.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/vl_io_0002.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0002_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select book_amt from vl_recon_ledger where recon_key = $1 and match_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/vl_io_0002.pgc" @@ -124,7 +127,7 @@ int vl_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } @@ -135,28 +138,26 @@ int vl_io_0002_touch(const char *key, long amount) #line 45 "app/dbio/vl_io_0002.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/vl_io_0002.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/vl_io_0002.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0002_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_recon_ledger set recon_amt = $1 , match_flag = 'Y' , chk_ts = now ( ) where recon_key = $2 and match_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0002.pgc" - +#line 57 "app/dbio/vl_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0002_touch"); @@ -173,32 +174,31 @@ long vl_io_0002_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0002.pgc" - char h_biz_date [ 9 ] ; +#line 70 "app/dbio/vl_io_0002.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0002.pgc" - long h_sum ; +#line 71 "app/dbio/vl_io_0002.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0002.pgc" +#line 72 "app/dbio/vl_io_0002.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0002_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from vl_recon_ledger where biz_date = $1 and match_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0002.pgc" +#line 82 "app/dbio/vl_io_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/vl_io_0002.pgc b/app/dbio/vl_io_0002.pgc index d84bf22..ca20db0 100644 --- a/app/dbio/vl_io_0002.pgc +++ b/app/dbio/vl_io_0002.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int vl_io_0002_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0002_t - WHERE key = :h_key; + EXEC SQL SELECT book_amt + INTO :h_val:h_ind + FROM vl_recon_ledger + WHERE recon_key = :h_key AND match_flag = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +35,26 @@ int vl_io_0002_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0002_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } int vl_io_0002_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0002_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE vl_recon_ledger + SET recon_amt = :h_amt, match_flag = 'Y', chk_ts = now() + WHERE recon_key = :h_key AND match_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0002_touch"); return TX_EDB; @@ -69,24 +67,23 @@ int vl_io_0002_touch(const char *key, long amount) long vl_io_0002_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM vl_io_0002_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM vl_recon_ledger + WHERE biz_date = :h_dt AND match_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0002_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/vl_io_0003.c b/app/dbio/vl_io_0003.c index 176ed11..f524618 100644 --- a/app/dbio/vl_io_0003.c +++ b/app/dbio/vl_io_0003.c @@ -96,24 +96,23 @@ int vl_io_0003_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0003.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0003.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0003.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0003_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a . recon_amt from vl_recon_ledger a join vl_recon_src b on a . recon_key = b . recon_key where a . recon_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/vl_io_0003.pgc" @@ -124,7 +123,7 @@ int vl_io_0003_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0003_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -135,28 +134,28 @@ int vl_io_0003_touch(const char *key, long amount) #line 45 "app/dbio/vl_io_0003.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/vl_io_0003.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/vl_io_0003.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0003_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_recon_ledger set book_amt = $1 where recon_key = $2 and recon_amt >= $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0003.pgc" - +#line 57 "app/dbio/vl_io_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0003_touch"); @@ -172,33 +171,38 @@ long vl_io_0003_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/vl_io_0003.pgc" - char h_biz_date [ 9 ] ; +#line 70 "app/dbio/vl_io_0003.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0003.pgc" - long h_sum ; +#line 71 "app/dbio/vl_io_0003.pgc" + long h_max ; + +#line 72 "app/dbio/vl_io_0003.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0003.pgc" +#line 73 "app/dbio/vl_io_0003.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0003_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( recon_amt ) from vl_recon_ledger where biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0003.pgc" + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 83 "app/dbio/vl_io_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0003_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/vl_io_0003.pgc b/app/dbio/vl_io_0003.pgc index e2cb5a5..207eda0 100644 --- a/app/dbio/vl_io_0003.pgc +++ b/app/dbio/vl_io_0003.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int vl_io_0003_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0003_t - WHERE key = :h_key; + EXEC SQL SELECT a.recon_amt + INTO :h_val + FROM vl_recon_ledger a + JOIN vl_recon_src b ON a.recon_key = b.recon_key + WHERE a.recon_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +35,26 @@ int vl_io_0003_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0003_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int vl_io_0003_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0003_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE vl_recon_ledger + SET book_amt = :h_amt + WHERE recon_key = :h_key AND recon_amt >= :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0003_touch"); return TX_EDB; @@ -69,24 +67,26 @@ int vl_io_0003_touch(const char *key, long amount) long vl_io_0003_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM vl_io_0003_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(recon_amt) + INTO :h_max:h_ind + FROM vl_recon_ledger + WHERE biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0003_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/vl_io_0004.c b/app/dbio/vl_io_0004.c index 29f977b..e96c283 100644 --- a/app/dbio/vl_io_0004.c +++ b/app/dbio/vl_io_0004.c @@ -96,35 +96,32 @@ int vl_io_0004_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0004.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0004.pgc" - long h_amount ; + long h_flag ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0004.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0004_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when exists ( select 1 from vl_recon_ledger where recon_key = $1 and match_flag = 'N' ) then 1 else 0 end", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/vl_io_0004.pgc" +#line 29 "app/dbio/vl_io_0004.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0004_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } @@ -134,36 +131,32 @@ int vl_io_0004_touch(const char *key, long amount) -#line 45 "app/dbio/vl_io_0004.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/vl_io_0004.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/vl_io_0004.pgc" - long h_amount ; +#line 43 "app/dbio/vl_io_0004.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/vl_io_0004.pgc" +#line 44 "app/dbio/vl_io_0004.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0004_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into vl_recon_hist ( recon_key , recon_amt , chk_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0004.pgc" - +#line 53 "app/dbio/vl_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,27 +166,26 @@ long vl_io_0004_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0004.pgc" - char h_biz_date [ 9 ] ; +#line 64 "app/dbio/vl_io_0004.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0004.pgc" +#line 65 "app/dbio/vl_io_0004.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0004.pgc" +#line 66 "app/dbio/vl_io_0004.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0004_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . recon_amt ) , 0 ) from vl_recon_ledger a join vl_recon_src b on a . recon_key = b . recon_key where a . biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0004.pgc" +#line 77 "app/dbio/vl_io_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/vl_io_0004.pgc b/app/dbio/vl_io_0004.pgc index ff1811c..be031b2 100644 --- a/app/dbio/vl_io_0004.pgc +++ b/app/dbio/vl_io_0004.pgc @@ -14,75 +14,67 @@ EXEC SQL INCLUDE sqlca; int vl_io_0004_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_flag; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0004_t - WHERE key = :h_key; + EXEC SQL SELECT CASE WHEN EXISTS ( + SELECT 1 FROM vl_recon_ledger + WHERE recon_key = :h_key AND match_flag = 'N') THEN 1 ELSE 0 END + INTO :h_flag; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0004_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } int vl_io_0004_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0004_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO vl_recon_hist (recon_key, recon_amt, chk_ts) + VALUES (:h_key, :h_amt, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0004_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long vl_io_0004_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.recon_amt), 0) INTO :h_sum - FROM vl_io_0004_t - WHERE biz_date = :h_biz_date; + FROM vl_recon_ledger a + JOIN vl_recon_src b ON a.recon_key = b.recon_key + WHERE a.biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0004_total"); diff --git a/app/dbio/vl_io_0005.c b/app/dbio/vl_io_0005.c index c0bc1bf..5ad4b3a 100644 --- a/app/dbio/vl_io_0005.c +++ b/app/dbio/vl_io_0005.c @@ -94,37 +94,40 @@ int vl_io_0005_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/vl_io_0005.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0005.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/vl_io_0005.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/vl_io_0005.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0005_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( recon_amt ) from vl_recon_ledger where acct_no = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/vl_io_0005.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0005_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,35 +138,31 @@ int vl_io_0005_touch(const char *key, long amount) #line 45 "app/dbio/vl_io_0005.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/vl_io_0005.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/vl_io_0005.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0005_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into vl_recon_ledger ( recon_key , recon_amt , chk_ts ) values ( $1 , $2 , now ( ) ) on conflict ( recon_key ) do update set recon_amt = excluded . recon_amt , chk_ts = now ( )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/vl_io_0005.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0005_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,32 +172,52 @@ long vl_io_0005_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0005.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/vl_io_0005.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0005.pgc" - long h_sum ; +#line 70 "app/dbio/vl_io_0005.pgc" + long h_grp ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0005.pgc" +#line 71 "app/dbio/vl_io_0005.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0005_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_dt ), __LINE__);\ + /* declare vl_io_0005_total_cur cursor for select coalesce ( sum ( recon_amt ) , 0 ) from vl_recon_ledger where biz_date = $1 group by acct_no */ +#line 82 "app/dbio/vl_io_0005.pgc" + +#line 82 "app/dbio/vl_io_0005.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare vl_io_0005_total_cur cursor for select coalesce ( sum ( recon_amt ) , 0 ) from vl_recon_ledger where biz_date = $1 group by acct_no", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 83 "app/dbio/vl_io_0005.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch vl_io_0005_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 85 "app/dbio/vl_io_0005.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("vl_io_0005_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0005_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 90 "app/dbio/vl_io_0005.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("vl_io_0005_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0005_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 95 "app/dbio/vl_io_0005.pgc" + + return acc; } diff --git a/app/dbio/vl_io_0005.pgc b/app/dbio/vl_io_0005.pgc index cbe3622..20a5a20 100644 --- a/app/dbio/vl_io_0005.pgc +++ b/app/dbio/vl_io_0005.pgc @@ -14,79 +14,84 @@ EXEC SQL INCLUDE sqlca; int vl_io_0005_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0005_t - WHERE key = :h_key; + EXEC SQL SELECT max(recon_amt) + INTO :h_val:h_ind + FROM vl_recon_ledger + WHERE acct_no = :h_key; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0005_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int vl_io_0005_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0005_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO vl_recon_ledger (recon_key, recon_amt, chk_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (recon_key) + DO UPDATE SET recon_amt = excluded.recon_amt, chk_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0005_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long vl_io_0005_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM vl_io_0005_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("vl_io_0005_total"); - return -1; + EXEC SQL DECLARE vl_io_0005_total_cur CURSOR FOR + SELECT coalesce(sum(recon_amt), 0) FROM vl_recon_ledger + WHERE biz_date = :h_dt GROUP BY acct_no; + EXEC SQL OPEN vl_io_0005_total_cur; + for (;;) { + EXEC SQL FETCH vl_io_0005_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("vl_io_0005_total"); + EXEC SQL CLOSE vl_io_0005_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE vl_io_0005_total_cur; + return acc; } diff --git a/app/dbio/vl_io_0006.c b/app/dbio/vl_io_0006.c index 855fa67..218fa49 100644 --- a/app/dbio/vl_io_0006.c +++ b/app/dbio/vl_io_0006.c @@ -94,37 +94,40 @@ int vl_io_0006_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/vl_io_0006.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0006.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/vl_io_0006.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/vl_io_0006.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0006_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( recon_amt ) from vl_recon_ledger where acct_no = $1 and match_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/vl_io_0006.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0006_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,24 @@ int vl_io_0006_touch(const char *key, long amount) #line 45 "app/dbio/vl_io_0006.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/vl_io_0006.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/vl_io_0006.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0006_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from vl_recon_hist where recon_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0006.pgc" - +#line 56 "app/dbio/vl_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0006_touch"); @@ -173,27 +172,26 @@ long vl_io_0006_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0006.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/vl_io_0006.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0006.pgc" +#line 70 "app/dbio/vl_io_0006.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0006.pgc" +#line 71 "app/dbio/vl_io_0006.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0006_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when match_flag = 'Y' then recon_amt else 0 end ) , 0 ) from vl_recon_ledger where biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0006.pgc" +#line 81 "app/dbio/vl_io_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/vl_io_0006.pgc b/app/dbio/vl_io_0006.pgc index 7e7d24b..3d47e0e 100644 --- a/app/dbio/vl_io_0006.pgc +++ b/app/dbio/vl_io_0006.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int vl_io_0006_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0006_t - WHERE key = :h_key; + EXEC SQL SELECT min(recon_amt) + INTO :h_val:h_ind + FROM vl_recon_ledger + WHERE acct_no = :h_key AND match_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0006_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int vl_io_0006_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0006_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM vl_recon_hist + WHERE recon_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0006_touch"); return TX_EDB; @@ -69,20 +66,19 @@ int vl_io_0006_touch(const char *key, long amount) long vl_io_0006_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(CASE WHEN match_flag = 'Y' THEN recon_amt ELSE 0 END), 0) INTO :h_sum - FROM vl_io_0006_t - WHERE biz_date = :h_biz_date; + FROM vl_recon_ledger + WHERE biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0006_total"); diff --git a/app/dbio/vl_io_0007.c b/app/dbio/vl_io_0007.c index 45b2d08..9d739da 100644 --- a/app/dbio/vl_io_0007.c +++ b/app/dbio/vl_io_0007.c @@ -96,35 +96,32 @@ int vl_io_0007_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0007.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0007.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0007.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0007_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( recon_amt ) , 0 ) from vl_recon_ledger where acct_no = $1 and match_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/vl_io_0007.pgc" +#line 29 "app/dbio/vl_io_0007.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0007_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +131,27 @@ int vl_io_0007_touch(const char *key, long amount) -#line 45 "app/dbio/vl_io_0007.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/vl_io_0007.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/vl_io_0007.pgc" - long h_amount ; +#line 43 "app/dbio/vl_io_0007.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/vl_io_0007.pgc" +#line 44 "app/dbio/vl_io_0007.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0007_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from vl_recon_hist where acct_no = $1 and recon_amt < $2 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0007.pgc" - +#line 53 "app/dbio/vl_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0007_touch"); @@ -173,32 +168,31 @@ long vl_io_0007_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0007.pgc" - char h_biz_date [ 9 ] ; +#line 66 "app/dbio/vl_io_0007.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0007.pgc" - long h_sum ; +#line 67 "app/dbio/vl_io_0007.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0007.pgc" +#line 68 "app/dbio/vl_io_0007.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0007_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct acct_no ) from vl_recon_ledger where biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0007.pgc" +#line 78 "app/dbio/vl_io_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0007_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/vl_io_0007.pgc b/app/dbio/vl_io_0007.pgc index 4471c3b..3113152 100644 --- a/app/dbio/vl_io_0007.pgc +++ b/app/dbio/vl_io_0007.pgc @@ -14,49 +14,43 @@ EXEC SQL INCLUDE sqlca; int vl_io_0007_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0007_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(recon_amt), 0) + INTO :h_val + FROM vl_recon_ledger + WHERE acct_no = :h_key AND match_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0007_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int vl_io_0007_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0007_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM vl_recon_hist + WHERE acct_no = :h_key AND recon_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0007_touch"); return TX_EDB; @@ -69,24 +63,23 @@ int vl_io_0007_touch(const char *key, long amount) long vl_io_0007_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM vl_io_0007_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(distinct acct_no) + INTO :h_cnt + FROM vl_recon_ledger + WHERE biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0007_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/vl_io_0008.c b/app/dbio/vl_io_0008.c index f5b81f7..05fdc2b 100644 --- a/app/dbio/vl_io_0008.c +++ b/app/dbio/vl_io_0008.c @@ -96,35 +96,53 @@ int vl_io_0008_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0008.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0008.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0008.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0008_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare vl_io_0008_fetch_cur cursor for select recon_amt from vl_recon_ledger where recon_key = $1 order by biz_date desc */ +#line 28 "app/dbio/vl_io_0008.pgc" + +#line 28 "app/dbio/vl_io_0008.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare vl_io_0008_fetch_cur cursor for select recon_amt from vl_recon_ledger where recon_key = $1 order by biz_date desc", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 29 "app/dbio/vl_io_0008.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch vl_io_0008_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/vl_io_0008.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0008_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 33 "app/dbio/vl_io_0008.pgc" + return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0008_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0008_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 38 "app/dbio/vl_io_0008.pgc" + return TX_EDB; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0008_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 41 "app/dbio/vl_io_0008.pgc" + + *out_amount = h_val; return TX_OK; } @@ -134,29 +152,29 @@ int vl_io_0008_touch(const char *key, long amount) -#line 45 "app/dbio/vl_io_0008.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/vl_io_0008.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/vl_io_0008.pgc" - long h_amount ; +#line 50 "app/dbio/vl_io_0008.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/vl_io_0008.pgc" +#line 51 "app/dbio/vl_io_0008.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0008_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_recon_ledger set recon_amt = recon_amt + $1 , match_flag = case when recon_amt + $2 > 0 then 'Y' else 'N' end , chk_ts = now ( ) where recon_key = $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0008.pgc" - +#line 63 "app/dbio/vl_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0008_touch"); @@ -173,27 +191,26 @@ long vl_io_0008_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0008.pgc" - char h_biz_date [ 9 ] ; +#line 76 "app/dbio/vl_io_0008.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0008.pgc" +#line 77 "app/dbio/vl_io_0008.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0008.pgc" +#line 78 "app/dbio/vl_io_0008.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0008_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( recon_amt ) , 0 ) from vl_recon_ledger where biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0008.pgc" +#line 88 "app/dbio/vl_io_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/vl_io_0008.pgc b/app/dbio/vl_io_0008.pgc index db9eab6..a24fdf9 100644 --- a/app/dbio/vl_io_0008.pgc +++ b/app/dbio/vl_io_0008.pgc @@ -14,49 +14,53 @@ EXEC SQL INCLUDE sqlca; int vl_io_0008_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0008_t - WHERE key = :h_key; + EXEC SQL DECLARE vl_io_0008_fetch_cur CURSOR FOR + SELECT recon_amt FROM vl_recon_ledger + WHERE recon_key = :h_key ORDER BY biz_date DESC; + EXEC SQL OPEN vl_io_0008_fetch_cur; + EXEC SQL FETCH vl_io_0008_fetch_cur INTO :h_val; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE vl_io_0008_fetch_cur; return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0008_fetch"); + EXEC SQL CLOSE vl_io_0008_fetch_cur; return TX_EDB; } - *out_amount = h_amount; + EXEC SQL CLOSE vl_io_0008_fetch_cur; + *out_amount = h_val; return TX_OK; } int vl_io_0008_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0008_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE vl_recon_ledger + SET recon_amt = recon_amt + :h_amt, + match_flag = CASE WHEN recon_amt + :h_amt > 0 THEN 'Y' ELSE 'N' END, + chk_ts = now() + WHERE recon_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0008_touch"); return TX_EDB; @@ -69,20 +73,19 @@ int vl_io_0008_touch(const char *key, long amount) long vl_io_0008_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(recon_amt), 0) INTO :h_sum - FROM vl_io_0008_t - WHERE biz_date = :h_biz_date; + FROM vl_recon_ledger + WHERE biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0008_total"); diff --git a/app/dbio/vl_io_0009.c b/app/dbio/vl_io_0009.c index 022f909..8698a66 100644 --- a/app/dbio/vl_io_0009.c +++ b/app/dbio/vl_io_0009.c @@ -96,26 +96,25 @@ int vl_io_0009_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0009.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0009.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0009.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0009_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select recon_amt from vl_recon_ledger where recon_key in ( select recon_key from vl_recon_src where acct_no = $1 ) order by recon_amt desc limit 1", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/vl_io_0009.pgc" +#line 32 "app/dbio/vl_io_0009.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int vl_io_0009_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0009_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int vl_io_0009_touch(const char *key, long amount) -#line 45 "app/dbio/vl_io_0009.pgc" - char h_key [ 16 ] ; - -#line 46 "app/dbio/vl_io_0009.pgc" - long h_amount ; -/* exec sql end declare section */ #line 47 "app/dbio/vl_io_0009.pgc" + char h_key [ 32 ] ; + +#line 48 "app/dbio/vl_io_0009.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 49 "app/dbio/vl_io_0009.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0009_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_recon_ledger set recon_amt = $1 , chk_ts = now ( ) where recon_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0009.pgc" - +#line 59 "app/dbio/vl_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0009_touch"); @@ -174,31 +171,30 @@ long vl_io_0009_total(const char *biz_date) #line 72 "app/dbio/vl_io_0009.pgc" - char h_biz_date [ 9 ] ; + char h_dt [ 16 ] ; #line 73 "app/dbio/vl_io_0009.pgc" - long h_sum ; + long h_cnt ; /* exec sql end declare section */ #line 74 "app/dbio/vl_io_0009.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0009_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from vl_recon_ledger where biz_date = $1 and match_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0009.pgc" +#line 84 "app/dbio/vl_io_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0009_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/vl_io_0009.pgc b/app/dbio/vl_io_0009.pgc index 1f184e1..a2f677a 100644 --- a/app/dbio/vl_io_0009.pgc +++ b/app/dbio/vl_io_0009.pgc @@ -14,20 +14,22 @@ EXEC SQL INCLUDE sqlca; int vl_io_0009_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0009_t - WHERE key = :h_key; + EXEC SQL SELECT recon_amt + INTO :h_val + FROM vl_recon_ledger + WHERE recon_key IN ( + SELECT recon_key FROM vl_recon_src WHERE acct_no = :h_key) + ORDER BY recon_amt DESC + LIMIT 1; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +37,26 @@ int vl_io_0009_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0009_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int vl_io_0009_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0009_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE vl_recon_ledger + SET recon_amt = :h_amt, chk_ts = now() + WHERE recon_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0009_touch"); return TX_EDB; @@ -69,24 +69,23 @@ int vl_io_0009_touch(const char *key, long amount) long vl_io_0009_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM vl_io_0009_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM vl_recon_ledger + WHERE biz_date = :h_dt AND match_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0009_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/vl_io_0010.c b/app/dbio/vl_io_0010.c index 2f15f59..e7edf3b 100644 --- a/app/dbio/vl_io_0010.c +++ b/app/dbio/vl_io_0010.c @@ -96,26 +96,25 @@ int vl_io_0010_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0010.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0010.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0010.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0010_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select recon_amt from vl_recon_ledger where recon_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/vl_io_0010.pgc" +#line 29 "app/dbio/vl_io_0010.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int vl_io_0010_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0010_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int vl_io_0010_touch(const char *key, long amount) -#line 45 "app/dbio/vl_io_0010.pgc" - char h_key [ 16 ] ; +#line 44 "app/dbio/vl_io_0010.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/vl_io_0010.pgc" - long h_amount ; +#line 45 "app/dbio/vl_io_0010.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/vl_io_0010.pgc" +#line 46 "app/dbio/vl_io_0010.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0010_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_recon_ledger set recon_amt = $1 , match_flag = 'Y' , chk_ts = now ( ) where recon_key = $2 and match_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0010.pgc" - +#line 56 "app/dbio/vl_io_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0010_touch"); @@ -172,33 +169,38 @@ long vl_io_0010_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/vl_io_0010.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/vl_io_0010.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0010.pgc" - long h_sum ; +#line 70 "app/dbio/vl_io_0010.pgc" + long h_max ; + +#line 71 "app/dbio/vl_io_0010.pgc" + short h_ind ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0010.pgc" +#line 72 "app/dbio/vl_io_0010.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0010_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( recon_amt ) from vl_recon_ledger where biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0010.pgc" + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 82 "app/dbio/vl_io_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0010_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/vl_io_0010.pgc b/app/dbio/vl_io_0010.pgc index 5edf017..9238757 100644 --- a/app/dbio/vl_io_0010.pgc +++ b/app/dbio/vl_io_0010.pgc @@ -14,20 +14,19 @@ EXEC SQL INCLUDE sqlca; int vl_io_0010_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0010_t - WHERE key = :h_key; + EXEC SQL SELECT recon_amt + INTO :h_val + FROM vl_recon_ledger + WHERE recon_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +34,26 @@ int vl_io_0010_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0010_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int vl_io_0010_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0010_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE vl_recon_ledger + SET recon_amt = :h_amt, match_flag = 'Y', chk_ts = now() + WHERE recon_key = :h_key AND match_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0010_touch"); return TX_EDB; @@ -69,24 +66,26 @@ int vl_io_0010_touch(const char *key, long amount) long vl_io_0010_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM vl_io_0010_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(recon_amt) + INTO :h_max:h_ind + FROM vl_recon_ledger + WHERE biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0010_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/vl_io_0011.c b/app/dbio/vl_io_0011.c index b066a05..f3b3607 100644 --- a/app/dbio/vl_io_0011.c +++ b/app/dbio/vl_io_0011.c @@ -94,27 +94,30 @@ int vl_io_0011_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/vl_io_0011.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0011.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/vl_io_0011.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/vl_io_0011.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0011_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select book_amt from vl_recon_ledger where recon_key = $1 and match_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/vl_io_0011.pgc" @@ -124,7 +127,7 @@ int vl_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } @@ -135,28 +138,28 @@ int vl_io_0011_touch(const char *key, long amount) #line 45 "app/dbio/vl_io_0011.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/vl_io_0011.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/vl_io_0011.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0011_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_recon_ledger set book_amt = $1 where recon_key = $2 and recon_amt >= $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0011.pgc" - +#line 57 "app/dbio/vl_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0011_touch"); @@ -173,27 +176,26 @@ long vl_io_0011_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0011.pgc" - char h_biz_date [ 9 ] ; +#line 70 "app/dbio/vl_io_0011.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0011.pgc" +#line 71 "app/dbio/vl_io_0011.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0011.pgc" +#line 72 "app/dbio/vl_io_0011.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0011_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . recon_amt ) , 0 ) from vl_recon_ledger a join vl_recon_src b on a . recon_key = b . recon_key where a . biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0011.pgc" +#line 83 "app/dbio/vl_io_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/vl_io_0011.pgc b/app/dbio/vl_io_0011.pgc index e8d2e88..124c5b5 100644 --- a/app/dbio/vl_io_0011.pgc +++ b/app/dbio/vl_io_0011.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int vl_io_0011_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0011_t - WHERE key = :h_key; + EXEC SQL SELECT book_amt + INTO :h_val:h_ind + FROM vl_recon_ledger + WHERE recon_key = :h_key AND match_flag = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +35,26 @@ int vl_io_0011_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0011_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } int vl_io_0011_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0011_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE vl_recon_ledger + SET book_amt = :h_amt + WHERE recon_key = :h_key AND recon_amt >= :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0011_touch"); return TX_EDB; @@ -69,20 +67,20 @@ int vl_io_0011_touch(const char *key, long amount) long vl_io_0011_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.recon_amt), 0) INTO :h_sum - FROM vl_io_0011_t - WHERE biz_date = :h_biz_date; + FROM vl_recon_ledger a + JOIN vl_recon_src b ON a.recon_key = b.recon_key + WHERE a.biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0011_total"); diff --git a/app/dbio/vl_io_0012.c b/app/dbio/vl_io_0012.c index b1c5849..91662d8 100644 --- a/app/dbio/vl_io_0012.c +++ b/app/dbio/vl_io_0012.c @@ -96,24 +96,23 @@ int vl_io_0012_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0012.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0012.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0012.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0012_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a . recon_amt from vl_recon_ledger a join vl_recon_src b on a . recon_key = b . recon_key where a . recon_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/vl_io_0012.pgc" @@ -124,7 +123,7 @@ int vl_io_0012_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0012_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -135,35 +134,31 @@ int vl_io_0012_touch(const char *key, long amount) #line 45 "app/dbio/vl_io_0012.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/vl_io_0012.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/vl_io_0012.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0012_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into vl_recon_hist ( recon_key , recon_amt , chk_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0012.pgc" - +#line 56 "app/dbio/vl_io_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0012_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,32 +168,52 @@ long vl_io_0012_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0012.pgc" - char h_biz_date [ 9 ] ; +#line 67 "app/dbio/vl_io_0012.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0012.pgc" - long h_sum ; +#line 68 "app/dbio/vl_io_0012.pgc" + long h_grp ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0012.pgc" +#line 69 "app/dbio/vl_io_0012.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0012_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_dt ), __LINE__);\ + /* declare vl_io_0012_total_cur cursor for select coalesce ( sum ( recon_amt ) , 0 ) from vl_recon_ledger where biz_date = $1 group by acct_no */ +#line 80 "app/dbio/vl_io_0012.pgc" + +#line 80 "app/dbio/vl_io_0012.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare vl_io_0012_total_cur cursor for select coalesce ( sum ( recon_amt ) , 0 ) from vl_recon_ledger where biz_date = $1 group by acct_no", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 81 "app/dbio/vl_io_0012.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch vl_io_0012_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0012.pgc" +#line 83 "app/dbio/vl_io_0012.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("vl_io_0012_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0012_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 88 "app/dbio/vl_io_0012.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("vl_io_0012_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0012_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 93 "app/dbio/vl_io_0012.pgc" + + return acc; } diff --git a/app/dbio/vl_io_0012.pgc b/app/dbio/vl_io_0012.pgc index 4c27181..df7b9fe 100644 --- a/app/dbio/vl_io_0012.pgc +++ b/app/dbio/vl_io_0012.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int vl_io_0012_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0012_t - WHERE key = :h_key; + EXEC SQL SELECT a.recon_amt + INTO :h_val + FROM vl_recon_ledger a + JOIN vl_recon_src b ON a.recon_key = b.recon_key + WHERE a.recon_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,58 +35,61 @@ int vl_io_0012_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0012_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int vl_io_0012_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0012_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO vl_recon_hist (recon_key, recon_amt, chk_ts) + VALUES (:h_key, :h_amt, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0012_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long vl_io_0012_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM vl_io_0012_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("vl_io_0012_total"); - return -1; + EXEC SQL DECLARE vl_io_0012_total_cur CURSOR FOR + SELECT coalesce(sum(recon_amt), 0) FROM vl_recon_ledger + WHERE biz_date = :h_dt GROUP BY acct_no; + EXEC SQL OPEN vl_io_0012_total_cur; + for (;;) { + EXEC SQL FETCH vl_io_0012_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("vl_io_0012_total"); + EXEC SQL CLOSE vl_io_0012_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE vl_io_0012_total_cur; + return acc; } diff --git a/app/dbio/vl_io_0013.c b/app/dbio/vl_io_0013.c index d4a4698..718790e 100644 --- a/app/dbio/vl_io_0013.c +++ b/app/dbio/vl_io_0013.c @@ -96,35 +96,32 @@ int vl_io_0013_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0013.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0013.pgc" - long h_amount ; + long h_flag ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0013.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0013_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when exists ( select 1 from vl_recon_ledger where recon_key = $1 and match_flag = 'N' ) then 1 else 0 end", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/vl_io_0013.pgc" +#line 29 "app/dbio/vl_io_0013.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0013_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } @@ -134,36 +131,32 @@ int vl_io_0013_touch(const char *key, long amount) -#line 45 "app/dbio/vl_io_0013.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/vl_io_0013.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/vl_io_0013.pgc" - long h_amount ; +#line 43 "app/dbio/vl_io_0013.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/vl_io_0013.pgc" +#line 44 "app/dbio/vl_io_0013.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0013_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into vl_recon_ledger ( recon_key , recon_amt , chk_ts ) values ( $1 , $2 , now ( ) ) on conflict ( recon_key ) do update set recon_amt = excluded . recon_amt , chk_ts = now ( )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0013.pgc" - +#line 55 "app/dbio/vl_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,27 +166,26 @@ long vl_io_0013_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0013.pgc" - char h_biz_date [ 9 ] ; +#line 66 "app/dbio/vl_io_0013.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0013.pgc" +#line 67 "app/dbio/vl_io_0013.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0013.pgc" +#line 68 "app/dbio/vl_io_0013.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0013_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when match_flag = 'Y' then recon_amt else 0 end ) , 0 ) from vl_recon_ledger where biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0013.pgc" +#line 78 "app/dbio/vl_io_0013.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/vl_io_0013.pgc b/app/dbio/vl_io_0013.pgc index 043a320..9fbb6ad 100644 --- a/app/dbio/vl_io_0013.pgc +++ b/app/dbio/vl_io_0013.pgc @@ -14,75 +14,68 @@ EXEC SQL INCLUDE sqlca; int vl_io_0013_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_flag; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0013_t - WHERE key = :h_key; + EXEC SQL SELECT CASE WHEN EXISTS ( + SELECT 1 FROM vl_recon_ledger + WHERE recon_key = :h_key AND match_flag = 'N') THEN 1 ELSE 0 END + INTO :h_flag; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0013_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } int vl_io_0013_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0013_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO vl_recon_ledger (recon_key, recon_amt, chk_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (recon_key) + DO UPDATE SET recon_amt = excluded.recon_amt, chk_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0013_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long vl_io_0013_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(CASE WHEN match_flag = 'Y' THEN recon_amt ELSE 0 END), 0) INTO :h_sum - FROM vl_io_0013_t - WHERE biz_date = :h_biz_date; + FROM vl_recon_ledger + WHERE biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0013_total"); diff --git a/app/dbio/vl_io_0014.c b/app/dbio/vl_io_0014.c index 8f02dd0..c4bf45e 100644 --- a/app/dbio/vl_io_0014.c +++ b/app/dbio/vl_io_0014.c @@ -94,37 +94,40 @@ int vl_io_0014_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/vl_io_0014.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0014.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/vl_io_0014.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/vl_io_0014.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0014_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( recon_amt ) from vl_recon_ledger where acct_no = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/vl_io_0014.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0014_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,24 @@ int vl_io_0014_touch(const char *key, long amount) #line 45 "app/dbio/vl_io_0014.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/vl_io_0014.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/vl_io_0014.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0014_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from vl_recon_hist where recon_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0014.pgc" - +#line 56 "app/dbio/vl_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0014_touch"); @@ -173,32 +172,31 @@ long vl_io_0014_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0014.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/vl_io_0014.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0014.pgc" - long h_sum ; +#line 70 "app/dbio/vl_io_0014.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0014.pgc" +#line 71 "app/dbio/vl_io_0014.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0014_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct acct_no ) from vl_recon_ledger where biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0014.pgc" +#line 81 "app/dbio/vl_io_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0014_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/vl_io_0014.pgc b/app/dbio/vl_io_0014.pgc index f509358..e57fbcc 100644 --- a/app/dbio/vl_io_0014.pgc +++ b/app/dbio/vl_io_0014.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int vl_io_0014_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0014_t - WHERE key = :h_key; + EXEC SQL SELECT max(recon_amt) + INTO :h_val:h_ind + FROM vl_recon_ledger + WHERE acct_no = :h_key; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0014_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int vl_io_0014_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0014_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM vl_recon_hist + WHERE recon_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0014_touch"); return TX_EDB; @@ -69,24 +66,23 @@ int vl_io_0014_touch(const char *key, long amount) long vl_io_0014_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM vl_io_0014_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(distinct acct_no) + INTO :h_cnt + FROM vl_recon_ledger + WHERE biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0014_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/vl_io_0015.c b/app/dbio/vl_io_0015.c index 99b36d8..99e5ba5 100644 --- a/app/dbio/vl_io_0015.c +++ b/app/dbio/vl_io_0015.c @@ -94,37 +94,40 @@ int vl_io_0015_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/vl_io_0015.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0015.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/vl_io_0015.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/vl_io_0015.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0015_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( recon_amt ) from vl_recon_ledger where acct_no = $1 and match_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/vl_io_0015.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0015_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,26 @@ int vl_io_0015_touch(const char *key, long amount) #line 45 "app/dbio/vl_io_0015.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/vl_io_0015.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/vl_io_0015.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0015_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from vl_recon_hist where acct_no = $1 and recon_amt < $2 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0015.pgc" - +#line 56 "app/dbio/vl_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0015_touch"); @@ -173,27 +174,26 @@ long vl_io_0015_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0015.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/vl_io_0015.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0015.pgc" +#line 70 "app/dbio/vl_io_0015.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0015.pgc" +#line 71 "app/dbio/vl_io_0015.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0015_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( recon_amt ) , 0 ) from vl_recon_ledger where biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0015.pgc" +#line 81 "app/dbio/vl_io_0015.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/vl_io_0015.pgc b/app/dbio/vl_io_0015.pgc index deecead..31d2246 100644 --- a/app/dbio/vl_io_0015.pgc +++ b/app/dbio/vl_io_0015.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int vl_io_0015_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0015_t - WHERE key = :h_key; + EXEC SQL SELECT min(recon_amt) + INTO :h_val:h_ind + FROM vl_recon_ledger + WHERE acct_no = :h_key AND match_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0015_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int vl_io_0015_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0015_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM vl_recon_hist + WHERE acct_no = :h_key AND recon_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0015_touch"); return TX_EDB; @@ -69,20 +66,19 @@ int vl_io_0015_touch(const char *key, long amount) long vl_io_0015_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(recon_amt), 0) INTO :h_sum - FROM vl_io_0015_t - WHERE biz_date = :h_biz_date; + FROM vl_recon_ledger + WHERE biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0015_total"); diff --git a/app/dbio/vl_io_0016.c b/app/dbio/vl_io_0016.c index 2ec653d..13a147d 100644 --- a/app/dbio/vl_io_0016.c +++ b/app/dbio/vl_io_0016.c @@ -96,35 +96,32 @@ int vl_io_0016_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0016.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0016.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0016.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0016_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( recon_amt ) , 0 ) from vl_recon_ledger where acct_no = $1 and match_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/vl_io_0016.pgc" +#line 29 "app/dbio/vl_io_0016.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0016_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +131,29 @@ int vl_io_0016_touch(const char *key, long amount) -#line 45 "app/dbio/vl_io_0016.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/vl_io_0016.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/vl_io_0016.pgc" - long h_amount ; +#line 43 "app/dbio/vl_io_0016.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/vl_io_0016.pgc" +#line 44 "app/dbio/vl_io_0016.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0016_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_recon_ledger set recon_amt = recon_amt + $1 , match_flag = case when recon_amt + $2 > 0 then 'Y' else 'N' end , chk_ts = now ( ) where recon_key = $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0016.pgc" - +#line 56 "app/dbio/vl_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0016_touch"); @@ -173,32 +170,31 @@ long vl_io_0016_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0016.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/vl_io_0016.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0016.pgc" - long h_sum ; +#line 70 "app/dbio/vl_io_0016.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0016.pgc" +#line 71 "app/dbio/vl_io_0016.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0016_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from vl_recon_ledger where biz_date = $1 and match_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0016.pgc" +#line 81 "app/dbio/vl_io_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0016_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/vl_io_0016.pgc b/app/dbio/vl_io_0016.pgc index 928bc92..d31ac84 100644 --- a/app/dbio/vl_io_0016.pgc +++ b/app/dbio/vl_io_0016.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int vl_io_0016_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0016_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(recon_amt), 0) + INTO :h_val + FROM vl_recon_ledger + WHERE acct_no = :h_key AND match_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0016_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int vl_io_0016_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0016_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE vl_recon_ledger + SET recon_amt = recon_amt + :h_amt, + match_flag = CASE WHEN recon_amt + :h_amt > 0 THEN 'Y' ELSE 'N' END, + chk_ts = now() + WHERE recon_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0016_touch"); return TX_EDB; @@ -69,24 +66,23 @@ int vl_io_0016_touch(const char *key, long amount) long vl_io_0016_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM vl_io_0016_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM vl_recon_ledger + WHERE biz_date = :h_dt AND match_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0016_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/vl_io_0017.c b/app/dbio/vl_io_0017.c index 28570aa..2c63634 100644 --- a/app/dbio/vl_io_0017.c +++ b/app/dbio/vl_io_0017.c @@ -96,35 +96,53 @@ int vl_io_0017_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0017.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0017.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0017.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0017_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare vl_io_0017_fetch_cur cursor for select recon_amt from vl_recon_ledger where recon_key = $1 order by biz_date desc */ +#line 28 "app/dbio/vl_io_0017.pgc" + +#line 28 "app/dbio/vl_io_0017.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare vl_io_0017_fetch_cur cursor for select recon_amt from vl_recon_ledger where recon_key = $1 order by biz_date desc", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 29 "app/dbio/vl_io_0017.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch vl_io_0017_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/vl_io_0017.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0017_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 33 "app/dbio/vl_io_0017.pgc" + return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0017_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0017_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 38 "app/dbio/vl_io_0017.pgc" + return TX_EDB; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0017_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 41 "app/dbio/vl_io_0017.pgc" + + *out_amount = h_val; return TX_OK; } @@ -134,29 +152,27 @@ int vl_io_0017_touch(const char *key, long amount) -#line 45 "app/dbio/vl_io_0017.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/vl_io_0017.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/vl_io_0017.pgc" - long h_amount ; +#line 50 "app/dbio/vl_io_0017.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/vl_io_0017.pgc" +#line 51 "app/dbio/vl_io_0017.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0017_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_recon_ledger set recon_amt = $1 , chk_ts = now ( ) where recon_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0017.pgc" - +#line 61 "app/dbio/vl_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0017_touch"); @@ -172,33 +188,38 @@ long vl_io_0017_total(const char *biz_date) /* exec sql begin declare section */ + -#line 72 "app/dbio/vl_io_0017.pgc" - char h_biz_date [ 9 ] ; - -#line 73 "app/dbio/vl_io_0017.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/vl_io_0017.pgc" + char h_dt [ 16 ] ; + +#line 75 "app/dbio/vl_io_0017.pgc" + long h_max ; + +#line 76 "app/dbio/vl_io_0017.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 77 "app/dbio/vl_io_0017.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0017_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( recon_amt ) from vl_recon_ledger where biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0017.pgc" + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} +#line 87 "app/dbio/vl_io_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0017_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/vl_io_0017.pgc b/app/dbio/vl_io_0017.pgc index e5379e6..d33b32a 100644 --- a/app/dbio/vl_io_0017.pgc +++ b/app/dbio/vl_io_0017.pgc @@ -14,49 +14,51 @@ EXEC SQL INCLUDE sqlca; int vl_io_0017_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0017_t - WHERE key = :h_key; + EXEC SQL DECLARE vl_io_0017_fetch_cur CURSOR FOR + SELECT recon_amt FROM vl_recon_ledger + WHERE recon_key = :h_key ORDER BY biz_date DESC; + EXEC SQL OPEN vl_io_0017_fetch_cur; + EXEC SQL FETCH vl_io_0017_fetch_cur INTO :h_val; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE vl_io_0017_fetch_cur; return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0017_fetch"); + EXEC SQL CLOSE vl_io_0017_fetch_cur; return TX_EDB; } - *out_amount = h_amount; + EXEC SQL CLOSE vl_io_0017_fetch_cur; + *out_amount = h_val; return TX_OK; } int vl_io_0017_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0017_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE vl_recon_ledger + SET recon_amt = :h_amt, chk_ts = now() + WHERE recon_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0017_touch"); return TX_EDB; @@ -69,24 +71,26 @@ int vl_io_0017_touch(const char *key, long amount) long vl_io_0017_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM vl_io_0017_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(recon_amt) + INTO :h_max:h_ind + FROM vl_recon_ledger + WHERE biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0017_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/vl_io_0018.c b/app/dbio/vl_io_0018.c index 8ed20f7..efbb717 100644 --- a/app/dbio/vl_io_0018.c +++ b/app/dbio/vl_io_0018.c @@ -96,26 +96,25 @@ int vl_io_0018_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0018.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0018.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0018.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0018_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select recon_amt from vl_recon_ledger where recon_key in ( select recon_key from vl_recon_src where acct_no = $1 ) order by recon_amt desc limit 1", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/vl_io_0018.pgc" +#line 32 "app/dbio/vl_io_0018.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int vl_io_0018_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0018_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,27 @@ int vl_io_0018_touch(const char *key, long amount) -#line 45 "app/dbio/vl_io_0018.pgc" - char h_key [ 16 ] ; - -#line 46 "app/dbio/vl_io_0018.pgc" - long h_amount ; -/* exec sql end declare section */ #line 47 "app/dbio/vl_io_0018.pgc" + char h_key [ 32 ] ; + +#line 48 "app/dbio/vl_io_0018.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 49 "app/dbio/vl_io_0018.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0018_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_recon_ledger set recon_amt = $1 , match_flag = 'Y' , chk_ts = now ( ) where recon_key = $2 and match_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0018.pgc" - +#line 59 "app/dbio/vl_io_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0018_touch"); @@ -174,7 +171,7 @@ long vl_io_0018_total(const char *biz_date) #line 72 "app/dbio/vl_io_0018.pgc" - char h_biz_date [ 9 ] ; + char h_dt [ 16 ] ; #line 73 "app/dbio/vl_io_0018.pgc" long h_sum ; @@ -184,12 +181,11 @@ long vl_io_0018_total(const char *biz_date) if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0018_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . recon_amt ) , 0 ) from vl_recon_ledger a join vl_recon_src b on a . recon_key = b . recon_key where a . biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} diff --git a/app/dbio/vl_io_0018.pgc b/app/dbio/vl_io_0018.pgc index 1f550a1..32705e0 100644 --- a/app/dbio/vl_io_0018.pgc +++ b/app/dbio/vl_io_0018.pgc @@ -14,20 +14,22 @@ EXEC SQL INCLUDE sqlca; int vl_io_0018_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0018_t - WHERE key = :h_key; + EXEC SQL SELECT recon_amt + INTO :h_val + FROM vl_recon_ledger + WHERE recon_key IN ( + SELECT recon_key FROM vl_recon_src WHERE acct_no = :h_key) + ORDER BY recon_amt DESC + LIMIT 1; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +37,26 @@ int vl_io_0018_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0018_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int vl_io_0018_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0018_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE vl_recon_ledger + SET recon_amt = :h_amt, match_flag = 'Y', chk_ts = now() + WHERE recon_key = :h_key AND match_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0018_touch"); return TX_EDB; @@ -69,20 +69,20 @@ int vl_io_0018_touch(const char *key, long amount) long vl_io_0018_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.recon_amt), 0) INTO :h_sum - FROM vl_io_0018_t - WHERE biz_date = :h_biz_date; + FROM vl_recon_ledger a + JOIN vl_recon_src b ON a.recon_key = b.recon_key + WHERE a.biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0018_total"); diff --git a/app/dbio/vl_io_0019.c b/app/dbio/vl_io_0019.c index 7ba1525..b2ef117 100644 --- a/app/dbio/vl_io_0019.c +++ b/app/dbio/vl_io_0019.c @@ -96,26 +96,25 @@ int vl_io_0019_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0019.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0019.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0019.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0019_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select recon_amt from vl_recon_ledger where recon_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/vl_io_0019.pgc" +#line 29 "app/dbio/vl_io_0019.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) @@ -124,7 +123,7 @@ int vl_io_0019_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0019_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +133,29 @@ int vl_io_0019_touch(const char *key, long amount) -#line 45 "app/dbio/vl_io_0019.pgc" - char h_key [ 16 ] ; +#line 44 "app/dbio/vl_io_0019.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/vl_io_0019.pgc" - long h_amount ; +#line 45 "app/dbio/vl_io_0019.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/vl_io_0019.pgc" +#line 46 "app/dbio/vl_io_0019.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0019_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_recon_ledger set book_amt = $1 where recon_key = $2 and recon_amt >= $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0019.pgc" - +#line 56 "app/dbio/vl_io_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0019_touch"); @@ -173,32 +172,52 @@ long vl_io_0019_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0019.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/vl_io_0019.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0019.pgc" - long h_sum ; +#line 70 "app/dbio/vl_io_0019.pgc" + long h_grp ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0019.pgc" +#line 71 "app/dbio/vl_io_0019.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0019_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_dt ), __LINE__);\ + /* declare vl_io_0019_total_cur cursor for select coalesce ( sum ( recon_amt ) , 0 ) from vl_recon_ledger where biz_date = $1 group by acct_no */ +#line 82 "app/dbio/vl_io_0019.pgc" + +#line 82 "app/dbio/vl_io_0019.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare vl_io_0019_total_cur cursor for select coalesce ( sum ( recon_amt ) , 0 ) from vl_recon_ledger where biz_date = $1 group by acct_no", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 83 "app/dbio/vl_io_0019.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch vl_io_0019_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 85 "app/dbio/vl_io_0019.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("vl_io_0019_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0019_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 90 "app/dbio/vl_io_0019.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("vl_io_0019_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0019_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 95 "app/dbio/vl_io_0019.pgc" + + return acc; } diff --git a/app/dbio/vl_io_0019.pgc b/app/dbio/vl_io_0019.pgc index 6b7bb16..0c4cdb7 100644 --- a/app/dbio/vl_io_0019.pgc +++ b/app/dbio/vl_io_0019.pgc @@ -14,20 +14,19 @@ EXEC SQL INCLUDE sqlca; int vl_io_0019_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0019_t - WHERE key = :h_key; + EXEC SQL SELECT recon_amt + INTO :h_val + FROM vl_recon_ledger + WHERE recon_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,28 +34,26 @@ int vl_io_0019_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0019_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int vl_io_0019_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0019_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE vl_recon_ledger + SET book_amt = :h_amt + WHERE recon_key = :h_key AND recon_amt >= :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0019_touch"); return TX_EDB; @@ -69,24 +66,32 @@ int vl_io_0019_touch(const char *key, long amount) long vl_io_0019_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM vl_io_0019_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("vl_io_0019_total"); - return -1; + EXEC SQL DECLARE vl_io_0019_total_cur CURSOR FOR + SELECT coalesce(sum(recon_amt), 0) FROM vl_recon_ledger + WHERE biz_date = :h_dt GROUP BY acct_no; + EXEC SQL OPEN vl_io_0019_total_cur; + for (;;) { + EXEC SQL FETCH vl_io_0019_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("vl_io_0019_total"); + EXEC SQL CLOSE vl_io_0019_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE vl_io_0019_total_cur; + return acc; } diff --git a/app/dbio/vl_io_0020.c b/app/dbio/vl_io_0020.c index 170b444..52e97ed 100644 --- a/app/dbio/vl_io_0020.c +++ b/app/dbio/vl_io_0020.c @@ -94,27 +94,30 @@ int vl_io_0020_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/vl_io_0020.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0020.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/vl_io_0020.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/vl_io_0020.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0020_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select book_amt from vl_recon_ledger where recon_key = $1 and match_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/vl_io_0020.pgc" @@ -124,7 +127,7 @@ int vl_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } @@ -135,35 +138,31 @@ int vl_io_0020_touch(const char *key, long amount) #line 45 "app/dbio/vl_io_0020.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/vl_io_0020.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/vl_io_0020.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0020_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into vl_recon_hist ( recon_key , recon_amt , chk_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0020.pgc" - +#line 56 "app/dbio/vl_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,27 +172,26 @@ long vl_io_0020_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0020.pgc" - char h_biz_date [ 9 ] ; +#line 67 "app/dbio/vl_io_0020.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0020.pgc" +#line 68 "app/dbio/vl_io_0020.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0020.pgc" +#line 69 "app/dbio/vl_io_0020.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0020_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( case when match_flag = 'Y' then recon_amt else 0 end ) , 0 ) from vl_recon_ledger where biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0020.pgc" +#line 79 "app/dbio/vl_io_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/vl_io_0020.pgc b/app/dbio/vl_io_0020.pgc index 6c637d5..cb62ed8 100644 --- a/app/dbio/vl_io_0020.pgc +++ b/app/dbio/vl_io_0020.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int vl_io_0020_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0020_t - WHERE key = :h_key; + EXEC SQL SELECT book_amt + INTO :h_val:h_ind + FROM vl_recon_ledger + WHERE recon_key = :h_key AND match_flag = 'Y'; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,54 +35,48 @@ int vl_io_0020_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0020_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = (h_ind < 0) ? 0 : h_val; return TX_OK; } int vl_io_0020_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0020_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO vl_recon_hist (recon_key, recon_amt, chk_ts) + VALUES (:h_key, :h_amt, now()); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0020_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long vl_io_0020_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(CASE WHEN match_flag = 'Y' THEN recon_amt ELSE 0 END), 0) INTO :h_sum - FROM vl_io_0020_t - WHERE biz_date = :h_biz_date; + FROM vl_recon_ledger + WHERE biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0020_total"); diff --git a/app/dbio/vl_io_0021.c b/app/dbio/vl_io_0021.c index 215b663..2355b7c 100644 --- a/app/dbio/vl_io_0021.c +++ b/app/dbio/vl_io_0021.c @@ -96,24 +96,23 @@ int vl_io_0021_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0021.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0021.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0021.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0021_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a . recon_amt from vl_recon_ledger a join vl_recon_src b on a . recon_key = b . recon_key where a . recon_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/vl_io_0021.pgc" @@ -124,7 +123,7 @@ int vl_io_0021_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0021_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -135,35 +134,31 @@ int vl_io_0021_touch(const char *key, long amount) #line 45 "app/dbio/vl_io_0021.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/vl_io_0021.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/vl_io_0021.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0021_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into vl_recon_ledger ( recon_key , recon_amt , chk_ts ) values ( $1 , $2 , now ( ) ) on conflict ( recon_key ) do update set recon_amt = excluded . recon_amt , chk_ts = now ( )", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} #line 58 "app/dbio/vl_io_0021.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0021_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } @@ -173,32 +168,31 @@ long vl_io_0021_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0021.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/vl_io_0021.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0021.pgc" - long h_sum ; +#line 70 "app/dbio/vl_io_0021.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0021.pgc" +#line 71 "app/dbio/vl_io_0021.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0021_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( distinct acct_no ) from vl_recon_ledger where biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0021.pgc" +#line 81 "app/dbio/vl_io_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0021_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/vl_io_0021.pgc b/app/dbio/vl_io_0021.pgc index 94be3fd..c85582c 100644 --- a/app/dbio/vl_io_0021.pgc +++ b/app/dbio/vl_io_0021.pgc @@ -14,20 +14,20 @@ EXEC SQL INCLUDE sqlca; int vl_io_0021_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0021_t - WHERE key = :h_key; + EXEC SQL SELECT a.recon_amt + INTO :h_val + FROM vl_recon_ledger a + JOIN vl_recon_src b ON a.recon_key = b.recon_key + WHERE a.recon_key = :h_key; if (sqlca.sqlcode == TX_SQL_NOTFOUND) return TX_ENOENT; @@ -35,58 +35,54 @@ int vl_io_0021_fetch(const char *key, long *out_amount) TX_DBIO_LOG_ERR("vl_io_0021_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int vl_io_0021_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0021_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL INSERT INTO vl_recon_ledger (recon_key, recon_amt, chk_ts) + VALUES (:h_key, :h_amt, now()) + ON CONFLICT (recon_key) + DO UPDATE SET recon_amt = excluded.recon_amt, chk_ts = now(); if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0021_touch"); return TX_EDB; } - if (sqlca.sqlerrd[2] == 0) - return TX_ENOENT; return TX_OK; } long vl_io_0021_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM vl_io_0021_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(distinct acct_no) + INTO :h_cnt + FROM vl_recon_ledger + WHERE biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0021_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/vl_io_0022.c b/app/dbio/vl_io_0022.c index 03bd2fd..09097f0 100644 --- a/app/dbio/vl_io_0022.c +++ b/app/dbio/vl_io_0022.c @@ -96,35 +96,32 @@ int vl_io_0022_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0022.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0022.pgc" - long h_amount ; + long h_flag ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0022.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0022_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select case when exists ( select 1 from vl_recon_ledger where recon_key = $1 and match_flag = 'N' ) then 1 else 0 end", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_flag),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/vl_io_0022.pgc" +#line 29 "app/dbio/vl_io_0022.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0022_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } @@ -134,29 +131,25 @@ int vl_io_0022_touch(const char *key, long amount) -#line 45 "app/dbio/vl_io_0022.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/vl_io_0022.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/vl_io_0022.pgc" - long h_amount ; +#line 43 "app/dbio/vl_io_0022.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/vl_io_0022.pgc" +#line 44 "app/dbio/vl_io_0022.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0022_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from vl_recon_hist where recon_key = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0022.pgc" - +#line 53 "app/dbio/vl_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0022_touch"); @@ -173,27 +166,26 @@ long vl_io_0022_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0022.pgc" - char h_biz_date [ 9 ] ; +#line 66 "app/dbio/vl_io_0022.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0022.pgc" +#line 67 "app/dbio/vl_io_0022.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0022.pgc" +#line 68 "app/dbio/vl_io_0022.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0022_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( recon_amt ) , 0 ) from vl_recon_ledger where biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0022.pgc" +#line 78 "app/dbio/vl_io_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/vl_io_0022.pgc b/app/dbio/vl_io_0022.pgc index 489c838..98e53d7 100644 --- a/app/dbio/vl_io_0022.pgc +++ b/app/dbio/vl_io_0022.pgc @@ -14,49 +14,43 @@ EXEC SQL INCLUDE sqlca; int vl_io_0022_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_flag; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0022_t - WHERE key = :h_key; + EXEC SQL SELECT CASE WHEN EXISTS ( + SELECT 1 FROM vl_recon_ledger + WHERE recon_key = :h_key AND match_flag = 'N') THEN 1 ELSE 0 END + INTO :h_flag; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0022_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_flag; return TX_OK; } int vl_io_0022_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0022_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM vl_recon_hist + WHERE recon_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0022_touch"); return TX_EDB; @@ -69,20 +63,19 @@ int vl_io_0022_touch(const char *key, long amount) long vl_io_0022_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(recon_amt), 0) INTO :h_sum - FROM vl_io_0022_t - WHERE biz_date = :h_biz_date; + FROM vl_recon_ledger + WHERE biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0022_total"); diff --git a/app/dbio/vl_io_0023.c b/app/dbio/vl_io_0023.c index e993e41..b236530 100644 --- a/app/dbio/vl_io_0023.c +++ b/app/dbio/vl_io_0023.c @@ -94,37 +94,40 @@ int vl_io_0023_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/vl_io_0023.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0023.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/vl_io_0023.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/vl_io_0023.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0023_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( recon_amt ) from vl_recon_ledger where acct_no = $1 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/vl_io_0023.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0023_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,26 @@ int vl_io_0023_touch(const char *key, long amount) #line 45 "app/dbio/vl_io_0023.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/vl_io_0023.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/vl_io_0023.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0023_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from vl_recon_hist where acct_no = $1 and recon_amt < $2 ", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0023.pgc" - +#line 56 "app/dbio/vl_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0023_touch"); @@ -173,32 +174,31 @@ long vl_io_0023_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0023.pgc" - char h_biz_date [ 9 ] ; +#line 69 "app/dbio/vl_io_0023.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0023.pgc" - long h_sum ; +#line 70 "app/dbio/vl_io_0023.pgc" + long h_cnt ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0023.pgc" +#line 71 "app/dbio/vl_io_0023.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0023_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from vl_recon_ledger where biz_date = $1 and match_flag = 'Y'", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0023.pgc" +#line 81 "app/dbio/vl_io_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0023_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/vl_io_0023.pgc b/app/dbio/vl_io_0023.pgc index 9530ee5..336df16 100644 --- a/app/dbio/vl_io_0023.pgc +++ b/app/dbio/vl_io_0023.pgc @@ -14,49 +14,46 @@ EXEC SQL INCLUDE sqlca; int vl_io_0023_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0023_t - WHERE key = :h_key; + EXEC SQL SELECT max(recon_amt) + INTO :h_val:h_ind + FROM vl_recon_ledger + WHERE acct_no = :h_key; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0023_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int vl_io_0023_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0023_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL DELETE FROM vl_recon_hist + WHERE acct_no = :h_key AND recon_amt < :h_amt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0023_touch"); return TX_EDB; @@ -69,24 +66,23 @@ int vl_io_0023_touch(const char *key, long amount) long vl_io_0023_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_cnt; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM vl_io_0023_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM vl_recon_ledger + WHERE biz_date = :h_dt AND match_flag = 'Y'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0023_total"); return -1; } - return h_sum; + return h_cnt; } diff --git a/app/dbio/vl_io_0024.c b/app/dbio/vl_io_0024.c index 87fc9f6..c864544 100644 --- a/app/dbio/vl_io_0024.c +++ b/app/dbio/vl_io_0024.c @@ -94,37 +94,40 @@ int vl_io_0024_fetch(const char *key, long *out_amount) /* exec sql begin declare section */ + #line 17 "app/dbio/vl_io_0024.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0024.pgc" - long h_amount ; -/* exec sql end declare section */ + long h_val ; + #line 19 "app/dbio/vl_io_0024.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 20 "app/dbio/vl_io_0024.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0024_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select min ( recon_amt ) from vl_recon_ledger where acct_no = $1 and match_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 30 "app/dbio/vl_io_0024.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0024_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } @@ -135,28 +138,28 @@ int vl_io_0024_touch(const char *key, long amount) #line 45 "app/dbio/vl_io_0024.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 46 "app/dbio/vl_io_0024.pgc" - long h_amount ; + long h_amt ; /* exec sql end declare section */ #line 47 "app/dbio/vl_io_0024.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0024_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_recon_ledger set recon_amt = recon_amt + $1 , match_flag = case when recon_amt + $2 > 0 then 'Y' else 'N' end , chk_ts = now ( ) where recon_key = $3 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0024.pgc" - +#line 59 "app/dbio/vl_io_0024.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0024_touch"); @@ -172,27 +175,30 @@ long vl_io_0024_total(const char *biz_date) /* exec sql begin declare section */ + #line 72 "app/dbio/vl_io_0024.pgc" - char h_biz_date [ 9 ] ; + char h_dt [ 16 ] ; #line 73 "app/dbio/vl_io_0024.pgc" - long h_sum ; -/* exec sql end declare section */ + long h_max ; + #line 74 "app/dbio/vl_io_0024.pgc" + short h_ind ; +/* exec sql end declare section */ +#line 75 "app/dbio/vl_io_0024.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0024_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max ( recon_amt ) from vl_recon_ledger where biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} + ECPGt_long,&(h_max),(long)1,(long)1,sizeof(long), + ECPGt_short,&(h_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} #line 85 "app/dbio/vl_io_0024.pgc" @@ -200,5 +206,7 @@ long vl_io_0024_total(const char *biz_date) TX_DBIO_LOG_ERR("vl_io_0024_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/vl_io_0024.pgc b/app/dbio/vl_io_0024.pgc index 62e53bf..c6f751e 100644 --- a/app/dbio/vl_io_0024.pgc +++ b/app/dbio/vl_io_0024.pgc @@ -14,49 +14,49 @@ EXEC SQL INCLUDE sqlca; int vl_io_0024_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; + short h_ind; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0024_t - WHERE key = :h_key; + EXEC SQL SELECT min(recon_amt) + INTO :h_val:h_ind + FROM vl_recon_ledger + WHERE acct_no = :h_key AND match_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0024_fetch"); return TX_EDB; } - *out_amount = h_amount; + if (h_ind < 0) + return TX_ENOENT; + *out_amount = h_val; return TX_OK; } int vl_io_0024_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0024_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE vl_recon_ledger + SET recon_amt = recon_amt + :h_amt, + match_flag = CASE WHEN recon_amt + :h_amt > 0 THEN 'Y' ELSE 'N' END, + chk_ts = now() + WHERE recon_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0024_touch"); return TX_EDB; @@ -69,24 +69,26 @@ int vl_io_0024_touch(const char *key, long amount) long vl_io_0024_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_max; + short h_ind; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM vl_io_0024_t - WHERE biz_date = :h_biz_date; + EXEC SQL SELECT max(recon_amt) + INTO :h_max:h_ind + FROM vl_recon_ledger + WHERE biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0024_total"); return -1; } - return h_sum; + if (h_ind < 0) + return 0; + return h_max; } diff --git a/app/dbio/vl_io_0025.c b/app/dbio/vl_io_0025.c index a1ad837..e724b9d 100644 --- a/app/dbio/vl_io_0025.c +++ b/app/dbio/vl_io_0025.c @@ -96,35 +96,32 @@ int vl_io_0025_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0025.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0025.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0025.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0025_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( recon_amt ) , 0 ) from vl_recon_ledger where acct_no = $1 and match_flag = 'Y'", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 30 "app/dbio/vl_io_0025.pgc" +#line 29 "app/dbio/vl_io_0025.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0025_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } @@ -134,29 +131,27 @@ int vl_io_0025_touch(const char *key, long amount) -#line 45 "app/dbio/vl_io_0025.pgc" - char h_key [ 16 ] ; +#line 42 "app/dbio/vl_io_0025.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/vl_io_0025.pgc" - long h_amount ; +#line 43 "app/dbio/vl_io_0025.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/vl_io_0025.pgc" +#line 44 "app/dbio/vl_io_0025.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0025_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_recon_ledger set recon_amt = $1 , chk_ts = now ( ) where recon_key = $2 ", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0025.pgc" - +#line 54 "app/dbio/vl_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0025_touch"); @@ -173,27 +168,26 @@ long vl_io_0025_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0025.pgc" - char h_biz_date [ 9 ] ; +#line 67 "app/dbio/vl_io_0025.pgc" + char h_dt [ 16 ] ; -#line 73 "app/dbio/vl_io_0025.pgc" +#line 68 "app/dbio/vl_io_0025.pgc" long h_sum ; /* exec sql end declare section */ -#line 74 "app/dbio/vl_io_0025.pgc" +#line 69 "app/dbio/vl_io_0025.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0025_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( a . recon_amt ) , 0 ) from vl_recon_ledger a join vl_recon_src b on a . recon_key = b . recon_key where a . biz_date = $1 ", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0025.pgc" +#line 80 "app/dbio/vl_io_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/dbio/vl_io_0025.pgc b/app/dbio/vl_io_0025.pgc index 1b6f110..cc6b3dd 100644 --- a/app/dbio/vl_io_0025.pgc +++ b/app/dbio/vl_io_0025.pgc @@ -14,49 +14,44 @@ EXEC SQL INCLUDE sqlca; int vl_io_0025_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0025_t - WHERE key = :h_key; + EXEC SQL SELECT coalesce(sum(recon_amt), 0) + INTO :h_val + FROM vl_recon_ledger + WHERE acct_no = :h_key AND match_flag = 'Y'; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) - return TX_ENOENT; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0025_fetch"); return TX_EDB; } - *out_amount = h_amount; + *out_amount = h_val; return TX_OK; } int vl_io_0025_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0025_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE vl_recon_ledger + SET recon_amt = :h_amt, chk_ts = now() + WHERE recon_key = :h_key; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0025_touch"); return TX_EDB; @@ -69,20 +64,20 @@ int vl_io_0025_touch(const char *key, long amount) long vl_io_0025_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; + char h_dt[16]; long h_sum; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; - - EXEC SQL SELECT coalesce(sum(amount), 0) + EXEC SQL SELECT coalesce(sum(a.recon_amt), 0) INTO :h_sum - FROM vl_io_0025_t - WHERE biz_date = :h_biz_date; + FROM vl_recon_ledger a + JOIN vl_recon_src b ON a.recon_key = b.recon_key + WHERE a.biz_date = :h_dt; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0025_total"); diff --git a/app/dbio/vl_io_0026.c b/app/dbio/vl_io_0026.c index 0aba6b6..c55b83a 100644 --- a/app/dbio/vl_io_0026.c +++ b/app/dbio/vl_io_0026.c @@ -96,35 +96,53 @@ int vl_io_0026_fetch(const char *key, long *out_amount) #line 17 "app/dbio/vl_io_0026.pgc" - char h_key [ 16 ] ; + char h_key [ 32 ] ; #line 18 "app/dbio/vl_io_0026.pgc" - long h_amount ; + long h_val ; /* exec sql end declare section */ #line 19 "app/dbio/vl_io_0026.pgc" if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from vl_io_0026_t where key = $1 ", - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGset_var( 0, ( h_key ), __LINE__);\ + /* declare vl_io_0026_fetch_cur cursor for select recon_amt from vl_recon_ledger where recon_key = $1 order by biz_date desc */ +#line 28 "app/dbio/vl_io_0026.pgc" + +#line 28 "app/dbio/vl_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare vl_io_0026_fetch_cur cursor for select recon_amt from vl_recon_ledger where recon_key = $1 order by biz_date desc", + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 29 "app/dbio/vl_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch vl_io_0026_fetch_cur", ECPGt_EOIT, + ECPGt_long,&(h_val),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} #line 30 "app/dbio/vl_io_0026.pgc" - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0026_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 33 "app/dbio/vl_io_0026.pgc" + return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0026_fetch"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0026_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 38 "app/dbio/vl_io_0026.pgc" + return TX_EDB; } - *out_amount = h_amount; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0026_fetch_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 41 "app/dbio/vl_io_0026.pgc" + + *out_amount = h_val; return TX_OK; } @@ -134,29 +152,27 @@ int vl_io_0026_touch(const char *key, long amount) -#line 45 "app/dbio/vl_io_0026.pgc" - char h_key [ 16 ] ; +#line 49 "app/dbio/vl_io_0026.pgc" + char h_key [ 32 ] ; -#line 46 "app/dbio/vl_io_0026.pgc" - long h_amount ; +#line 50 "app/dbio/vl_io_0026.pgc" + long h_amt ; /* exec sql end declare section */ -#line 47 "app/dbio/vl_io_0026.pgc" +#line 51 "app/dbio/vl_io_0026.pgc" if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; + h_amt = amount; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_io_0026_t set amount = $1 , upd_ts = now ( ) where key = $2 ", - ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update vl_recon_ledger set recon_amt = $1 , match_flag = 'Y' , chk_ts = now ( ) where recon_key = $2 and match_flag = 'N'", + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, - ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_char,(h_key),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 58 "app/dbio/vl_io_0026.pgc" - +#line 61 "app/dbio/vl_io_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0026_touch"); @@ -173,32 +189,52 @@ long vl_io_0026_total(const char *biz_date) -#line 72 "app/dbio/vl_io_0026.pgc" - char h_biz_date [ 9 ] ; - -#line 73 "app/dbio/vl_io_0026.pgc" - long h_sum ; -/* exec sql end declare section */ #line 74 "app/dbio/vl_io_0026.pgc" + char h_dt [ 16 ] ; + +#line 75 "app/dbio/vl_io_0026.pgc" + long h_grp ; +/* exec sql end declare section */ +#line 76 "app/dbio/vl_io_0026.pgc" if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) from vl_io_0026_t where biz_date = $1 ", - ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), - ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, - ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGset_var( 1, ( h_dt ), __LINE__);\ + /* declare vl_io_0026_total_cur cursor for select coalesce ( sum ( recon_amt ) , 0 ) from vl_recon_ledger where biz_date = $1 group by acct_no */ +#line 87 "app/dbio/vl_io_0026.pgc" + +#line 87 "app/dbio/vl_io_0026.pgc" + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare vl_io_0026_total_cur cursor for select coalesce ( sum ( recon_amt ) , 0 ) from vl_recon_ledger where biz_date = $1 group by acct_no", + ECPGt_char,(h_dt),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 88 "app/dbio/vl_io_0026.pgc" + + for (;;) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch vl_io_0026_total_cur", ECPGt_EOIT, + ECPGt_long,&(h_grp),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/dbio/vl_io_0026.pgc" +#line 90 "app/dbio/vl_io_0026.pgc" + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("vl_io_0026_total"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0026_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 95 "app/dbio/vl_io_0026.pgc" - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("vl_io_0026_total"); - return -1; + return -1; + } + acc += h_grp; } - return h_sum; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close vl_io_0026_total_cur", ECPGt_EOIT, ECPGt_EORT);} +#line 100 "app/dbio/vl_io_0026.pgc" + + return acc; } diff --git a/app/dbio/vl_io_0026.pgc b/app/dbio/vl_io_0026.pgc index f8ea192..2fc40ce 100644 --- a/app/dbio/vl_io_0026.pgc +++ b/app/dbio/vl_io_0026.pgc @@ -14,49 +14,51 @@ EXEC SQL INCLUDE sqlca; int vl_io_0026_fetch(const char *key, long *out_amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_val; EXEC SQL END DECLARE SECTION; if (!key || !out_amount) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL SELECT amount - INTO :h_amount - FROM vl_io_0026_t - WHERE key = :h_key; + EXEC SQL DECLARE vl_io_0026_fetch_cur CURSOR FOR + SELECT recon_amt FROM vl_recon_ledger + WHERE recon_key = :h_key ORDER BY biz_date DESC; + EXEC SQL OPEN vl_io_0026_fetch_cur; + EXEC SQL FETCH vl_io_0026_fetch_cur INTO :h_val; - if (sqlca.sqlcode == TX_SQL_NOTFOUND) + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + EXEC SQL CLOSE vl_io_0026_fetch_cur; return TX_ENOENT; + } if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0026_fetch"); + EXEC SQL CLOSE vl_io_0026_fetch_cur; return TX_EDB; } - *out_amount = h_amount; + EXEC SQL CLOSE vl_io_0026_fetch_cur; + *out_amount = h_val; return TX_OK; } int vl_io_0026_touch(const char *key, long amount) { EXEC SQL BEGIN DECLARE SECTION; - char h_key[16]; - long h_amount; + char h_key[32]; + long h_amt; EXEC SQL END DECLARE SECTION; if (!key) return TX_EINVAL; - strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - h_amount = amount; - - EXEC SQL UPDATE vl_io_0026_t - SET amount = :h_amount, upd_ts = now() - WHERE key = :h_key; + h_amt = amount; + EXEC SQL UPDATE vl_recon_ledger + SET recon_amt = :h_amt, match_flag = 'Y', chk_ts = now() + WHERE recon_key = :h_key AND match_flag = 'N'; if (sqlca.sqlcode != TX_SQL_OK) { TX_DBIO_LOG_ERR("vl_io_0026_touch"); return TX_EDB; @@ -69,24 +71,32 @@ int vl_io_0026_touch(const char *key, long amount) long vl_io_0026_total(const char *biz_date) { EXEC SQL BEGIN DECLARE SECTION; - char h_biz_date[9]; - long h_sum; + char h_dt[16]; + long h_grp; EXEC SQL END DECLARE SECTION; if (!biz_date) return -1; + strncpy(h_dt, biz_date, sizeof(h_dt) - 1); + h_dt[sizeof(h_dt) - 1] = '\0'; - strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1); - h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + long acc = 0; - EXEC SQL SELECT coalesce(sum(amount), 0) - INTO :h_sum - FROM vl_io_0026_t - WHERE biz_date = :h_biz_date; - - if (sqlca.sqlcode != TX_SQL_OK) { - TX_DBIO_LOG_ERR("vl_io_0026_total"); - return -1; + EXEC SQL DECLARE vl_io_0026_total_cur CURSOR FOR + SELECT coalesce(sum(recon_amt), 0) FROM vl_recon_ledger + WHERE biz_date = :h_dt GROUP BY acct_no; + EXEC SQL OPEN vl_io_0026_total_cur; + for (;;) { + EXEC SQL FETCH vl_io_0026_total_cur INTO :h_grp; + if (sqlca.sqlcode == TX_SQL_NOTFOUND) + break; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("vl_io_0026_total"); + EXEC SQL CLOSE vl_io_0026_total_cur; + return -1; + } + acc += h_grp; } - return h_sum; + EXEC SQL CLOSE vl_io_0026_total_cur; + return acc; } diff --git a/app/online/ac_ol_0001.c b/app/online/ac_ol_0001.c index caf1391..091387e 100644 --- a/app/online/ac_ol_0001.c +++ b/app/online/ac_ol_0001.c @@ -162,7 +162,7 @@ TX_SERVICE(AC_OL_0001, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 53 "app/online/ac_ol_0001.pgc" +#line 52 "app/online/ac_ol_0001.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/ac_ol_0001.pgc b/app/online/ac_ol_0001.pgc index af81839..1dde55b 100644 --- a/app/online/ac_ol_0001.pgc +++ b/app/online/ac_ol_0001.pgc @@ -46,8 +46,7 @@ TX_SERVICE(AC_OL_0001, ctx) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL - SELECT status, amount, fee, merch_id, card_no, biz_date + EXEC SQL SELECT status, amount, fee, merch_id, card_no, biz_date INTO :h_status, :h_amount, :h_fee, :h_merch_id, :h_card_no, :h_biz_date FROM ac_ledger WHERE key = :h_key; diff --git a/app/online/ac_ol_0002.c b/app/online/ac_ol_0002.c index 50a5018..4e13791 100644 --- a/app/online/ac_ol_0002.c +++ b/app/online/ac_ol_0002.c @@ -172,7 +172,7 @@ TX_SERVICE(AC_OL_0002, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_limit_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 72 "app/online/ac_ol_0002.pgc" +#line 71 "app/online/ac_ol_0002.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -201,7 +201,7 @@ TX_SERVICE(AC_OL_0002, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_dup),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 98 "app/online/ac_ol_0002.pgc" +#line 96 "app/online/ac_ol_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { diff --git a/app/online/ac_ol_0002.pgc b/app/online/ac_ol_0002.pgc index cb1ec10..e2c9061 100644 --- a/app/online/ac_ol_0002.pgc +++ b/app/online/ac_ol_0002.pgc @@ -65,8 +65,7 @@ TX_SERVICE(AC_OL_0002, ctx) h_merch_id[sizeof(h_merch_id) - 1] = '\0'; strncpy(h_status, "A", sizeof(h_status)); - EXEC SQL - SELECT fee_rate, limit_amt INTO :h_fee_rate, :h_limit_amt + EXEC SQL SELECT fee_rate, limit_amt INTO :h_fee_rate, :h_limit_amt FROM merchant WHERE merch_id = :h_merch_id AND status = :h_status; @@ -92,8 +91,7 @@ TX_SERVICE(AC_OL_0002, ctx) return; } - EXEC SQL - SELECT count(*) INTO :h_dup + EXEC SQL SELECT count(*) INTO :h_dup FROM ac_ledger WHERE key = :h_key; diff --git a/app/online/ac_ol_0003.c b/app/online/ac_ol_0003.c index b6d9787..3b856aa 100644 --- a/app/online/ac_ol_0003.c +++ b/app/online/ac_ol_0003.c @@ -180,7 +180,7 @@ TX_SERVICE(AC_OL_0003, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_merch_active),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 72 "app/online/ac_ol_0003.pgc" +#line 71 "app/online/ac_ol_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -201,7 +201,7 @@ TX_SERVICE(AC_OL_0003, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_dup),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 90 "app/online/ac_ol_0003.pgc" +#line 88 "app/online/ac_ol_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -247,7 +247,7 @@ TX_SERVICE(AC_OL_0003, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_acq_type),(long)4,(long)1,(4)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 123 "app/online/ac_ol_0003.pgc" +#line 120 "app/online/ac_ol_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK || sqlca.sqlerrd[2] != 1) { diff --git a/app/online/ac_ol_0003.pgc b/app/online/ac_ol_0003.pgc index 012045c..9e96b12 100644 --- a/app/online/ac_ol_0003.pgc +++ b/app/online/ac_ol_0003.pgc @@ -65,8 +65,7 @@ TX_SERVICE(AC_OL_0003, ctx) strncpy(h_merch_id, merch, sizeof(h_merch_id) - 1); h_merch_id[sizeof(h_merch_id) - 1] = '\0'; - EXEC SQL - SELECT count(*) INTO :h_merch_active + EXEC SQL SELECT count(*) INTO :h_merch_active FROM merchant WHERE merch_id = :h_merch_id AND status = 'A'; @@ -84,8 +83,7 @@ TX_SERVICE(AC_OL_0003, ctx) return; } - EXEC SQL - SELECT count(*) INTO :h_dup + EXEC SQL SELECT count(*) INTO :h_dup FROM ac_ledger WHERE key = :h_key; @@ -115,8 +113,7 @@ TX_SERVICE(AC_OL_0003, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[AC_OL_0003] tx_begin 경고"); - EXEC SQL - INSERT INTO ac_ledger + EXEC SQL INSERT INTO ac_ledger (key, merch_id, card_no, amount, biz_date, status, fee, acq_type) VALUES (:h_key, :h_merch_id, :h_card_no, :h_amount, :h_biz_date, diff --git a/app/online/ac_ol_0004.c b/app/online/ac_ol_0004.c index c61c294..200047e 100644 --- a/app/online/ac_ol_0004.c +++ b/app/online/ac_ol_0004.c @@ -173,7 +173,7 @@ TX_SERVICE(AC_OL_0004, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_appr_status),(long)2,(long)1,(2)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 59 "app/online/ac_ol_0004.pgc" +#line 58 "app/online/ac_ol_0004.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -234,7 +234,7 @@ TX_SERVICE(AC_OL_0004, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_appr_no),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 106 "app/online/ac_ol_0004.pgc" +#line 104 "app/online/ac_ol_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK || sqlca.sqlerrd[2] != 1) { diff --git a/app/online/ac_ol_0004.pgc b/app/online/ac_ol_0004.pgc index f446cf4..2854701 100644 --- a/app/online/ac_ol_0004.pgc +++ b/app/online/ac_ol_0004.pgc @@ -52,8 +52,7 @@ TX_SERVICE(AC_OL_0004, ctx) strncpy(h_appr_no, apprno, sizeof(h_appr_no) - 1); h_appr_no[sizeof(h_appr_no) - 1] = '\0'; - EXEC SQL - SELECT amount, merch_id, card_no, appr_status + EXEC SQL SELECT amount, merch_id, card_no, appr_status INTO :h_amount, :h_merch_id, :h_card_no, :h_appr_status FROM approval WHERE approval_no = :h_appr_no; @@ -97,8 +96,7 @@ TX_SERVICE(AC_OL_0004, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[AC_OL_0004] tx_begin 경고"); - EXEC SQL - INSERT INTO ac_ledger + EXEC SQL INSERT INTO ac_ledger (key, merch_id, card_no, amount, biz_date, status, fee, acq_type, approval_no) VALUES diff --git a/app/online/ac_ol_0005.c b/app/online/ac_ol_0005.c index 36618ae..b803a3c 100644 --- a/app/online/ac_ol_0005.c +++ b/app/online/ac_ol_0005.c @@ -151,7 +151,7 @@ TX_SERVICE(AC_OL_0005, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 54 "app/online/ac_ol_0005.pgc" +#line 53 "app/online/ac_ol_0005.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -192,7 +192,7 @@ TX_SERVICE(AC_OL_0005, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 93 "app/online/ac_ol_0005.pgc" +#line 91 "app/online/ac_ol_0005.pgc" if (sqlca.sqlcode != TX_SQL_OK || sqlca.sqlerrd[2] != 1) { diff --git a/app/online/ac_ol_0005.pgc b/app/online/ac_ol_0005.pgc index 223382b..e58e8d0 100644 --- a/app/online/ac_ol_0005.pgc +++ b/app/online/ac_ol_0005.pgc @@ -47,8 +47,7 @@ TX_SERVICE(AC_OL_0005, ctx) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL - SELECT status, amount, biz_date + EXEC SQL SELECT status, amount, biz_date INTO :h_status, :h_amount, :h_biz_date FROM ac_ledger WHERE key = :h_key; @@ -86,8 +85,7 @@ TX_SERVICE(AC_OL_0005, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[AC_OL_0005] tx_begin 경고"); - EXEC SQL - UPDATE ac_ledger + EXEC SQL UPDATE ac_ledger SET status = :h_cancel_status, upd_ts = now() WHERE key = :h_key; diff --git a/app/online/ac_ol_0006.c b/app/online/ac_ol_0006.c index f128c57..33fee99 100644 --- a/app/online/ac_ol_0006.c +++ b/app/online/ac_ol_0006.c @@ -184,7 +184,7 @@ TX_SERVICE(AC_OL_0006, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 65 "app/online/ac_ol_0006.pgc" +#line 64 "app/online/ac_ol_0006.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -205,7 +205,7 @@ TX_SERVICE(AC_OL_0006, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_fee_rate),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 83 "app/online/ac_ol_0006.pgc" +#line 81 "app/online/ac_ol_0006.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -230,7 +230,7 @@ TX_SERVICE(AC_OL_0006, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 105 "app/online/ac_ol_0006.pgc" +#line 102 "app/online/ac_ol_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK || sqlca.sqlerrd[2] != 1) { @@ -266,7 +266,7 @@ TX_SERVICE(AC_OL_0006, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 129 "app/online/ac_ol_0006.pgc" +#line 125 "app/online/ac_ol_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK || sqlca.sqlerrd[2] != 1) { diff --git a/app/online/ac_ol_0006.pgc b/app/online/ac_ol_0006.pgc index a0a4dc1..60dde04 100644 --- a/app/online/ac_ol_0006.pgc +++ b/app/online/ac_ol_0006.pgc @@ -58,8 +58,7 @@ TX_SERVICE(AC_OL_0006, ctx) tx_log(TX_LOG_WARN, "[AC_OL_0006] tx_begin 경고"); } - EXEC SQL - SELECT amount, fee, merch_id, card_no, biz_date + EXEC SQL SELECT amount, fee, merch_id, card_no, biz_date INTO :h_old_amount, :h_old_fee, :h_merch_id, :h_card_no, :h_biz_date FROM ac_ledger WHERE key = :h_key; @@ -77,8 +76,7 @@ TX_SERVICE(AC_OL_0006, ctx) return; } - EXEC SQL - SELECT fee_rate INTO :h_fee_rate + EXEC SQL SELECT fee_rate INTO :h_fee_rate FROM merchant WHERE merch_id = :h_merch_id; @@ -97,8 +95,7 @@ TX_SERVICE(AC_OL_0006, ctx) h_new_fee = h_new_amount * h_fee_rate / 10000; - EXEC SQL - UPDATE ac_ledger + EXEC SQL UPDATE ac_ledger SET amount = :h_new_amount, fee = :h_new_fee, upd_ts = now() @@ -120,8 +117,7 @@ TX_SERVICE(AC_OL_0006, ctx) strcat(h_corr_key, "-C"); strncpy(h_status, AC_ST_DONE, sizeof(h_status)); - EXEC SQL - INSERT INTO ac_ledger + EXEC SQL INSERT INTO ac_ledger (key, merch_id, card_no, amount, biz_date, status, fee, acq_type, orig_key) VALUES diff --git a/app/online/ac_ol_0007.c b/app/online/ac_ol_0007.c index 0d2c133..8646329 100644 --- a/app/online/ac_ol_0007.c +++ b/app/online/ac_ol_0007.c @@ -168,7 +168,7 @@ TX_SERVICE(AC_OL_0007, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 57 "app/online/ac_ol_0007.pgc" +#line 56 "app/online/ac_ol_0007.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -200,7 +200,7 @@ TX_SERVICE(AC_OL_0007, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 87 "app/online/ac_ol_0007.pgc" +#line 85 "app/online/ac_ol_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK || sqlca.sqlerrd[2] != 1) { @@ -234,7 +234,7 @@ TX_SERVICE(AC_OL_0007, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 111 "app/online/ac_ol_0007.pgc" +#line 108 "app/online/ac_ol_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK || sqlca.sqlerrd[2] != 1) { diff --git a/app/online/ac_ol_0007.pgc b/app/online/ac_ol_0007.pgc index 93c0732..4c2b88e 100644 --- a/app/online/ac_ol_0007.pgc +++ b/app/online/ac_ol_0007.pgc @@ -50,8 +50,7 @@ TX_SERVICE(AC_OL_0007, ctx) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL - SELECT amount, merch_id, card_no, biz_date + EXEC SQL SELECT amount, merch_id, card_no, biz_date INTO :h_orig_amount, :h_merch_id, :h_card_no, :h_biz_date FROM ac_ledger WHERE key = :h_key; @@ -80,8 +79,7 @@ TX_SERVICE(AC_OL_0007, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[AC_OL_0007] tx_begin 경고"); - EXEC SQL - UPDATE ac_ledger + EXEC SQL UPDATE ac_ledger SET amount = :h_remaining, upd_ts = now() WHERE key = :h_key; @@ -102,8 +100,7 @@ TX_SERVICE(AC_OL_0007, ctx) strcat(h_part_key, "-P"); strncpy(h_status, AC_ST_DONE, sizeof(h_status)); - EXEC SQL - INSERT INTO ac_ledger + EXEC SQL INSERT INTO ac_ledger (key, merch_id, card_no, amount, biz_date, status, fee, acq_type, orig_key) VALUES diff --git a/app/online/ac_ol_0008.c b/app/online/ac_ol_0008.c index f4c6875..84ba249 100644 --- a/app/online/ac_ol_0008.c +++ b/app/online/ac_ol_0008.c @@ -220,7 +220,7 @@ TX_SERVICE(AC_OL_0008, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,&(h_install_month),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 103 "app/online/ac_ol_0008.pgc" +#line 102 "app/online/ac_ol_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK || sqlca.sqlerrd[2] != 1) { diff --git a/app/online/ac_ol_0008.pgc b/app/online/ac_ol_0008.pgc index a4dc157..2eb80a8 100644 --- a/app/online/ac_ol_0008.pgc +++ b/app/online/ac_ol_0008.pgc @@ -94,8 +94,7 @@ TX_SERVICE(AC_OL_0008, ctx) h_row_fee = row_amt * 25 / 10000; /* 할부 수수료 0.25% */ h_install_month = i; - EXEC SQL - INSERT INTO ac_ledger + EXEC SQL INSERT INTO ac_ledger (key, merch_id, card_no, amount, biz_date, status, fee, acq_type, install_month) VALUES diff --git a/app/online/ac_ol_0025.c b/app/online/ac_ol_0025.c index 0fe2841..dee3bcf 100644 --- a/app/online/ac_ol_0025.c +++ b/app/online/ac_ol_0025.c @@ -171,7 +171,7 @@ TX_SERVICE(AC_OL_0025, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_totamt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 77 "app/online/ac_ol_0025.pgc" +#line 76 "app/online/ac_ol_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -195,7 +195,7 @@ TX_SERVICE(AC_OL_0025, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_char,(h_oldest),(long)16,(long)1,(16)*sizeof(char), ECPGt_short,&(h_oldest_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);} -#line 100 "app/online/ac_ol_0025.pgc" +#line 98 "app/online/ac_ol_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { diff --git a/app/online/ac_ol_0025.pgc b/app/online/ac_ol_0025.pgc index d3e34a2..340b2ce 100644 --- a/app/online/ac_ol_0025.pgc +++ b/app/online/ac_ol_0025.pgc @@ -69,8 +69,7 @@ TX_SERVICE(AC_OL_0025, ctx) } /* ---- 3. 미매입 접수건 집계 (건수 + 합계금액) ---- */ - EXEC SQL - SELECT COUNT(*), COALESCE(SUM(amount), 0) + EXEC SQL SELECT COUNT(*), COALESCE(SUM(amount), 0) INTO :h_cnt, :h_totamt FROM ac_ledger WHERE biz_date <= :h_biz_date @@ -92,8 +91,7 @@ TX_SERVICE(AC_OL_0025, ctx) memset(h_oldest, 0, sizeof(h_oldest)); h_oldest_ind = -1; - EXEC SQL - SELECT MIN(key) + EXEC SQL SELECT MIN(key) INTO :h_oldest:h_oldest_ind FROM ac_ledger WHERE biz_date <= :h_biz_date diff --git a/app/online/ac_ol_0027.c b/app/online/ac_ol_0027.c index 53ad606..840e11c 100644 --- a/app/online/ac_ol_0027.c +++ b/app/online/ac_ol_0027.c @@ -170,7 +170,7 @@ TX_SERVICE(AC_OL_0027, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_totfee),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 67 "app/online/ac_ol_0027.pgc" +#line 66 "app/online/ac_ol_0027.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { diff --git a/app/online/ac_ol_0027.pgc b/app/online/ac_ol_0027.pgc index 7ff3fd9..c80a0d7 100644 --- a/app/online/ac_ol_0027.pgc +++ b/app/online/ac_ol_0027.pgc @@ -59,8 +59,7 @@ TX_SERVICE(AC_OL_0027, ctx) h_status_settled[sizeof(h_status_settled) - 1] = '\0'; /* ---- 2. 완료 + 정산완료 건 집계 ---- */ - EXEC SQL - SELECT COUNT(*), COALESCE(SUM(amount), 0), COALESCE(SUM(fee), 0) + EXEC SQL SELECT COUNT(*), COALESCE(SUM(amount), 0), COALESCE(SUM(fee), 0) INTO :h_cnt, :h_tot, :h_totfee FROM ac_ledger WHERE biz_date = :h_biz_date diff --git a/app/online/ac_ol_0029.c b/app/online/ac_ol_0029.c index 47b94ea..77ce1ab 100644 --- a/app/online/ac_ol_0029.c +++ b/app/online/ac_ol_0029.c @@ -174,7 +174,7 @@ TX_SERVICE(AC_OL_0029, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_status),(long)2,(long)1,(2)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 70 "app/online/ac_ol_0029.pgc" +#line 69 "app/online/ac_ol_0029.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/ac_ol_0029.pgc b/app/online/ac_ol_0029.pgc index 27b6ca2..9daa192 100644 --- a/app/online/ac_ol_0029.pgc +++ b/app/online/ac_ol_0029.pgc @@ -63,8 +63,7 @@ TX_SERVICE(AC_OL_0029, ctx) strncpy(h_claim_no, claimno, sizeof(h_claim_no) - 1); /* ---- 3. 청구내역 단건 조회 ---- */ - EXEC SQL - SELECT merch_id, biz_date, amount, file_seq, status + EXEC SQL SELECT merch_id, biz_date, amount, file_seq, status INTO :h_merch_id, :h_biz_date, :h_amount, :h_file_seq, :h_status FROM ac_claim WHERE claim_no = :h_claim_no; diff --git a/app/online/ac_ol_0030.c b/app/online/ac_ol_0030.c index 9984420..f8cd6ac 100644 --- a/app/online/ac_ol_0030.c +++ b/app/online/ac_ol_0030.c @@ -175,7 +175,7 @@ TX_SERVICE(AC_OL_0030, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_dupcnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 76 "app/online/ac_ol_0030.pgc" +#line 75 "app/online/ac_ol_0030.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -223,7 +223,7 @@ TX_SERVICE(AC_OL_0030, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 118 "app/online/ac_ol_0030.pgc" +#line 116 "app/online/ac_ol_0030.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/ac_ol_0030.pgc b/app/online/ac_ol_0030.pgc index 9396655..c74ae2c 100644 --- a/app/online/ac_ol_0030.pgc +++ b/app/online/ac_ol_0030.pgc @@ -66,8 +66,7 @@ TX_SERVICE(AC_OL_0030, ctx) h_status_fail[sizeof(h_status_fail) - 1] = '\0'; /* ---- 2. 중복 집합 크기 사전 확인 ---- */ - EXEC SQL - SELECT COUNT(*) + EXEC SQL SELECT COUNT(*) INTO :h_dupcnt FROM ac_ledger WHERE merch_id = :h_merch_id @@ -101,8 +100,7 @@ TX_SERVICE(AC_OL_0030, ctx) return; } - EXEC SQL - UPDATE ac_ledger + EXEC SQL UPDATE ac_ledger SET status = :h_status_fail, upd_ts = now() WHERE merch_id = :h_merch_id AND card_no = :h_card_no diff --git a/app/online/ac_ol_0031.c b/app/online/ac_ol_0031.c index badd8d9..ee56706 100644 --- a/app/online/ac_ol_0031.c +++ b/app/online/ac_ol_0031.c @@ -149,7 +149,7 @@ TX_SERVICE(AC_OL_0031, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_char,(h_status),(long)2,(long)1,(2)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 59 "app/online/ac_ol_0031.pgc" +#line 58 "app/online/ac_ol_0031.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -193,7 +193,7 @@ TX_SERVICE(AC_OL_0031, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 100 "app/online/ac_ol_0031.pgc" +#line 98 "app/online/ac_ol_0031.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/ac_ol_0031.pgc b/app/online/ac_ol_0031.pgc index b8bfda3..725ce54 100644 --- a/app/online/ac_ol_0031.pgc +++ b/app/online/ac_ol_0031.pgc @@ -52,8 +52,7 @@ TX_SERVICE(AC_OL_0031, ctx) h_status_settled[sizeof(h_status_settled) - 1] = '\0'; /* ---- 2. 현재 상태 조회 ---- */ - EXEC SQL - SELECT status + EXEC SQL SELECT status INTO :h_status FROM ac_ledger WHERE key = :h_key; @@ -94,8 +93,7 @@ TX_SERVICE(AC_OL_0031, ctx) return; } - EXEC SQL - UPDATE ac_ledger + EXEC SQL UPDATE ac_ledger SET hold_yn = :h_hold, upd_ts = now() WHERE key = :h_key; diff --git a/app/online/ac_ol_0032.c b/app/online/ac_ol_0032.c index 84f1964..8a4f300 100644 --- a/app/online/ac_ol_0032.c +++ b/app/online/ac_ol_0032.c @@ -154,7 +154,7 @@ TX_SERVICE(AC_OL_0032, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_appr_amount),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 60 "app/online/ac_ol_0032.pgc" +#line 59 "app/online/ac_ol_0032.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -188,7 +188,7 @@ TX_SERVICE(AC_OL_0032, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 89 "app/online/ac_ol_0032.pgc" +#line 87 "app/online/ac_ol_0032.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/ac_ol_0032.pgc b/app/online/ac_ol_0032.pgc index 7394f03..38c21e6 100644 --- a/app/online/ac_ol_0032.pgc +++ b/app/online/ac_ol_0032.pgc @@ -52,8 +52,7 @@ TX_SERVICE(AC_OL_0032, ctx) h_status_done[sizeof(h_status_done) - 1] = '\0'; /* ---- 2. 신규 승인번호 유효성 확인 (정상승인 건만 매핑 허용) ---- */ - EXEC SQL - SELECT amount + EXEC SQL SELECT amount INTO :h_appr_amount FROM approval WHERE approval_no = :h_new_appr @@ -83,8 +82,7 @@ TX_SERVICE(AC_OL_0032, ctx) return; } - EXEC SQL - UPDATE ac_ledger + EXEC SQL UPDATE ac_ledger SET approval_no = :h_new_appr, status = :h_status_done, upd_ts = now() WHERE key = :h_key; diff --git a/app/online/au_ol_0001.c b/app/online/au_ol_0001.c index 968cfcc..2058b77 100644 --- a/app/online/au_ol_0001.c +++ b/app/online/au_ol_0001.c @@ -10,13 +10,15 @@ /* * au_ol_0001.pgc - 승인한도 온라인 서비스 (AU_OL_0001) [tier=easy] * - * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 au 표준 DBIO 를 - * 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응) + * 처리키(KEY)로 승인원장을 조회하고, 해당 가맹점의 승인한도 마스터 + * (au_limit)에서 일한도/기사용액을 임베디드 SQL 로 읽어 가용한도 + * (avail = daily_limit - used_amt)를 산출해 함께 응답한다. (조회 전용) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "au_core.h" @@ -89,13 +91,32 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/au_ol_0001.pgc" +#line 17 "app/online/au_ol_0001.pgc" TX_SERVICE(AU_OL_0001, ctx) { + /* exec sql begin declare section */ + + + + +#line 22 "app/online/au_ol_0001.pgc" + char h_merch_id [ 16 ] ; + +#line 23 "app/online/au_ol_0001.pgc" + long h_daily_limit ; + +#line 24 "app/online/au_ol_0001.pgc" + long h_used_amt ; +/* exec sql end declare section */ +#line 25 "app/online/au_ol_0001.pgc" + + au_rec_t rec; char key[16]; + char avail_won[32]; + long avail; int rc; tx_log(TX_LOG_INFO, "[AU_OL_0001] 승인한도 단건조회 서비스 진입"); @@ -115,11 +136,46 @@ TX_SERVICE(AU_OL_0001, ctx) return; } + /* 가맹점 승인한도 마스터 조회 (임베디드 SQL) */ + strncpy(h_merch_id, rec.merch_id, sizeof(h_merch_id) - 1); + h_merch_id[sizeof(h_merch_id) - 1] = '\0'; + h_daily_limit = 0; + h_used_amt = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select daily_limit , used_amt from au_limit where merch_id = $1 ", + ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_daily_limit),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_used_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 59 "app/online/au_ol_0001.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[AU_OL_0001] 한도마스터 미등록 merch=%s", rec.merch_id); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT au_limit"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + avail = h_daily_limit - h_used_amt; + if (avail < 0) + avail = 0; + amount_format_won(avail, avail_won, sizeof(avail_won)); + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); tx_buf_sets(ctx->out, "STATUS", rec.status); - tx_log(TX_LOG_INFO, "[AU_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); + tx_buf_setlong(ctx->out, "DAILYLIMIT", h_daily_limit); + tx_buf_setlong(ctx->out, "USEDAMT", h_used_amt); + tx_buf_setlong(ctx->out, "AVAIL", avail); + tx_buf_sets(ctx->out, "AVAILWON", avail_won); + + tx_log(TX_LOG_INFO, "[AU_OL_0001] 조회완료 key=%s amount=%ld 가용한도=%ld", + key, rec.amount, avail); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/au_ol_0001.pgc b/app/online/au_ol_0001.pgc index f9459e9..9ca27a8 100644 --- a/app/online/au_ol_0001.pgc +++ b/app/online/au_ol_0001.pgc @@ -2,13 +2,15 @@ /* * au_ol_0001.pgc - 승인한도 온라인 서비스 (AU_OL_0001) [tier=easy] * - * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 au 표준 DBIO 를 - * 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응) + * 처리키(KEY)로 승인원장을 조회하고, 해당 가맹점의 승인한도 마스터 + * (au_limit)에서 일한도/기사용액을 임베디드 SQL 로 읽어 가용한도 + * (avail = daily_limit - used_amt)를 산출해 함께 응답한다. (조회 전용) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "au_core.h" @@ -16,8 +18,16 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(AU_OL_0001, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch_id[16]; + long h_daily_limit; + long h_used_amt; + EXEC SQL END DECLARE SECTION; + au_rec_t rec; char key[16]; + char avail_won[32]; + long avail; int rc; tx_log(TX_LOG_INFO, "[AU_OL_0001] 승인한도 단건조회 서비스 진입"); @@ -37,11 +47,41 @@ TX_SERVICE(AU_OL_0001, ctx) return; } + /* 가맹점 승인한도 마스터 조회 (임베디드 SQL) */ + strncpy(h_merch_id, rec.merch_id, sizeof(h_merch_id) - 1); + h_merch_id[sizeof(h_merch_id) - 1] = '\0'; + h_daily_limit = 0; + h_used_amt = 0; + + EXEC SQL SELECT daily_limit, used_amt + INTO :h_daily_limit, :h_used_amt + FROM au_limit + WHERE merch_id = :h_merch_id; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[AU_OL_0001] 한도마스터 미등록 merch=%s", rec.merch_id); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT au_limit"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + avail = h_daily_limit - h_used_amt; + if (avail < 0) + avail = 0; + amount_format_won(avail, avail_won, sizeof(avail_won)); + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); tx_buf_sets(ctx->out, "STATUS", rec.status); - tx_log(TX_LOG_INFO, "[AU_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); + tx_buf_setlong(ctx->out, "DAILYLIMIT", h_daily_limit); + tx_buf_setlong(ctx->out, "USEDAMT", h_used_amt); + tx_buf_setlong(ctx->out, "AVAIL", avail); + tx_buf_sets(ctx->out, "AVAILWON", avail_won); + + tx_log(TX_LOG_INFO, "[AU_OL_0001] 조회완료 key=%s amount=%ld 가용한도=%ld", + key, rec.amount, avail); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/au_ol_0008.c b/app/online/au_ol_0008.c index 7741788..c5c577a 100644 --- a/app/online/au_ol_0008.c +++ b/app/online/au_ol_0008.c @@ -10,8 +10,10 @@ /* * au_ol_0008.pgc - 승인요청 매입사 중계(tx_call) (AU_OL_0008) [tier=hard] * - * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 임베디드 SQL / 표준 - * DBIO / tx_call 로 처리한 뒤 응답 TXBUF 를 구성한다. + * 요청 승인건에 대해 가맹점 승인한도(au_limit)를 임베디드 SQL 로 확인하고, + * 승인요청 이력행(au_appr_req)을 적재한 뒤 매입사(AU_ISSUER)로 tx_call + * 중계한다. 매입사 승인응답이 정상이면 가맹점 기사용액(used_amt)을 증액 + * 반영한다. 원장 반영은 하나의 트랜잭션으로 처리한다. */ #include #include @@ -90,32 +92,116 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/au_ol_0008.pgc" +#line 18 "app/online/au_ol_0008.pgc" TX_SERVICE(AU_OL_0008, ctx) { - char key[16]; - if (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) != TX_OK) { - tx_log(TX_LOG_ERROR, "[AU_OL_0008] KEY 누락"); - tx_return(ctx, TX_EINVAL, ctx->out); - return; - } + /* exec sql begin declare section */ + + + + + + + +#line 23 "app/online/au_ol_0008.pgc" + char h_key [ 16 ] ; + +#line 24 "app/online/au_ol_0008.pgc" + char h_merch_id [ 16 ] ; + +#line 25 "app/online/au_ol_0008.pgc" + char h_card_no [ 20 ] ; + +#line 26 "app/online/au_ol_0008.pgc" + long h_amount ; + +#line 27 "app/online/au_ol_0008.pgc" + long h_daily_limit ; + +#line 28 "app/online/au_ol_0008.pgc" + long h_used_amt ; +/* exec sql end declare section */ +#line 29 "app/online/au_ol_0008.pgc" + + TXBUF *req; - char merch[16], card[20], resp[8]; - long amount = 0; + char key[16], merch[16], card[20], resp[8]; + long amount = 0, avail; int rc; tx_log(TX_LOG_INFO, "[AU_OL_0008] 승인요청 중계 진입"); - if (tx_buf_get(ctx->in, "MERCHID", merch, sizeof(merch)) != TX_OK || + + if (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) != TX_OK || + tx_buf_get(ctx->in, "MERCHID", merch, sizeof(merch)) != TX_OK || tx_buf_get(ctx->in, "CARDNO", card, sizeof(card)) != TX_OK) { + tx_log(TX_LOG_ERROR, "[AU_OL_0008] 필수 필드 누락"); tx_return(ctx, TX_EINVAL, ctx->out); return; } tx_buf_getlong(ctx->in, "AMOUNT", &amount); + strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + strncpy(h_merch_id, merch, sizeof(h_merch_id) - 1); h_merch_id[sizeof(h_merch_id) - 1] = '\0'; + strncpy(h_card_no, card, sizeof(h_card_no) - 1); h_card_no[sizeof(h_card_no) - 1] = '\0'; + h_amount = amount; + + /* 1) 가맹점 승인한도 확인 */ + h_daily_limit = 0; + h_used_amt = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select daily_limit , used_amt from au_limit where merch_id = $1 ", + ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_daily_limit),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_used_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 58 "app/online/au_ol_0008.pgc" + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT au_limit"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + avail = h_daily_limit - h_used_amt; + if (h_daily_limit > 0 && amount > avail) { + tx_log(TX_LOG_WARN, "[AU_OL_0008] 한도초과 merch=%s req=%ld avail=%ld", + merch, amount, avail); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); + tx_return(ctx, TX_EINVAL, ctx->out); + return; + } + + /* 2) 승인요청 이력행 적재 (요청상태 'Q') */ + if (tx_begin() != TX_OK) { + tx_log(TX_LOG_ERROR, "[AU_OL_0008] 트랜잭션 시작 실패"); + tx_return(ctx, TX_FAIL, ctx->out); + return; + } + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into au_appr_req ( req_key , merch_id , card_no , req_amount , req_status ) values ( $1 , $2 , $3 , $4 , 'Q' )", + 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_char,(h_card_no),(long)20,(long)1,(20)*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_EOIT, ECPGt_EORT);} +#line 83 "app/online/au_ol_0008.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT au_appr_req"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + /* 3) 매입사 중계 (tx_call) */ req = tx_buf_alloc(); if (!req) { + tx_abort(); tx_return(ctx, TX_ENOMEM, ctx->out); return; } @@ -129,6 +215,7 @@ TX_SERVICE(AU_OL_0008, ctx) tx_buf_free(req); if (rc != TX_OK) { tx_log(TX_LOG_ERROR, "[AU_OL_0008] 매입사 중계 실패 rc=%d(%s)", rc, tx_strerror(rc)); + tx_abort(); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); tx_return(ctx, rc, ctx->out); @@ -137,6 +224,37 @@ TX_SERVICE(AU_OL_0008, ctx) if (tx_buf_get(ctx->out, "RESPCODE", resp, sizeof(resp)) != TX_OK) strcpy(resp, RESP_OK); - tx_log(TX_LOG_INFO, "[AU_OL_0008] 중계 응답 key=%s resp=%s", key, resp); + + /* 4) 승인 성공 시 요청상태 완료 + 기사용액 증액 */ + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_appr_req set req_status = 'A' where req_key = $1 ", + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 121 "app/online/au_ol_0008.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE au_appr_req"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update au_limit set used_amt = used_amt + $1 where merch_id = $2 ", + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + 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_EOIT, ECPGt_EORT);} +#line 131 "app/online/au_ol_0008.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE au_limit used_amt"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + tx_commit(); + + tx_log(TX_LOG_INFO, "[AU_OL_0008] 중계 응답 key=%s resp=%s used+=%ld", + key, resp, amount); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/au_ol_0008.pgc b/app/online/au_ol_0008.pgc index 71789af..7409f1c 100644 --- a/app/online/au_ol_0008.pgc +++ b/app/online/au_ol_0008.pgc @@ -2,8 +2,10 @@ /* * au_ol_0008.pgc - 승인요청 매입사 중계(tx_call) (AU_OL_0008) [tier=hard] * - * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 임베디드 SQL / 표준 - * DBIO / tx_call 로 처리한 뒤 응답 TXBUF 를 구성한다. + * 요청 승인건에 대해 가맹점 승인한도(au_limit)를 임베디드 SQL 로 확인하고, + * 승인요청 이력행(au_appr_req)을 적재한 뒤 매입사(AU_ISSUER)로 tx_call + * 중계한다. 매입사 승인응답이 정상이면 가맹점 기사용액(used_amt)을 증액 + * 반영한다. 원장 반영은 하나의 트랜잭션으로 처리한다. */ #include #include @@ -17,27 +19,79 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(AU_OL_0008, ctx) { - char key[16]; - if (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) != TX_OK) { - tx_log(TX_LOG_ERROR, "[AU_OL_0008] KEY 누락"); - tx_return(ctx, TX_EINVAL, ctx->out); - return; - } + EXEC SQL BEGIN DECLARE SECTION; + char h_key[16]; + char h_merch_id[16]; + char h_card_no[20]; + long h_amount; + long h_daily_limit; + long h_used_amt; + EXEC SQL END DECLARE SECTION; + TXBUF *req; - char merch[16], card[20], resp[8]; - long amount = 0; + char key[16], merch[16], card[20], resp[8]; + long amount = 0, avail; int rc; tx_log(TX_LOG_INFO, "[AU_OL_0008] 승인요청 중계 진입"); - if (tx_buf_get(ctx->in, "MERCHID", merch, sizeof(merch)) != TX_OK || + + if (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) != TX_OK || + tx_buf_get(ctx->in, "MERCHID", merch, sizeof(merch)) != TX_OK || tx_buf_get(ctx->in, "CARDNO", card, sizeof(card)) != TX_OK) { + tx_log(TX_LOG_ERROR, "[AU_OL_0008] 필수 필드 누락"); tx_return(ctx, TX_EINVAL, ctx->out); return; } tx_buf_getlong(ctx->in, "AMOUNT", &amount); + strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + strncpy(h_merch_id, merch, sizeof(h_merch_id) - 1); h_merch_id[sizeof(h_merch_id) - 1] = '\0'; + strncpy(h_card_no, card, sizeof(h_card_no) - 1); h_card_no[sizeof(h_card_no) - 1] = '\0'; + h_amount = amount; + + /* 1) 가맹점 승인한도 확인 */ + h_daily_limit = 0; + h_used_amt = 0; + EXEC SQL SELECT daily_limit, used_amt + INTO :h_daily_limit, :h_used_amt + FROM au_limit + WHERE merch_id = :h_merch_id; + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT au_limit"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + avail = h_daily_limit - h_used_amt; + if (h_daily_limit > 0 && amount > avail) { + tx_log(TX_LOG_WARN, "[AU_OL_0008] 한도초과 merch=%s req=%ld avail=%ld", + merch, amount, avail); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); + tx_return(ctx, TX_EINVAL, ctx->out); + return; + } + + /* 2) 승인요청 이력행 적재 (요청상태 'Q') */ + if (tx_begin() != TX_OK) { + tx_log(TX_LOG_ERROR, "[AU_OL_0008] 트랜잭션 시작 실패"); + tx_return(ctx, TX_FAIL, ctx->out); + return; + } + EXEC SQL INSERT INTO au_appr_req + (req_key, merch_id, card_no, req_amount, req_status) + VALUES + (:h_key, :h_merch_id, :h_card_no, :h_amount, 'Q'); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT au_appr_req"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + /* 3) 매입사 중계 (tx_call) */ req = tx_buf_alloc(); if (!req) { + tx_abort(); tx_return(ctx, TX_ENOMEM, ctx->out); return; } @@ -51,6 +105,7 @@ TX_SERVICE(AU_OL_0008, ctx) tx_buf_free(req); if (rc != TX_OK) { tx_log(TX_LOG_ERROR, "[AU_OL_0008] 매입사 중계 실패 rc=%d(%s)", rc, tx_strerror(rc)); + tx_abort(); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); tx_return(ctx, rc, ctx->out); @@ -59,6 +114,31 @@ TX_SERVICE(AU_OL_0008, ctx) if (tx_buf_get(ctx->out, "RESPCODE", resp, sizeof(resp)) != TX_OK) strcpy(resp, RESP_OK); - tx_log(TX_LOG_INFO, "[AU_OL_0008] 중계 응답 key=%s resp=%s", key, resp); + + /* 4) 승인 성공 시 요청상태 완료 + 기사용액 증액 */ + EXEC SQL UPDATE au_appr_req + SET req_status = 'A' + WHERE req_key = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE au_appr_req"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + EXEC SQL UPDATE au_limit + SET used_amt = used_amt + :h_amount + WHERE merch_id = :h_merch_id; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE au_limit used_amt"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + tx_commit(); + + tx_log(TX_LOG_INFO, "[AU_OL_0008] 중계 응답 key=%s resp=%s used+=%ld", + key, resp, amount); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/au_ol_0009.c b/app/online/au_ol_0009.c index 6726141..7a6f2ef 100644 --- a/app/online/au_ol_0009.c +++ b/app/online/au_ol_0009.c @@ -10,8 +10,10 @@ /* * au_ol_0009.pgc - 대행승인 fallback(주센터 실패시 백업) (AU_OL_0009) [tier=hard] * - * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 임베디드 SQL / 표준 - * DBIO / tx_call 로 처리한 뒤 응답 TXBUF 를 구성한다. + * 주센터(au_center) 가동상태를 임베디드 SQL 로 확인해 정상이면 주센터 + * (AU_ISSUER)로, 장애면 곧바로 대행센터(AU_STANDIN)로 tx_call 한다. + * 주센터 tx_call 이 실패해도 대행센터로 전환하며, 대행 처리분은 + * 대행승인 이력(au_standin_log)에 기록한다. */ #include #include @@ -90,24 +92,68 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/au_ol_0009.pgc" +#line 18 "app/online/au_ol_0009.pgc" TX_SERVICE(AU_OL_0009, ctx) { + /* exec sql begin declare section */ + + + + + +#line 23 "app/online/au_ol_0009.pgc" + char h_center_id [ 8 ] ; + +#line 24 "app/online/au_ol_0009.pgc" + char h_center_status [ 2 ] ; + +#line 25 "app/online/au_ol_0009.pgc" + char h_key [ 16 ] ; + +#line 26 "app/online/au_ol_0009.pgc" + long h_amount ; +/* exec sql end declare section */ +#line 27 "app/online/au_ol_0009.pgc" + + + TXBUF *req; char key[16]; + long amount = 0; + int rc, standin = 0, primary_down; + + tx_log(TX_LOG_INFO, "[AU_OL_0009] 대행승인 fallback 진입"); + if (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) != TX_OK) { tx_log(TX_LOG_ERROR, "[AU_OL_0009] KEY 누락"); tx_return(ctx, TX_EINVAL, ctx->out); return; } - TXBUF *req; - long amount = 0; - int rc; - - tx_log(TX_LOG_INFO, "[AU_OL_0009] 대행승인 fallback 진입"); tx_buf_getlong(ctx->in, "AMOUNT", &amount); + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_amount = amount; + + /* 주센터 가동상태 조회 (center_id='PRIMARY') */ + strcpy(h_center_id, "PRIMARY"); + strcpy(h_center_status, "U"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select center_status from au_center where center_id = $1 ", + ECPGt_char,(h_center_id),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_center_status),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 53 "app/online/au_ol_0009.pgc" + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT au_center"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + /* 상태 'U'(Up)=정상, 그 외는 장애로 간주 */ + primary_down = (strncmp(h_center_status, "U", 1) != 0); + req = tx_buf_alloc(); if (!req) { tx_return(ctx, TX_ENOMEM, ctx->out); @@ -116,15 +162,22 @@ TX_SERVICE(AU_OL_0009, ctx) tx_buf_sets(req, "KEY", key); tx_buf_setlong(req, "AMOUNT", amount); - rc = tx_call("AU_ISSUER", req, ctx->out); - if (rc != TX_OK) { - tx_log(TX_LOG_WARN, "[AU_OL_0009] 주센터 실패 rc=%d, 대행센터 전환", rc); + if (!primary_down) { + rc = tx_call("AU_ISSUER", req, ctx->out); + if (rc != TX_OK) { + tx_log(TX_LOG_WARN, "[AU_OL_0009] 주센터 응답실패 rc=%d, 대행 전환", rc); + primary_down = 1; + } + } else { + rc = TX_FAIL; + tx_log(TX_LOG_WARN, "[AU_OL_0009] 주센터 장애(status=%s), 대행 전환", + h_center_status); + } + + if (primary_down) { tx_buf_reset(ctx->out); rc = tx_call("AU_STANDIN", req, ctx->out); - if (rc == TX_OK) - tx_buf_sets(ctx->out, "STANDIN", "Y"); - } else { - tx_buf_sets(ctx->out, "STANDIN", "N"); + standin = (rc == TX_OK); } tx_buf_free(req); @@ -134,6 +187,31 @@ TX_SERVICE(AU_OL_0009, ctx) tx_return(ctx, rc, ctx->out); return; } - tx_log(TX_LOG_INFO, "[AU_OL_0009] fallback 처리완료 key=%s", key); + + tx_buf_sets(ctx->out, "STANDIN", standin ? "Y" : "N"); + + /* 대행 처리분은 이력에 기록 */ + if (standin) { + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[AU_OL_0009] tx_begin 경고"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into au_standin_log ( req_key , req_amount , center_status ) values ( $1 , $2 , $3 )", + ECPGt_char,(h_key),(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_char,(h_center_status),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 105 "app/online/au_ol_0009.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT au_standin_log"); + tx_abort(); + } else { + tx_commit(); + } + } + + tx_log(TX_LOG_INFO, "[AU_OL_0009] fallback 처리완료 key=%s standin=%s", + key, standin ? "Y" : "N"); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/au_ol_0009.pgc b/app/online/au_ol_0009.pgc index f1300e5..fa86551 100644 --- a/app/online/au_ol_0009.pgc +++ b/app/online/au_ol_0009.pgc @@ -2,8 +2,10 @@ /* * au_ol_0009.pgc - 대행승인 fallback(주센터 실패시 백업) (AU_OL_0009) [tier=hard] * - * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 임베디드 SQL / 표준 - * DBIO / tx_call 로 처리한 뒤 응답 TXBUF 를 구성한다. + * 주센터(au_center) 가동상태를 임베디드 SQL 로 확인해 정상이면 주센터 + * (AU_ISSUER)로, 장애면 곧바로 대행센터(AU_STANDIN)로 tx_call 한다. + * 주센터 tx_call 이 실패해도 대행센터로 전환하며, 대행 처리분은 + * 대행승인 이력(au_standin_log)에 기록한다. */ #include #include @@ -17,19 +19,46 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(AU_OL_0009, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_center_id[8]; + char h_center_status[2]; + char h_key[16]; + long h_amount; + EXEC SQL END DECLARE SECTION; + + TXBUF *req; char key[16]; + long amount = 0; + int rc, standin = 0, primary_down; + + tx_log(TX_LOG_INFO, "[AU_OL_0009] 대행승인 fallback 진입"); + if (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) != TX_OK) { tx_log(TX_LOG_ERROR, "[AU_OL_0009] KEY 누락"); tx_return(ctx, TX_EINVAL, ctx->out); return; } - TXBUF *req; - long amount = 0; - int rc; - - tx_log(TX_LOG_INFO, "[AU_OL_0009] 대행승인 fallback 진입"); tx_buf_getlong(ctx->in, "AMOUNT", &amount); + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_amount = amount; + + /* 주센터 가동상태 조회 (center_id='PRIMARY') */ + strcpy(h_center_id, "PRIMARY"); + strcpy(h_center_status, "U"); + EXEC SQL SELECT center_status + INTO :h_center_status + FROM au_center + WHERE center_id = :h_center_id; + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT au_center"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + /* 상태 'U'(Up)=정상, 그 외는 장애로 간주 */ + primary_down = (strncmp(h_center_status, "U", 1) != 0); + req = tx_buf_alloc(); if (!req) { tx_return(ctx, TX_ENOMEM, ctx->out); @@ -38,15 +67,22 @@ TX_SERVICE(AU_OL_0009, ctx) tx_buf_sets(req, "KEY", key); tx_buf_setlong(req, "AMOUNT", amount); - rc = tx_call("AU_ISSUER", req, ctx->out); - if (rc != TX_OK) { - tx_log(TX_LOG_WARN, "[AU_OL_0009] 주센터 실패 rc=%d, 대행센터 전환", rc); + if (!primary_down) { + rc = tx_call("AU_ISSUER", req, ctx->out); + if (rc != TX_OK) { + tx_log(TX_LOG_WARN, "[AU_OL_0009] 주센터 응답실패 rc=%d, 대행 전환", rc); + primary_down = 1; + } + } else { + rc = TX_FAIL; + tx_log(TX_LOG_WARN, "[AU_OL_0009] 주센터 장애(status=%s), 대행 전환", + h_center_status); + } + + if (primary_down) { tx_buf_reset(ctx->out); rc = tx_call("AU_STANDIN", req, ctx->out); - if (rc == TX_OK) - tx_buf_sets(ctx->out, "STANDIN", "Y"); - } else { - tx_buf_sets(ctx->out, "STANDIN", "N"); + standin = (rc == TX_OK); } tx_buf_free(req); @@ -56,6 +92,26 @@ TX_SERVICE(AU_OL_0009, ctx) tx_return(ctx, rc, ctx->out); return; } - tx_log(TX_LOG_INFO, "[AU_OL_0009] fallback 처리완료 key=%s", key); + + tx_buf_sets(ctx->out, "STANDIN", standin ? "Y" : "N"); + + /* 대행 처리분은 이력에 기록 */ + if (standin) { + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[AU_OL_0009] tx_begin 경고"); + EXEC SQL INSERT INTO au_standin_log + (req_key, req_amount, center_status) + VALUES + (:h_key, :h_amount, :h_center_status); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT au_standin_log"); + tx_abort(); + } else { + tx_commit(); + } + } + + tx_log(TX_LOG_INFO, "[AU_OL_0009] fallback 처리완료 key=%s standin=%s", + key, standin ? "Y" : "N"); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cl_ol_0001.c b/app/online/cl_ol_0001.c index 76f426d..05b5b87 100644 --- a/app/online/cl_ol_0001.c +++ b/app/online/cl_ol_0001.c @@ -12,11 +12,14 @@ * * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 cl 표준 DBIO 를 * 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응) + * 단건 조회 결과에 더해 원장 확장필드(카드번호/수수료/최종반영시각)를 + * cl_ledger 에서 직접 SELECT 하여 응답에 실어 감사표시를 지원한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cl_core.h" @@ -89,11 +92,32 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/cl_ol_0001.pgc" +#line 18 "app/online/cl_ol_0001.pgc" TX_SERVICE(CL_OL_0001, ctx) { + /* exec sql begin declare section */ + + + + + +#line 23 "app/online/cl_ol_0001.pgc" + char h_key [ 16 ] ; + +#line 24 "app/online/cl_ol_0001.pgc" + char h_card_no [ 24 ] ; + +#line 25 "app/online/cl_ol_0001.pgc" + long h_fee ; + +#line 26 "app/online/cl_ol_0001.pgc" + char h_upd_ts [ 24 ] ; +/* exec sql end declare section */ +#line 27 "app/online/cl_ol_0001.pgc" + + cl_rec_t rec; char key[16]; int rc; @@ -115,11 +139,42 @@ TX_SERVICE(CL_OL_0001, ctx) return; } + /* 원장 확장필드 직접 조회 (카드번호/수수료/최종반영시각) */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_card_no[0] = '\0'; + h_upd_ts[0] = '\0'; + h_fee = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select card_no , fee , to_char ( upd_ts , 'YYYYMMDDHH24MISS' ) from cl_ledger where key = $1 ", + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_card_no),(long)24,(long)1,(24)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_upd_ts),(long)24,(long)1,(24)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 60 "app/online/cl_ol_0001.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[CL_OL_0001] 확장필드 원장 없음 key=%s", key); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CL_OL_0001 SELECT cl_ledger ext"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); tx_buf_sets(ctx->out, "STATUS", rec.status); - tx_log(TX_LOG_INFO, "[CL_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); + tx_buf_sets(ctx->out, "CARDNO", h_card_no); + tx_buf_setlong(ctx->out, "FEE", h_fee); + tx_buf_sets(ctx->out, "UPDTS", h_upd_ts); + tx_log(TX_LOG_INFO, "[CL_OL_0001] 조회완료 key=%s amount=%ld fee=%ld", + key, rec.amount, h_fee); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cl_ol_0001.pgc b/app/online/cl_ol_0001.pgc index 4d65ae1..34f08ba 100644 --- a/app/online/cl_ol_0001.pgc +++ b/app/online/cl_ol_0001.pgc @@ -4,11 +4,14 @@ * * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 cl 표준 DBIO 를 * 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응) + * 단건 조회 결과에 더해 원장 확장필드(카드번호/수수료/최종반영시각)를 + * cl_ledger 에서 직접 SELECT 하여 응답에 실어 감사표시를 지원한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cl_core.h" @@ -16,6 +19,13 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(CL_OL_0001, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_key[16]; + char h_card_no[24]; + long h_fee; + char h_upd_ts[24]; + EXEC SQL END DECLARE SECTION; + cl_rec_t rec; char key[16]; int rc; @@ -37,11 +47,35 @@ TX_SERVICE(CL_OL_0001, ctx) return; } + /* 원장 확장필드 직접 조회 (카드번호/수수료/최종반영시각) */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_card_no[0] = '\0'; + h_upd_ts[0] = '\0'; + h_fee = 0; + + EXEC SQL SELECT card_no, fee, to_char(upd_ts, 'YYYYMMDDHH24MISS') + INTO :h_card_no, :h_fee, :h_upd_ts + FROM cl_ledger + WHERE key = :h_key; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[CL_OL_0001] 확장필드 원장 없음 key=%s", key); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CL_OL_0001 SELECT cl_ledger ext"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); tx_buf_sets(ctx->out, "STATUS", rec.status); - tx_log(TX_LOG_INFO, "[CL_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); + tx_buf_sets(ctx->out, "CARDNO", h_card_no); + tx_buf_setlong(ctx->out, "FEE", h_fee); + tx_buf_sets(ctx->out, "UPDTS", h_upd_ts); + tx_log(TX_LOG_INFO, "[CL_OL_0001] 조회완료 key=%s amount=%ld fee=%ld", + key, rec.amount, h_fee); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cl_ol_0015.c b/app/online/cl_ol_0015.c index 62e7bbd..b5029a8 100644 --- a/app/online/cl_ol_0015.c +++ b/app/online/cl_ol_0015.c @@ -12,7 +12,8 @@ * * 마감 상태조회. 요청 처리키(KEY) 단건에 대해 표준 DBIO cl_rec_select 로 * 원장 레코드를 읽어, 상태코드/금액/영업일과 함께 마감여부(status='S')를 - * 판정하여 응답한다. (read-only 단건 판정) + * 판정하여 응답한다. 아울러 동일 가맹점·동일 영업일의 형제 거래 건수/ + * 금액합계를 cl_ledger 에서 직접 집계(SELECT)하여 맥락을 함께 제공한다. * * ── 서비스 계약(Contract) ──────────────────────────────────────────── * 입력 필드: @@ -27,6 +28,8 @@ * STATUS 상태코드(R/M/U/S) * STATUSLABEL 상태 한글 라벨(접수/처리완료/불일치/정산완료) * CLOSED 마감여부(Y=정산완료 S / N=그 외) + * SIBLINGCNT 동일 가맹점·영업일 형제 거래 건수 + * SIBLINGSUM 동일 가맹점·영업일 형제 거래 금액합계 * * ── 상태코드 정의 ──────────────────────────────────────────────────── * R(접수) → M(처리완료) → S(정산완료/마감확정) @@ -37,12 +40,14 @@ * 1) 요청 TXBUF 에서 KEY 추출 및 필수검증 * 2) cl_rec_select 로 단건 원장 조회 (없으면 RESP_INVALID) * 3) status 를 CL_ST_* 상수와 비교하여 라벨/마감여부 산출 - * 4) 응답 TXBUF 구성 후 tx_return + * 4) 동일 가맹점·영업일 형제 집계 SELECT + * 5) 응답 TXBUF 구성 후 tx_return */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cl_core.h" @@ -115,11 +120,32 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 41 "app/online/cl_ol_0015.pgc" +#line 46 "app/online/cl_ol_0015.pgc" TX_SERVICE(CL_OL_0015, ctx) { + /* exec sql begin declare section */ + + + + + +#line 51 "app/online/cl_ol_0015.pgc" + char h_merch_id [ 16 ] ; + +#line 52 "app/online/cl_ol_0015.pgc" + char h_biz_date [ 9 ] ; + +#line 53 "app/online/cl_ol_0015.pgc" + long h_sib_cnt ; + +#line 54 "app/online/cl_ol_0015.pgc" + long h_sib_sum ; +/* exec sql end declare section */ +#line 55 "app/online/cl_ol_0015.pgc" + + cl_rec_t rec; char key[16]; char won[40]; @@ -171,7 +197,33 @@ TX_SERVICE(CL_OL_0015, ctx) /* 4. 스냅샷 요약행 여부 판정 (merch_id='*SNAP' 규약) */ is_snap = (strcmp(rec.merch_id, "*SNAP") == 0); - /* 5. 응답 구성 */ + /* 5. 동일 가맹점·동일 영업일 형제 거래 집계 (read-only 맥락) */ + strncpy(h_merch_id, rec.merch_id, sizeof(h_merch_id) - 1); + h_merch_id[sizeof(h_merch_id) - 1] = '\0'; + strncpy(h_biz_date, rec.biz_date, sizeof(h_biz_date) - 1); + h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + h_sib_cnt = 0; + h_sib_sum = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) , coalesce ( sum ( amount ) , 0 ) from cl_ledger where merch_id = $1 and biz_date = $2 ", + ECPGt_char,(h_merch_id),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_sib_cnt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sib_sum),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 120 "app/online/cl_ol_0015.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("CL_OL_0015 sibling aggregate"); + h_sib_cnt = 0; + h_sib_sum = 0; + } + + /* 6. 응답 구성 */ amount_format_won(rec.amount, won, sizeof(won)); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); @@ -185,15 +237,17 @@ TX_SERVICE(CL_OL_0015, ctx) tx_buf_sets(ctx->out, "STATUSLABEL", st_label); tx_buf_sets(ctx->out, "CLOSED", is_settled ? "Y" : "N"); tx_buf_sets(ctx->out, "SNAPSHOT", is_snap ? "Y" : "N"); + tx_buf_setlong(ctx->out, "SIBLINGCNT", h_sib_cnt); + tx_buf_setlong(ctx->out, "SIBLINGSUM", h_sib_sum); - /* 6. 스냅샷 요약행은 집계행이므로 별도 안내 로깅 */ + /* 7. 스냅샷 요약행은 집계행이므로 별도 안내 로깅 */ if (is_snap) tx_log(TX_LOG_INFO, "[CL_OL_0015] 스냅샷 요약행 조회 key=%s biz=%s Σ=%ld", rec.key, rec.biz_date, rec.amount); tx_log(TX_LOG_INFO, - "[CL_OL_0015] 상태조회 key=%s status=%s(%s) 마감여부=%s", - rec.key, rec.status, st_label, is_settled ? "Y" : "N"); + "[CL_OL_0015] 상태조회 key=%s status=%s(%s) 마감여부=%s 형제=%ld건", + rec.key, rec.status, st_label, is_settled ? "Y" : "N", h_sib_cnt); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cl_ol_0015.pgc b/app/online/cl_ol_0015.pgc index 7eda47f..abc9646 100644 --- a/app/online/cl_ol_0015.pgc +++ b/app/online/cl_ol_0015.pgc @@ -4,7 +4,8 @@ * * 마감 상태조회. 요청 처리키(KEY) 단건에 대해 표준 DBIO cl_rec_select 로 * 원장 레코드를 읽어, 상태코드/금액/영업일과 함께 마감여부(status='S')를 - * 판정하여 응답한다. (read-only 단건 판정) + * 판정하여 응답한다. 아울러 동일 가맹점·동일 영업일의 형제 거래 건수/ + * 금액합계를 cl_ledger 에서 직접 집계(SELECT)하여 맥락을 함께 제공한다. * * ── 서비스 계약(Contract) ──────────────────────────────────────────── * 입력 필드: @@ -19,6 +20,8 @@ * STATUS 상태코드(R/M/U/S) * STATUSLABEL 상태 한글 라벨(접수/처리완료/불일치/정산완료) * CLOSED 마감여부(Y=정산완료 S / N=그 외) + * SIBLINGCNT 동일 가맹점·영업일 형제 거래 건수 + * SIBLINGSUM 동일 가맹점·영업일 형제 거래 금액합계 * * ── 상태코드 정의 ──────────────────────────────────────────────────── * R(접수) → M(처리완료) → S(정산완료/마감확정) @@ -29,12 +32,14 @@ * 1) 요청 TXBUF 에서 KEY 추출 및 필수검증 * 2) cl_rec_select 로 단건 원장 조회 (없으면 RESP_INVALID) * 3) status 를 CL_ST_* 상수와 비교하여 라벨/마감여부 산출 - * 4) 응답 TXBUF 구성 후 tx_return + * 4) 동일 가맹점·영업일 형제 집계 SELECT + * 5) 응답 TXBUF 구성 후 tx_return */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cl_core.h" @@ -42,6 +47,13 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(CL_OL_0015, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch_id[16]; + char h_biz_date[9]; + long h_sib_cnt; + long h_sib_sum; + EXEC SQL END DECLARE SECTION; + cl_rec_t rec; char key[16]; char won[40]; @@ -93,7 +105,27 @@ TX_SERVICE(CL_OL_0015, ctx) /* 4. 스냅샷 요약행 여부 판정 (merch_id='*SNAP' 규약) */ is_snap = (strcmp(rec.merch_id, "*SNAP") == 0); - /* 5. 응답 구성 */ + /* 5. 동일 가맹점·동일 영업일 형제 거래 집계 (read-only 맥락) */ + strncpy(h_merch_id, rec.merch_id, sizeof(h_merch_id) - 1); + h_merch_id[sizeof(h_merch_id) - 1] = '\0'; + strncpy(h_biz_date, rec.biz_date, sizeof(h_biz_date) - 1); + h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + h_sib_cnt = 0; + h_sib_sum = 0; + + EXEC SQL SELECT count(*), coalesce(sum(amount), 0) + INTO :h_sib_cnt, :h_sib_sum + FROM cl_ledger + WHERE merch_id = :h_merch_id + AND biz_date = :h_biz_date; + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("CL_OL_0015 sibling aggregate"); + h_sib_cnt = 0; + h_sib_sum = 0; + } + + /* 6. 응답 구성 */ amount_format_won(rec.amount, won, sizeof(won)); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); @@ -107,15 +139,17 @@ TX_SERVICE(CL_OL_0015, ctx) tx_buf_sets(ctx->out, "STATUSLABEL", st_label); tx_buf_sets(ctx->out, "CLOSED", is_settled ? "Y" : "N"); tx_buf_sets(ctx->out, "SNAPSHOT", is_snap ? "Y" : "N"); + tx_buf_setlong(ctx->out, "SIBLINGCNT", h_sib_cnt); + tx_buf_setlong(ctx->out, "SIBLINGSUM", h_sib_sum); - /* 6. 스냅샷 요약행은 집계행이므로 별도 안내 로깅 */ + /* 7. 스냅샷 요약행은 집계행이므로 별도 안내 로깅 */ if (is_snap) tx_log(TX_LOG_INFO, "[CL_OL_0015] 스냅샷 요약행 조회 key=%s biz=%s Σ=%ld", rec.key, rec.biz_date, rec.amount); tx_log(TX_LOG_INFO, - "[CL_OL_0015] 상태조회 key=%s status=%s(%s) 마감여부=%s", - rec.key, rec.status, st_label, is_settled ? "Y" : "N"); + "[CL_OL_0015] 상태조회 key=%s status=%s(%s) 마감여부=%s 형제=%ld건", + rec.key, rec.status, st_label, is_settled ? "Y" : "N", h_sib_cnt); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cl_ol_0017.c b/app/online/cl_ol_0017.c index 093f8c9..85615ec 100644 --- a/app/online/cl_ol_0017.c +++ b/app/online/cl_ol_0017.c @@ -104,6 +104,23 @@ struct sqlca_t *ECPGget_sqlca(void); TX_SERVICE(CL_OL_0017, ctx) { + /* exec sql begin declare section */ + + + + +#line 30 "app/online/cl_ol_0017.pgc" + char h_biz_date [ 9 ] ; + +#line 31 "app/online/cl_ol_0017.pgc" + long h_db_total ; + +#line 32 "app/online/cl_ol_0017.pgc" + long h_db_amt ; +/* exec sql end declare section */ +#line 33 "app/online/cl_ol_0017.pgc" + + char bizdate[16]; char reqid[32]; char oper[32]; @@ -111,6 +128,7 @@ TX_SERVICE(CL_OL_0017, ctx) char summary[TX_VAL_LEN]; long recv_cnt, done_cnt, fail_cnt, settled_cnt; long total_cnt, processed_cnt, complete_rate; + long db_diff; int valid; tx_log(TX_LOG_INFO, "[CL_OL_0017] 일마감 검증 서비스 진입"); @@ -155,6 +173,38 @@ TX_SERVICE(CL_OL_0017, ctx) } total_cnt = recv_cnt + done_cnt + fail_cnt + settled_cnt; + /* + * 3-1) 원장 직접 집계로 상태별 DBIO 합계를 교차검증한다. + * DBIO 채널 합계(total_cnt)와 원장 실집계(h_db_total)가 + * 다르면 대사 불일치로 간주하여 감사 로그를 남긴다. + */ + strncpy(h_biz_date, bizdate, sizeof(h_biz_date) - 1); + h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + h_db_total = 0; + h_db_amt = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) , coalesce ( sum ( amount ) , 0 ) from cl_ledger where biz_date = $1 ", + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_db_total),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_db_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 100 "app/online/cl_ol_0017.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("CL_OL_0017 direct total"); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + db_diff = total_cnt - h_db_total; + if (db_diff != 0) + tx_log(TX_LOG_WARN, "[CL_OL_0017] 집계 대사 불일치 dbio=%ld ledger=%ld", + total_cnt, h_db_total); + /* 4) 일마감 유효성 판정: 미마감 잔량이 0 이어야 유효 */ valid = (recv_cnt == 0) ? 1 : 0; @@ -184,6 +234,10 @@ TX_SERVICE(CL_OL_0017, ctx) tx_buf_setlong(ctx->out, "FAILCNT", fail_cnt); tx_buf_setlong(ctx->out, "SETTLEDCNT", settled_cnt); tx_buf_setlong(ctx->out, "TOTALCNT", total_cnt); + tx_buf_setlong(ctx->out, "DBTOTAL", h_db_total); + tx_buf_setlong(ctx->out, "DBAMT", h_db_amt); + tx_buf_setlong(ctx->out, "DBDIFF", db_diff); + tx_buf_sets(ctx->out, "RECONMATCH", (db_diff == 0) ? "Y" : "N"); tx_buf_setlong(ctx->out, "PROCESSEDCNT", processed_cnt); tx_buf_setlong(ctx->out, "COMPLETERATE", complete_rate); tx_buf_sets(ctx->out, "NEXTBIZ", nextbiz); diff --git a/app/online/cl_ol_0017.pgc b/app/online/cl_ol_0017.pgc index f439909..7b821e9 100644 --- a/app/online/cl_ol_0017.pgc +++ b/app/online/cl_ol_0017.pgc @@ -26,6 +26,12 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(CL_OL_0017, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_biz_date[9]; + long h_db_total; + long h_db_amt; + EXEC SQL END DECLARE SECTION; + char bizdate[16]; char reqid[32]; char oper[32]; @@ -33,6 +39,7 @@ TX_SERVICE(CL_OL_0017, ctx) char summary[TX_VAL_LEN]; long recv_cnt, done_cnt, fail_cnt, settled_cnt; long total_cnt, processed_cnt, complete_rate; + long db_diff; int valid; tx_log(TX_LOG_INFO, "[CL_OL_0017] 일마감 검증 서비스 진입"); @@ -77,6 +84,33 @@ TX_SERVICE(CL_OL_0017, ctx) } total_cnt = recv_cnt + done_cnt + fail_cnt + settled_cnt; + /* + * 3-1) 원장 직접 집계로 상태별 DBIO 합계를 교차검증한다. + * DBIO 채널 합계(total_cnt)와 원장 실집계(h_db_total)가 + * 다르면 대사 불일치로 간주하여 감사 로그를 남긴다. + */ + strncpy(h_biz_date, bizdate, sizeof(h_biz_date) - 1); + h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + h_db_total = 0; + h_db_amt = 0; + + EXEC SQL SELECT count(*), coalesce(sum(amount), 0) + INTO :h_db_total, :h_db_amt + FROM cl_ledger + WHERE biz_date = :h_biz_date; + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("CL_OL_0017 direct total"); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + db_diff = total_cnt - h_db_total; + if (db_diff != 0) + tx_log(TX_LOG_WARN, "[CL_OL_0017] 집계 대사 불일치 dbio=%ld ledger=%ld", + total_cnt, h_db_total); + /* 4) 일마감 유효성 판정: 미마감 잔량이 0 이어야 유효 */ valid = (recv_cnt == 0) ? 1 : 0; @@ -106,6 +140,10 @@ TX_SERVICE(CL_OL_0017, ctx) tx_buf_setlong(ctx->out, "FAILCNT", fail_cnt); tx_buf_setlong(ctx->out, "SETTLEDCNT", settled_cnt); tx_buf_setlong(ctx->out, "TOTALCNT", total_cnt); + tx_buf_setlong(ctx->out, "DBTOTAL", h_db_total); + tx_buf_setlong(ctx->out, "DBAMT", h_db_amt); + tx_buf_setlong(ctx->out, "DBDIFF", db_diff); + tx_buf_sets(ctx->out, "RECONMATCH", (db_diff == 0) ? "Y" : "N"); tx_buf_setlong(ctx->out, "PROCESSEDCNT", processed_cnt); tx_buf_setlong(ctx->out, "COMPLETERATE", complete_rate); tx_buf_sets(ctx->out, "NEXTBIZ", nextbiz); diff --git a/app/online/cl_ol_0019.c b/app/online/cl_ol_0019.c index a60ea7e..af6f38e 100644 --- a/app/online/cl_ol_0019.c +++ b/app/online/cl_ol_0019.c @@ -101,6 +101,31 @@ struct sqlca_t *ECPGget_sqlca(void); TX_SERVICE(CL_OL_0019, ctx) { + /* exec sql begin declare section */ + + + + + + +#line 27 "app/online/cl_ol_0019.pgc" + char h_key [ 16 ] ; + +#line 28 "app/online/cl_ol_0019.pgc" + char h_prev_st [ 2 ] ; + +#line 29 "app/online/cl_ol_0019.pgc" + char h_new_st [ 2 ] ; + +#line 30 "app/online/cl_ol_0019.pgc" + char h_oper [ 32 ] ; + +#line 31 "app/online/cl_ol_0019.pgc" + char h_reqid [ 32 ] ; +/* exec sql end declare section */ +#line 32 "app/online/cl_ol_0019.pgc" + + cl_rec_t rec; char key[16]; char reqid[32]; @@ -181,6 +206,40 @@ TX_SERVICE(CL_OL_0019, ctx) return; } + /* 취소 승인 감사이력 적재 (동일 트랜잭션) */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + strncpy(h_prev_st, CL_ST_FAIL, sizeof(h_prev_st)); + strncpy(h_new_st, CL_ST_DONE, sizeof(h_new_st)); + strncpy(h_oper, oper, sizeof(h_oper) - 1); + h_oper[sizeof(h_oper) - 1] = '\0'; + strncpy(h_reqid, reqid, sizeof(h_reqid) - 1); + h_reqid[sizeof(h_reqid) - 1] = '\0'; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cl_cancel_audit ( key , prev_status , new_status , oper , reqid , chg_ts ) values ( $1 , $2 , $3 , $4 , $5 , now ( ) )", + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_prev_st),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_new_st),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_oper),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_reqid),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 126 "app/online/cl_ol_0019.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CL_OL_0019 INSERT cl_cancel_audit"); + tx_abort(); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_buf_sets(ctx->out, "APPROVED", "N"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_commit(); /* 5) 승인 결과 응답 (원거래 요약 포함) */ diff --git a/app/online/cl_ol_0019.pgc b/app/online/cl_ol_0019.pgc index 95517cf..1c9a818 100644 --- a/app/online/cl_ol_0019.pgc +++ b/app/online/cl_ol_0019.pgc @@ -23,6 +23,14 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(CL_OL_0019, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_key[16]; + char h_prev_st[2]; + char h_new_st[2]; + char h_oper[32]; + char h_reqid[32]; + EXEC SQL END DECLARE SECTION; + cl_rec_t rec; char key[16]; char reqid[32]; @@ -103,6 +111,30 @@ TX_SERVICE(CL_OL_0019, ctx) return; } + /* 취소 승인 감사이력 적재 (동일 트랜잭션) */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + strncpy(h_prev_st, CL_ST_FAIL, sizeof(h_prev_st)); + strncpy(h_new_st, CL_ST_DONE, sizeof(h_new_st)); + strncpy(h_oper, oper, sizeof(h_oper) - 1); + h_oper[sizeof(h_oper) - 1] = '\0'; + strncpy(h_reqid, reqid, sizeof(h_reqid) - 1); + h_reqid[sizeof(h_reqid) - 1] = '\0'; + + EXEC SQL INSERT INTO cl_cancel_audit + (key, prev_status, new_status, oper, reqid, chg_ts) + VALUES (:h_key, :h_prev_st, :h_new_st, :h_oper, :h_reqid, now()); + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CL_OL_0019 INSERT cl_cancel_audit"); + tx_abort(); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_buf_sets(ctx->out, "APPROVED", "N"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_commit(); /* 5) 승인 결과 응답 (원거래 요약 포함) */ diff --git a/app/online/cl_ol_0023.c b/app/online/cl_ol_0023.c index 91d2e61..8cd66ab 100644 --- a/app/online/cl_ol_0023.c +++ b/app/online/cl_ol_0023.c @@ -106,6 +106,27 @@ struct sqlca_t *ECPGget_sqlca(void); TX_SERVICE(CL_OL_0023, ctx) { + /* exec sql begin declare section */ + + + + + +#line 32 "app/online/cl_ol_0023.pgc" + char h_biz_date [ 9 ] ; + +#line 33 "app/online/cl_ol_0023.pgc" + char h_st_done [ 2 ] ; + +#line 34 "app/online/cl_ol_0023.pgc" + long h_db_used ; + +#line 35 "app/online/cl_ol_0023.pgc" + char h_max_key [ 16 ] ; +/* exec sql end declare section */ +#line 36 "app/online/cl_ol_0023.pgc" + + char bizdate[16]; char reqid[32]; char channel[16]; @@ -164,6 +185,36 @@ TX_SERVICE(CL_OL_0023, ctx) * - 가용 여력(avail)은 일 상한(cap)에서 소진수를 뺀 값이며 * 음수가 되지 않도록 0 하한으로 보정한다. */ + /* + * 2-1) 원장 직접 집계로 소진수(마감완료 M)를 재확인하고, 이미 발급된 + * 최대 처리키를 조회하여 채번 연속성의 근거로 삼는다. + */ + strncpy(h_biz_date, bizdate, sizeof(h_biz_date) - 1); + h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + strncpy(h_st_done, CL_ST_DONE, sizeof(h_st_done)); + h_db_used = 0; + h_max_key[0] = '\0'; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) , coalesce ( max ( key ) , '' ) from cl_ledger where biz_date = $1 and status = $2 ", + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_st_done),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_db_used),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_max_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 110 "app/online/cl_ol_0023.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("CL_OL_0023 direct used"); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + next_no = done_cnt + 1; avail = (cap > done_cnt) ? (cap - done_cnt) : 0; usage_rate = (cap > 0) ? (done_cnt * 100 / cap) : 0; @@ -180,6 +231,8 @@ TX_SERVICE(CL_OL_0023, ctx) tx_buf_sets(ctx->out, "REQID", reqid); tx_buf_sets(ctx->out, "CHANNEL", channel); tx_buf_setlong(ctx->out, "USEDCNT", done_cnt); + tx_buf_setlong(ctx->out, "DBUSED", h_db_used); + tx_buf_sets(ctx->out, "MAXKEY", h_max_key); tx_buf_setlong(ctx->out, "RECVCNT", recv_cnt); tx_buf_setlong(ctx->out, "SETTLEDCNT", settled_cnt); tx_buf_setlong(ctx->out, "CAP", cap); diff --git a/app/online/cl_ol_0023.pgc b/app/online/cl_ol_0023.pgc index ebafe95..4e2d476 100644 --- a/app/online/cl_ol_0023.pgc +++ b/app/online/cl_ol_0023.pgc @@ -28,6 +28,13 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(CL_OL_0023, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_biz_date[9]; + char h_st_done[2]; + long h_db_used; + char h_max_key[16]; + EXEC SQL END DECLARE SECTION; + char bizdate[16]; char reqid[32]; char channel[16]; @@ -86,6 +93,30 @@ TX_SERVICE(CL_OL_0023, ctx) * - 가용 여력(avail)은 일 상한(cap)에서 소진수를 뺀 값이며 * 음수가 되지 않도록 0 하한으로 보정한다. */ + /* + * 2-1) 원장 직접 집계로 소진수(마감완료 M)를 재확인하고, 이미 발급된 + * 최대 처리키를 조회하여 채번 연속성의 근거로 삼는다. + */ + strncpy(h_biz_date, bizdate, sizeof(h_biz_date) - 1); + h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + strncpy(h_st_done, CL_ST_DONE, sizeof(h_st_done)); + h_db_used = 0; + h_max_key[0] = '\0'; + + EXEC SQL SELECT count(*), coalesce(max(key), '') + INTO :h_db_used, :h_max_key + FROM cl_ledger + WHERE biz_date = :h_biz_date + AND status = :h_st_done; + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("CL_OL_0023 direct used"); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + next_no = done_cnt + 1; avail = (cap > done_cnt) ? (cap - done_cnt) : 0; usage_rate = (cap > 0) ? (done_cnt * 100 / cap) : 0; @@ -102,6 +133,8 @@ TX_SERVICE(CL_OL_0023, ctx) tx_buf_sets(ctx->out, "REQID", reqid); tx_buf_sets(ctx->out, "CHANNEL", channel); tx_buf_setlong(ctx->out, "USEDCNT", done_cnt); + tx_buf_setlong(ctx->out, "DBUSED", h_db_used); + tx_buf_sets(ctx->out, "MAXKEY", h_max_key); tx_buf_setlong(ctx->out, "RECVCNT", recv_cnt); tx_buf_setlong(ctx->out, "SETTLEDCNT", settled_cnt); tx_buf_setlong(ctx->out, "CAP", cap); diff --git a/app/online/cl_ol_0025.c b/app/online/cl_ol_0025.c index bdf4b06..33d7921 100644 --- a/app/online/cl_ol_0025.c +++ b/app/online/cl_ol_0025.c @@ -105,6 +105,39 @@ struct sqlca_t *ECPGget_sqlca(void); TX_SERVICE(CL_OL_0025, ctx) { + /* exec sql begin declare section */ + + + + + + + + +#line 31 "app/online/cl_ol_0025.pgc" + char h_biz_date [ 9 ] ; + +#line 32 "app/online/cl_ol_0025.pgc" + char h_severity [ 8 ] ; + +#line 33 "app/online/cl_ol_0025.pgc" + char h_target [ 32 ] ; + +#line 34 "app/online/cl_ol_0025.pgc" + char h_reqid [ 32 ] ; + +#line 35 "app/online/cl_ol_0025.pgc" + long h_recv ; + +#line 36 "app/online/cl_ol_0025.pgc" + long h_fail ; + +#line 37 "app/online/cl_ol_0025.pgc" + char h_alert [ TX_VAL_LEN ] ; +/* exec sql end declare section */ +#line 38 "app/online/cl_ol_0025.pgc" + + char bizdate[16]; char reqid[32]; char target[32]; @@ -112,6 +145,7 @@ TX_SERVICE(CL_OL_0025, ctx) const char *severity; long recv_cnt, fail_cnt, settled_cnt, done_cnt; long pending, total_cnt; + long logged = 0; int need_alert; tx_log(TX_LOG_INFO, "[CL_OL_0025] 알림 재발송 서비스 진입"); @@ -175,8 +209,58 @@ TX_SERVICE(CL_OL_0025, ctx) "[마감알림/%s] %s 마감 정상완료(정산완료 %ld건) - 조치 불필요", severity, bizdate, settled_cnt); + /* + * 4) 알림 발송 이력 적재. 알림이 필요한 경우에만 cl_alert_log 에 + * 남기며, 발송 이력은 재발송 중복방지/감사추적의 근거가 된다. + */ + if (need_alert) { + strncpy(h_biz_date, bizdate, sizeof(h_biz_date) - 1); + h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + strncpy(h_severity, severity, sizeof(h_severity) - 1); + h_severity[sizeof(h_severity) - 1] = '\0'; + strncpy(h_target, target, sizeof(h_target) - 1); + h_target[sizeof(h_target) - 1] = '\0'; + strncpy(h_reqid, reqid, sizeof(h_reqid) - 1); + h_reqid[sizeof(h_reqid) - 1] = '\0'; + strncpy(h_alert, alert, sizeof(h_alert) - 1); + h_alert[sizeof(h_alert) - 1] = '\0'; + h_recv = recv_cnt; + h_fail = fail_cnt; + + if (tx_begin() != TX_OK) { + tx_log(TX_LOG_WARN, "[CL_OL_0025] tx_begin 경고"); + } else { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cl_alert_log ( biz_date , severity , recv_cnt , fail_cnt , target , reqid , alert_msg , sent_ts ) values ( $1 , $2 , $3 , $4 , $5 , $6 , $7 , now ( ) )", + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_severity),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_recv),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fail),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_target),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_reqid),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_alert),(long)TX_VAL_LEN,(long)1,(TX_VAL_LEN)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 136 "app/online/cl_ol_0025.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CL_OL_0025 INSERT cl_alert_log"); + tx_abort(); + } else { + logged = (long)sqlca.sqlerrd[2]; + tx_commit(); + } + } + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); + tx_buf_setlong(ctx->out, "LOGGED", logged); tx_buf_sets(ctx->out, "TYPE", "ALERT"); tx_buf_sets(ctx->out, "BIZDATE", bizdate); tx_buf_sets(ctx->out, "REQID", reqid); diff --git a/app/online/cl_ol_0025.pgc b/app/online/cl_ol_0025.pgc index 245bc59..839df01 100644 --- a/app/online/cl_ol_0025.pgc +++ b/app/online/cl_ol_0025.pgc @@ -27,6 +27,16 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(CL_OL_0025, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_biz_date[9]; + char h_severity[8]; + char h_target[32]; + char h_reqid[32]; + long h_recv; + long h_fail; + char h_alert[TX_VAL_LEN]; + EXEC SQL END DECLARE SECTION; + char bizdate[16]; char reqid[32]; char target[32]; @@ -34,6 +44,7 @@ TX_SERVICE(CL_OL_0025, ctx) const char *severity; long recv_cnt, fail_cnt, settled_cnt, done_cnt; long pending, total_cnt; + long logged = 0; int need_alert; tx_log(TX_LOG_INFO, "[CL_OL_0025] 알림 재발송 서비스 진입"); @@ -97,8 +108,46 @@ TX_SERVICE(CL_OL_0025, ctx) "[마감알림/%s] %s 마감 정상완료(정산완료 %ld건) - 조치 불필요", severity, bizdate, settled_cnt); + /* + * 4) 알림 발송 이력 적재. 알림이 필요한 경우에만 cl_alert_log 에 + * 남기며, 발송 이력은 재발송 중복방지/감사추적의 근거가 된다. + */ + if (need_alert) { + strncpy(h_biz_date, bizdate, sizeof(h_biz_date) - 1); + h_biz_date[sizeof(h_biz_date) - 1] = '\0'; + strncpy(h_severity, severity, sizeof(h_severity) - 1); + h_severity[sizeof(h_severity) - 1] = '\0'; + strncpy(h_target, target, sizeof(h_target) - 1); + h_target[sizeof(h_target) - 1] = '\0'; + strncpy(h_reqid, reqid, sizeof(h_reqid) - 1); + h_reqid[sizeof(h_reqid) - 1] = '\0'; + strncpy(h_alert, alert, sizeof(h_alert) - 1); + h_alert[sizeof(h_alert) - 1] = '\0'; + h_recv = recv_cnt; + h_fail = fail_cnt; + + if (tx_begin() != TX_OK) { + tx_log(TX_LOG_WARN, "[CL_OL_0025] tx_begin 경고"); + } else { + EXEC SQL INSERT INTO cl_alert_log + (biz_date, severity, recv_cnt, fail_cnt, + target, reqid, alert_msg, sent_ts) + VALUES (:h_biz_date, :h_severity, :h_recv, :h_fail, + :h_target, :h_reqid, :h_alert, now()); + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CL_OL_0025 INSERT cl_alert_log"); + tx_abort(); + } else { + logged = (long)sqlca.sqlerrd[2]; + tx_commit(); + } + } + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); + tx_buf_setlong(ctx->out, "LOGGED", logged); tx_buf_sets(ctx->out, "TYPE", "ALERT"); tx_buf_sets(ctx->out, "BIZDATE", bizdate); tx_buf_sets(ctx->out, "REQID", reqid); diff --git a/app/online/cl_ol_0031.c b/app/online/cl_ol_0031.c index 30a7e62..950225c 100644 --- a/app/online/cl_ol_0031.c +++ b/app/online/cl_ol_0031.c @@ -103,6 +103,31 @@ struct sqlca_t *ECPGget_sqlca(void); TX_SERVICE(CL_OL_0031, ctx) { + /* exec sql begin declare section */ + + + + + + +#line 29 "app/online/cl_ol_0031.pgc" + char h_ss1 [ 16 ] ; + +#line 30 "app/online/cl_ol_0031.pgc" + char h_ss2 [ 16 ] ; + +#line 31 "app/online/cl_ol_0031.pgc" + long h_diff ; + +#line 32 "app/online/cl_ol_0031.pgc" + char h_direction [ 8 ] ; + +#line 33 "app/online/cl_ol_0031.pgc" + char h_reqid [ 32 ] ; +/* exec sql end declare section */ +#line 34 "app/online/cl_ol_0031.pgc" + + cl_rec_t rec1, rec2; char ss1[16], ss2[16]; char reqid[32]; @@ -111,6 +136,7 @@ TX_SERVICE(CL_OL_0031, ctx) const char *direction; long diff, cnt_diff, abs_diff; long rate; + long persisted = 0; int rc1, rc2; tx_log(TX_LOG_INFO, "[CL_OL_0031] 마감 스냅샷 비교 서비스 진입"); @@ -172,6 +198,43 @@ TX_SERVICE(CL_OL_0031, ctx) "스냅샷 %s(%ld) -> %s(%ld) 변동 %ld원 (%s %ld%%)", ss1, rec1.amount, ss2, rec2.amount, diff, direction, rate); + /* 5) 비교 결과를 cl_snap_diff 에 적재하여 감사이력으로 남긴다. */ + strncpy(h_ss1, ss1, sizeof(h_ss1) - 1); + h_ss1[sizeof(h_ss1) - 1] = '\0'; + strncpy(h_ss2, ss2, sizeof(h_ss2) - 1); + h_ss2[sizeof(h_ss2) - 1] = '\0'; + strncpy(h_direction, direction, sizeof(h_direction) - 1); + h_direction[sizeof(h_direction) - 1] = '\0'; + strncpy(h_reqid, reqid, sizeof(h_reqid) - 1); + h_reqid[sizeof(h_reqid) - 1] = '\0'; + h_diff = diff; + + if (tx_begin() != TX_OK) { + tx_log(TX_LOG_WARN, "[CL_OL_0031] tx_begin 경고"); + } else { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cl_snap_diff ( ss1_key , ss2_key , amt_diff , direction , reqid , cmp_ts ) values ( $1 , $2 , $3 , $4 , $5 , now ( ) )", + ECPGt_char,(h_ss1),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_ss2),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_diff),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_direction),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_reqid),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 122 "app/online/cl_ol_0031.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CL_OL_0031 INSERT cl_snap_diff"); + tx_abort(); + } else { + persisted = (long)sqlca.sqlerrd[2]; + tx_commit(); + } + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "SS1", ss1); @@ -187,6 +250,7 @@ TX_SERVICE(CL_OL_0031, ctx) tx_buf_setlong(ctx->out, "CNTDIFF", cnt_diff); tx_buf_setlong(ctx->out, "RATE", rate); tx_buf_sets(ctx->out, "DIRECTION", direction); + tx_buf_setlong(ctx->out, "PERSISTED", persisted); tx_buf_sets(ctx->out, "SUMMARY", summary); tx_buf_sets(ctx->out, "MATCH", (diff == 0) ? "Y" : "N"); /* 유의미 변동 여부(절대변동이 기준의 1% 초과) */ diff --git a/app/online/cl_ol_0031.pgc b/app/online/cl_ol_0031.pgc index d979252..c895f72 100644 --- a/app/online/cl_ol_0031.pgc +++ b/app/online/cl_ol_0031.pgc @@ -25,6 +25,14 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(CL_OL_0031, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_ss1[16]; + char h_ss2[16]; + long h_diff; + char h_direction[8]; + char h_reqid[32]; + EXEC SQL END DECLARE SECTION; + cl_rec_t rec1, rec2; char ss1[16], ss2[16]; char reqid[32]; @@ -33,6 +41,7 @@ TX_SERVICE(CL_OL_0031, ctx) const char *direction; long diff, cnt_diff, abs_diff; long rate; + long persisted = 0; int rc1, rc2; tx_log(TX_LOG_INFO, "[CL_OL_0031] 마감 스냅샷 비교 서비스 진입"); @@ -94,6 +103,33 @@ TX_SERVICE(CL_OL_0031, ctx) "스냅샷 %s(%ld) -> %s(%ld) 변동 %ld원 (%s %ld%%)", ss1, rec1.amount, ss2, rec2.amount, diff, direction, rate); + /* 5) 비교 결과를 cl_snap_diff 에 적재하여 감사이력으로 남긴다. */ + strncpy(h_ss1, ss1, sizeof(h_ss1) - 1); + h_ss1[sizeof(h_ss1) - 1] = '\0'; + strncpy(h_ss2, ss2, sizeof(h_ss2) - 1); + h_ss2[sizeof(h_ss2) - 1] = '\0'; + strncpy(h_direction, direction, sizeof(h_direction) - 1); + h_direction[sizeof(h_direction) - 1] = '\0'; + strncpy(h_reqid, reqid, sizeof(h_reqid) - 1); + h_reqid[sizeof(h_reqid) - 1] = '\0'; + h_diff = diff; + + if (tx_begin() != TX_OK) { + tx_log(TX_LOG_WARN, "[CL_OL_0031] tx_begin 경고"); + } else { + EXEC SQL INSERT INTO cl_snap_diff + (ss1_key, ss2_key, amt_diff, direction, reqid, cmp_ts) + VALUES (:h_ss1, :h_ss2, :h_diff, :h_direction, :h_reqid, now()); + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CL_OL_0031 INSERT cl_snap_diff"); + tx_abort(); + } else { + persisted = (long)sqlca.sqlerrd[2]; + tx_commit(); + } + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "SS1", ss1); @@ -109,6 +145,7 @@ TX_SERVICE(CL_OL_0031, ctx) tx_buf_setlong(ctx->out, "CNTDIFF", cnt_diff); tx_buf_setlong(ctx->out, "RATE", rate); tx_buf_sets(ctx->out, "DIRECTION", direction); + tx_buf_setlong(ctx->out, "PERSISTED", persisted); tx_buf_sets(ctx->out, "SUMMARY", summary); tx_buf_sets(ctx->out, "MATCH", (diff == 0) ? "Y" : "N"); /* 유의미 변동 여부(절대변동이 기준의 1% 초과) */ diff --git a/app/online/cm_ol_0001.c b/app/online/cm_ol_0001.c index 98639cb..a25acec 100644 --- a/app/online/cm_ol_0001.c +++ b/app/online/cm_ol_0001.c @@ -152,7 +152,7 @@ TX_SERVICE(CM_OL_0001, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_int,&(h_sort),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 55 "app/online/cm_ol_0001.pgc" +#line 54 "app/online/cm_ol_0001.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/cm_ol_0001.pgc b/app/online/cm_ol_0001.pgc index db9fed3..0f18081 100644 --- a/app/online/cm_ol_0001.pgc +++ b/app/online/cm_ol_0001.pgc @@ -46,8 +46,7 @@ TX_SERVICE(CM_OL_0001, ctx) strncpy(h_code, code, sizeof(h_code) - 1); h_sort = 0; - EXEC SQL - SELECT code_name, attr_val, sort_no + EXEC SQL SELECT code_name, attr_val, sort_no INTO :h_name, :h_attr, :h_sort FROM cm_code WHERE grp_cd = :h_grp diff --git a/app/online/cm_ol_0002.c b/app/online/cm_ol_0002.c index fcbd827..a86a1ee 100644 --- a/app/online/cm_ol_0002.c +++ b/app/online/cm_ol_0002.c @@ -12,13 +12,15 @@ * * 요청의 기준일자(DATE, YYYYMMDD)를 검증한 뒤 date_next_business 로 * 다음 영업일을 산출하고, 기준일의 요일번호/요일명/주말여부를 함께 - * 응답한다. DB 접근이 없는 순수 유틸리티 로직. + * 응답한다. 아울러 휴일 마스터(cm_holiday)를 조회하여 기준일이 지정 + * 공휴일인지(HOLIDAY=Y/N)와 휴일명을 응답에 반영한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -91,7 +93,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/cm_ol_0002.pgc" +#line 19 "app/online/cm_ol_0002.pgc" /* 요일번호(0=일..6=토)를 한글 표기로 변환 */ @@ -108,10 +110,28 @@ static const char *weekday_name(int wd) TX_SERVICE(CM_OL_0002, ctx) { + /* exec sql begin declare section */ + + + + +#line 36 "app/online/cm_ol_0002.pgc" + char h_date [ 9 ] ; + +#line 37 "app/online/cm_ol_0002.pgc" + char h_holi_nm [ 64 ] ; + +#line 38 "app/online/cm_ol_0002.pgc" + long h_holi_cnt ; +/* exec sql end declare section */ +#line 39 "app/online/cm_ol_0002.pgc" + + char base_date[9]; char next_date[9]; int wd; int weekend; + int is_holiday; tx_log(TX_LOG_INFO, "[CM_OL_0002] 영업일 계산 서비스 진입"); @@ -139,14 +159,40 @@ TX_SERVICE(CM_OL_0002, ctx) return; } + /* 지정 공휴일 여부 조회 (휴일 마스터) */ + strncpy(h_date, base_date, sizeof(h_date) - 1); + h_date[sizeof(h_date) - 1] = '\0'; + h_holi_cnt = 0; + h_holi_nm[0] = '\0'; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) , coalesce ( max ( holi_nm ) , '' ) from cm_holiday where holi_date = $1 and use_yn = 'Y'", + ECPGt_char,(h_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_holi_cnt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_holi_nm),(long)64,(long)1,(64)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 83 "app/online/cm_ol_0002.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("CM_OL_0002 SELECT cm_holiday"); + h_holi_cnt = 0; + h_holi_nm[0] = '\0'; + } + is_holiday = (h_holi_cnt > 0) ? 1 : 0; + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "DATE", base_date); tx_buf_sets(ctx->out, "NEXTBIZ", next_date); tx_buf_setlong(ctx->out, "WEEKDAY", (long)wd); tx_buf_sets(ctx->out, "WEEKDAYNM", weekday_name(wd)); tx_buf_sets(ctx->out, "WEEKEND", weekend ? "Y" : "N"); + tx_buf_sets(ctx->out, "HOLIDAY", is_holiday ? "Y" : "N"); + tx_buf_sets(ctx->out, "HOLINM", h_holi_nm); - tx_log(TX_LOG_INFO, "[CM_OL_0002] 계산완료 date=%s(%s) next=%s weekend=%s", - base_date, weekday_name(wd), next_date, weekend ? "Y" : "N"); + tx_log(TX_LOG_INFO, "[CM_OL_0002] 계산완료 date=%s(%s) next=%s weekend=%s holiday=%s", + base_date, weekday_name(wd), next_date, weekend ? "Y" : "N", + is_holiday ? "Y" : "N"); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0002.pgc b/app/online/cm_ol_0002.pgc index 6f09b21..b6e2472 100644 --- a/app/online/cm_ol_0002.pgc +++ b/app/online/cm_ol_0002.pgc @@ -4,13 +4,15 @@ * * 요청의 기준일자(DATE, YYYYMMDD)를 검증한 뒤 date_next_business 로 * 다음 영업일을 산출하고, 기준일의 요일번호/요일명/주말여부를 함께 - * 응답한다. DB 접근이 없는 순수 유틸리티 로직. + * 응답한다. 아울러 휴일 마스터(cm_holiday)를 조회하여 기준일이 지정 + * 공휴일인지(HOLIDAY=Y/N)와 휴일명을 응답에 반영한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -30,10 +32,17 @@ static const char *weekday_name(int wd) TX_SERVICE(CM_OL_0002, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_date[9]; + char h_holi_nm[64]; + long h_holi_cnt; + EXEC SQL END DECLARE SECTION; + char base_date[9]; char next_date[9]; int wd; int weekend; + int is_holiday; tx_log(TX_LOG_INFO, "[CM_OL_0002] 영업일 계산 서비스 진입"); @@ -61,14 +70,36 @@ TX_SERVICE(CM_OL_0002, ctx) return; } + /* 지정 공휴일 여부 조회 (휴일 마스터) */ + strncpy(h_date, base_date, sizeof(h_date) - 1); + h_date[sizeof(h_date) - 1] = '\0'; + h_holi_cnt = 0; + h_holi_nm[0] = '\0'; + + EXEC SQL SELECT count(*), coalesce(max(holi_nm), '') + INTO :h_holi_cnt, :h_holi_nm + FROM cm_holiday + WHERE holi_date = :h_date + AND use_yn = 'Y'; + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("CM_OL_0002 SELECT cm_holiday"); + h_holi_cnt = 0; + h_holi_nm[0] = '\0'; + } + is_holiday = (h_holi_cnt > 0) ? 1 : 0; + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "DATE", base_date); tx_buf_sets(ctx->out, "NEXTBIZ", next_date); tx_buf_setlong(ctx->out, "WEEKDAY", (long)wd); tx_buf_sets(ctx->out, "WEEKDAYNM", weekday_name(wd)); tx_buf_sets(ctx->out, "WEEKEND", weekend ? "Y" : "N"); + tx_buf_sets(ctx->out, "HOLIDAY", is_holiday ? "Y" : "N"); + tx_buf_sets(ctx->out, "HOLINM", h_holi_nm); - tx_log(TX_LOG_INFO, "[CM_OL_0002] 계산완료 date=%s(%s) next=%s weekend=%s", - base_date, weekday_name(wd), next_date, weekend ? "Y" : "N"); + tx_log(TX_LOG_INFO, "[CM_OL_0002] 계산완료 date=%s(%s) next=%s weekend=%s holiday=%s", + base_date, weekday_name(wd), next_date, weekend ? "Y" : "N", + is_holiday ? "Y" : "N"); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0003.c b/app/online/cm_ol_0003.c index cbe819c..4269d30 100644 --- a/app/online/cm_ol_0003.c +++ b/app/online/cm_ol_0003.c @@ -12,13 +12,15 @@ * * 요청의 입력금액(AMOUNT)을 amount_format_won 으로 천단위 콤마/원 * 표기 문자열로 변환하고, amount_is_valid 로 금액 유효범위 여부를 - * 함께 응답한다. DB 접근이 없는 순수 유틸리티 로직. + * 함께 응답한다. 아울러 금액정책 마스터(cm_amt_policy)에서 표준 상한 + * (max_amt)을 조회하여 정책상한 초과여부(OVERPOLICY=Y/N)를 통지한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -91,16 +93,30 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/cm_ol_0003.pgc" +#line 19 "app/online/cm_ol_0003.pgc" TX_SERVICE(CM_OL_0003, ctx) { + /* exec sql begin declare section */ + + + +#line 24 "app/online/cm_ol_0003.pgc" + char h_policy [ 16 ] ; + +#line 25 "app/online/cm_ol_0003.pgc" + long h_max_amt ; +/* exec sql end declare section */ +#line 26 "app/online/cm_ol_0003.pgc" + + char amt_field[32]; char won_disp[48]; char plain_disp[32]; long amount = 0; int valid; + int over_policy = 0; tx_log(TX_LOG_INFO, "[CM_OL_0003] 금액 포맷 유틸 서비스 진입"); @@ -123,6 +139,28 @@ TX_SERVICE(CM_OL_0003, ctx) /* 유효범위를 벗어나도 표기 자체는 제공하되 VALID=N 으로 통지 */ } + /* 정책 상한 조회 (정책구분 PARAM 우선, 없으면 DEFAULT) */ + if (tx_buf_get(ctx->in, "POLICY", h_policy, sizeof(h_policy)) != TX_OK) + strncpy(h_policy, "DEFAULT", sizeof(h_policy) - 1); + h_policy[sizeof(h_policy) - 1] = '\0'; + h_max_amt = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select max_amt from cm_amt_policy where policy_cd = $1 and use_yn = 'Y'", + ECPGt_char,(h_policy),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_max_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 66 "app/online/cm_ol_0003.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_INFO, "[CM_OL_0003] 정책 미등록 policy=%s (상한검증 생략)", h_policy); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0003 SELECT cm_amt_policy"); + } else if (h_max_amt > 0 && amount > h_max_amt) { + over_policy = 1; + } + amount_format_won(amount, won_disp, sizeof(won_disp)); if (amount_format(amount, plain_disp, sizeof(plain_disp)) != 0) { strncpy(plain_disp, "0", sizeof(plain_disp) - 1); @@ -133,8 +171,10 @@ TX_SERVICE(CM_OL_0003, ctx) tx_buf_sets(ctx->out, "WONDISP", won_disp); tx_buf_sets(ctx->out, "PLAINDISP", plain_disp); tx_buf_sets(ctx->out, "VALID", valid ? "Y" : "N"); + tx_buf_setlong(ctx->out, "POLICYMAX", h_max_amt); + tx_buf_sets(ctx->out, "OVERPOLICY", over_policy ? "Y" : "N"); - tx_log(TX_LOG_INFO, "[CM_OL_0003] 포맷완료 amount=%ld disp=%s valid=%s", - amount, won_disp, valid ? "Y" : "N"); + tx_log(TX_LOG_INFO, "[CM_OL_0003] 포맷완료 amount=%ld disp=%s valid=%s over=%s", + amount, won_disp, valid ? "Y" : "N", over_policy ? "Y" : "N"); tx_return(ctx, valid ? TX_OK : TX_EINVAL, ctx->out); } diff --git a/app/online/cm_ol_0003.pgc b/app/online/cm_ol_0003.pgc index 70b4c6e..edc17fb 100644 --- a/app/online/cm_ol_0003.pgc +++ b/app/online/cm_ol_0003.pgc @@ -4,13 +4,15 @@ * * 요청의 입력금액(AMOUNT)을 amount_format_won 으로 천단위 콤마/원 * 표기 문자열로 변환하고, amount_is_valid 로 금액 유효범위 여부를 - * 함께 응답한다. DB 접근이 없는 순수 유틸리티 로직. + * 함께 응답한다. 아울러 금액정책 마스터(cm_amt_policy)에서 표준 상한 + * (max_amt)을 조회하여 정책상한 초과여부(OVERPOLICY=Y/N)를 통지한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -18,11 +20,17 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(CM_OL_0003, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_policy[16]; + long h_max_amt; + EXEC SQL END DECLARE SECTION; + char amt_field[32]; char won_disp[48]; char plain_disp[32]; long amount = 0; int valid; + int over_policy = 0; tx_log(TX_LOG_INFO, "[CM_OL_0003] 금액 포맷 유틸 서비스 진입"); @@ -45,6 +53,26 @@ TX_SERVICE(CM_OL_0003, ctx) /* 유효범위를 벗어나도 표기 자체는 제공하되 VALID=N 으로 통지 */ } + /* 정책 상한 조회 (정책구분 PARAM 우선, 없으면 DEFAULT) */ + if (tx_buf_get(ctx->in, "POLICY", h_policy, sizeof(h_policy)) != TX_OK) + strncpy(h_policy, "DEFAULT", sizeof(h_policy) - 1); + h_policy[sizeof(h_policy) - 1] = '\0'; + h_max_amt = 0; + + EXEC SQL SELECT max_amt + INTO :h_max_amt + FROM cm_amt_policy + WHERE policy_cd = :h_policy + AND use_yn = 'Y'; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_INFO, "[CM_OL_0003] 정책 미등록 policy=%s (상한검증 생략)", h_policy); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0003 SELECT cm_amt_policy"); + } else if (h_max_amt > 0 && amount > h_max_amt) { + over_policy = 1; + } + amount_format_won(amount, won_disp, sizeof(won_disp)); if (amount_format(amount, plain_disp, sizeof(plain_disp)) != 0) { strncpy(plain_disp, "0", sizeof(plain_disp) - 1); @@ -55,8 +83,10 @@ TX_SERVICE(CM_OL_0003, ctx) tx_buf_sets(ctx->out, "WONDISP", won_disp); tx_buf_sets(ctx->out, "PLAINDISP", plain_disp); tx_buf_sets(ctx->out, "VALID", valid ? "Y" : "N"); + tx_buf_setlong(ctx->out, "POLICYMAX", h_max_amt); + tx_buf_sets(ctx->out, "OVERPOLICY", over_policy ? "Y" : "N"); - tx_log(TX_LOG_INFO, "[CM_OL_0003] 포맷완료 amount=%ld disp=%s valid=%s", - amount, won_disp, valid ? "Y" : "N"); + tx_log(TX_LOG_INFO, "[CM_OL_0003] 포맷완료 amount=%ld disp=%s valid=%s over=%s", + amount, won_disp, valid ? "Y" : "N", over_policy ? "Y" : "N"); tx_return(ctx, valid ? TX_OK : TX_EINVAL, ctx->out); } diff --git a/app/online/cm_ol_0004.c b/app/online/cm_ol_0004.c index 36e9ec4..db6f1cc 100644 --- a/app/online/cm_ol_0004.c +++ b/app/online/cm_ol_0004.c @@ -12,13 +12,15 @@ * * 요청의 공통헤더 원천 필드(전문길이/전문종별/채널/거래일시)를 파싱· * 검증한 뒤, 고정 자리수의 표준 공통헤더 문자열로 재구성하여 응답한다. - * DB 접근이 없는 순수 전문 조립 로직. + * 채널코드는 채널 마스터(cm_channel)를 조회하여 채널명/사용여부를 + * 확인하며, 미등록·미사용 채널이면 반려한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -91,7 +93,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/cm_ol_0004.pgc" +#line 19 "app/online/cm_ol_0004.pgc" /* 전문종별 코드 → 표준 2자리 구분자 매핑 */ @@ -105,6 +107,23 @@ static const char *header_kind_tag(const char *kind) TX_SERVICE(CM_OL_0004, ctx) { + /* exec sql begin declare section */ + + + + +#line 33 "app/online/cm_ol_0004.pgc" + char h_channel [ 4 ] ; + +#line 34 "app/online/cm_ol_0004.pgc" + char h_channel_nm [ 40 ] ; + +#line 35 "app/online/cm_ol_0004.pgc" + char h_use_yn [ 2 ] ; +/* exec sql end declare section */ +#line 36 "app/online/cm_ol_0004.pgc" + + char msglen_f[8]; char kind[8]; char channel[4]; @@ -153,6 +172,38 @@ TX_SERVICE(CM_OL_0004, ctx) return; } + /* 채널 마스터 조회 : 채널명/사용여부 확인 */ + strncpy(h_channel, channel, sizeof(h_channel) - 1); + h_channel[sizeof(h_channel) - 1] = '\0'; + h_channel_nm[0] = '\0'; + strncpy(h_use_yn, "N", sizeof(h_use_yn)); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select channel_nm , use_yn from cm_channel where channel_cd = $1 ", + ECPGt_char,(h_channel),(long)4,(long)1,(4)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_channel_nm),(long)40,(long)1,(40)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_use_yn),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 95 "app/online/cm_ol_0004.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[CM_OL_0004] 미등록 채널 channel=%s", channel); + tx_return(ctx, TX_ENOENT, ctx->out); + return; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0004 SELECT cm_channel"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + if (strcmp(h_use_yn, "Y") != 0) { + tx_log(TX_LOG_WARN, "[CM_OL_0004] 미사용 채널 channel=%s", channel); + tx_return(ctx, TX_EINVAL, ctx->out); + return; + } + /* 표준 공통헤더 = 길이(4) + 종별태그(2) + 채널(2) + 거래일시(14) */ snprintf(std_header, sizeof(std_header), "%04ld%2s%-2.2s%-14.14s", msglen, tag, channel, datetime); @@ -161,8 +212,10 @@ TX_SERVICE(CM_OL_0004, ctx) tx_buf_sets(ctx->out, "STDHEADER", std_header); tx_buf_setlong(ctx->out, "MSGLEN", msglen); tx_buf_sets(ctx->out, "KINDTAG", tag); + tx_buf_sets(ctx->out, "CHANNELNM", h_channel_nm); tx_buf_setlong(ctx->out, "HDRLEN", (long)strlen(std_header)); - tx_log(TX_LOG_INFO, "[CM_OL_0004] 헤더조립 완료 tag=%s header=[%s]", tag, std_header); + tx_log(TX_LOG_INFO, "[CM_OL_0004] 헤더조립 완료 tag=%s channel=%s(%s) header=[%s]", + tag, channel, h_channel_nm, std_header); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0004.pgc b/app/online/cm_ol_0004.pgc index ed44e8f..ff5d4ea 100644 --- a/app/online/cm_ol_0004.pgc +++ b/app/online/cm_ol_0004.pgc @@ -4,13 +4,15 @@ * * 요청의 공통헤더 원천 필드(전문길이/전문종별/채널/거래일시)를 파싱· * 검증한 뒤, 고정 자리수의 표준 공통헤더 문자열로 재구성하여 응답한다. - * DB 접근이 없는 순수 전문 조립 로직. + * 채널코드는 채널 마스터(cm_channel)를 조회하여 채널명/사용여부를 + * 확인하며, 미등록·미사용 채널이면 반려한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -27,6 +29,12 @@ static const char *header_kind_tag(const char *kind) TX_SERVICE(CM_OL_0004, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_channel[4]; + char h_channel_nm[40]; + char h_use_yn[2]; + EXEC SQL END DECLARE SECTION; + char msglen_f[8]; char kind[8]; char channel[4]; @@ -75,6 +83,33 @@ TX_SERVICE(CM_OL_0004, ctx) return; } + /* 채널 마스터 조회 : 채널명/사용여부 확인 */ + strncpy(h_channel, channel, sizeof(h_channel) - 1); + h_channel[sizeof(h_channel) - 1] = '\0'; + h_channel_nm[0] = '\0'; + strncpy(h_use_yn, "N", sizeof(h_use_yn)); + + EXEC SQL SELECT channel_nm, use_yn + INTO :h_channel_nm, :h_use_yn + FROM cm_channel + WHERE channel_cd = :h_channel; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[CM_OL_0004] 미등록 채널 channel=%s", channel); + tx_return(ctx, TX_ENOENT, ctx->out); + return; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0004 SELECT cm_channel"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + if (strcmp(h_use_yn, "Y") != 0) { + tx_log(TX_LOG_WARN, "[CM_OL_0004] 미사용 채널 channel=%s", channel); + tx_return(ctx, TX_EINVAL, ctx->out); + return; + } + /* 표준 공통헤더 = 길이(4) + 종별태그(2) + 채널(2) + 거래일시(14) */ snprintf(std_header, sizeof(std_header), "%04ld%2s%-2.2s%-14.14s", msglen, tag, channel, datetime); @@ -83,8 +118,10 @@ TX_SERVICE(CM_OL_0004, ctx) tx_buf_sets(ctx->out, "STDHEADER", std_header); tx_buf_setlong(ctx->out, "MSGLEN", msglen); tx_buf_sets(ctx->out, "KINDTAG", tag); + tx_buf_sets(ctx->out, "CHANNELNM", h_channel_nm); tx_buf_setlong(ctx->out, "HDRLEN", (long)strlen(std_header)); - tx_log(TX_LOG_INFO, "[CM_OL_0004] 헤더조립 완료 tag=%s header=[%s]", tag, std_header); + tx_log(TX_LOG_INFO, "[CM_OL_0004] 헤더조립 완료 tag=%s channel=%s(%s) header=[%s]", + tag, channel, h_channel_nm, std_header); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0005.c b/app/online/cm_ol_0005.c index 6c7fb74..e0fae14 100644 --- a/app/online/cm_ol_0005.c +++ b/app/online/cm_ol_0005.c @@ -159,7 +159,7 @@ TX_SERVICE(CM_OL_0005, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_action),(long)8,(long)1,(8)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 62 "app/online/cm_ol_0005.pgc" +#line 61 "app/online/cm_ol_0005.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/cm_ol_0005.pgc b/app/online/cm_ol_0005.pgc index 34e3431..d202b58 100644 --- a/app/online/cm_ol_0005.pgc +++ b/app/online/cm_ol_0005.pgc @@ -53,8 +53,7 @@ TX_SERVICE(CM_OL_0005, ctx) strncpy(h_errcd, errcd, sizeof(h_errcd) - 1); strncpy(h_lang, lang, sizeof(h_lang) - 1); - EXEC SQL - SELECT msg_text, severity, action_cd + EXEC SQL SELECT msg_text, severity, action_cd INTO :h_msgtext, :h_severity, :h_action FROM cm_msg WHERE err_cd = :h_errcd diff --git a/app/online/cm_ol_0006.c b/app/online/cm_ol_0006.c index c678fa3..121f429 100644 --- a/app/online/cm_ol_0006.c +++ b/app/online/cm_ol_0006.c @@ -162,7 +162,7 @@ TX_SERVICE(CM_OL_0006, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_prefix),(long)8,(long)1,(8)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 64 "app/online/cm_ol_0006.pgc" +#line 63 "app/online/cm_ol_0006.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -190,7 +190,7 @@ TX_SERVICE(CM_OL_0006, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_seqkey),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 90 "app/online/cm_ol_0006.pgc" +#line 88 "app/online/cm_ol_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/cm_ol_0006.pgc b/app/online/cm_ol_0006.pgc index 202ecb1..4103a36 100644 --- a/app/online/cm_ol_0006.pgc +++ b/app/online/cm_ol_0006.pgc @@ -56,8 +56,7 @@ TX_SERVICE(CM_OL_0006, ctx) h_width = 0; /* 순환최대치/자리수/접두어 확보 (행잠금) */ - EXEC SQL - SELECT cur_val, max_val, seq_width, prefix + EXEC SQL SELECT cur_val, max_val, seq_width, prefix INTO :h_seqval, :h_maxval, :h_width, :h_prefix FROM cm_seq WHERE seq_key = :h_seqkey @@ -83,8 +82,7 @@ TX_SERVICE(CM_OL_0006, ctx) tx_log(TX_LOG_INFO, "[CM_OL_0006] 순번 순환 리셋 seqkey=%s", seqkey); } - EXEC SQL - UPDATE cm_seq + EXEC SQL UPDATE cm_seq SET cur_val = :h_seqval, upd_ts = CURRENT_TIMESTAMP WHERE seq_key = :h_seqkey; diff --git a/app/online/cm_ol_0007.c b/app/online/cm_ol_0007.c index 82355fb..eddae6a 100644 --- a/app/online/cm_ol_0007.c +++ b/app/online/cm_ol_0007.c @@ -180,7 +180,7 @@ TX_SERVICE(CM_OL_0007, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_logseq),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 84 "app/online/cm_ol_0007.pgc" +#line 83 "app/online/cm_ol_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -206,7 +206,7 @@ TX_SERVICE(CM_OL_0007, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_xid),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 100 "app/online/cm_ol_0007.pgc" +#line 98 "app/online/cm_ol_0007.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/cm_ol_0007.pgc b/app/online/cm_ol_0007.pgc index 4692b78..5ab5e24 100644 --- a/app/online/cm_ol_0007.pgc +++ b/app/online/cm_ol_0007.pgc @@ -77,8 +77,7 @@ TX_SERVICE(CM_OL_0007, ctx) } /* 당일 로그일련번호 채번 (당일 최대치 +1) */ - EXEC SQL - SELECT COALESCE(MAX(log_seq), 0) + 1 + EXEC SQL SELECT COALESCE(MAX(log_seq), 0) + 1 INTO :h_logseq FROM cm_log WHERE biz_date = :h_bizdate; @@ -93,8 +92,7 @@ TX_SERVICE(CM_OL_0007, ctx) h_logseq = 1; } - EXEC SQL - INSERT INTO cm_log + EXEC SQL INSERT INTO cm_log (biz_date, log_seq, log_level, module_id, log_msg, xid, reg_ts) VALUES (:h_bizdate, :h_logseq, :h_level, :h_module, :h_message, :h_xid, CURRENT_TIMESTAMP); diff --git a/app/online/cm_ol_0008.c b/app/online/cm_ol_0008.c index 41d3568..7871570 100644 --- a/app/online/cm_ol_0008.c +++ b/app/online/cm_ol_0008.c @@ -154,7 +154,7 @@ TX_SERVICE(CM_OL_0008, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_expired),(long)2,(long)1,(2)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 58 "app/online/cm_ol_0008.pgc" +#line 57 "app/online/cm_ol_0008.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/cm_ol_0008.pgc b/app/online/cm_ol_0008.pgc index b5a9a29..ac4c6b0 100644 --- a/app/online/cm_ol_0008.pgc +++ b/app/online/cm_ol_0008.pgc @@ -48,8 +48,7 @@ TX_SERVICE(CM_OL_0008, ctx) strncpy(h_sessid, sessid, sizeof(h_sessid) - 1); /* 만료판정은 DB 현재시각과 비교하여 산출 */ - EXEC SQL - SELECT user_id, + EXEC SQL SELECT user_id, sess_status, TO_CHAR(expire_ts, 'YYYYMMDDHH24MISS'), CASE WHEN expire_ts < CURRENT_TIMESTAMP THEN 'Y' ELSE 'N' END diff --git a/app/online/cm_ol_0009.c b/app/online/cm_ol_0009.c index c7f41d5..84d1cfd 100644 --- a/app/online/cm_ol_0009.c +++ b/app/online/cm_ol_0009.c @@ -172,7 +172,7 @@ TX_SERVICE(CM_OL_0009, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_quotedate),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 77 "app/online/cm_ol_0009.pgc" +#line 76 "app/online/cm_ol_0009.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/cm_ol_0009.pgc b/app/online/cm_ol_0009.pgc index d455f67..5779b5f 100644 --- a/app/online/cm_ol_0009.pgc +++ b/app/online/cm_ol_0009.pgc @@ -66,8 +66,7 @@ TX_SERVICE(CM_OL_0009, ctx) h_scale = 0; /* 기준일 이하 최근 고시 1건 */ - EXEC SQL - SELECT rate_scaled, rate_scale, quote_date + EXEC SQL SELECT rate_scaled, rate_scale, quote_date INTO :h_scaled, :h_scale, :h_quotedate FROM cm_rate WHERE cur_cd = :h_cur diff --git a/app/online/cm_ol_0011.c b/app/online/cm_ol_0011.c index 25367a9..0655a8e 100644 --- a/app/online/cm_ol_0011.c +++ b/app/online/cm_ol_0011.c @@ -146,7 +146,7 @@ TX_SERVICE(CM_OL_0011, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_desc),(long)128,(long)1,(128)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 53 "app/online/cm_ol_0011.pgc" +#line 52 "app/online/cm_ol_0011.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/cm_ol_0011.pgc b/app/online/cm_ol_0011.pgc index ddee1e3..34461b9 100644 --- a/app/online/cm_ol_0011.pgc +++ b/app/online/cm_ol_0011.pgc @@ -45,8 +45,7 @@ TX_SERVICE(CM_OL_0011, ctx) memset(h_desc, 0, sizeof(h_desc)); strncpy(h_pkey, pkey, sizeof(h_pkey) - 1); - EXEC SQL - SELECT param_val, data_type, param_desc + EXEC SQL SELECT param_val, data_type, param_desc INTO :h_pval, :h_dtype, :h_desc FROM cm_param WHERE param_key = :h_pkey diff --git a/app/online/cm_ol_0012.c b/app/online/cm_ol_0012.c index b70c181..f9150f2 100644 --- a/app/online/cm_ol_0012.c +++ b/app/online/cm_ol_0012.c @@ -153,7 +153,7 @@ TX_SERVICE(CM_OL_0012, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_dst_name),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 56 "app/online/cm_ol_0012.pgc" +#line 55 "app/online/cm_ol_0012.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/cm_ol_0012.pgc b/app/online/cm_ol_0012.pgc index 85b6f28..4ab46d3 100644 --- a/app/online/cm_ol_0012.pgc +++ b/app/online/cm_ol_0012.pgc @@ -47,8 +47,7 @@ TX_SERVICE(CM_OL_0012, ctx) strncpy(h_src_sys, src_sys, sizeof(h_src_sys) - 1); strncpy(h_src_cd, src_cd, sizeof(h_src_cd) - 1); - EXEC SQL - SELECT dst_sys, dst_cd, dst_name + EXEC SQL SELECT dst_sys, dst_cd, dst_name INTO :h_dst_sys, :h_dst_cd, :h_dst_name FROM cm_code_map WHERE src_sys = :h_src_sys diff --git a/app/online/cm_ol_0013.c b/app/online/cm_ol_0013.c index c2b7c6c..e55ebb2 100644 --- a/app/online/cm_ol_0013.c +++ b/app/online/cm_ol_0013.c @@ -12,13 +12,15 @@ * * 요청의 원문(DATA) 에 대해 바이트 XOR 누적(LRC) 체크섬을 순수 로직으로 * 계산하고, 기대값(EXPECT, 16진 2자리) 과 비교하여 일치여부(MATCH=Y/N)를 - * 응답한다. 대외 전문 무결성 검증 공통 루틴. DB 접근 없음. + * 응답한다. 대외 전문 무결성 검증 공통 루틴. 검증 결과는 무결성 감사 + * 이력(cm_lrc_log)에 적재하여 사후 추적을 지원한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -91,7 +93,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/cm_ol_0013.pgc" +#line 19 "app/online/cm_ol_0013.pgc" /* 문자열 전 구간 바이트 XOR 로 LRC(종방향 중복검사) 계산 */ @@ -108,12 +110,30 @@ static unsigned char lrc_calc(const char *data, int len) TX_SERVICE(CM_OL_0013, ctx) { + /* exec sql begin declare section */ + + + + +#line 36 "app/online/cm_ol_0013.pgc" + long h_data_len ; + +#line 37 "app/online/cm_ol_0013.pgc" + char h_lrc [ 4 ] ; + +#line 38 "app/online/cm_ol_0013.pgc" + char h_match [ 4 ] ; +/* exec sql end declare section */ +#line 39 "app/online/cm_ol_0013.pgc" + + char data[256]; char expect[8]; unsigned char lrc; unsigned int exp_val = 0; char calc_hex[4]; int match; + long logged = 0; tx_log(TX_LOG_INFO, "[CM_OL_0013] 체크섬 검증 서비스 진입"); @@ -138,9 +158,39 @@ TX_SERVICE(CM_OL_0013, ctx) match = -1; /* 비교 미수행 */ } + /* 무결성 검증 이력 적재 */ + h_data_len = (long)strlen(data); + strncpy(h_lrc, calc_hex, sizeof(h_lrc) - 1); + h_lrc[sizeof(h_lrc) - 1] = '\0'; + strncpy(h_match, (match < 0) ? "NA" : (match ? "Y" : "N"), sizeof(h_match) - 1); + h_match[sizeof(h_match) - 1] = '\0'; + + if (tx_begin() != TX_OK) { + tx_log(TX_LOG_WARN, "[CM_OL_0013] tx_begin 경고"); + } else { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cm_lrc_log ( data_len , lrc_hex , match_yn , chk_ts ) values ( $1 , $2 , $3 , now ( ) )", + ECPGt_long,&(h_data_len),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_lrc),(long)4,(long)1,(4)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_match),(long)4,(long)1,(4)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 84 "app/online/cm_ol_0013.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0013 INSERT cm_lrc_log"); + tx_abort(); + } else { + logged = (long)sqlca.sqlerrd[2]; + tx_commit(); + } + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "LRC", calc_hex); tx_buf_setlong(ctx->out, "LRCDEC", (long)lrc); + tx_buf_setlong(ctx->out, "LOGGED", logged); if (match < 0) { tx_buf_sets(ctx->out, "MATCH", "N/A"); tx_log(TX_LOG_INFO, "[CM_OL_0013] LRC 계산 lrc=%s (비교 미수행)", calc_hex); diff --git a/app/online/cm_ol_0013.pgc b/app/online/cm_ol_0013.pgc index 55bdb2d..ac7366b 100644 --- a/app/online/cm_ol_0013.pgc +++ b/app/online/cm_ol_0013.pgc @@ -4,13 +4,15 @@ * * 요청의 원문(DATA) 에 대해 바이트 XOR 누적(LRC) 체크섬을 순수 로직으로 * 계산하고, 기대값(EXPECT, 16진 2자리) 과 비교하여 일치여부(MATCH=Y/N)를 - * 응답한다. 대외 전문 무결성 검증 공통 루틴. DB 접근 없음. + * 응답한다. 대외 전문 무결성 검증 공통 루틴. 검증 결과는 무결성 감사 + * 이력(cm_lrc_log)에 적재하여 사후 추적을 지원한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -30,12 +32,19 @@ static unsigned char lrc_calc(const char *data, int len) TX_SERVICE(CM_OL_0013, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + long h_data_len; + char h_lrc[4]; + char h_match[4]; + EXEC SQL END DECLARE SECTION; + char data[256]; char expect[8]; unsigned char lrc; unsigned int exp_val = 0; char calc_hex[4]; int match; + long logged = 0; tx_log(TX_LOG_INFO, "[CM_OL_0013] 체크섬 검증 서비스 진입"); @@ -60,9 +69,33 @@ TX_SERVICE(CM_OL_0013, ctx) match = -1; /* 비교 미수행 */ } + /* 무결성 검증 이력 적재 */ + h_data_len = (long)strlen(data); + strncpy(h_lrc, calc_hex, sizeof(h_lrc) - 1); + h_lrc[sizeof(h_lrc) - 1] = '\0'; + strncpy(h_match, (match < 0) ? "NA" : (match ? "Y" : "N"), sizeof(h_match) - 1); + h_match[sizeof(h_match) - 1] = '\0'; + + if (tx_begin() != TX_OK) { + tx_log(TX_LOG_WARN, "[CM_OL_0013] tx_begin 경고"); + } else { + EXEC SQL INSERT INTO cm_lrc_log + (data_len, lrc_hex, match_yn, chk_ts) + VALUES (:h_data_len, :h_lrc, :h_match, now()); + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0013 INSERT cm_lrc_log"); + tx_abort(); + } else { + logged = (long)sqlca.sqlerrd[2]; + tx_commit(); + } + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "LRC", calc_hex); tx_buf_setlong(ctx->out, "LRCDEC", (long)lrc); + tx_buf_setlong(ctx->out, "LOGGED", logged); if (match < 0) { tx_buf_sets(ctx->out, "MATCH", "N/A"); tx_log(TX_LOG_INFO, "[CM_OL_0013] LRC 계산 lrc=%s (비교 미수행)", calc_hex); diff --git a/app/online/cm_ol_0014.c b/app/online/cm_ol_0014.c index 5844f5f..dfbea66 100644 --- a/app/online/cm_ol_0014.c +++ b/app/online/cm_ol_0014.c @@ -12,13 +12,15 @@ * * 요청의 영업일(DATE, YYYYMMDD)을 date_is_valid 로 검증한 뒤 * YYYY.MM.DD 표기 + 한글 요일명을 포함한 표시문자열로 변환하여 - * 응답한다. 화면/리포트 공통 날짜표기 루틴. DB 접근 없음. + * 응답한다. 화면/리포트 공통 날짜표기 루틴. 추가로 휴일 마스터 + * (cm_holiday)에서 휴일명/휴일구분을 조회하여 표시문자열에 반영한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -91,7 +93,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/cm_ol_0014.pgc" +#line 19 "app/online/cm_ol_0014.pgc" TX_SERVICE(CM_OL_0014, ctx) @@ -99,10 +101,29 @@ TX_SERVICE(CM_OL_0014, ctx) static const char *WDAY_KR[7] = { "일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일" }; + + /* exec sql begin declare section */ + + + + +#line 28 "app/online/cm_ol_0014.pgc" + char h_date [ 9 ] ; + +#line 29 "app/online/cm_ol_0014.pgc" + char h_holi_nm [ 64 ] ; + +#line 30 "app/online/cm_ol_0014.pgc" + char h_holi_type [ 4 ] ; +/* exec sql end declare section */ +#line 31 "app/online/cm_ol_0014.pgc" + + char date[16]; char dotted[16]; - char display[48]; + char display[80]; int wd; + int is_holiday; tx_log(TX_LOG_INFO, "[CM_OL_0014] 날짜 포맷 변환 서비스 진입"); @@ -130,7 +151,37 @@ TX_SERVICE(CM_OL_0014, ctx) return; } - snprintf(display, sizeof(display), "%s (%s)", dotted, WDAY_KR[wd]); + /* 휴일 마스터에서 휴일명/휴일구분 조회 */ + strncpy(h_date, date, sizeof(h_date) - 1); + h_date[sizeof(h_date) - 1] = '\0'; + h_holi_nm[0] = '\0'; + h_holi_type[0] = '\0'; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select holi_nm , holi_type from cm_holiday where holi_date = $1 and use_yn = 'Y'", + ECPGt_char,(h_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_holi_nm),(long)64,(long)1,(64)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_holi_type),(long)4,(long)1,(4)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 75 "app/online/cm_ol_0014.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + is_holiday = 0; + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0014 SELECT cm_holiday"); + is_holiday = 0; + h_holi_nm[0] = '\0'; + h_holi_type[0] = '\0'; + } else { + is_holiday = 1; + } + + if (is_holiday) + snprintf(display, sizeof(display), "%s (%s, %s)", dotted, WDAY_KR[wd], h_holi_nm); + else + snprintf(display, sizeof(display), "%s (%s)", dotted, WDAY_KR[wd]); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "DATE", date); @@ -138,6 +189,9 @@ TX_SERVICE(CM_OL_0014, ctx) tx_buf_sets(ctx->out, "WDAYNM", WDAY_KR[wd]); tx_buf_setlong(ctx->out, "WDAY", (long)wd); tx_buf_sets(ctx->out, "DISPLAY", display); + tx_buf_sets(ctx->out, "HOLIDAY", is_holiday ? "Y" : "N"); + tx_buf_sets(ctx->out, "HOLINM", h_holi_nm); + tx_buf_sets(ctx->out, "HOLITYPE", h_holi_type); tx_log(TX_LOG_INFO, "[CM_OL_0014] 변환완료 %s -> %s", date, display); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0014.pgc b/app/online/cm_ol_0014.pgc index 01c27c8..69a2010 100644 --- a/app/online/cm_ol_0014.pgc +++ b/app/online/cm_ol_0014.pgc @@ -4,13 +4,15 @@ * * 요청의 영업일(DATE, YYYYMMDD)을 date_is_valid 로 검증한 뒤 * YYYY.MM.DD 표기 + 한글 요일명을 포함한 표시문자열로 변환하여 - * 응답한다. 화면/리포트 공통 날짜표기 루틴. DB 접근 없음. + * 응답한다. 화면/리포트 공통 날짜표기 루틴. 추가로 휴일 마스터 + * (cm_holiday)에서 휴일명/휴일구분을 조회하여 표시문자열에 반영한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -21,10 +23,18 @@ TX_SERVICE(CM_OL_0014, ctx) static const char *WDAY_KR[7] = { "일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일" }; + + EXEC SQL BEGIN DECLARE SECTION; + char h_date[9]; + char h_holi_nm[64]; + char h_holi_type[4]; + EXEC SQL END DECLARE SECTION; + char date[16]; char dotted[16]; - char display[48]; + char display[80]; int wd; + int is_holiday; tx_log(TX_LOG_INFO, "[CM_OL_0014] 날짜 포맷 변환 서비스 진입"); @@ -52,7 +62,33 @@ TX_SERVICE(CM_OL_0014, ctx) return; } - snprintf(display, sizeof(display), "%s (%s)", dotted, WDAY_KR[wd]); + /* 휴일 마스터에서 휴일명/휴일구분 조회 */ + strncpy(h_date, date, sizeof(h_date) - 1); + h_date[sizeof(h_date) - 1] = '\0'; + h_holi_nm[0] = '\0'; + h_holi_type[0] = '\0'; + + EXEC SQL SELECT holi_nm, holi_type + INTO :h_holi_nm, :h_holi_type + FROM cm_holiday + WHERE holi_date = :h_date + AND use_yn = 'Y'; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + is_holiday = 0; + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0014 SELECT cm_holiday"); + is_holiday = 0; + h_holi_nm[0] = '\0'; + h_holi_type[0] = '\0'; + } else { + is_holiday = 1; + } + + if (is_holiday) + snprintf(display, sizeof(display), "%s (%s, %s)", dotted, WDAY_KR[wd], h_holi_nm); + else + snprintf(display, sizeof(display), "%s (%s)", dotted, WDAY_KR[wd]); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "DATE", date); @@ -60,6 +96,9 @@ TX_SERVICE(CM_OL_0014, ctx) tx_buf_sets(ctx->out, "WDAYNM", WDAY_KR[wd]); tx_buf_setlong(ctx->out, "WDAY", (long)wd); tx_buf_sets(ctx->out, "DISPLAY", display); + tx_buf_sets(ctx->out, "HOLIDAY", is_holiday ? "Y" : "N"); + tx_buf_sets(ctx->out, "HOLINM", h_holi_nm); + tx_buf_sets(ctx->out, "HOLITYPE", h_holi_type); tx_log(TX_LOG_INFO, "[CM_OL_0014] 변환완료 %s -> %s", date, display); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0015.c b/app/online/cm_ol_0015.c index 654d95e..4e0a385 100644 --- a/app/online/cm_ol_0015.c +++ b/app/online/cm_ol_0015.c @@ -12,13 +12,15 @@ * * 요청의 영업일(DATE)에 대해 cm 표준 DBIO(cm_rec_count/cm_rec_sum)를 * 조합하여 상태별 건수(접수/완료/실패/정산)와 총 거래금액을 집계해 - * 응답한다. 일마감/모니터링 대시보드용 공통 집계 서비스. + * 응답한다. 아울러 cm_ledger 원장을 직접 집계(SELECT)하여 총건수/금액/ + * 수수료합계를 산출하고 DBIO 집계와 교차검증한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -91,14 +93,36 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/cm_ol_0015.pgc" +#line 19 "app/online/cm_ol_0015.pgc" TX_SERVICE(CM_OL_0015, ctx) { + /* exec sql begin declare section */ + + + + + +#line 24 "app/online/cm_ol_0015.pgc" + char h_date [ 9 ] ; + +#line 25 "app/online/cm_ol_0015.pgc" + long h_db_cnt ; + +#line 26 "app/online/cm_ol_0015.pgc" + long h_db_amt ; + +#line 27 "app/online/cm_ol_0015.pgc" + long h_db_fee ; +/* exec sql end declare section */ +#line 28 "app/online/cm_ol_0015.pgc" + + char date[16]; long c_recv, c_done, c_fail, c_settled, c_total; long sum_amt = 0; + long recon_diff; int rc; tx_log(TX_LOG_INFO, "[CM_OL_0015] 통계 공통 조회 서비스 진입"); @@ -134,6 +158,33 @@ TX_SERVICE(CM_OL_0015, ctx) sum_amt = 0; } + /* 원장 직접 집계 (건수/금액/수수료 합계) 로 DBIO 결과 교차검증 */ + strncpy(h_date, date, sizeof(h_date) - 1); + h_date[sizeof(h_date) - 1] = '\0'; + h_db_cnt = 0; + h_db_amt = 0; + h_db_fee = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) , coalesce ( sum ( amount ) , 0 ) , coalesce ( sum ( fee ) , 0 ) from cm_ledger where biz_date = $1 ", + ECPGt_char,(h_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_db_cnt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_db_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_db_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 79 "app/online/cm_ol_0015.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("CM_OL_0015 direct aggregate"); + h_db_cnt = 0; + h_db_amt = 0; + h_db_fee = 0; + } + recon_diff = c_total - h_db_cnt; + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "DATE", date); tx_buf_setlong(ctx->out, "CNTRECV", c_recv); @@ -142,8 +193,13 @@ TX_SERVICE(CM_OL_0015, ctx) tx_buf_setlong(ctx->out, "CNTSETTLED", c_settled); tx_buf_setlong(ctx->out, "CNTTOTAL", c_total); tx_buf_setlong(ctx->out, "SUMAMT", sum_amt); + tx_buf_setlong(ctx->out, "DBCOUNT", h_db_cnt); + tx_buf_setlong(ctx->out, "DBAMT", h_db_amt); + tx_buf_setlong(ctx->out, "SUMFEE", h_db_fee); + tx_buf_setlong(ctx->out, "RECONDIFF", recon_diff); + tx_buf_sets(ctx->out, "RECONMATCH", (recon_diff == 0) ? "Y" : "N"); tx_log(TX_LOG_INFO, - "[CM_OL_0015] 집계완료 date=%s 총건=%ld 완료=%ld 합계=%ld", - date, c_total, c_done, sum_amt); + "[CM_OL_0015] 집계완료 date=%s 총건=%ld 완료=%ld 합계=%ld 수수료=%ld", + date, c_total, c_done, sum_amt, h_db_fee); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0015.pgc b/app/online/cm_ol_0015.pgc index 336eae8..e3e2279 100644 --- a/app/online/cm_ol_0015.pgc +++ b/app/online/cm_ol_0015.pgc @@ -4,13 +4,15 @@ * * 요청의 영업일(DATE)에 대해 cm 표준 DBIO(cm_rec_count/cm_rec_sum)를 * 조합하여 상태별 건수(접수/완료/실패/정산)와 총 거래금액을 집계해 - * 응답한다. 일마감/모니터링 대시보드용 공통 집계 서비스. + * 응답한다. 아울러 cm_ledger 원장을 직접 집계(SELECT)하여 총건수/금액/ + * 수수료합계를 산출하고 DBIO 집계와 교차검증한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -18,9 +20,17 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(CM_OL_0015, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_date[9]; + long h_db_cnt; + long h_db_amt; + long h_db_fee; + EXEC SQL END DECLARE SECTION; + char date[16]; long c_recv, c_done, c_fail, c_settled, c_total; long sum_amt = 0; + long recon_diff; int rc; tx_log(TX_LOG_INFO, "[CM_OL_0015] 통계 공통 조회 서비스 진입"); @@ -56,6 +66,26 @@ TX_SERVICE(CM_OL_0015, ctx) sum_amt = 0; } + /* 원장 직접 집계 (건수/금액/수수료 합계) 로 DBIO 결과 교차검증 */ + strncpy(h_date, date, sizeof(h_date) - 1); + h_date[sizeof(h_date) - 1] = '\0'; + h_db_cnt = 0; + h_db_amt = 0; + h_db_fee = 0; + + EXEC SQL SELECT count(*), coalesce(sum(amount), 0), coalesce(sum(fee), 0) + INTO :h_db_cnt, :h_db_amt, :h_db_fee + FROM cm_ledger + WHERE biz_date = :h_date; + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("CM_OL_0015 direct aggregate"); + h_db_cnt = 0; + h_db_amt = 0; + h_db_fee = 0; + } + recon_diff = c_total - h_db_cnt; + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "DATE", date); tx_buf_setlong(ctx->out, "CNTRECV", c_recv); @@ -64,8 +94,13 @@ TX_SERVICE(CM_OL_0015, ctx) tx_buf_setlong(ctx->out, "CNTSETTLED", c_settled); tx_buf_setlong(ctx->out, "CNTTOTAL", c_total); tx_buf_setlong(ctx->out, "SUMAMT", sum_amt); + tx_buf_setlong(ctx->out, "DBCOUNT", h_db_cnt); + tx_buf_setlong(ctx->out, "DBAMT", h_db_amt); + tx_buf_setlong(ctx->out, "SUMFEE", h_db_fee); + tx_buf_setlong(ctx->out, "RECONDIFF", recon_diff); + tx_buf_sets(ctx->out, "RECONMATCH", (recon_diff == 0) ? "Y" : "N"); tx_log(TX_LOG_INFO, - "[CM_OL_0015] 집계완료 date=%s 총건=%ld 완료=%ld 합계=%ld", - date, c_total, c_done, sum_amt); + "[CM_OL_0015] 집계완료 date=%s 총건=%ld 완료=%ld 합계=%ld 수수료=%ld", + date, c_total, c_done, sum_amt, h_db_fee); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0016.c b/app/online/cm_ol_0016.c index 4ea565c..6273f98 100644 --- a/app/online/cm_ol_0016.c +++ b/app/online/cm_ol_0016.c @@ -150,7 +150,7 @@ TX_SERVICE(CM_OL_0016, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 51 "app/online/cm_ol_0016.pgc" +#line 50 "app/online/cm_ol_0016.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/cm_ol_0016.pgc b/app/online/cm_ol_0016.pgc index 2a2691c..af89c96 100644 --- a/app/online/cm_ol_0016.pgc +++ b/app/online/cm_ol_0016.pgc @@ -44,8 +44,7 @@ TX_SERVICE(CM_OL_0016, ctx) strncpy(h_batch_id, batch_id, sizeof(h_batch_id) - 1); h_run_cnt = 0; - EXEC SQL - SELECT last_run_dt, run_status, run_cnt, biz_date + EXEC SQL SELECT last_run_dt, run_status, run_cnt, biz_date INTO :h_last_run, :h_run_status, :h_run_cnt, :h_biz_date FROM cm_batch_ctl WHERE batch_id = :h_batch_id; diff --git a/app/online/cm_ol_0018.c b/app/online/cm_ol_0018.c index d6bf573..bfb1ddf 100644 --- a/app/online/cm_ol_0018.c +++ b/app/online/cm_ol_0018.c @@ -147,7 +147,7 @@ TX_SERVICE(CM_OL_0018, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_int,&(h_holi_cnt),(long)1,(long)1,sizeof(int), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 60 "app/online/cm_ol_0018.pgc" +#line 59 "app/online/cm_ol_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -162,7 +162,7 @@ TX_SERVICE(CM_OL_0018, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_char,(h_holi_name),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 73 "app/online/cm_ol_0018.pgc" +#line 71 "app/online/cm_ol_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) strncpy(h_holi_name, "공휴일", sizeof(h_holi_name) - 1); diff --git a/app/online/cm_ol_0018.pgc b/app/online/cm_ol_0018.pgc index d3c514d..2683bb3 100644 --- a/app/online/cm_ol_0018.pgc +++ b/app/online/cm_ol_0018.pgc @@ -53,8 +53,7 @@ TX_SERVICE(CM_OL_0018, ctx) strncpy(h_date, date, sizeof(h_date) - 1); h_holi_cnt = 0; - EXEC SQL - SELECT COUNT(*) + EXEC SQL SELECT COUNT(*) INTO :h_holi_cnt FROM cm_holiday WHERE holi_date = :h_date; @@ -66,8 +65,7 @@ TX_SERVICE(CM_OL_0018, ctx) } if (h_holi_cnt > 0) { is_holiday = 1; - EXEC SQL - SELECT holi_name + EXEC SQL SELECT holi_name INTO :h_holi_name FROM cm_holiday WHERE holi_date = :h_date; diff --git a/app/online/cm_ol_0019.c b/app/online/cm_ol_0019.c index 76c3e76..bbdfed4 100644 --- a/app/online/cm_ol_0019.c +++ b/app/online/cm_ol_0019.c @@ -12,13 +12,15 @@ * * 요청의 일자(DATE, YYYYMMDD)에 대해 date_weekday 로 요일 인덱스 * (0=일 ~ 6=토)를 구하고 한글 요일명(일~토)으로 매핑하여 요일 인덱스/ - * 요일명/주말여부를 응답한다. 순수 로직 요일 산출 공통 서비스. DB 접근 없음. + * 요일명/주말여부를 응답한다. 추가로 영업일 달력(cm_biz_calendar)을 + * 조회하여 해당일이 영업일(BIZDAY=Y/N)인지와 비고를 응답한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -91,7 +93,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/cm_ol_0019.pgc" +#line 19 "app/online/cm_ol_0019.pgc" TX_SERVICE(CM_OL_0019, ctx) @@ -99,10 +101,29 @@ TX_SERVICE(CM_OL_0019, ctx) static const char *WDAY_SHORT[7] = { "일", "월", "화", "수", "목", "금", "토" }; + + /* exec sql begin declare section */ + + + + +#line 28 "app/online/cm_ol_0019.pgc" + char h_date [ 9 ] ; + +#line 29 "app/online/cm_ol_0019.pgc" + char h_biz_yn [ 2 ] ; + +#line 30 "app/online/cm_ol_0019.pgc" + char h_remark [ 64 ] ; +/* exec sql end declare section */ +#line 31 "app/online/cm_ol_0019.pgc" + + char date[16]; char label[8]; int wd; int weekend; + int biz_day; tx_log(TX_LOG_INFO, "[CM_OL_0019] 요일 계산 서비스 진입"); @@ -129,13 +150,38 @@ TX_SERVICE(CM_OL_0019, ctx) weekend = (wd == 0 || wd == 6) ? 1 : 0; snprintf(label, sizeof(label), "%s요일", WDAY_SHORT[wd]); + /* 영업일 달력 조회 : 등록이 있으면 그 값을 우선, 없으면 주말 반대로 */ + strncpy(h_date, date, sizeof(h_date) - 1); + h_date[sizeof(h_date) - 1] = '\0'; + strncpy(h_biz_yn, weekend ? "N" : "Y", sizeof(h_biz_yn)); + h_remark[0] = '\0'; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select biz_yn , coalesce ( remark , '' ) from cm_biz_calendar where cal_date = $1 ", + ECPGt_char,(h_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_biz_yn),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_remark),(long)64,(long)1,(64)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 73 "app/online/cm_ol_0019.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_DEBUG, "[CM_OL_0019] 달력 미등록 date=%s (요일기준 판정)", date); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0019 SELECT cm_biz_calendar"); + } + biz_day = (strcmp(h_biz_yn, "Y") == 0) ? 1 : 0; + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "DATE", date); tx_buf_setlong(ctx->out, "WDAY", (long)wd); tx_buf_sets(ctx->out, "WDAYNM", WDAY_SHORT[wd]); tx_buf_sets(ctx->out, "WDAYLABEL", label); tx_buf_sets(ctx->out, "WEEKEND", weekend ? "Y" : "N"); - tx_log(TX_LOG_INFO, "[CM_OL_0019] 계산완료 date=%s 요일=%s 주말=%s", - date, label, weekend ? "Y" : "N"); + tx_buf_sets(ctx->out, "BIZDAY", biz_day ? "Y" : "N"); + tx_buf_sets(ctx->out, "REMARK", h_remark); + tx_log(TX_LOG_INFO, "[CM_OL_0019] 계산완료 date=%s 요일=%s 주말=%s 영업일=%s", + date, label, weekend ? "Y" : "N", biz_day ? "Y" : "N"); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0019.pgc b/app/online/cm_ol_0019.pgc index 48585df..69f53fc 100644 --- a/app/online/cm_ol_0019.pgc +++ b/app/online/cm_ol_0019.pgc @@ -4,13 +4,15 @@ * * 요청의 일자(DATE, YYYYMMDD)에 대해 date_weekday 로 요일 인덱스 * (0=일 ~ 6=토)를 구하고 한글 요일명(일~토)으로 매핑하여 요일 인덱스/ - * 요일명/주말여부를 응답한다. 순수 로직 요일 산출 공통 서비스. DB 접근 없음. + * 요일명/주말여부를 응답한다. 추가로 영업일 달력(cm_biz_calendar)을 + * 조회하여 해당일이 영업일(BIZDAY=Y/N)인지와 비고를 응답한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -21,10 +23,18 @@ TX_SERVICE(CM_OL_0019, ctx) static const char *WDAY_SHORT[7] = { "일", "월", "화", "수", "목", "금", "토" }; + + EXEC SQL BEGIN DECLARE SECTION; + char h_date[9]; + char h_biz_yn[2]; + char h_remark[64]; + EXEC SQL END DECLARE SECTION; + char date[16]; char label[8]; int wd; int weekend; + int biz_day; tx_log(TX_LOG_INFO, "[CM_OL_0019] 요일 계산 서비스 진입"); @@ -51,13 +61,33 @@ TX_SERVICE(CM_OL_0019, ctx) weekend = (wd == 0 || wd == 6) ? 1 : 0; snprintf(label, sizeof(label), "%s요일", WDAY_SHORT[wd]); + /* 영업일 달력 조회 : 등록이 있으면 그 값을 우선, 없으면 주말 반대로 */ + strncpy(h_date, date, sizeof(h_date) - 1); + h_date[sizeof(h_date) - 1] = '\0'; + strncpy(h_biz_yn, weekend ? "N" : "Y", sizeof(h_biz_yn)); + h_remark[0] = '\0'; + + EXEC SQL SELECT biz_yn, coalesce(remark, '') + INTO :h_biz_yn, :h_remark + FROM cm_biz_calendar + WHERE cal_date = :h_date; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_DEBUG, "[CM_OL_0019] 달력 미등록 date=%s (요일기준 판정)", date); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0019 SELECT cm_biz_calendar"); + } + biz_day = (strcmp(h_biz_yn, "Y") == 0) ? 1 : 0; + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "DATE", date); tx_buf_setlong(ctx->out, "WDAY", (long)wd); tx_buf_sets(ctx->out, "WDAYNM", WDAY_SHORT[wd]); tx_buf_sets(ctx->out, "WDAYLABEL", label); tx_buf_sets(ctx->out, "WEEKEND", weekend ? "Y" : "N"); - tx_log(TX_LOG_INFO, "[CM_OL_0019] 계산완료 date=%s 요일=%s 주말=%s", - date, label, weekend ? "Y" : "N"); + tx_buf_sets(ctx->out, "BIZDAY", biz_day ? "Y" : "N"); + tx_buf_sets(ctx->out, "REMARK", h_remark); + tx_log(TX_LOG_INFO, "[CM_OL_0019] 계산완료 date=%s 요일=%s 주말=%s 영업일=%s", + date, label, weekend ? "Y" : "N", biz_day ? "Y" : "N"); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0020.c b/app/online/cm_ol_0020.c index 0244f4b..1d3c789 100644 --- a/app/online/cm_ol_0020.c +++ b/app/online/cm_ol_0020.c @@ -12,13 +12,14 @@ * * 요청의 금액(AMOUNT)을 만/억/조 단위 절(節)로 분해하여 한글 금액표기 * (예: 123000000 -> "일억이천삼백만")로 변환하여 응답한다. 증서/전표 - * 출력용 순수 로직 변환 서비스. DB 접근 없음. - * (ATMI void SVC(TPSVCINFO*) 대응) + * 출력용 변환 서비스. 변환 결과는 증서 발급 감사이력(cm_amt_hangeul_log) + * 에 적재하여 발급 근거로 남긴다. (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -91,7 +92,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/cm_ol_0020.pgc" +#line 18 "app/online/cm_ol_0020.pgc" /* 0~9999 한 절(節)을 천/백/십 단위 한글로 변환하여 out 에 누적 */ @@ -122,12 +123,26 @@ static void hangeul_group(int val, char *out, int outlen) TX_SERVICE(CM_OL_0020, ctx) { static const char *GUNIT[4] = { "", "만", "억", "조" }; + + /* exec sql begin declare section */ + + + +#line 50 "app/online/cm_ol_0020.pgc" + long h_amount ; + +#line 51 "app/online/cm_ol_0020.pgc" + char h_hangeul [ 128 ] ; +/* exec sql end declare section */ +#line 52 "app/online/cm_ol_0020.pgc" + + char hangeul[128]; char won_fmt[48]; long amount = 0; long n; + long logged = 0; int neg = 0; - int g; int groups[4]; int i; @@ -170,10 +185,36 @@ TX_SERVICE(CM_OL_0020, ctx) /* 교차표시용: 콤마 구분 숫자표기 */ amount_format_won(amount, won_fmt, sizeof(won_fmt)); + /* 변환 결과 증서 감사이력 적재 */ + h_amount = amount; + strncpy(h_hangeul, hangeul, sizeof(h_hangeul) - 1); + h_hangeul[sizeof(h_hangeul) - 1] = '\0'; + + if (tx_begin() != TX_OK) { + tx_log(TX_LOG_WARN, "[CM_OL_0020] tx_begin 경고"); + } else { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cm_amt_hangeul_log ( amount , hangeul_txt , conv_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_hangeul),(long)128,(long)1,(128)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 112 "app/online/cm_ol_0020.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0020 INSERT cm_amt_hangeul_log"); + tx_abort(); + } else { + logged = (long)sqlca.sqlerrd[2]; + tx_commit(); + } + } + tx_buf_reset(ctx->out); tx_buf_setlong(ctx->out, "AMOUNT", amount); tx_buf_sets(ctx->out, "HANGEUL", hangeul); tx_buf_sets(ctx->out, "WON", won_fmt); + tx_buf_setlong(ctx->out, "LOGGED", logged); tx_log(TX_LOG_INFO, "[CM_OL_0020] 변환완료 amount=%ld -> %s", amount, hangeul); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0020.pgc b/app/online/cm_ol_0020.pgc index c0be1b2..8fb2a09 100644 --- a/app/online/cm_ol_0020.pgc +++ b/app/online/cm_ol_0020.pgc @@ -4,13 +4,14 @@ * * 요청의 금액(AMOUNT)을 만/억/조 단위 절(節)로 분해하여 한글 금액표기 * (예: 123000000 -> "일억이천삼백만")로 변환하여 응답한다. 증서/전표 - * 출력용 순수 로직 변환 서비스. DB 접근 없음. - * (ATMI void SVC(TPSVCINFO*) 대응) + * 출력용 변환 서비스. 변환 결과는 증서 발급 감사이력(cm_amt_hangeul_log) + * 에 적재하여 발급 근거로 남긴다. (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -44,12 +45,18 @@ static void hangeul_group(int val, char *out, int outlen) TX_SERVICE(CM_OL_0020, ctx) { static const char *GUNIT[4] = { "", "만", "억", "조" }; + + EXEC SQL BEGIN DECLARE SECTION; + long h_amount; + char h_hangeul[128]; + EXEC SQL END DECLARE SECTION; + char hangeul[128]; char won_fmt[48]; long amount = 0; long n; + long logged = 0; int neg = 0; - int g; int groups[4]; int i; @@ -92,10 +99,32 @@ TX_SERVICE(CM_OL_0020, ctx) /* 교차표시용: 콤마 구분 숫자표기 */ amount_format_won(amount, won_fmt, sizeof(won_fmt)); + /* 변환 결과 증서 감사이력 적재 */ + h_amount = amount; + strncpy(h_hangeul, hangeul, sizeof(h_hangeul) - 1); + h_hangeul[sizeof(h_hangeul) - 1] = '\0'; + + if (tx_begin() != TX_OK) { + tx_log(TX_LOG_WARN, "[CM_OL_0020] tx_begin 경고"); + } else { + EXEC SQL INSERT INTO cm_amt_hangeul_log + (amount, hangeul_txt, conv_ts) + VALUES (:h_amount, :h_hangeul, now()); + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0020 INSERT cm_amt_hangeul_log"); + tx_abort(); + } else { + logged = (long)sqlca.sqlerrd[2]; + tx_commit(); + } + } + tx_buf_reset(ctx->out); tx_buf_setlong(ctx->out, "AMOUNT", amount); tx_buf_sets(ctx->out, "HANGEUL", hangeul); tx_buf_sets(ctx->out, "WON", won_fmt); + tx_buf_setlong(ctx->out, "LOGGED", logged); tx_log(TX_LOG_INFO, "[CM_OL_0020] 변환완료 amount=%ld -> %s", amount, hangeul); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0021.c b/app/online/cm_ol_0021.c index a5512d3..f41cdc5 100644 --- a/app/online/cm_ol_0021.c +++ b/app/online/cm_ol_0021.c @@ -157,7 +157,7 @@ TX_SERVICE(CM_OL_0021, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_base),(long)8,(long)1,(8)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 64 "app/online/cm_ol_0021.pgc" +#line 63 "app/online/cm_ol_0021.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/cm_ol_0021.pgc b/app/online/cm_ol_0021.pgc index 94179dc..242fce5 100644 --- a/app/online/cm_ol_0021.pgc +++ b/app/online/cm_ol_0021.pgc @@ -56,8 +56,7 @@ TX_SERVICE(CM_OL_0021, ctx) h_rate = 0; h_scale = 0; - EXEC SQL - SELECT rate, rate_scale, base_cd + EXEC SQL SELECT rate, rate_scale, base_cd INTO :h_rate, :h_scale, :h_base FROM cm_rate WHERE cur_cd = :h_cur diff --git a/app/online/cm_ol_0022.c b/app/online/cm_ol_0022.c index d4346a5..94e4f19 100644 --- a/app/online/cm_ol_0022.c +++ b/app/online/cm_ol_0022.c @@ -12,12 +12,15 @@ * * 요청의 카드번호(CARDNO)에서 숫자만 추출하여 앞 6자리/뒤 4자리만 * 노출하고 가운데를 '*' 로 치환한 마스킹 결과와 자릿수를 응답한다. - * DB 접근 없는 순수 로직 서비스. (ATMI void SVC(TPSVCINFO*) 대응) + * 아울러 앞 6자리(BIN)로 카드 BIN 마스터(mm_card_bin)를 조회하여 + * 카드사코드/브랜드를 응답에 함께 실어 준다. + * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -90,7 +93,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/cm_ol_0022.pgc" +#line 19 "app/online/cm_ol_0022.pgc" /* 카드번호 문자열에서 숫자만 추출해 dst 로 복사, 유효 자릿수 반환 */ @@ -110,11 +113,29 @@ static int cm_digits_only(const char *src, char *dst, int dstlen) TX_SERVICE(CM_OL_0022, ctx) { + /* exec sql begin declare section */ + + + + +#line 39 "app/online/cm_ol_0022.pgc" + char h_bin [ 7 ] ; + +#line 40 "app/online/cm_ol_0022.pgc" + char h_issuer_cd [ 8 ] ; + +#line 41 "app/online/cm_ol_0022.pgc" + char h_brand [ 16 ] ; +/* exec sql end declare section */ +#line 42 "app/online/cm_ol_0022.pgc" + + char cardno[32]; char digits[24]; char masked[24]; int len; int i; + int bin_found = 0; tx_log(TX_LOG_INFO, "[CM_OL_0022] 카드번호 마스킹 서비스 진입"); @@ -141,10 +162,39 @@ TX_SERVICE(CM_OL_0022, ctx) } masked[len] = '\0'; + /* 앞 6자리 BIN 으로 카드사/브랜드 조회 */ + memcpy(h_bin, digits, 6); + h_bin[6] = '\0'; + h_issuer_cd[0] = '\0'; + h_brand[0] = '\0'; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select issuer_cd , brand_nm from mm_card_bin where bin = $1 ", + ECPGt_char,(h_bin),(long)7,(long)1,(7)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_issuer_cd),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_brand),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 85 "app/online/cm_ol_0022.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_INFO, "[CM_OL_0022] 미등록 BIN bin=%s", h_bin); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0022 SELECT mm_card_bin"); + } else { + bin_found = 1; + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "MASKED", masked); tx_buf_setlong(ctx->out, "DIGITS", (long)len); + tx_buf_sets(ctx->out, "BIN", h_bin); + tx_buf_sets(ctx->out, "ISSUER", h_issuer_cd); + tx_buf_sets(ctx->out, "BRAND", h_brand); + tx_buf_sets(ctx->out, "BINFOUND", bin_found ? "Y" : "N"); tx_buf_sets(ctx->out, "RESULT", "OK"); - tx_log(TX_LOG_INFO, "[CM_OL_0022] 마스킹 완료 masked=%s len=%d", masked, len); + tx_log(TX_LOG_INFO, "[CM_OL_0022] 마스킹 완료 masked=%s len=%d issuer=%s", + masked, len, h_issuer_cd); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0022.pgc b/app/online/cm_ol_0022.pgc index c969db6..22bdcd7 100644 --- a/app/online/cm_ol_0022.pgc +++ b/app/online/cm_ol_0022.pgc @@ -4,12 +4,15 @@ * * 요청의 카드번호(CARDNO)에서 숫자만 추출하여 앞 6자리/뒤 4자리만 * 노출하고 가운데를 '*' 로 치환한 마스킹 결과와 자릿수를 응답한다. - * DB 접근 없는 순수 로직 서비스. (ATMI void SVC(TPSVCINFO*) 대응) + * 아울러 앞 6자리(BIN)로 카드 BIN 마스터(mm_card_bin)를 조회하여 + * 카드사코드/브랜드를 응답에 함께 실어 준다. + * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -32,11 +35,18 @@ static int cm_digits_only(const char *src, char *dst, int dstlen) TX_SERVICE(CM_OL_0022, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_bin[7]; + char h_issuer_cd[8]; + char h_brand[16]; + EXEC SQL END DECLARE SECTION; + char cardno[32]; char digits[24]; char masked[24]; int len; int i; + int bin_found = 0; tx_log(TX_LOG_INFO, "[CM_OL_0022] 카드번호 마스킹 서비스 진입"); @@ -63,10 +73,34 @@ TX_SERVICE(CM_OL_0022, ctx) } masked[len] = '\0'; + /* 앞 6자리 BIN 으로 카드사/브랜드 조회 */ + memcpy(h_bin, digits, 6); + h_bin[6] = '\0'; + h_issuer_cd[0] = '\0'; + h_brand[0] = '\0'; + + EXEC SQL SELECT issuer_cd, brand_nm + INTO :h_issuer_cd, :h_brand + FROM mm_card_bin + WHERE bin = :h_bin; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_INFO, "[CM_OL_0022] 미등록 BIN bin=%s", h_bin); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0022 SELECT mm_card_bin"); + } else { + bin_found = 1; + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "MASKED", masked); tx_buf_setlong(ctx->out, "DIGITS", (long)len); + tx_buf_sets(ctx->out, "BIN", h_bin); + tx_buf_sets(ctx->out, "ISSUER", h_issuer_cd); + tx_buf_sets(ctx->out, "BRAND", h_brand); + tx_buf_sets(ctx->out, "BINFOUND", bin_found ? "Y" : "N"); tx_buf_sets(ctx->out, "RESULT", "OK"); - tx_log(TX_LOG_INFO, "[CM_OL_0022] 마스킹 완료 masked=%s len=%d", masked, len); + tx_log(TX_LOG_INFO, "[CM_OL_0022] 마스킹 완료 masked=%s len=%d issuer=%s", + masked, len, h_issuer_cd); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0023.c b/app/online/cm_ol_0023.c index 84c32c6..4064951 100644 --- a/app/online/cm_ol_0023.c +++ b/app/online/cm_ol_0023.c @@ -138,7 +138,7 @@ TX_SERVICE(CM_OL_0023, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_char,(h_name),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 51 "app/online/cm_ol_0023.pgc" +#line 50 "app/online/cm_ol_0023.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/cm_ol_0023.pgc b/app/online/cm_ol_0023.pgc index 5604a86..276a5f4 100644 --- a/app/online/cm_ol_0023.pgc +++ b/app/online/cm_ol_0023.pgc @@ -42,8 +42,7 @@ TX_SERVICE(CM_OL_0023, ctx) strncpy(h_grp, grp, sizeof(h_grp) - 1); strncpy(h_code, code, sizeof(h_code) - 1); - EXEC SQL - SELECT code_name + EXEC SQL SELECT code_name INTO :h_name FROM cm_code WHERE grp_cd = :h_grp diff --git a/app/online/cm_ol_0024.c b/app/online/cm_ol_0024.c index a43a792..2cc4722 100644 --- a/app/online/cm_ol_0024.c +++ b/app/online/cm_ol_0024.c @@ -144,7 +144,7 @@ TX_SERVICE(CM_OL_0024, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_maxval),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 50 "app/online/cm_ol_0024.pgc" +#line 49 "app/online/cm_ol_0024.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/cm_ol_0024.pgc b/app/online/cm_ol_0024.pgc index 7dbc480..f40eae3 100644 --- a/app/online/cm_ol_0024.pgc +++ b/app/online/cm_ol_0024.pgc @@ -43,8 +43,7 @@ TX_SERVICE(CM_OL_0024, ctx) h_maxval = 0; /* 현재값만 읽고 갱신하지 않는다 (미리보기) */ - EXEC SQL - SELECT cur_val, inc_by, max_val + EXEC SQL SELECT cur_val, inc_by, max_val INTO :h_curval, :h_incby, :h_maxval FROM cm_seq WHERE seq_key = :h_seqkey; diff --git a/app/online/cm_ol_0025.c b/app/online/cm_ol_0025.c index 0c46c0c..f043ecd 100644 --- a/app/online/cm_ol_0025.c +++ b/app/online/cm_ol_0025.c @@ -139,7 +139,7 @@ TX_SERVICE(CM_OL_0025, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_updts),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 50 "app/online/cm_ol_0025.pgc" +#line 49 "app/online/cm_ol_0025.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/cm_ol_0025.pgc b/app/online/cm_ol_0025.pgc index 04a3d90..21f67f3 100644 --- a/app/online/cm_ol_0025.pgc +++ b/app/online/cm_ol_0025.pgc @@ -43,8 +43,7 @@ TX_SERVICE(CM_OL_0025, ctx) memset(&h_updts, 0, sizeof(h_updts)); strncpy(h_pkey, pkey, sizeof(h_pkey) - 1); - EXEC SQL - SELECT param_val, TO_CHAR(upd_ts, 'YYYYMMDDHH24MISS') + EXEC SQL SELECT param_val, TO_CHAR(upd_ts, 'YYYYMMDDHH24MISS') INTO :h_pval, :h_updts FROM cm_param WHERE param_key = :h_pkey; diff --git a/app/online/cm_ol_0026.c b/app/online/cm_ol_0026.c index fde1bb7..7439559 100644 --- a/app/online/cm_ol_0026.c +++ b/app/online/cm_ol_0026.c @@ -158,7 +158,7 @@ TX_SERVICE(CM_OL_0026, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_ver),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 71 "app/online/cm_ol_0026.pgc" +#line 70 "app/online/cm_ol_0026.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -188,7 +188,7 @@ TX_SERVICE(CM_OL_0026, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_ckey),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 99 "app/online/cm_ol_0026.pgc" +#line 97 "app/online/cm_ol_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/cm_ol_0026.pgc b/app/online/cm_ol_0026.pgc index 6990aa4..8d8a0db 100644 --- a/app/online/cm_ol_0026.pgc +++ b/app/online/cm_ol_0026.pgc @@ -64,8 +64,7 @@ TX_SERVICE(CM_OL_0026, ctx) h_ver = 0; /* 현재 캐시버전 조회 */ - EXEC SQL - SELECT cache_ver + EXEC SQL SELECT cache_ver INTO :h_ver FROM cm_param WHERE param_key = :h_ckey; @@ -92,8 +91,7 @@ TX_SERVICE(CM_OL_0026, ctx) return; } - EXEC SQL - UPDATE cm_param + EXEC SQL UPDATE cm_param SET cache_ver = :newver, upd_ts = SYSTIMESTAMP WHERE param_key = :h_ckey; diff --git a/app/online/cm_ol_0027.c b/app/online/cm_ol_0027.c index fd67617..b7469dc 100644 --- a/app/online/cm_ol_0027.c +++ b/app/online/cm_ol_0027.c @@ -11,13 +11,15 @@ * cm_ol_0027.pgc - 체크디짓 검증 서비스 (CM_OL_0027) [tier=medium] * * 입력 번호(NUMBER: 카드/계좌 등)에 Luhn(모드10) 알고리즘을 적용하여 - * 유효성(VALID=Y/N)과 계산된 체크디짓을 응답한다. DB 접근 없는 순수 로직. + * 유효성(VALID=Y/N)과 계산된 체크디짓을 응답한다. 검증 시도와 결과는 + * 무결성 감사이력(cm_luhn_audit)에 적재하여 사후 추적을 지원한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -90,7 +92,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/cm_ol_0027.pgc" +#line 18 "app/online/cm_ol_0027.pgc" /* 숫자만 추출 후 자릿수 반환 */ @@ -133,11 +135,33 @@ static int cm_luhn_mod(const char *digits, int len, int offset) TX_SERVICE(CM_OL_0027, ctx) { + /* exec sql begin declare section */ + + + + + +#line 61 "app/online/cm_ol_0027.pgc" + char h_bin [ 7 ] ; + +#line 62 "app/online/cm_ol_0027.pgc" + long h_num_len ; + +#line 63 "app/online/cm_ol_0027.pgc" + char h_valid [ 2 ] ; + +#line 64 "app/online/cm_ol_0027.pgc" + long h_checkdigit ; +/* exec sql end declare section */ +#line 65 "app/online/cm_ol_0027.pgc" + + char number[40]; char digits[36]; int len; int valid; int checkdigit; + long logged = 0; tx_log(TX_LOG_INFO, "[CM_OL_0027] 체크디짓 검증 서비스 진입"); @@ -160,10 +184,42 @@ TX_SERVICE(CM_OL_0027, ctx) /* 본체(마지막 자리 제외)에 대해 산출되는 정상 체크디짓 */ checkdigit = (10 - cm_luhn_mod(digits, len - 1, 0)) % 10; + /* 검증 시도·결과 감사이력 적재 (BIN 은 앞 6자리, 부족 시 있는 만큼) */ + memset(h_bin, 0, sizeof(h_bin)); + memcpy(h_bin, digits, (len >= 6) ? 6 : len); + h_num_len = (long)len; + strncpy(h_valid, valid ? "Y" : "N", sizeof(h_valid)); + h_checkdigit = (long)checkdigit; + + if (tx_begin() != TX_OK) { + tx_log(TX_LOG_WARN, "[CM_OL_0027] tx_begin 경고"); + } else { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into cm_luhn_audit ( bin6 , num_len , valid_yn , check_digit , chk_ts ) values ( $1 , $2 , $3 , $4 , now ( ) )", + ECPGt_char,(h_bin),(long)7,(long)1,(7)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_num_len),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_valid),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_checkdigit),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 107 "app/online/cm_ol_0027.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0027 INSERT cm_luhn_audit"); + tx_abort(); + } else { + logged = (long)sqlca.sqlerrd[2]; + tx_commit(); + } + } + tx_buf_reset(ctx->out); tx_buf_setlong(ctx->out, "DIGITS", (long)len); tx_buf_sets(ctx->out, "VALID", valid ? "Y" : "N"); tx_buf_setlong(ctx->out, "CHECKDIGIT", (long)checkdigit); + tx_buf_setlong(ctx->out, "LOGGED", logged); tx_log(TX_LOG_INFO, "[CM_OL_0027] 검증완료 len=%d valid=%s cd=%d", len, valid ? "Y" : "N", checkdigit); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/cm_ol_0027.pgc b/app/online/cm_ol_0027.pgc index add74aa..622bb1e 100644 --- a/app/online/cm_ol_0027.pgc +++ b/app/online/cm_ol_0027.pgc @@ -3,13 +3,15 @@ * cm_ol_0027.pgc - 체크디짓 검증 서비스 (CM_OL_0027) [tier=medium] * * 입력 번호(NUMBER: 카드/계좌 등)에 Luhn(모드10) 알고리즘을 적용하여 - * 유효성(VALID=Y/N)과 계산된 체크디짓을 응답한다. DB 접근 없는 순수 로직. + * 유효성(VALID=Y/N)과 계산된 체크디짓을 응답한다. 검증 시도와 결과는 + * 무결성 감사이력(cm_luhn_audit)에 적재하여 사후 추적을 지원한다. * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -55,11 +57,19 @@ static int cm_luhn_mod(const char *digits, int len, int offset) TX_SERVICE(CM_OL_0027, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_bin[7]; + long h_num_len; + char h_valid[2]; + long h_checkdigit; + EXEC SQL END DECLARE SECTION; + char number[40]; char digits[36]; int len; int valid; int checkdigit; + long logged = 0; tx_log(TX_LOG_INFO, "[CM_OL_0027] 체크디짓 검증 서비스 진입"); @@ -82,10 +92,34 @@ TX_SERVICE(CM_OL_0027, ctx) /* 본체(마지막 자리 제외)에 대해 산출되는 정상 체크디짓 */ checkdigit = (10 - cm_luhn_mod(digits, len - 1, 0)) % 10; + /* 검증 시도·결과 감사이력 적재 (BIN 은 앞 6자리, 부족 시 있는 만큼) */ + memset(h_bin, 0, sizeof(h_bin)); + memcpy(h_bin, digits, (len >= 6) ? 6 : len); + h_num_len = (long)len; + strncpy(h_valid, valid ? "Y" : "N", sizeof(h_valid)); + h_checkdigit = (long)checkdigit; + + if (tx_begin() != TX_OK) { + tx_log(TX_LOG_WARN, "[CM_OL_0027] tx_begin 경고"); + } else { + EXEC SQL INSERT INTO cm_luhn_audit + (bin6, num_len, valid_yn, check_digit, chk_ts) + VALUES (:h_bin, :h_num_len, :h_valid, :h_checkdigit, now()); + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0027 INSERT cm_luhn_audit"); + tx_abort(); + } else { + logged = (long)sqlca.sqlerrd[2]; + tx_commit(); + } + } + tx_buf_reset(ctx->out); tx_buf_setlong(ctx->out, "DIGITS", (long)len); tx_buf_sets(ctx->out, "VALID", valid ? "Y" : "N"); tx_buf_setlong(ctx->out, "CHECKDIGIT", (long)checkdigit); + tx_buf_setlong(ctx->out, "LOGGED", logged); tx_log(TX_LOG_INFO, "[CM_OL_0027] 검증완료 len=%d valid=%s cd=%d", len, valid ? "Y" : "N", checkdigit); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/cm_ol_0028.c b/app/online/cm_ol_0028.c index a0392f9..a9e3295 100644 --- a/app/online/cm_ol_0028.c +++ b/app/online/cm_ol_0028.c @@ -12,12 +12,15 @@ * * 입력 시각(HHMMSS 6자리)을 HH:MM:SS 로 변환하고 각 필드의 범위를 * 검증(시 0~23, 분/초 0~59)하여 포맷 결과와 총 경과초를 응답한다. - * DB 접근 없는 순수 로직 서비스. (ATMI void SVC(TPSVCINFO*) 대응) + * 아울러 시간정책 마스터(cm_time_policy)에서 마감시각(cutoff_secs)을 + * 조회하여 입력 시각의 마감초과 여부(AFTERCUTOFF=Y/N)를 통지한다. + * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -90,11 +93,24 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/cm_ol_0028.pgc" +#line 19 "app/online/cm_ol_0028.pgc" TX_SERVICE(CM_OL_0028, ctx) { + /* exec sql begin declare section */ + + + +#line 24 "app/online/cm_ol_0028.pgc" + char h_policy [ 16 ] ; + +#line 25 "app/online/cm_ol_0028.pgc" + long h_cutoff ; +/* exec sql end declare section */ +#line 26 "app/online/cm_ol_0028.pgc" + + char hms[16]; char formatted[16]; int hh; @@ -102,6 +118,7 @@ TX_SERVICE(CM_OL_0028, ctx) int ss; int i; long secs; + int after_cutoff = 0; tx_log(TX_LOG_INFO, "[CM_OL_0028] 시간 포맷 변환 서비스 진입"); @@ -138,10 +155,35 @@ TX_SERVICE(CM_OL_0028, ctx) sprintf(formatted, "%02d:%02d:%02d", hh, mm, ss); secs = (long)hh * 3600 + (long)mm * 60 + ss; + /* 시간정책 조회 : 마감시각(초). 정책구분 미지정 시 CUTOFF 기본 */ + if (tx_buf_get(ctx->in, "POLICY", h_policy, sizeof(h_policy)) != TX_OK) + strncpy(h_policy, "CUTOFF", sizeof(h_policy) - 1); + h_policy[sizeof(h_policy) - 1] = '\0'; + h_cutoff = -1; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select cutoff_secs from cm_time_policy where policy_cd = $1 and use_yn = 'Y'", + ECPGt_char,(h_policy),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_cutoff),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 82 "app/online/cm_ol_0028.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_INFO, "[CM_OL_0028] 시간정책 미등록 policy=%s", h_policy); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0028 SELECT cm_time_policy"); + } else if (h_cutoff >= 0 && secs > h_cutoff) { + after_cutoff = 1; + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "HMS", hms); tx_buf_sets(ctx->out, "FORMATTED", formatted); tx_buf_setlong(ctx->out, "SECONDS", secs); - tx_log(TX_LOG_INFO, "[CM_OL_0028] 변환완료 %s -> %s (%ld초)", hms, formatted, secs); + tx_buf_setlong(ctx->out, "CUTOFF", h_cutoff); + tx_buf_sets(ctx->out, "AFTERCUTOFF", after_cutoff ? "Y" : "N"); + tx_log(TX_LOG_INFO, "[CM_OL_0028] 변환완료 %s -> %s (%ld초) cutoff=%ld", + hms, formatted, secs, h_cutoff); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0028.pgc b/app/online/cm_ol_0028.pgc index f3295de..dff5798 100644 --- a/app/online/cm_ol_0028.pgc +++ b/app/online/cm_ol_0028.pgc @@ -4,12 +4,15 @@ * * 입력 시각(HHMMSS 6자리)을 HH:MM:SS 로 변환하고 각 필드의 범위를 * 검증(시 0~23, 분/초 0~59)하여 포맷 결과와 총 경과초를 응답한다. - * DB 접근 없는 순수 로직 서비스. (ATMI void SVC(TPSVCINFO*) 대응) + * 아울러 시간정책 마스터(cm_time_policy)에서 마감시각(cutoff_secs)을 + * 조회하여 입력 시각의 마감초과 여부(AFTERCUTOFF=Y/N)를 통지한다. + * (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -17,6 +20,11 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(CM_OL_0028, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_policy[16]; + long h_cutoff; + EXEC SQL END DECLARE SECTION; + char hms[16]; char formatted[16]; int hh; @@ -24,6 +32,7 @@ TX_SERVICE(CM_OL_0028, ctx) int ss; int i; long secs; + int after_cutoff = 0; tx_log(TX_LOG_INFO, "[CM_OL_0028] 시간 포맷 변환 서비스 진입"); @@ -60,10 +69,33 @@ TX_SERVICE(CM_OL_0028, ctx) sprintf(formatted, "%02d:%02d:%02d", hh, mm, ss); secs = (long)hh * 3600 + (long)mm * 60 + ss; + /* 시간정책 조회 : 마감시각(초). 정책구분 미지정 시 CUTOFF 기본 */ + if (tx_buf_get(ctx->in, "POLICY", h_policy, sizeof(h_policy)) != TX_OK) + strncpy(h_policy, "CUTOFF", sizeof(h_policy) - 1); + h_policy[sizeof(h_policy) - 1] = '\0'; + h_cutoff = -1; + + EXEC SQL SELECT cutoff_secs + INTO :h_cutoff + FROM cm_time_policy + WHERE policy_cd = :h_policy + AND use_yn = 'Y'; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_INFO, "[CM_OL_0028] 시간정책 미등록 policy=%s", h_policy); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0028 SELECT cm_time_policy"); + } else if (h_cutoff >= 0 && secs > h_cutoff) { + after_cutoff = 1; + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "HMS", hms); tx_buf_sets(ctx->out, "FORMATTED", formatted); tx_buf_setlong(ctx->out, "SECONDS", secs); - tx_log(TX_LOG_INFO, "[CM_OL_0028] 변환완료 %s -> %s (%ld초)", hms, formatted, secs); + tx_buf_setlong(ctx->out, "CUTOFF", h_cutoff); + tx_buf_sets(ctx->out, "AFTERCUTOFF", after_cutoff ? "Y" : "N"); + tx_log(TX_LOG_INFO, "[CM_OL_0028] 변환완료 %s -> %s (%ld초) cutoff=%ld", + hms, formatted, secs, h_cutoff); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/cm_ol_0029.c b/app/online/cm_ol_0029.c index 8901a8e..5a6af88 100644 --- a/app/online/cm_ol_0029.c +++ b/app/online/cm_ol_0029.c @@ -142,7 +142,7 @@ TX_SERVICE(CM_OL_0029, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_total),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 53 "app/online/cm_ol_0029.pgc" +#line 52 "app/online/cm_ol_0029.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/cm_ol_0029.pgc b/app/online/cm_ol_0029.pgc index 1ecb610..49bf2d7 100644 --- a/app/online/cm_ol_0029.pgc +++ b/app/online/cm_ol_0029.pgc @@ -46,8 +46,7 @@ TX_SERVICE(CM_OL_0029, ctx) h_cnt = 0; h_total = 0; - EXEC SQL - SELECT NVL(SUM(cnt), 0), NVL(SUM(total_amt), 0) + EXEC SQL SELECT NVL(SUM(cnt), 0), NVL(SUM(total_amt), 0) INTO :h_cnt, :h_total FROM cm_daily_v WHERE biz_date = :h_date; diff --git a/app/online/cm_ol_0030.c b/app/online/cm_ol_0030.c index c922d72..41dc102 100644 --- a/app/online/cm_ol_0030.c +++ b/app/online/cm_ol_0030.c @@ -145,7 +145,7 @@ TX_SERVICE(CM_OL_0030, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_state),(long)2,(long)1,(2)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 56 "app/online/cm_ol_0030.pgc" +#line 55 "app/online/cm_ol_0030.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/cm_ol_0030.pgc b/app/online/cm_ol_0030.pgc index 72e4c3b..9aeacab 100644 --- a/app/online/cm_ol_0030.pgc +++ b/app/online/cm_ol_0030.pgc @@ -49,8 +49,7 @@ TX_SERVICE(CM_OL_0030, ctx) strncpy(h_sid, sid, sizeof(h_sid) - 1); h_exp = 0; - EXEC SQL - SELECT expire_epoch, sess_state + EXEC SQL SELECT expire_epoch, sess_state INTO :h_exp, :h_state FROM cm_session WHERE sess_id = :h_sid; diff --git a/app/online/cm_ol_0031.c b/app/online/cm_ol_0031.c index dbc87fc..9851c46 100644 --- a/app/online/cm_ol_0031.c +++ b/app/online/cm_ol_0031.c @@ -12,13 +12,15 @@ * * 내부 처리결과코드(RC, 정수)를 대외 표준 응답코드(4자리 문자열)로 매핑한다. * TxCore 오류상수(TX_OK/TX_ENOENT/...) 및 업무 결과코드를 msg_layout.h 의 - * 표준 대외코드(RESP_OK/RESP_INVALID/RESP_NOMERCH/RESP_SYSERR)로 환산해 - * 응답한다. DB 접근 없는 in-code 규칙 매핑. (ATMI void SVC(TPSVCINFO*) 대응) + * 표준 대외코드(RESP_OK/RESP_INVALID/RESP_NOMERCH/RESP_SYSERR)로 환산한 뒤, + * 대외 응답코드 마스터(cm_resp_code)를 조회하여 대외 설명문/응답그룹을 + * 응답에 함께 실어 준다. (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -91,7 +93,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/cm_ol_0031.pgc" +#line 19 "app/online/cm_ol_0031.pgc" /* 내부 RC -> 대외 표준 응답코드 문자열 매핑 규칙 */ @@ -125,6 +127,23 @@ static const char *cm_map_resp(int rc, const char **desc) TX_SERVICE(CM_OL_0031, ctx) { + /* exec sql begin declare section */ + + + + +#line 53 "app/online/cm_ol_0031.pgc" + char h_resp [ 8 ] ; + +#line 54 "app/online/cm_ol_0031.pgc" + char h_ext_desc [ 80 ] ; + +#line 55 "app/online/cm_ol_0031.pgc" + char h_resp_grp [ 8 ] ; +/* exec sql end declare section */ +#line 56 "app/online/cm_ol_0031.pgc" + + long rc = 0; const char *resp; const char *desc = ""; @@ -139,10 +158,38 @@ TX_SERVICE(CM_OL_0031, ctx) resp = cm_map_resp((int)rc, &desc); + /* 대외 응답코드 마스터에서 표준 설명문/응답그룹 조회 */ + strncpy(h_resp, resp, sizeof(h_resp) - 1); + h_resp[sizeof(h_resp) - 1] = '\0'; + h_ext_desc[0] = '\0'; + h_resp_grp[0] = '\0'; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select ext_desc , resp_grp from cm_resp_code where resp_cd = $1 ", + ECPGt_char,(h_resp),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_ext_desc),(long)80,(long)1,(80)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_resp_grp),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 81 "app/online/cm_ol_0031.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_INFO, "[CM_OL_0031] 대외코드 미등록 resp=%s (내부설명 사용)", resp); + strncpy(h_ext_desc, desc, sizeof(h_ext_desc) - 1); + h_ext_desc[sizeof(h_ext_desc) - 1] = '\0'; + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0031 SELECT cm_resp_code"); + strncpy(h_ext_desc, desc, sizeof(h_ext_desc) - 1); + h_ext_desc[sizeof(h_ext_desc) - 1] = '\0'; + } + tx_buf_reset(ctx->out); tx_buf_setlong(ctx->out, "RC", rc); tx_buf_sets(ctx->out, "RESPCODE", resp); tx_buf_sets(ctx->out, "RESPDESC", desc); + tx_buf_sets(ctx->out, "EXTDESC", h_ext_desc); + tx_buf_sets(ctx->out, "RESPGRP", h_resp_grp); tx_buf_sets(ctx->out, "SUCCESS", (strcmp(resp, RESP_OK) == 0) ? "Y" : "N"); tx_log(TX_LOG_INFO, "[CM_OL_0031] 매핑완료 rc=%ld -> resp=%s(%s)", rc, resp, desc); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/cm_ol_0031.pgc b/app/online/cm_ol_0031.pgc index b9fb50a..a91dfa1 100644 --- a/app/online/cm_ol_0031.pgc +++ b/app/online/cm_ol_0031.pgc @@ -4,13 +4,15 @@ * * 내부 처리결과코드(RC, 정수)를 대외 표준 응답코드(4자리 문자열)로 매핑한다. * TxCore 오류상수(TX_OK/TX_ENOENT/...) 및 업무 결과코드를 msg_layout.h 의 - * 표준 대외코드(RESP_OK/RESP_INVALID/RESP_NOMERCH/RESP_SYSERR)로 환산해 - * 응답한다. DB 접근 없는 in-code 규칙 매핑. (ATMI void SVC(TPSVCINFO*) 대응) + * 표준 대외코드(RESP_OK/RESP_INVALID/RESP_NOMERCH/RESP_SYSERR)로 환산한 뒤, + * 대외 응답코드 마스터(cm_resp_code)를 조회하여 대외 설명문/응답그룹을 + * 응답에 함께 실어 준다. (ATMI void SVC(TPSVCINFO*) 대응) */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "cm_core.h" @@ -47,6 +49,12 @@ static const char *cm_map_resp(int rc, const char **desc) TX_SERVICE(CM_OL_0031, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_resp[8]; + char h_ext_desc[80]; + char h_resp_grp[8]; + EXEC SQL END DECLARE SECTION; + long rc = 0; const char *resp; const char *desc = ""; @@ -61,10 +69,33 @@ TX_SERVICE(CM_OL_0031, ctx) resp = cm_map_resp((int)rc, &desc); + /* 대외 응답코드 마스터에서 표준 설명문/응답그룹 조회 */ + strncpy(h_resp, resp, sizeof(h_resp) - 1); + h_resp[sizeof(h_resp) - 1] = '\0'; + h_ext_desc[0] = '\0'; + h_resp_grp[0] = '\0'; + + EXEC SQL SELECT ext_desc, resp_grp + INTO :h_ext_desc, :h_resp_grp + FROM cm_resp_code + WHERE resp_cd = :h_resp; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_INFO, "[CM_OL_0031] 대외코드 미등록 resp=%s (내부설명 사용)", resp); + strncpy(h_ext_desc, desc, sizeof(h_ext_desc) - 1); + h_ext_desc[sizeof(h_ext_desc) - 1] = '\0'; + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("CM_OL_0031 SELECT cm_resp_code"); + strncpy(h_ext_desc, desc, sizeof(h_ext_desc) - 1); + h_ext_desc[sizeof(h_ext_desc) - 1] = '\0'; + } + tx_buf_reset(ctx->out); tx_buf_setlong(ctx->out, "RC", rc); tx_buf_sets(ctx->out, "RESPCODE", resp); tx_buf_sets(ctx->out, "RESPDESC", desc); + tx_buf_sets(ctx->out, "EXTDESC", h_ext_desc); + tx_buf_sets(ctx->out, "RESPGRP", h_resp_grp); tx_buf_sets(ctx->out, "SUCCESS", (strcmp(resp, RESP_OK) == 0) ? "Y" : "N"); tx_log(TX_LOG_INFO, "[CM_OL_0031] 매핑완료 rc=%ld -> resp=%s(%s)", rc, resp, desc); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/lg_ol_0001.c b/app/online/lg_ol_0001.c index 82e2269..2283bcc 100644 --- a/app/online/lg_ol_0001.c +++ b/app/online/lg_ol_0001.c @@ -11,12 +11,14 @@ * lg_ol_0001.pgc - 원장 온라인 서비스 (LG_OL_0001) [tier=easy] * * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 lg 표준 DBIO 를 - * 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응) + * 통해 처리한 뒤, 원장(lg_ledger)을 임베디드 조회하여 수수료/등록일시와 + * 해당 가맹점의 당일 원장 건수를 함께 응답한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "lg_core.h" @@ -89,14 +91,44 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/lg_ol_0001.pgc" +#line 17 "app/online/lg_ol_0001.pgc" TX_SERVICE(LG_OL_0001, ctx) { + /* exec sql begin declare section */ + + + + + + + +#line 22 "app/online/lg_ol_0001.pgc" + char h_key [ 16 ] ; + +#line 23 "app/online/lg_ol_0001.pgc" + char h_merch [ 16 ] ; + +#line 24 "app/online/lg_ol_0001.pgc" + char h_bizdate [ 9 ] ; + +#line 25 "app/online/lg_ol_0001.pgc" + long h_fee ; + +#line 26 "app/online/lg_ol_0001.pgc" + char h_reg_ts [ 32 ] ; + +#line 27 "app/online/lg_ol_0001.pgc" + long h_day_cnt ; +/* exec sql end declare section */ +#line 28 "app/online/lg_ol_0001.pgc" + + lg_rec_t rec; char key[16]; int rc; + long day_cnt = 0; tx_log(TX_LOG_INFO, "[LG_OL_0001] 원장 단건조회 서비스 진입"); @@ -115,11 +147,56 @@ TX_SERVICE(LG_OL_0001, ctx) return; } + /* 원장 수수료/등록일시 임베디드 조회 */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_fee = 0; + memset(h_reg_ts, 0, sizeof(h_reg_ts)); + memset(h_bizdate, 0, sizeof(h_bizdate)); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select fee , biz_date , to_char ( reg_ts , 'YYYYMMDDHH24MISS' ) from lg_ledger where key = $1 ", + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_bizdate),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_reg_ts),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 62 "app/online/lg_ol_0001.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT lg_ledger"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + /* 동일 가맹점 당일 원장 건수 집계 */ + strncpy(h_merch, rec.merch_id, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_day_cnt = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from lg_ledger where merch_id = $1 and biz_date = $2 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_bizdate),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_day_cnt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 78 "app/online/lg_ol_0001.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) + day_cnt = h_day_cnt; + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); + tx_buf_setlong(ctx->out, "FEE", h_fee); tx_buf_sets(ctx->out, "STATUS", rec.status); - tx_log(TX_LOG_INFO, "[LG_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); + tx_buf_sets(ctx->out, "REGTS", h_reg_ts); + tx_buf_setlong(ctx->out, "DAYCNT", day_cnt); + tx_log(TX_LOG_INFO, "[LG_OL_0001] 조회완료 key=%s amount=%ld fee=%ld 당일건수=%ld", + key, rec.amount, h_fee, day_cnt); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/lg_ol_0001.pgc b/app/online/lg_ol_0001.pgc index b482dd6..85dc811 100644 --- a/app/online/lg_ol_0001.pgc +++ b/app/online/lg_ol_0001.pgc @@ -3,12 +3,14 @@ * lg_ol_0001.pgc - 원장 온라인 서비스 (LG_OL_0001) [tier=easy] * * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 lg 표준 DBIO 를 - * 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응) + * 통해 처리한 뒤, 원장(lg_ledger)을 임베디드 조회하여 수수료/등록일시와 + * 해당 가맹점의 당일 원장 건수를 함께 응답한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "lg_core.h" @@ -16,9 +18,19 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(LG_OL_0001, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_key[16]; + char h_merch[16]; + char h_bizdate[9]; + long h_fee; + char h_reg_ts[32]; + long h_day_cnt; + EXEC SQL END DECLARE SECTION; + lg_rec_t rec; char key[16]; int rc; + long day_cnt = 0; tx_log(TX_LOG_INFO, "[LG_OL_0001] 원장 단건조회 서비스 진입"); @@ -37,11 +49,45 @@ TX_SERVICE(LG_OL_0001, ctx) return; } + /* 원장 수수료/등록일시 임베디드 조회 */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_fee = 0; + memset(h_reg_ts, 0, sizeof(h_reg_ts)); + memset(h_bizdate, 0, sizeof(h_bizdate)); + + EXEC SQL SELECT fee, biz_date, to_char(reg_ts, 'YYYYMMDDHH24MISS') + INTO :h_fee, :h_bizdate, :h_reg_ts + FROM lg_ledger + WHERE key = :h_key; + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT lg_ledger"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + /* 동일 가맹점 당일 원장 건수 집계 */ + strncpy(h_merch, rec.merch_id, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_day_cnt = 0; + EXEC SQL SELECT count(*) + INTO :h_day_cnt + FROM lg_ledger + WHERE merch_id = :h_merch + AND biz_date = :h_bizdate; + if (sqlca.sqlcode == TX_SQL_OK) + day_cnt = h_day_cnt; + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); + tx_buf_setlong(ctx->out, "FEE", h_fee); tx_buf_sets(ctx->out, "STATUS", rec.status); - tx_log(TX_LOG_INFO, "[LG_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); + tx_buf_sets(ctx->out, "REGTS", h_reg_ts); + tx_buf_setlong(ctx->out, "DAYCNT", day_cnt); + tx_log(TX_LOG_INFO, "[LG_OL_0001] 조회완료 key=%s amount=%ld fee=%ld 당일건수=%ld", + key, rec.amount, h_fee, day_cnt); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/lg_ol_0002.c b/app/online/lg_ol_0002.c index e70baf3..d392922 100644 --- a/app/online/lg_ol_0002.c +++ b/app/online/lg_ol_0002.c @@ -10,13 +10,15 @@ /* * lg_ol_0002.pgc - 원장 온라인 서비스 (LG_OL_0002) [tier=hard] * - * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 lg 표준 DBIO 를 - * 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응) + * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 lg 표준 DBIO 로 + * 원장 반영 → 후속 서비스 연계 → 커밋의 오케스트레이션을 수행한다. + * 당일 합계/건수는 원장(lg_ledger) 임베디드 집계로 교차검증한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "lg_core.h" @@ -89,14 +91,35 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/lg_ol_0002.pgc" +#line 17 "app/online/lg_ol_0002.pgc" TX_SERVICE(LG_OL_0002, ctx) { + /* exec sql begin declare section */ + + + + + +#line 22 "app/online/lg_ol_0002.pgc" + char h_merch [ 16 ] ; + +#line 23 "app/online/lg_ol_0002.pgc" + char h_bizdate [ 9 ] ; + +#line 24 "app/online/lg_ol_0002.pgc" + long h_daysum ; + +#line 25 "app/online/lg_ol_0002.pgc" + long h_daycnt ; +/* exec sql end declare section */ +#line 26 "app/online/lg_ol_0002.pgc" + + lg_rec_t rec; char key[16], merch[16], bizdate[16], nextbiz[9]; - long amount = 0, daysum = 0; + long amount = 0, daysum = 0, daycnt = 0; int rc; TXBUF *sub_in; TXBUF *sub_out; @@ -161,9 +184,28 @@ TX_SERVICE(LG_OL_0002, ctx) tx_buf_free(sub_in); tx_buf_free(sub_out); - /* 교차 검증: 당일 합계 재계산 */ - if (lg_rec_sum(bizdate, &daysum) != TX_OK) - daysum = 0; + /* 교차 검증: 당일 합계/건수 임베디드 재집계 */ + strncpy(h_merch, merch, sizeof(h_merch) - 1); h_merch[sizeof(h_merch) - 1] = '\0'; + strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); h_bizdate[sizeof(h_bizdate) - 1] = '\0'; + h_daysum = 0; + h_daycnt = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) , 0 ) , count ( * ) from lg_ledger where merch_id = $1 and biz_date = $2 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_bizdate),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_daysum),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_daycnt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 104 "app/online/lg_ol_0002.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) { + daysum = h_daysum; + daycnt = h_daycnt; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT lg_ledger 당일집계"); + } tx_commit(); @@ -171,6 +213,8 @@ TX_SERVICE(LG_OL_0002, ctx) tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "KEY", key); tx_buf_setlong(ctx->out, "DAYSUM", daysum); - tx_log(TX_LOG_INFO, "[LG_OL_0002] 완료 key=%s 당일합계=%ld", key, daysum); + tx_buf_setlong(ctx->out, "DAYCNT", daycnt); + tx_log(TX_LOG_INFO, "[LG_OL_0002] 완료 key=%s 당일합계=%ld 당일건수=%ld", + key, daysum, daycnt); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/lg_ol_0002.pgc b/app/online/lg_ol_0002.pgc index 81485ab..8631616 100644 --- a/app/online/lg_ol_0002.pgc +++ b/app/online/lg_ol_0002.pgc @@ -2,13 +2,15 @@ /* * lg_ol_0002.pgc - 원장 온라인 서비스 (LG_OL_0002) [tier=hard] * - * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 lg 표준 DBIO 를 - * 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응) + * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 lg 표준 DBIO 로 + * 원장 반영 → 후속 서비스 연계 → 커밋의 오케스트레이션을 수행한다. + * 당일 합계/건수는 원장(lg_ledger) 임베디드 집계로 교차검증한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "lg_core.h" @@ -16,9 +18,16 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(LG_OL_0002, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + char h_bizdate[9]; + long h_daysum; + long h_daycnt; + EXEC SQL END DECLARE SECTION; + lg_rec_t rec; char key[16], merch[16], bizdate[16], nextbiz[9]; - long amount = 0, daysum = 0; + long amount = 0, daysum = 0, daycnt = 0; int rc; TXBUF *sub_in; TXBUF *sub_out; @@ -83,9 +92,22 @@ TX_SERVICE(LG_OL_0002, ctx) tx_buf_free(sub_in); tx_buf_free(sub_out); - /* 교차 검증: 당일 합계 재계산 */ - if (lg_rec_sum(bizdate, &daysum) != TX_OK) - daysum = 0; + /* 교차 검증: 당일 합계/건수 임베디드 재집계 */ + strncpy(h_merch, merch, sizeof(h_merch) - 1); h_merch[sizeof(h_merch) - 1] = '\0'; + strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); h_bizdate[sizeof(h_bizdate) - 1] = '\0'; + h_daysum = 0; + h_daycnt = 0; + EXEC SQL SELECT coalesce(sum(amount), 0), count(*) + INTO :h_daysum, :h_daycnt + FROM lg_ledger + WHERE merch_id = :h_merch + AND biz_date = :h_bizdate; + if (sqlca.sqlcode == TX_SQL_OK) { + daysum = h_daysum; + daycnt = h_daycnt; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT lg_ledger 당일집계"); + } tx_commit(); @@ -93,6 +115,8 @@ TX_SERVICE(LG_OL_0002, ctx) tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "KEY", key); tx_buf_setlong(ctx->out, "DAYSUM", daysum); - tx_log(TX_LOG_INFO, "[LG_OL_0002] 완료 key=%s 당일합계=%ld", key, daysum); + tx_buf_setlong(ctx->out, "DAYCNT", daycnt); + tx_log(TX_LOG_INFO, "[LG_OL_0002] 완료 key=%s 당일합계=%ld 당일건수=%ld", + key, daysum, daycnt); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0001.c b/app/online/mg_ol_0001.c index 92ab7cf..1ca9c5b 100644 --- a/app/online/mg_ol_0001.c +++ b/app/online/mg_ol_0001.c @@ -18,6 +18,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -90,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/mg_ol_0001.pgc" +#line 17 "app/online/mg_ol_0001.pgc" TX_SERVICE(MG_OL_0001, ctx) @@ -152,6 +153,57 @@ TX_SERVICE(MG_OL_0001, ctx) return; } + /* 5-b) 원시전문 수신 저널(mg_recv_log)에 임베디드 SQL 로 접수 이력 적재 */ + { + /* exec sql begin declare section */ + + + + + +#line 81 "app/online/mg_ol_0001.pgc" + char h_rv_key [ 16 ] ; + +#line 82 "app/online/mg_ol_0001.pgc" + char h_rv_merch [ 16 ] ; + +#line 83 "app/online/mg_ol_0001.pgc" + long h_rv_amount ; + +#line 84 "app/online/mg_ol_0001.pgc" + long h_rv_rawlen ; +/* exec sql end declare section */ +#line 85 "app/online/mg_ol_0001.pgc" + + + strncpy(h_rv_key, rec.key, sizeof(h_rv_key) - 1); + h_rv_key[sizeof(h_rv_key) - 1] = '\0'; + strncpy(h_rv_merch, rec.merch_id, sizeof(h_rv_merch) - 1); + h_rv_merch[sizeof(h_rv_merch) - 1] = '\0'; + h_rv_amount = rec.amount; + h_rv_rawlen = (long)strlen(raw); + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_recv_log ( recv_key , merch_id , recv_amount , raw_len , recv_status ) values ( $1 , $2 , $3 , $4 , 'R' )", + ECPGt_char,(h_rv_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_rv_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_rv_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_rv_rawlen),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 97 "app/online/mg_ol_0001.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_recv_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + /* 6) 수신확인 응답 구성 */ tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESP", RESP_OK); diff --git a/app/online/mg_ol_0001.pgc b/app/online/mg_ol_0001.pgc index ff4d27e..ef4946d 100644 --- a/app/online/mg_ol_0001.pgc +++ b/app/online/mg_ol_0001.pgc @@ -10,6 +10,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -74,6 +75,35 @@ TX_SERVICE(MG_OL_0001, ctx) return; } + /* 5-b) 원시전문 수신 저널(mg_recv_log)에 임베디드 SQL 로 접수 이력 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_rv_key[16]; + char h_rv_merch[16]; + long h_rv_amount; + long h_rv_rawlen; + EXEC SQL END DECLARE SECTION; + + strncpy(h_rv_key, rec.key, sizeof(h_rv_key) - 1); + h_rv_key[sizeof(h_rv_key) - 1] = '\0'; + strncpy(h_rv_merch, rec.merch_id, sizeof(h_rv_merch) - 1); + h_rv_merch[sizeof(h_rv_merch) - 1] = '\0'; + h_rv_amount = rec.amount; + h_rv_rawlen = (long)strlen(raw); + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_recv_log + (recv_key, merch_id, recv_amount, raw_len, recv_status) + VALUES (:h_rv_key, :h_rv_merch, :h_rv_amount, :h_rv_rawlen, 'R'); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_recv_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + /* 6) 수신확인 응답 구성 */ tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESP", RESP_OK); diff --git a/app/online/mg_ol_0002.c b/app/online/mg_ol_0002.c index 9a97bbd..26516d3 100644 --- a/app/online/mg_ol_0002.c +++ b/app/online/mg_ol_0002.c @@ -18,6 +18,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -90,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/mg_ol_0002.pgc" +#line 17 "app/online/mg_ol_0002.pgc" TX_SERVICE(MG_OL_0002, ctx) @@ -170,6 +171,51 @@ TX_SERVICE(MG_OL_0002, ctx) tx_buf_sets(ctx->out, "MSGTYPE", MSG_TYPE_RESP); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); + + /* 7) 송신 이력(mg_send_log)에 임베디드 SQL 로 기록 */ + { + /* exec sql begin declare section */ + + + + +#line 100 "app/online/mg_ol_0002.pgc" + char h_slog_key [ 16 ] ; + +#line 101 "app/online/mg_ol_0002.pgc" + char h_slog_type [ 8 ] ; + +#line 102 "app/online/mg_ol_0002.pgc" + long h_slog_amt ; +/* exec sql end declare section */ +#line 103 "app/online/mg_ol_0002.pgc" + + + strncpy(h_slog_key, rec.key, sizeof(h_slog_key) - 1); + h_slog_key[sizeof(h_slog_key) - 1] = '\0'; + strncpy(h_slog_type, MSG_TYPE_RESP, sizeof(h_slog_type) - 1); + h_slog_type[sizeof(h_slog_type) - 1] = '\0'; + h_slog_amt = rec.amount; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_send_log ( send_key , msg_type , send_amount , send_status ) values ( $1 , $2 , $3 , 'S' )", + ECPGt_char,(h_slog_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_slog_type),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_slog_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 114 "app/online/mg_ol_0002.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_send_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0002] 응답전문 송신완료 key=%s len=%d amount=%ld", rec.key, MSG_ACQ_LEN, rec.amount); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/mg_ol_0002.pgc b/app/online/mg_ol_0002.pgc index 6b32256..b941dcf 100644 --- a/app/online/mg_ol_0002.pgc +++ b/app/online/mg_ol_0002.pgc @@ -10,6 +10,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -92,6 +93,34 @@ TX_SERVICE(MG_OL_0002, ctx) tx_buf_sets(ctx->out, "MSGTYPE", MSG_TYPE_RESP); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); + + /* 7) 송신 이력(mg_send_log)에 임베디드 SQL 로 기록 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_slog_key[16]; + char h_slog_type[8]; + long h_slog_amt; + EXEC SQL END DECLARE SECTION; + + strncpy(h_slog_key, rec.key, sizeof(h_slog_key) - 1); + h_slog_key[sizeof(h_slog_key) - 1] = '\0'; + strncpy(h_slog_type, MSG_TYPE_RESP, sizeof(h_slog_type) - 1); + h_slog_type[sizeof(h_slog_type) - 1] = '\0'; + h_slog_amt = rec.amount; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_send_log + (send_key, msg_type, send_amount, send_status) + VALUES (:h_slog_key, :h_slog_type, :h_slog_amt, 'S'); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_send_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0002] 응답전문 송신완료 key=%s len=%d amount=%ld", rec.key, MSG_ACQ_LEN, rec.amount); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/mg_ol_0003.c b/app/online/mg_ol_0003.c index d94cf61..62f6da4 100644 --- a/app/online/mg_ol_0003.c +++ b/app/online/mg_ol_0003.c @@ -18,6 +18,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -90,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/mg_ol_0003.pgc" +#line 17 "app/online/mg_ol_0003.pgc" /* 그리드 컬럼 순서 규약: 0=처리키 1=가맹점 2=카드 3=금액 4=영업일 */ @@ -185,6 +186,58 @@ TX_SERVICE(MG_OL_0003, ctx) tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); tx_buf_sets(ctx->out, "BIZDATE", rec.biz_date); tx_buf_setlong(ctx->out, "MAPPED", (long)MG3_COL_REQUIRED); + + /* 5) 매핑 결과를 매핑감사 테이블(mg_map_audit)에 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + + +#line 115 "app/online/mg_ol_0003.pgc" + char h_map_key [ 16 ] ; + +#line 116 "app/online/mg_ol_0003.pgc" + char h_map_merch [ 16 ] ; + +#line 117 "app/online/mg_ol_0003.pgc" + long h_map_cols ; + +#line 118 "app/online/mg_ol_0003.pgc" + long h_map_amt ; +/* exec sql end declare section */ +#line 119 "app/online/mg_ol_0003.pgc" + + + strncpy(h_map_key, rec.key, sizeof(h_map_key) - 1); + h_map_key[sizeof(h_map_key) - 1] = '\0'; + strncpy(h_map_merch, rec.merch_id, sizeof(h_map_merch) - 1); + h_map_merch[sizeof(h_map_merch) - 1] = '\0'; + h_map_cols = (long)MG3_COL_REQUIRED; + h_map_amt = rec.amount; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_map_audit ( map_key , merch_id , col_cnt , map_amount ) values ( $1 , $2 , $3 , $4 )", + ECPGt_char,(h_map_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_map_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_map_cols),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_map_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 131 "app/online/mg_ol_0003.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_map_audit"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0003] 그리드 매핑완료 key=%s cols=%d amount=%ld", rec.key, MG3_COL_REQUIRED, rec.amount); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/mg_ol_0003.pgc b/app/online/mg_ol_0003.pgc index 0cecf25..83e1fa9 100644 --- a/app/online/mg_ol_0003.pgc +++ b/app/online/mg_ol_0003.pgc @@ -10,6 +10,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -107,6 +108,36 @@ TX_SERVICE(MG_OL_0003, ctx) tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); tx_buf_sets(ctx->out, "BIZDATE", rec.biz_date); tx_buf_setlong(ctx->out, "MAPPED", (long)MG3_COL_REQUIRED); + + /* 5) 매핑 결과를 매핑감사 테이블(mg_map_audit)에 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_map_key[16]; + char h_map_merch[16]; + long h_map_cols; + long h_map_amt; + EXEC SQL END DECLARE SECTION; + + strncpy(h_map_key, rec.key, sizeof(h_map_key) - 1); + h_map_key[sizeof(h_map_key) - 1] = '\0'; + strncpy(h_map_merch, rec.merch_id, sizeof(h_map_merch) - 1); + h_map_merch[sizeof(h_map_merch) - 1] = '\0'; + h_map_cols = (long)MG3_COL_REQUIRED; + h_map_amt = rec.amount; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_map_audit + (map_key, merch_id, col_cnt, map_amount) + VALUES (:h_map_key, :h_map_merch, :h_map_cols, :h_map_amt); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_map_audit"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0003] 그리드 매핑완료 key=%s cols=%d amount=%ld", rec.key, MG3_COL_REQUIRED, rec.amount); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/mg_ol_0004.c b/app/online/mg_ol_0004.c index 3d0a3a6..16d7f86 100644 --- a/app/online/mg_ol_0004.c +++ b/app/online/mg_ol_0004.c @@ -18,6 +18,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -90,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/mg_ol_0004.pgc" +#line 17 "app/online/mg_ol_0004.pgc" TX_SERVICE(MG_OL_0004, ctx) @@ -154,6 +155,51 @@ TX_SERVICE(MG_OL_0004, ctx) tx_buf_sets(ctx->out, "SESSION", token); tx_buf_setlong(ctx->out, "XID", (long)xid); tx_buf_setlong(ctx->out, "AUTHHASH", (long)(h & 0x7fffffffUL)); + + /* 6) 발급 세션을 세션 테이블(mg_session)에 개설상태('O')로 임베디드 SQL 등록 */ + { + /* exec sql begin declare section */ + + + + +#line 84 "app/online/mg_ol_0004.pgc" + char h_sess_token [ 40 ] ; + +#line 85 "app/online/mg_ol_0004.pgc" + char h_sess_chan [ 24 ] ; + +#line 86 "app/online/mg_ol_0004.pgc" + long h_sess_xid ; +/* exec sql end declare section */ +#line 87 "app/online/mg_ol_0004.pgc" + + + strncpy(h_sess_token, token, sizeof(h_sess_token) - 1); + h_sess_token[sizeof(h_sess_token) - 1] = '\0'; + strncpy(h_sess_chan, chanid, sizeof(h_sess_chan) - 1); + h_sess_chan[sizeof(h_sess_chan) - 1] = '\0'; + h_sess_xid = (long)xid; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_session ( session_token , chan_id , xid , sess_status ) values ( $1 , $2 , $3 , 'O' )", + ECPGt_char,(h_sess_token),(long)40,(long)1,(40)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_sess_chan),(long)24,(long)1,(24)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sess_xid),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 98 "app/online/mg_ol_0004.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_session"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0004] 세션 개설완료 chan=%s session=%s", chanid, token); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0004.pgc b/app/online/mg_ol_0004.pgc index d8bf050..f1f98f1 100644 --- a/app/online/mg_ol_0004.pgc +++ b/app/online/mg_ol_0004.pgc @@ -10,6 +10,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -76,6 +77,34 @@ TX_SERVICE(MG_OL_0004, ctx) tx_buf_sets(ctx->out, "SESSION", token); tx_buf_setlong(ctx->out, "XID", (long)xid); tx_buf_setlong(ctx->out, "AUTHHASH", (long)(h & 0x7fffffffUL)); + + /* 6) 발급 세션을 세션 테이블(mg_session)에 개설상태('O')로 임베디드 SQL 등록 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_sess_token[40]; + char h_sess_chan[24]; + long h_sess_xid; + EXEC SQL END DECLARE SECTION; + + strncpy(h_sess_token, token, sizeof(h_sess_token) - 1); + h_sess_token[sizeof(h_sess_token) - 1] = '\0'; + strncpy(h_sess_chan, chanid, sizeof(h_sess_chan) - 1); + h_sess_chan[sizeof(h_sess_chan) - 1] = '\0'; + h_sess_xid = (long)xid; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_session + (session_token, chan_id, xid, sess_status) + VALUES (:h_sess_token, :h_sess_chan, :h_sess_xid, 'O'); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_session"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0004] 세션 개설완료 chan=%s session=%s", chanid, token); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0006.c b/app/online/mg_ol_0006.c index d866eda..68d1b4e 100644 --- a/app/online/mg_ol_0006.c +++ b/app/online/mg_ol_0006.c @@ -18,6 +18,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -90,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/mg_ol_0006.pgc" +#line 17 "app/online/mg_ol_0006.pgc" TX_SERVICE(MG_OL_0006, ctx) @@ -161,6 +162,51 @@ TX_SERVICE(MG_OL_0006, ctx) tx_buf_sets(ctx->out, "SRCTYPE", MSG_TYPE_RECV); tx_buf_sets(ctx->out, "DSTTYPE", MSG_TYPE_RECON); tx_buf_sets(ctx->out, "RESP", RESP_OK); + + /* 6) 변환 이력(mg_convert_log)을 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + +#line 91 "app/online/mg_ol_0006.pgc" + char h_conv_key [ 16 ] ; + +#line 92 "app/online/mg_ol_0006.pgc" + char h_conv_src [ 8 ] ; + +#line 93 "app/online/mg_ol_0006.pgc" + char h_conv_dst [ 8 ] ; +/* exec sql end declare section */ +#line 94 "app/online/mg_ol_0006.pgc" + + + msg_field_copy(h_conv_key, dst.approval_no, FLD_APPROVAL_LEN); + strncpy(h_conv_src, MSG_TYPE_RECV, sizeof(h_conv_src) - 1); + h_conv_src[sizeof(h_conv_src) - 1] = '\0'; + strncpy(h_conv_dst, MSG_TYPE_RECON, sizeof(h_conv_dst) - 1); + h_conv_dst[sizeof(h_conv_dst) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_convert_log ( conv_key , src_type , dst_type ) values ( $1 , $2 , $3 )", + ECPGt_char,(h_conv_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_conv_src),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_conv_dst),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 105 "app/online/mg_ol_0006.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_convert_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0006] 포맷 변환완료 0200->0500 len=%d", MSG_ACQ_LEN); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0006.pgc b/app/online/mg_ol_0006.pgc index 132bd67..678010b 100644 --- a/app/online/mg_ol_0006.pgc +++ b/app/online/mg_ol_0006.pgc @@ -10,6 +10,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -83,6 +84,34 @@ TX_SERVICE(MG_OL_0006, ctx) tx_buf_sets(ctx->out, "SRCTYPE", MSG_TYPE_RECV); tx_buf_sets(ctx->out, "DSTTYPE", MSG_TYPE_RECON); tx_buf_sets(ctx->out, "RESP", RESP_OK); + + /* 6) 변환 이력(mg_convert_log)을 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_conv_key[16]; + char h_conv_src[8]; + char h_conv_dst[8]; + EXEC SQL END DECLARE SECTION; + + msg_field_copy(h_conv_key, dst.approval_no, FLD_APPROVAL_LEN); + strncpy(h_conv_src, MSG_TYPE_RECV, sizeof(h_conv_src) - 1); + h_conv_src[sizeof(h_conv_src) - 1] = '\0'; + strncpy(h_conv_dst, MSG_TYPE_RECON, sizeof(h_conv_dst) - 1); + h_conv_dst[sizeof(h_conv_dst) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_convert_log + (conv_key, src_type, dst_type) + VALUES (:h_conv_key, :h_conv_src, :h_conv_dst); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_convert_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0006] 포맷 변환완료 0200->0500 len=%d", MSG_ACQ_LEN); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0007.c b/app/online/mg_ol_0007.c index ca0a7a4..accaab5 100644 --- a/app/online/mg_ol_0007.c +++ b/app/online/mg_ol_0007.c @@ -18,6 +18,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -90,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/mg_ol_0007.pgc" +#line 17 "app/online/mg_ol_0007.pgc" TX_SERVICE(MG_OL_0007, ctx) @@ -152,6 +153,43 @@ TX_SERVICE(MG_OL_0007, ctx) tx_buf_setlong(ctx->out, "RAWLEN", (long)MSG_ACQ_LEN); tx_buf_sets(ctx->out, "MSGTYPE", MSG_TYPE_RESP); tx_buf_set(ctx->out, "RESPCODE", errcode, FLD_RESP_LEN); + + /* 6) 오류회신 이력(mg_error_log)을 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + +#line 82 "app/online/mg_ol_0007.pgc" + char h_err_key [ 16 ] ; + +#line 83 "app/online/mg_ol_0007.pgc" + char h_err_code [ 8 ] ; +/* exec sql end declare section */ +#line 84 "app/online/mg_ol_0007.pgc" + + + msg_field_copy(h_err_key, msg.approval_no, FLD_APPROVAL_LEN); + strncpy(h_err_code, errcode, sizeof(h_err_code) - 1); + h_err_code[sizeof(h_err_code) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_error_log ( err_key , err_code ) values ( $1 , $2 )", + ECPGt_char,(h_err_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_err_code),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 93 "app/online/mg_ol_0007.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_error_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0007] 오류전문 생성완료 respcode=%.4s", errcode); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0007.pgc b/app/online/mg_ol_0007.pgc index 41a73ce..9068173 100644 --- a/app/online/mg_ol_0007.pgc +++ b/app/online/mg_ol_0007.pgc @@ -10,6 +10,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -74,6 +75,31 @@ TX_SERVICE(MG_OL_0007, ctx) tx_buf_setlong(ctx->out, "RAWLEN", (long)MSG_ACQ_LEN); tx_buf_sets(ctx->out, "MSGTYPE", MSG_TYPE_RESP); tx_buf_set(ctx->out, "RESPCODE", errcode, FLD_RESP_LEN); + + /* 6) 오류회신 이력(mg_error_log)을 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_err_key[16]; + char h_err_code[8]; + EXEC SQL END DECLARE SECTION; + + msg_field_copy(h_err_key, msg.approval_no, FLD_APPROVAL_LEN); + strncpy(h_err_code, errcode, sizeof(h_err_code) - 1); + h_err_code[sizeof(h_err_code) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_error_log + (err_key, err_code) + VALUES (:h_err_key, :h_err_code); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_error_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0007] 오류전문 생성완료 respcode=%.4s", errcode); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0008.c b/app/online/mg_ol_0008.c index 449665c..7b4ad0c 100644 --- a/app/online/mg_ol_0008.c +++ b/app/online/mg_ol_0008.c @@ -18,6 +18,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -90,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/mg_ol_0008.pgc" +#line 17 "app/online/mg_ol_0008.pgc" typedef struct { @@ -155,6 +156,58 @@ TX_SERVICE(MG_OL_0008, ctx) tx_log(TX_LOG_WARN, "[MG_OL_0008] 라우팅 규칙 미매칭 type=%s merch=%s -> 기본채널", mtype, merch); + /* 2-b) DB 라우팅 규칙(mg_route)이 있으면 그것을 우선 적용 (임베디드 SQL) */ + { + /* exec sql begin declare section */ + + + + + +#line 84 "app/online/mg_ol_0008.pgc" + char h_mtype [ 8 ] ; + +#line 85 "app/online/mg_ol_0008.pgc" + char h_prefix [ 4 ] ; + +#line 86 "app/online/mg_ol_0008.pgc" + char h_dest [ 16 ] ; + +#line 87 "app/online/mg_ol_0008.pgc" + long h_prio ; +/* exec sql end declare section */ +#line 88 "app/online/mg_ol_0008.pgc" + + + strncpy(h_mtype, mtype, sizeof(h_mtype) - 1); + h_mtype[sizeof(h_mtype) - 1] = '\0'; + h_prefix[0] = merch[0]; + h_prefix[1] = '\0'; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select dest_chan , priority from mg_route where msg_type = $1 and merch_prefix = $2 ", + ECPGt_char,(h_mtype),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_prefix),(long)4,(long)1,(4)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_dest),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_prio),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 99 "app/online/mg_ol_0008.pgc" + + + if (sqlca.sqlcode == TX_SQL_OK) { + strncpy(dest, h_dest, sizeof(dest) - 1); + dest[sizeof(dest) - 1] = '\0'; + prio = (int)h_prio; + matched = 1; + tx_log(TX_LOG_INFO, "[MG_OL_0008] DB 라우팅 규칙 적용 dest=%s prio=%d", + dest, prio); + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT mg_route"); + } + } + /* 3) 라우팅 결과 응답 */ tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESP", RESP_OK); diff --git a/app/online/mg_ol_0008.pgc b/app/online/mg_ol_0008.pgc index 253d915..226cd73 100644 --- a/app/online/mg_ol_0008.pgc +++ b/app/online/mg_ol_0008.pgc @@ -10,6 +10,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -77,6 +78,38 @@ TX_SERVICE(MG_OL_0008, ctx) tx_log(TX_LOG_WARN, "[MG_OL_0008] 라우팅 규칙 미매칭 type=%s merch=%s -> 기본채널", mtype, merch); + /* 2-b) DB 라우팅 규칙(mg_route)이 있으면 그것을 우선 적용 (임베디드 SQL) */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_mtype[8]; + char h_prefix[4]; + char h_dest[16]; + long h_prio; + EXEC SQL END DECLARE SECTION; + + strncpy(h_mtype, mtype, sizeof(h_mtype) - 1); + h_mtype[sizeof(h_mtype) - 1] = '\0'; + h_prefix[0] = merch[0]; + h_prefix[1] = '\0'; + + EXEC SQL SELECT dest_chan, priority + INTO :h_dest, :h_prio + FROM mg_route + WHERE msg_type = :h_mtype + AND merch_prefix = :h_prefix; + + if (sqlca.sqlcode == TX_SQL_OK) { + strncpy(dest, h_dest, sizeof(dest) - 1); + dest[sizeof(dest) - 1] = '\0'; + prio = (int)h_prio; + matched = 1; + tx_log(TX_LOG_INFO, "[MG_OL_0008] DB 라우팅 규칙 적용 dest=%s prio=%d", + dest, prio); + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT mg_route"); + } + } + /* 3) 라우팅 결과 응답 */ tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESP", RESP_OK); diff --git a/app/online/mg_ol_0010.c b/app/online/mg_ol_0010.c index ddc6fdd..b14a871 100644 --- a/app/online/mg_ol_0010.c +++ b/app/online/mg_ol_0010.c @@ -18,6 +18,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -90,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/mg_ol_0010.pgc" +#line 17 "app/online/mg_ol_0010.pgc" #define MG10_MAXRUN 255 @@ -165,6 +166,49 @@ TX_SERVICE(MG_OL_0010, ctx) tx_buf_setlong(ctx->out, "COMPLEN", (long)complen); tx_buf_setlong(ctx->out, "RATIO", ratio); tx_buf_setlong(ctx->out, "VERIFY", 1); + + /* 6) 압축 통계(mg_compress_stat)를 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + +#line 95 "app/online/mg_ol_0010.pgc" + long h_raw_len ; + +#line 96 "app/online/mg_ol_0010.pgc" + long h_comp_len ; + +#line 97 "app/online/mg_ol_0010.pgc" + long h_ratio ; +/* exec sql end declare section */ +#line 98 "app/online/mg_ol_0010.pgc" + + + h_raw_len = (long)rawlen; + h_comp_len = (long)complen; + h_ratio = ratio; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_compress_stat ( raw_len , comp_len , comp_ratio ) values ( $1 , $2 , $3 )", + ECPGt_long,&(h_raw_len),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_comp_len),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_ratio),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 107 "app/online/mg_ol_0010.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_compress_stat"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0010] 압축완료 raw=%d comp=%d ratio=%ld%%", rawlen, complen, ratio); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/mg_ol_0010.pgc b/app/online/mg_ol_0010.pgc index d50c88f..bb95773 100644 --- a/app/online/mg_ol_0010.pgc +++ b/app/online/mg_ol_0010.pgc @@ -10,6 +10,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -87,6 +88,32 @@ TX_SERVICE(MG_OL_0010, ctx) tx_buf_setlong(ctx->out, "COMPLEN", (long)complen); tx_buf_setlong(ctx->out, "RATIO", ratio); tx_buf_setlong(ctx->out, "VERIFY", 1); + + /* 6) 압축 통계(mg_compress_stat)를 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + long h_raw_len; + long h_comp_len; + long h_ratio; + EXEC SQL END DECLARE SECTION; + + h_raw_len = (long)rawlen; + h_comp_len = (long)complen; + h_ratio = ratio; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_compress_stat + (raw_len, comp_len, comp_ratio) + VALUES (:h_raw_len, :h_comp_len, :h_ratio); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_compress_stat"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0010] 압축완료 raw=%d comp=%d ratio=%ld%%", rawlen, complen, ratio); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/mg_ol_0011.c b/app/online/mg_ol_0011.c index aa7f5c8..835baad 100644 --- a/app/online/mg_ol_0011.c +++ b/app/online/mg_ol_0011.c @@ -17,6 +17,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -89,7 +90,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/mg_ol_0011.pgc" +#line 16 "app/online/mg_ol_0011.pgc" TX_SERVICE(MG_OL_0011, ctx) @@ -145,6 +146,50 @@ TX_SERVICE(MG_OL_0011, ctx) tx_buf_sets(ctx->out, "FIELDS", present); tx_buf_setlong(ctx->out, "COUNT", (long)cnt); tx_buf_setlong(ctx->out, "SECONDARY", (long)secondary); + + /* 비트맵 파싱 결과(mg_bitmap_log)를 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + +#line 75 "app/online/mg_ol_0011.pgc" + char h_bm_bitmap [ 24 ] ; + +#line 76 "app/online/mg_ol_0011.pgc" + long h_bm_count ; + +#line 77 "app/online/mg_ol_0011.pgc" + long h_bm_secondary ; +/* exec sql end declare section */ +#line 78 "app/online/mg_ol_0011.pgc" + + + strncpy(h_bm_bitmap, bitmap, sizeof(h_bm_bitmap) - 1); + h_bm_bitmap[sizeof(h_bm_bitmap) - 1] = '\0'; + h_bm_count = (long)cnt; + h_bm_secondary = (long)secondary; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_bitmap_log ( primary_bitmap , field_count , secondary_yn ) values ( $1 , $2 , $3 )", + ECPGt_char,(h_bm_bitmap),(long)24,(long)1,(24)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_bm_count),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_bm_secondary),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 88 "app/online/mg_ol_0011.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_bitmap_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0011] 파싱완료 present=%d secondary=%d", cnt, secondary); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0011.pgc b/app/online/mg_ol_0011.pgc index 08a8b8b..6c6e90a 100644 --- a/app/online/mg_ol_0011.pgc +++ b/app/online/mg_ol_0011.pgc @@ -9,6 +9,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -67,6 +68,33 @@ TX_SERVICE(MG_OL_0011, ctx) tx_buf_sets(ctx->out, "FIELDS", present); tx_buf_setlong(ctx->out, "COUNT", (long)cnt); tx_buf_setlong(ctx->out, "SECONDARY", (long)secondary); + + /* 비트맵 파싱 결과(mg_bitmap_log)를 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_bm_bitmap[24]; + long h_bm_count; + long h_bm_secondary; + EXEC SQL END DECLARE SECTION; + + strncpy(h_bm_bitmap, bitmap, sizeof(h_bm_bitmap) - 1); + h_bm_bitmap[sizeof(h_bm_bitmap) - 1] = '\0'; + h_bm_count = (long)cnt; + h_bm_secondary = (long)secondary; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_bitmap_log + (primary_bitmap, field_count, secondary_yn) + VALUES (:h_bm_bitmap, :h_bm_count, :h_bm_secondary); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_bitmap_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0011] 파싱완료 present=%d secondary=%d", cnt, secondary); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0012.c b/app/online/mg_ol_0012.c index 97d98e1..35b20e1 100644 --- a/app/online/mg_ol_0012.c +++ b/app/online/mg_ol_0012.c @@ -18,6 +18,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -90,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/mg_ol_0012.pgc" +#line 17 "app/online/mg_ol_0012.pgc" /* 검증 단계 플래그 */ @@ -183,5 +184,55 @@ TX_SERVICE(MG_OL_0012, ctx) } tx_buf_setlong(ctx->out, "FLAGS", (long)flags); tx_buf_setlong(ctx->out, "CHKDIGIT", (long)calc); + + /* 6) 검증 결과(mg_validate_log)를 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + + +#line 113 "app/online/mg_ol_0012.pgc" + char h_v_type [ 8 ] ; + +#line 114 "app/online/mg_ol_0012.pgc" + long h_v_flags ; + +#line 115 "app/online/mg_ol_0012.pgc" + long h_v_chk ; + +#line 116 "app/online/mg_ol_0012.pgc" + long h_v_valid ; +/* exec sql end declare section */ +#line 117 "app/online/mg_ol_0012.pgc" + + + msg_field_copy(h_v_type, msg.msg_type, FLD_MSG_TYPE_LEN); + h_v_flags = (long)flags; + h_v_chk = (long)calc; + h_v_valid = (flags == MG12_F_ALL) ? 1 : 0; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_validate_log ( msg_type , check_flags , check_digit , valid_yn ) values ( $1 , $2 , $3 , $4 )", + ECPGt_char,(h_v_type),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_v_flags),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_v_chk),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_v_valid),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 127 "app/online/mg_ol_0012.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_validate_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, (flags == MG12_F_ALL) ? TX_OK : TX_FAIL, ctx->out); } diff --git a/app/online/mg_ol_0012.pgc b/app/online/mg_ol_0012.pgc index 9690fb0..ce4178c 100644 --- a/app/online/mg_ol_0012.pgc +++ b/app/online/mg_ol_0012.pgc @@ -10,6 +10,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -105,5 +106,33 @@ TX_SERVICE(MG_OL_0012, ctx) } tx_buf_setlong(ctx->out, "FLAGS", (long)flags); tx_buf_setlong(ctx->out, "CHKDIGIT", (long)calc); + + /* 6) 검증 결과(mg_validate_log)를 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_v_type[8]; + long h_v_flags; + long h_v_chk; + long h_v_valid; + EXEC SQL END DECLARE SECTION; + + msg_field_copy(h_v_type, msg.msg_type, FLD_MSG_TYPE_LEN); + h_v_flags = (long)flags; + h_v_chk = (long)calc; + h_v_valid = (flags == MG12_F_ALL) ? 1 : 0; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_validate_log + (msg_type, check_flags, check_digit, valid_yn) + VALUES (:h_v_type, :h_v_flags, :h_v_chk, :h_v_valid); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_validate_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, (flags == MG12_F_ALL) ? TX_OK : TX_FAIL, ctx->out); } diff --git a/app/online/mg_ol_0013.c b/app/online/mg_ol_0013.c index 12ed9b7..92bc731 100644 --- a/app/online/mg_ol_0013.c +++ b/app/online/mg_ol_0013.c @@ -19,6 +19,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -91,7 +92,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/mg_ol_0013.pgc" +#line 18 "app/online/mg_ol_0013.pgc" /* 채널 어댑터 정규화 규칙 */ @@ -120,6 +121,39 @@ TX_SERVICE(MG_OL_0013, ctx) } rawlen = (int)strlen(raw); + /* 채널별 헤더 규격(mg_chan_hdr)에서 기대 본문 오프셋을 조회 (참고/교차검증) */ + { + /* exec sql begin declare section */ + + + +#line 49 "app/online/mg_ol_0013.pgc" + char h_chan_code [ 8 ] ; + +#line 50 "app/online/mg_ol_0013.pgc" + long h_hdr_bodyoff ; +/* exec sql end declare section */ +#line 51 "app/online/mg_ol_0013.pgc" + + + strncpy(h_chan_code, chan, sizeof(h_chan_code) - 1); + h_chan_code[sizeof(h_chan_code) - 1] = '\0'; + h_hdr_bodyoff = -1; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select body_offset from mg_chan_hdr where chan_code = $1 ", + ECPGt_char,(h_chan_code),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_hdr_bodyoff),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 60 "app/online/mg_ol_0013.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) + tx_log(TX_LOG_INFO, "[MG_OL_0013] 헤더규격 조회 chan=%s bodyoff=%ld", + chan, h_hdr_bodyoff); + else if (sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT mg_chan_hdr"); + } + memset(mtype, 0, sizeof(mtype)); memset(yyyymmdd, 0, sizeof(yyyymmdd)); memset(hhmmss, 0, sizeof(hhmmss)); diff --git a/app/online/mg_ol_0013.pgc b/app/online/mg_ol_0013.pgc index 20acae2..63a29ed 100644 --- a/app/online/mg_ol_0013.pgc +++ b/app/online/mg_ol_0013.pgc @@ -11,6 +11,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -42,6 +43,28 @@ TX_SERVICE(MG_OL_0013, ctx) } rawlen = (int)strlen(raw); + /* 채널별 헤더 규격(mg_chan_hdr)에서 기대 본문 오프셋을 조회 (참고/교차검증) */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_chan_code[8]; + long h_hdr_bodyoff; + EXEC SQL END DECLARE SECTION; + + strncpy(h_chan_code, chan, sizeof(h_chan_code) - 1); + h_chan_code[sizeof(h_chan_code) - 1] = '\0'; + h_hdr_bodyoff = -1; + + EXEC SQL SELECT body_offset + INTO :h_hdr_bodyoff + FROM mg_chan_hdr + WHERE chan_code = :h_chan_code; + if (sqlca.sqlcode == TX_SQL_OK) + tx_log(TX_LOG_INFO, "[MG_OL_0013] 헤더규격 조회 chan=%s bodyoff=%ld", + chan, h_hdr_bodyoff); + else if (sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT mg_chan_hdr"); + } + memset(mtype, 0, sizeof(mtype)); memset(yyyymmdd, 0, sizeof(yyyymmdd)); memset(hhmmss, 0, sizeof(hhmmss)); diff --git a/app/online/mg_ol_0015.c b/app/online/mg_ol_0015.c index 5d4b627..724f409 100644 --- a/app/online/mg_ol_0015.c +++ b/app/online/mg_ol_0015.c @@ -19,6 +19,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -91,7 +92,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/mg_ol_0015.pgc" +#line 18 "app/online/mg_ol_0015.pgc" /* 노드 헬스 점수: 100 만점, 낮을수록 위험 (임계 = 40) */ @@ -169,6 +170,59 @@ TX_SERVICE(MG_OL_0015, ctx) reason = "DEGRADED"; } + /* 절체 판정 결과를 노드상태 테이블(mg_node_state)에 임베디드 SQL 로 반영 */ + { + /* exec sql begin declare section */ + + + + + +#line 98 "app/online/mg_ol_0015.pgc" + char h_active [ 8 ] ; + +#line 99 "app/online/mg_ol_0015.pgc" + char h_reason [ 16 ] ; + +#line 100 "app/online/mg_ol_0015.pgc" + long h_ascore ; + +#line 101 "app/online/mg_ol_0015.pgc" + long h_sscore ; +/* exec sql end declare section */ +#line 102 "app/online/mg_ol_0015.pgc" + + + strncpy(h_active, selected, sizeof(h_active) - 1); + h_active[sizeof(h_active) - 1] = '\0'; + strncpy(h_reason, reason, sizeof(h_reason) - 1); + h_reason[sizeof(h_reason) - 1] = '\0'; + h_ascore = (long)a_score; + h_sscore = (long)s_score; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_node_state set active_node = $1 , switch_reason = $2 , active_score = $3 , standby_score = $4 where cluster_id = 'MG'", + ECPGt_char,(h_active),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_reason),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_ascore),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sscore),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 117 "app/online/mg_ol_0015.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE mg_node_state"); + tx_abort(); + } else { + if (sqlca.sqlerrd[2] == 0) + tx_log(TX_LOG_WARN, "[MG_OL_0015] 노드상태 행 없음 cluster=MG"); + tx_commit(); + } + } + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "SELECTED", selected); diff --git a/app/online/mg_ol_0015.pgc b/app/online/mg_ol_0015.pgc index f1a942d..d755ca8 100644 --- a/app/online/mg_ol_0015.pgc +++ b/app/online/mg_ol_0015.pgc @@ -11,6 +11,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -91,6 +92,40 @@ TX_SERVICE(MG_OL_0015, ctx) reason = "DEGRADED"; } + /* 절체 판정 결과를 노드상태 테이블(mg_node_state)에 임베디드 SQL 로 반영 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_active[8]; + char h_reason[16]; + long h_ascore; + long h_sscore; + EXEC SQL END DECLARE SECTION; + + strncpy(h_active, selected, sizeof(h_active) - 1); + h_active[sizeof(h_active) - 1] = '\0'; + strncpy(h_reason, reason, sizeof(h_reason) - 1); + h_reason[sizeof(h_reason) - 1] = '\0'; + h_ascore = (long)a_score; + h_sscore = (long)s_score; + + if (tx_begin() == TX_OK) { + EXEC SQL UPDATE mg_node_state + SET active_node = :h_active, + switch_reason = :h_reason, + active_score = :h_ascore, + standby_score = :h_sscore + WHERE cluster_id = 'MG'; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE mg_node_state"); + tx_abort(); + } else { + if (sqlca.sqlerrd[2] == 0) + tx_log(TX_LOG_WARN, "[MG_OL_0015] 노드상태 행 없음 cluster=MG"); + tx_commit(); + } + } + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "SELECTED", selected); diff --git a/app/online/mg_ol_0016.c b/app/online/mg_ol_0016.c index 87bb984..24d74a7 100644 --- a/app/online/mg_ol_0016.c +++ b/app/online/mg_ol_0016.c @@ -18,6 +18,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -90,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/mg_ol_0016.pgc" +#line 17 "app/online/mg_ol_0016.pgc" TX_SERVICE(MG_OL_0016, ctx) @@ -149,6 +150,49 @@ TX_SERVICE(MG_OL_0016, ctx) tx_buf_setlong(ctx->out, "AVGAMT", avg_amt); tx_buf_setlong(ctx->out, "DONERATE", (long)done_rate); tx_buf_sets(ctx->out, "SUMWON", wonbuf); + + /* 정산완료 건수/최대 거래금액은 원장(mg_ledger)에서 직접 임베디드 SQL 집계 */ + { + /* exec sql begin declare section */ + + + + +#line 79 "app/online/mg_ol_0016.pgc" + char h_stat_bd [ 9 ] ; + +#line 80 "app/online/mg_ol_0016.pgc" + long h_cnt_settled ; + +#line 81 "app/online/mg_ol_0016.pgc" + long h_max_amt ; +/* exec sql end declare section */ +#line 82 "app/online/mg_ol_0016.pgc" + + + strncpy(h_stat_bd, bizdate, sizeof(h_stat_bd) - 1); + h_stat_bd[sizeof(h_stat_bd) - 1] = '\0'; + h_cnt_settled = 0; + h_max_amt = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) , coalesce ( MAX ( amount ) , 0 ) from mg_ledger where biz_date = $1 and status = 'S'", + ECPGt_char,(h_stat_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_cnt_settled),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_max_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 93 "app/online/mg_ol_0016.pgc" + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT mg_ledger settled stat"); + h_cnt_settled = 0; + h_max_amt = 0; + } + tx_buf_setlong(ctx->out, "CNTSETTLED", h_cnt_settled); + tx_buf_setlong(ctx->out, "MAXAMT", h_max_amt); + } + tx_log(TX_LOG_INFO, "[MG_OL_0016] 통계완료 date=%s total=%ld sum=%ld rate=%d%%", bizdate, cnt_total, sum_amt, done_rate); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/mg_ol_0016.pgc b/app/online/mg_ol_0016.pgc index 18b802f..1b8c80d 100644 --- a/app/online/mg_ol_0016.pgc +++ b/app/online/mg_ol_0016.pgc @@ -10,6 +10,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -71,6 +72,34 @@ TX_SERVICE(MG_OL_0016, ctx) tx_buf_setlong(ctx->out, "AVGAMT", avg_amt); tx_buf_setlong(ctx->out, "DONERATE", (long)done_rate); tx_buf_sets(ctx->out, "SUMWON", wonbuf); + + /* 정산완료 건수/최대 거래금액은 원장(mg_ledger)에서 직접 임베디드 SQL 집계 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_stat_bd[9]; + long h_cnt_settled; + long h_max_amt; + EXEC SQL END DECLARE SECTION; + + strncpy(h_stat_bd, bizdate, sizeof(h_stat_bd) - 1); + h_stat_bd[sizeof(h_stat_bd) - 1] = '\0'; + h_cnt_settled = 0; + h_max_amt = 0; + + EXEC SQL SELECT COUNT(*), COALESCE(MAX(amount), 0) + INTO :h_cnt_settled, :h_max_amt + FROM mg_ledger + WHERE biz_date = :h_stat_bd + AND status = 'S'; + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT mg_ledger settled stat"); + h_cnt_settled = 0; + h_max_amt = 0; + } + tx_buf_setlong(ctx->out, "CNTSETTLED", h_cnt_settled); + tx_buf_setlong(ctx->out, "MAXAMT", h_max_amt); + } + tx_log(TX_LOG_INFO, "[MG_OL_0016] 통계완료 date=%s total=%ld sum=%ld rate=%d%%", bizdate, cnt_total, sum_amt, done_rate); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/mg_ol_0017.c b/app/online/mg_ol_0017.c index 942b9e1..a436782 100644 --- a/app/online/mg_ol_0017.c +++ b/app/online/mg_ol_0017.c @@ -20,6 +20,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -92,7 +93,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 18 "app/online/mg_ol_0017.pgc" +#line 19 "app/online/mg_ol_0017.pgc" #define SKEW_LIMIT 300 /* 허용 시계편차 300초 */ @@ -182,6 +183,50 @@ TX_SERVICE(MG_OL_0017, ctx) tx_buf_sets(ctx->out, "ECHODATE", today); tx_buf_setlong(ctx->out, "SEQ", seq); tx_buf_setlong(ctx->out, "TXNSEC", tx_sec); + + /* 헬스체크 이력(mg_health_log)을 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + +#line 112 "app/online/mg_ol_0017.pgc" + char h_hc_date [ 9 ] ; + +#line 113 "app/online/mg_ol_0017.pgc" + long h_hc_seq ; + +#line 114 "app/online/mg_ol_0017.pgc" + long h_hc_sec ; +/* exec sql end declare section */ +#line 115 "app/online/mg_ol_0017.pgc" + + + strncpy(h_hc_date, today, sizeof(h_hc_date) - 1); + h_hc_date[sizeof(h_hc_date) - 1] = '\0'; + h_hc_seq = seq; + h_hc_sec = tx_sec; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_health_log ( echo_date , echo_seq , txn_sec ) values ( $1 , $2 , $3 )", + ECPGt_char,(h_hc_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_hc_seq),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_hc_sec),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 125 "app/online/mg_ol_0017.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_health_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0017] 헬스응답 반환 seq=%ld txnsec=%ld", seq, tx_sec); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0017.pgc b/app/online/mg_ol_0017.pgc index 2a6e724..087ffba 100644 --- a/app/online/mg_ol_0017.pgc +++ b/app/online/mg_ol_0017.pgc @@ -12,6 +12,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -104,6 +105,33 @@ TX_SERVICE(MG_OL_0017, ctx) tx_buf_sets(ctx->out, "ECHODATE", today); tx_buf_setlong(ctx->out, "SEQ", seq); tx_buf_setlong(ctx->out, "TXNSEC", tx_sec); + + /* 헬스체크 이력(mg_health_log)을 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_hc_date[9]; + long h_hc_seq; + long h_hc_sec; + EXEC SQL END DECLARE SECTION; + + strncpy(h_hc_date, today, sizeof(h_hc_date) - 1); + h_hc_date[sizeof(h_hc_date) - 1] = '\0'; + h_hc_seq = seq; + h_hc_sec = tx_sec; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_health_log + (echo_date, echo_seq, txn_sec) + VALUES (:h_hc_date, :h_hc_seq, :h_hc_sec); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_health_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0017] 헬스응답 반환 seq=%ld txnsec=%ld", seq, tx_sec); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0018.c b/app/online/mg_ol_0018.c index f7fcdad..6ac312a 100644 --- a/app/online/mg_ol_0018.c +++ b/app/online/mg_ol_0018.c @@ -19,6 +19,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -91,7 +92,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/mg_ol_0018.pgc" +#line 18 "app/online/mg_ol_0018.pgc" TX_SERVICE(MG_OL_0018, ctx) @@ -132,7 +133,52 @@ TX_SERVICE(MG_OL_0018, ctx) /* 승인번호: 요청값 우선, 없으면 가맹점+금액 기반 채번 */ if (tx_buf_get(ctx->in, "APPROVAL", approval, sizeof(approval)) != TX_OK || approval[0] == '\0') { - snprintf(apnbuf, sizeof(apnbuf), "%08ld", (amount % 100000000L)); + /* 승인번호 채번: 승인번호 시퀀스 마스터(mg_appr_seq)에서 임베디드 SQL 로 채번 */ + /* exec sql begin declare section */ + + + +#line 60 "app/online/mg_ol_0018.pgc" + char h_seq_name [ 8 ] ; + +#line 61 "app/online/mg_ol_0018.pgc" + long h_last_no ; +/* exec sql end declare section */ +#line 62 "app/online/mg_ol_0018.pgc" + + + strcpy(h_seq_name, "APPR"); + h_last_no = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select last_no from mg_appr_seq where seq_name = $1 ", + ECPGt_char,(h_seq_name),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_last_no),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 70 "app/online/mg_ol_0018.pgc" + + + if (sqlca.sqlcode == TX_SQL_OK) { + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update mg_appr_seq set last_no = last_no + 1 where seq_name = $1 ", + ECPGt_char,(h_seq_name),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 76 "app/online/mg_ol_0018.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE mg_appr_seq"); + tx_abort(); + } else { + tx_commit(); + } + } + snprintf(apnbuf, sizeof(apnbuf), "%08ld", ((h_last_no + 1) % 100000000L)); + } else { + if (sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT mg_appr_seq"); + /* 시퀀스 미비 시 금액기반 폴백 채번 */ + snprintf(apnbuf, sizeof(apnbuf), "%08ld", (amount % 100000000L)); + } } else { strncpy(apnbuf, approval, sizeof(apnbuf) - 1); apnbuf[sizeof(apnbuf) - 1] = '\0'; diff --git a/app/online/mg_ol_0018.pgc b/app/online/mg_ol_0018.pgc index af8ef8a..1fab48e 100644 --- a/app/online/mg_ol_0018.pgc +++ b/app/online/mg_ol_0018.pgc @@ -11,6 +11,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -54,7 +55,39 @@ TX_SERVICE(MG_OL_0018, ctx) /* 승인번호: 요청값 우선, 없으면 가맹점+금액 기반 채번 */ if (tx_buf_get(ctx->in, "APPROVAL", approval, sizeof(approval)) != TX_OK || approval[0] == '\0') { - snprintf(apnbuf, sizeof(apnbuf), "%08ld", (amount % 100000000L)); + /* 승인번호 채번: 승인번호 시퀀스 마스터(mg_appr_seq)에서 임베디드 SQL 로 채번 */ + EXEC SQL BEGIN DECLARE SECTION; + char h_seq_name[8]; + long h_last_no; + EXEC SQL END DECLARE SECTION; + + strcpy(h_seq_name, "APPR"); + h_last_no = 0; + + EXEC SQL SELECT last_no + INTO :h_last_no + FROM mg_appr_seq + WHERE seq_name = :h_seq_name; + + if (sqlca.sqlcode == TX_SQL_OK) { + if (tx_begin() == TX_OK) { + EXEC SQL UPDATE mg_appr_seq + SET last_no = last_no + 1 + WHERE seq_name = :h_seq_name; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE mg_appr_seq"); + tx_abort(); + } else { + tx_commit(); + } + } + snprintf(apnbuf, sizeof(apnbuf), "%08ld", ((h_last_no + 1) % 100000000L)); + } else { + if (sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT mg_appr_seq"); + /* 시퀀스 미비 시 금액기반 폴백 채번 */ + snprintf(apnbuf, sizeof(apnbuf), "%08ld", (amount % 100000000L)); + } } else { strncpy(apnbuf, approval, sizeof(apnbuf) - 1); apnbuf[sizeof(apnbuf) - 1] = '\0'; diff --git a/app/online/mg_ol_0019.c b/app/online/mg_ol_0019.c index acb4d7b..4deb21b 100644 --- a/app/online/mg_ol_0019.c +++ b/app/online/mg_ol_0019.c @@ -21,6 +21,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -93,7 +94,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 19 "app/online/mg_ol_0019.pgc" +#line 20 "app/online/mg_ol_0019.pgc" #define HDR_LEN 25 @@ -195,6 +196,58 @@ TX_SERVICE(MG_OL_0019, ctx) tx_buf_setlong(ctx->out, "DECLLEN", decl_body); tx_buf_setlong(ctx->out, "REALLEN", real_body); tx_buf_sets(ctx->out, "LENMATCH", (decl_body == real_body) ? "Y" : "N"); + + /* 공통헤더 파싱 이력(mg_hdr_log)을 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + + +#line 125 "app/online/mg_ol_0019.pgc" + char h_hl_type [ 8 ] ; + +#line 126 "app/online/mg_ol_0019.pgc" + char h_hl_chan [ 4 ] ; + +#line 127 "app/online/mg_ol_0019.pgc" + long h_hl_decl ; + +#line 128 "app/online/mg_ol_0019.pgc" + long h_hl_real ; +/* exec sql end declare section */ +#line 129 "app/online/mg_ol_0019.pgc" + + + strncpy(h_hl_type, mtype, sizeof(h_hl_type) - 1); + h_hl_type[sizeof(h_hl_type) - 1] = '\0'; + strncpy(h_hl_chan, chan, sizeof(h_hl_chan) - 1); + h_hl_chan[sizeof(h_hl_chan) - 1] = '\0'; + h_hl_decl = decl_body; + h_hl_real = real_body; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_hdr_log ( msg_type , chan , decl_len , real_len ) values ( $1 , $2 , $3 , $4 )", + ECPGt_char,(h_hl_type),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_hl_chan),(long)4,(long)1,(4)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_hl_decl),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_hl_real),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 141 "app/online/mg_ol_0019.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_hdr_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0019] 헤더파싱 완료 type=%s chan=%s date=%s time=%s", mtype, chan, cdate, ctime); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/mg_ol_0019.pgc b/app/online/mg_ol_0019.pgc index 622d72e..c744961 100644 --- a/app/online/mg_ol_0019.pgc +++ b/app/online/mg_ol_0019.pgc @@ -13,6 +13,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -117,6 +118,36 @@ TX_SERVICE(MG_OL_0019, ctx) tx_buf_setlong(ctx->out, "DECLLEN", decl_body); tx_buf_setlong(ctx->out, "REALLEN", real_body); tx_buf_sets(ctx->out, "LENMATCH", (decl_body == real_body) ? "Y" : "N"); + + /* 공통헤더 파싱 이력(mg_hdr_log)을 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_hl_type[8]; + char h_hl_chan[4]; + long h_hl_decl; + long h_hl_real; + EXEC SQL END DECLARE SECTION; + + strncpy(h_hl_type, mtype, sizeof(h_hl_type) - 1); + h_hl_type[sizeof(h_hl_type) - 1] = '\0'; + strncpy(h_hl_chan, chan, sizeof(h_hl_chan) - 1); + h_hl_chan[sizeof(h_hl_chan) - 1] = '\0'; + h_hl_decl = decl_body; + h_hl_real = real_body; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_hdr_log + (msg_type, chan, decl_len, real_len) + VALUES (:h_hl_type, :h_hl_chan, :h_hl_decl, :h_hl_real); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_hdr_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0019] 헤더파싱 완료 type=%s chan=%s date=%s time=%s", mtype, chan, cdate, ctime); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/mg_ol_0021.c b/app/online/mg_ol_0021.c index 2854cb4..07b14a6 100644 --- a/app/online/mg_ol_0021.c +++ b/app/online/mg_ol_0021.c @@ -19,6 +19,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -91,7 +92,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/mg_ol_0021.pgc" +#line 18 "app/online/mg_ol_0021.pgc" #define PAN_HEAD 6 /* 앞 노출 자릿수 (BIN) */ @@ -145,6 +146,43 @@ TX_SERVICE(MG_OL_0021, ctx) tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MASKED", masked); tx_buf_setlong(ctx->out, "PANLEN", (long)len); + + /* 마스킹 이력(mg_mask_log)을 임베디드 SQL 로 적재 (원본 PAN 은 저장하지 않음) */ + { + /* exec sql begin declare section */ + + + +#line 75 "app/online/mg_ol_0021.pgc" + char h_mk_masked [ 24 ] ; + +#line 76 "app/online/mg_ol_0021.pgc" + long h_mk_len ; +/* exec sql end declare section */ +#line 77 "app/online/mg_ol_0021.pgc" + + + strncpy(h_mk_masked, masked, sizeof(h_mk_masked) - 1); + h_mk_masked[sizeof(h_mk_masked) - 1] = '\0'; + h_mk_len = (long)len; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_mask_log ( masked_pan , pan_len ) values ( $1 , $2 )", + ECPGt_char,(h_mk_masked),(long)24,(long)1,(24)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_mk_len),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 86 "app/online/mg_ol_0021.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_mask_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0021] 마스킹 완료 len=%d masked=%s", len, masked); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0021.pgc b/app/online/mg_ol_0021.pgc index 97399bc..dac96db 100644 --- a/app/online/mg_ol_0021.pgc +++ b/app/online/mg_ol_0021.pgc @@ -11,6 +11,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -67,6 +68,31 @@ TX_SERVICE(MG_OL_0021, ctx) tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MASKED", masked); tx_buf_setlong(ctx->out, "PANLEN", (long)len); + + /* 마스킹 이력(mg_mask_log)을 임베디드 SQL 로 적재 (원본 PAN 은 저장하지 않음) */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_mk_masked[24]; + long h_mk_len; + EXEC SQL END DECLARE SECTION; + + strncpy(h_mk_masked, masked, sizeof(h_mk_masked) - 1); + h_mk_masked[sizeof(h_mk_masked) - 1] = '\0'; + h_mk_len = (long)len; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_mask_log + (masked_pan, pan_len) + VALUES (:h_mk_masked, :h_mk_len); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_mask_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0021] 마스킹 완료 len=%d masked=%s", len, masked); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0022.c b/app/online/mg_ol_0022.c index 8798059..500ac43 100644 --- a/app/online/mg_ol_0022.c +++ b/app/online/mg_ol_0022.c @@ -19,6 +19,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -91,7 +92,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/mg_ol_0022.pgc" +#line 18 "app/online/mg_ol_0022.pgc" #define MAX_FRAG 32 @@ -176,6 +177,49 @@ TX_SERVICE(MG_OL_0022, ctx) tx_buf_sets(ctx->out, "FULLMSG", full); tx_buf_setlong(ctx->out, "FRAGCNT", (long)filled); tx_buf_setlong(ctx->out, "MERGEDLEN", (long)merged_len); + + /* 재조립 이력(mg_reasm_log)을 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + +#line 106 "app/online/mg_ol_0022.pgc" + long h_rs_frag ; + +#line 107 "app/online/mg_ol_0022.pgc" + long h_rs_merged ; + +#line 108 "app/online/mg_ol_0022.pgc" + long h_rs_decl ; +/* exec sql end declare section */ +#line 109 "app/online/mg_ol_0022.pgc" + + + h_rs_frag = (long)filled; + h_rs_merged = (long)merged_len; + h_rs_decl = totlen; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_reasm_log ( frag_cnt , merged_len , decl_len ) values ( $1 , $2 , $3 )", + ECPGt_long,&(h_rs_frag),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_rs_merged),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_rs_decl),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 118 "app/online/mg_ol_0022.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_reasm_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0022] 재조립 완료 조각=%d 길이=%d", filled, merged_len); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0022.pgc b/app/online/mg_ol_0022.pgc index 2ff1044..1038e2b 100644 --- a/app/online/mg_ol_0022.pgc +++ b/app/online/mg_ol_0022.pgc @@ -11,6 +11,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -98,6 +99,32 @@ TX_SERVICE(MG_OL_0022, ctx) tx_buf_sets(ctx->out, "FULLMSG", full); tx_buf_setlong(ctx->out, "FRAGCNT", (long)filled); tx_buf_setlong(ctx->out, "MERGEDLEN", (long)merged_len); + + /* 재조립 이력(mg_reasm_log)을 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + long h_rs_frag; + long h_rs_merged; + long h_rs_decl; + EXEC SQL END DECLARE SECTION; + + h_rs_frag = (long)filled; + h_rs_merged = (long)merged_len; + h_rs_decl = totlen; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_reasm_log + (frag_cnt, merged_len, decl_len) + VALUES (:h_rs_frag, :h_rs_merged, :h_rs_decl); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_reasm_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0022] 재조립 완료 조각=%d 길이=%d", filled, merged_len); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0023.c b/app/online/mg_ol_0023.c index e4a3dc9..904c0be 100644 --- a/app/online/mg_ol_0023.c +++ b/app/online/mg_ol_0023.c @@ -147,7 +147,7 @@ TX_SERVICE(MG_OL_0023, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_status),(long)2,(long)1,(2)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 54 "app/online/mg_ol_0023.pgc" +#line 53 "app/online/mg_ol_0023.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -187,7 +187,7 @@ TX_SERVICE(MG_OL_0023, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_token),(long)33,(long)1,(33)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 92 "app/online/mg_ol_0023.pgc" +#line 90 "app/online/mg_ol_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK || sqlca.sqlerrd[2] != 1) { diff --git a/app/online/mg_ol_0023.pgc b/app/online/mg_ol_0023.pgc index e09f801..89e74dd 100644 --- a/app/online/mg_ol_0023.pgc +++ b/app/online/mg_ol_0023.pgc @@ -48,8 +48,7 @@ TX_SERVICE(MG_OL_0023, ctx) h_token[sizeof(h_token) - 1] = '\0'; /* 2) 현재 세션 상태 조회 */ - EXEC SQL - SELECT chan_cd, status INTO :h_chan_cd, :h_status + EXEC SQL SELECT chan_cd, status INTO :h_chan_cd, :h_status FROM mg_chan WHERE sess_token = :h_token; @@ -85,8 +84,7 @@ TX_SERVICE(MG_OL_0023, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[MG_OL_0023] tx_begin 경고"); - EXEC SQL - UPDATE mg_chan + EXEC SQL UPDATE mg_chan SET status = :h_close_st, closed_ts = now() WHERE sess_token = :h_token; diff --git a/app/online/mg_ol_0024.c b/app/online/mg_ol_0024.c index 0fbdc80..3ac16aa 100644 --- a/app/online/mg_ol_0024.c +++ b/app/online/mg_ol_0024.c @@ -19,6 +19,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -91,7 +92,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/mg_ol_0024.pgc" +#line 18 "app/online/mg_ol_0024.pgc" #define MG_TIMEOUT_DEFAULT_MS 5000L @@ -171,5 +172,48 @@ TX_SERVICE(MG_OL_0024, ctx) tx_log(TX_LOG_INFO, "[MG_OL_0024] 정상 경과=%ldms 임계=%ldms", elapsed, threshold); + /* 타임아웃 판정 이력(mg_timeout_log)을 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + +#line 100 "app/online/mg_ol_0024.pgc" + long h_to_elapsed ; + +#line 101 "app/online/mg_ol_0024.pgc" + long h_to_thresh ; + +#line 102 "app/online/mg_ol_0024.pgc" + char h_to_flag [ 2 ] ; +/* exec sql end declare section */ +#line 103 "app/online/mg_ol_0024.pgc" + + + h_to_elapsed = elapsed; + h_to_thresh = threshold; + h_to_flag[0] = is_timeout ? 'Y' : 'N'; + h_to_flag[1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_timeout_log ( elapsed_ms , thresh_ms , timeout_yn ) values ( $1 , $2 , $3 )", + ECPGt_long,&(h_to_elapsed),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_to_thresh),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_to_flag),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 113 "app/online/mg_ol_0024.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_timeout_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0024.pgc b/app/online/mg_ol_0024.pgc index ce0caf5..6c2e3a5 100644 --- a/app/online/mg_ol_0024.pgc +++ b/app/online/mg_ol_0024.pgc @@ -11,6 +11,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -93,5 +94,31 @@ TX_SERVICE(MG_OL_0024, ctx) tx_log(TX_LOG_INFO, "[MG_OL_0024] 정상 경과=%ldms 임계=%ldms", elapsed, threshold); + /* 타임아웃 판정 이력(mg_timeout_log)을 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + long h_to_elapsed; + long h_to_thresh; + char h_to_flag[2]; + EXEC SQL END DECLARE SECTION; + + h_to_elapsed = elapsed; + h_to_thresh = threshold; + h_to_flag[0] = is_timeout ? 'Y' : 'N'; + h_to_flag[1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_timeout_log + (elapsed_ms, thresh_ms, timeout_yn) + VALUES (:h_to_elapsed, :h_to_thresh, :h_to_flag); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_timeout_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0025.c b/app/online/mg_ol_0025.c index 5be2767..6c15726 100644 --- a/app/online/mg_ol_0025.c +++ b/app/online/mg_ol_0025.c @@ -172,7 +172,7 @@ TX_SERVICE(MG_OL_0025, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_char,(h_dup_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 81 "app/online/mg_ol_0025.pgc" +#line 80 "app/online/mg_ol_0025.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/mg_ol_0025.pgc b/app/online/mg_ol_0025.pgc index 27fae9b..f361240 100644 --- a/app/online/mg_ol_0025.pgc +++ b/app/online/mg_ol_0025.pgc @@ -71,8 +71,7 @@ TX_SERVICE(MG_OL_0025, ctx) memset(h_dup_key, 0, sizeof(h_dup_key)); /* 3) 최근 처리원장에서 동일 조합 조회 (최근 1건) */ - EXEC SQL - SELECT key INTO :h_dup_key + EXEC SQL SELECT key INTO :h_dup_key FROM mg_ledger WHERE stan = :h_stan AND merch_id = :h_merch diff --git a/app/online/mg_ol_0026.c b/app/online/mg_ol_0026.c index 568e871..6c826d6 100644 --- a/app/online/mg_ol_0026.c +++ b/app/online/mg_ol_0026.c @@ -19,6 +19,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -91,7 +92,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/mg_ol_0026.pgc" +#line 18 "app/online/mg_ol_0026.pgc" /* 문자열 가운데를 마스킹: 앞 keep_head, 뒤 keep_tail 만 보존. 치환자릿수 반환 */ @@ -155,6 +156,49 @@ TX_SERVICE(MG_OL_0026, ctx) /* 3) 치환건수 응답 */ tx_buf_setlong(ctx->out, "MASKED", (long)masked); + + /* 개인정보 치환 감사(mg_pii_log)를 임베디드 SQL 로 적재 (원본값은 저장 안함) */ + { + /* exec sql begin declare section */ + + + + +#line 85 "app/online/mg_ol_0026.pgc" + long h_pii_card ; + +#line 86 "app/online/mg_ol_0026.pgc" + long h_pii_rrn ; + +#line 87 "app/online/mg_ol_0026.pgc" + long h_pii_masked ; +/* exec sql end declare section */ +#line 88 "app/online/mg_ol_0026.pgc" + + + h_pii_card = have_card ? 1 : 0; + h_pii_rrn = have_rrn ? 1 : 0; + h_pii_masked = (long)masked; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_pii_log ( card_flag , rrn_flag , masked_digits ) values ( $1 , $2 , $3 )", + ECPGt_long,&(h_pii_card),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_pii_rrn),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_pii_masked),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 97 "app/online/mg_ol_0026.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_pii_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0026] 치환완료 치환자릿수=%d", masked); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0026.pgc b/app/online/mg_ol_0026.pgc index 3d0ae5d..5542601 100644 --- a/app/online/mg_ol_0026.pgc +++ b/app/online/mg_ol_0026.pgc @@ -11,6 +11,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -77,6 +78,32 @@ TX_SERVICE(MG_OL_0026, ctx) /* 3) 치환건수 응답 */ tx_buf_setlong(ctx->out, "MASKED", (long)masked); + + /* 개인정보 치환 감사(mg_pii_log)를 임베디드 SQL 로 적재 (원본값은 저장 안함) */ + { + EXEC SQL BEGIN DECLARE SECTION; + long h_pii_card; + long h_pii_rrn; + long h_pii_masked; + EXEC SQL END DECLARE SECTION; + + h_pii_card = have_card ? 1 : 0; + h_pii_rrn = have_rrn ? 1 : 0; + h_pii_masked = (long)masked; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_pii_log + (card_flag, rrn_flag, masked_digits) + VALUES (:h_pii_card, :h_pii_rrn, :h_pii_masked); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_pii_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0026] 치환완료 치환자릿수=%d", masked); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0027.c b/app/online/mg_ol_0027.c index 5505090..2519b4f 100644 --- a/app/online/mg_ol_0027.c +++ b/app/online/mg_ol_0027.c @@ -19,6 +19,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -91,7 +92,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/mg_ol_0027.pgc" +#line 18 "app/online/mg_ol_0027.pgc" #define MG_LEN_PREFIX 4 @@ -152,6 +153,42 @@ TX_SERVICE(MG_OL_0027, ctx) tx_buf_sets(ctx->out, "RESP", RESP_OK); tx_buf_sets(ctx->out, "MATCH", "Y"); + + /* 프레이밍 길이검증 통과 이력(mg_frame_log)을 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + +#line 82 "app/online/mg_ol_0027.pgc" + long h_fr_decl ; + +#line 83 "app/online/mg_ol_0027.pgc" + long h_fr_actual ; +/* exec sql end declare section */ +#line 84 "app/online/mg_ol_0027.pgc" + + + h_fr_decl = (long)declared; + h_fr_actual = (long)actual; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_frame_log ( decl_len , actual_len , match_yn ) values ( $1 , $2 , 'Y' )", + ECPGt_long,&(h_fr_decl),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fr_actual),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 92 "app/online/mg_ol_0027.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_frame_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0027] 길이 일치 len=%d", declared); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0027.pgc b/app/online/mg_ol_0027.pgc index 718409b..6fb3292 100644 --- a/app/online/mg_ol_0027.pgc +++ b/app/online/mg_ol_0027.pgc @@ -11,6 +11,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -74,6 +75,30 @@ TX_SERVICE(MG_OL_0027, ctx) tx_buf_sets(ctx->out, "RESP", RESP_OK); tx_buf_sets(ctx->out, "MATCH", "Y"); + + /* 프레이밍 길이검증 통과 이력(mg_frame_log)을 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + long h_fr_decl; + long h_fr_actual; + EXEC SQL END DECLARE SECTION; + + h_fr_decl = (long)declared; + h_fr_actual = (long)actual; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_frame_log + (decl_len, actual_len, match_yn) + VALUES (:h_fr_decl, :h_fr_actual, 'Y'); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_frame_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0027] 길이 일치 len=%d", declared); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0028.c b/app/online/mg_ol_0028.c index 8386e35..3297cfc 100644 --- a/app/online/mg_ol_0028.c +++ b/app/online/mg_ol_0028.c @@ -18,6 +18,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -90,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/mg_ol_0028.pgc" +#line 17 "app/online/mg_ol_0028.pgc" #define MG_BCD_MAX 32 @@ -173,6 +174,50 @@ TX_SERVICE(MG_OL_0028, ctx) tx_buf_setlong(ctx->out, "DIGITS", (long)ndigit); tx_buf_setlong(ctx->out, "PACKLEN", (long)plen); tx_buf_sets(ctx->out, "BCDHEX", hex); + + /* BCD 인코딩 이력(mg_bcd_log)을 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + +#line 103 "app/online/mg_ol_0028.pgc" + long h_bcd_digits ; + +#line 104 "app/online/mg_ol_0028.pgc" + long h_bcd_packlen ; + +#line 105 "app/online/mg_ol_0028.pgc" + char h_bcd_hex [ MG_BCD_MAX * 2 + 1 ] ; +/* exec sql end declare section */ +#line 106 "app/online/mg_ol_0028.pgc" + + + h_bcd_digits = (long)ndigit; + h_bcd_packlen = (long)plen; + strncpy(h_bcd_hex, hex, sizeof(h_bcd_hex) - 1); + h_bcd_hex[sizeof(h_bcd_hex) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_bcd_log ( digit_len , pack_len , bcd_hex ) values ( $1 , $2 , $3 )", + ECPGt_long,&(h_bcd_digits),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_bcd_packlen),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_bcd_hex),(long)MG_BCD_MAX * 2 + 1,(long)1,(MG_BCD_MAX * 2 + 1)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 116 "app/online/mg_ol_0028.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_bcd_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0028] 인코딩완료 자릿수=%d 패킹=%dbyte hex=%s", ndigit, plen, hex); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/mg_ol_0028.pgc b/app/online/mg_ol_0028.pgc index 1b78944..43ef28f 100644 --- a/app/online/mg_ol_0028.pgc +++ b/app/online/mg_ol_0028.pgc @@ -10,6 +10,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -95,6 +96,33 @@ TX_SERVICE(MG_OL_0028, ctx) tx_buf_setlong(ctx->out, "DIGITS", (long)ndigit); tx_buf_setlong(ctx->out, "PACKLEN", (long)plen); tx_buf_sets(ctx->out, "BCDHEX", hex); + + /* BCD 인코딩 이력(mg_bcd_log)을 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + long h_bcd_digits; + long h_bcd_packlen; + char h_bcd_hex[MG_BCD_MAX * 2 + 1]; + EXEC SQL END DECLARE SECTION; + + h_bcd_digits = (long)ndigit; + h_bcd_packlen = (long)plen; + strncpy(h_bcd_hex, hex, sizeof(h_bcd_hex) - 1); + h_bcd_hex[sizeof(h_bcd_hex) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_bcd_log + (digit_len, pack_len, bcd_hex) + VALUES (:h_bcd_digits, :h_bcd_packlen, :h_bcd_hex); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_bcd_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0028] 인코딩완료 자릿수=%d 패킹=%dbyte hex=%s", ndigit, plen, hex); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/mg_ol_0029.c b/app/online/mg_ol_0029.c index aaf54a7..794ea27 100644 --- a/app/online/mg_ol_0029.c +++ b/app/online/mg_ol_0029.c @@ -18,6 +18,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -90,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/mg_ol_0029.pgc" +#line 17 "app/online/mg_ol_0029.pgc" /* 바이트열 XOR LRC 계산 (초기값 0) */ @@ -137,6 +138,50 @@ TX_SERVICE(MG_OL_0029, ctx) tx_buf_setlong(ctx->out, "BODYLEN", (long)rawlen); tx_buf_setlong(ctx->out, "LRC", (long)lrc); tx_buf_sets(ctx->out, "TRAILER", trailer); + + /* 트레일러(LRC) 생성 이력(mg_lrc_log)을 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + +#line 67 "app/online/mg_ol_0029.pgc" + long h_lrc_bodylen ; + +#line 68 "app/online/mg_ol_0029.pgc" + long h_lrc_value ; + +#line 69 "app/online/mg_ol_0029.pgc" + char h_lrc_trailer [ 3 ] ; +/* exec sql end declare section */ +#line 70 "app/online/mg_ol_0029.pgc" + + + h_lrc_bodylen = (long)rawlen; + h_lrc_value = (long)lrc; + strncpy(h_lrc_trailer, trailer, sizeof(h_lrc_trailer) - 1); + h_lrc_trailer[sizeof(h_lrc_trailer) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_lrc_log ( body_len , lrc_value , trailer_hex ) values ( $1 , $2 , $3 )", + ECPGt_long,&(h_lrc_bodylen),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_lrc_value),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_lrc_trailer),(long)3,(long)1,(3)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 80 "app/online/mg_ol_0029.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_lrc_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0029] 트레일러 생성완료 len=%d lrc=%02X", rawlen, lrc); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/mg_ol_0029.pgc b/app/online/mg_ol_0029.pgc index bc411fd..208ace2 100644 --- a/app/online/mg_ol_0029.pgc +++ b/app/online/mg_ol_0029.pgc @@ -10,6 +10,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -59,6 +60,33 @@ TX_SERVICE(MG_OL_0029, ctx) tx_buf_setlong(ctx->out, "BODYLEN", (long)rawlen); tx_buf_setlong(ctx->out, "LRC", (long)lrc); tx_buf_sets(ctx->out, "TRAILER", trailer); + + /* 트레일러(LRC) 생성 이력(mg_lrc_log)을 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + long h_lrc_bodylen; + long h_lrc_value; + char h_lrc_trailer[3]; + EXEC SQL END DECLARE SECTION; + + h_lrc_bodylen = (long)rawlen; + h_lrc_value = (long)lrc; + strncpy(h_lrc_trailer, trailer, sizeof(h_lrc_trailer) - 1); + h_lrc_trailer[sizeof(h_lrc_trailer) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_lrc_log + (body_len, lrc_value, trailer_hex) + VALUES (:h_lrc_bodylen, :h_lrc_value, :h_lrc_trailer); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_lrc_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[MG_OL_0029] 트레일러 생성완료 len=%d lrc=%02X", rawlen, lrc); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/mg_ol_0030.c b/app/online/mg_ol_0030.c index 2151a76..60dabc0 100644 --- a/app/online/mg_ol_0030.c +++ b/app/online/mg_ol_0030.c @@ -19,6 +19,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -91,7 +92,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 17 "app/online/mg_ol_0030.pgc" +#line 18 "app/online/mg_ol_0030.pgc" #define MG_MAX_RETRY 3 @@ -140,5 +141,56 @@ TX_SERVICE(MG_OL_0030, ctx) tx_log(TX_LOG_ERROR, "[MG_OL_0030] NAK 재시도한도 소진 code=%s retry=%ld", respcode, retry); } + + /* ACK/NAK 판정 이력(mg_ack_log)을 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + + +#line 70 "app/online/mg_ol_0030.pgc" + char h_ak_result [ 4 ] ; + +#line 71 "app/online/mg_ol_0030.pgc" + long h_ak_send ; + +#line 72 "app/online/mg_ol_0030.pgc" + long h_ak_recv ; + +#line 73 "app/online/mg_ol_0030.pgc" + long h_ak_retry ; +/* exec sql end declare section */ +#line 74 "app/online/mg_ol_0030.pgc" + + + strncpy(h_ak_result, is_ack ? "ACK" : "NAK", sizeof(h_ak_result) - 1); + h_ak_result[sizeof(h_ak_result) - 1] = '\0'; + h_ak_send = send_seq; + h_ak_recv = recv_seq; + h_ak_retry = retry; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into mg_ack_log ( result , send_seq , recv_seq , retry_cnt ) values ( $1 , $2 , $3 , $4 )", + ECPGt_char,(h_ak_result),(long)4,(long)1,(4)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_ak_send),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_ak_recv),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_ak_retry),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 85 "app/online/mg_ol_0030.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_ack_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0030.pgc b/app/online/mg_ol_0030.pgc index 4ee50b7..1f6ebfc 100644 --- a/app/online/mg_ol_0030.pgc +++ b/app/online/mg_ol_0030.pgc @@ -11,6 +11,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -62,5 +63,34 @@ TX_SERVICE(MG_OL_0030, ctx) tx_log(TX_LOG_ERROR, "[MG_OL_0030] NAK 재시도한도 소진 code=%s retry=%ld", respcode, retry); } + + /* ACK/NAK 판정 이력(mg_ack_log)을 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_ak_result[4]; + long h_ak_send; + long h_ak_recv; + long h_ak_retry; + EXEC SQL END DECLARE SECTION; + + strncpy(h_ak_result, is_ack ? "ACK" : "NAK", sizeof(h_ak_result) - 1); + h_ak_result[sizeof(h_ak_result) - 1] = '\0'; + h_ak_send = send_seq; + h_ak_recv = recv_seq; + h_ak_retry = retry; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO mg_ack_log + (result, send_seq, recv_seq, retry_cnt) + VALUES (:h_ak_result, :h_ak_send, :h_ak_recv, :h_ak_retry); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT mg_ack_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mg_ol_0031.c b/app/online/mg_ol_0031.c index 3a5c299..8d8128b 100644 --- a/app/online/mg_ol_0031.c +++ b/app/online/mg_ol_0031.c @@ -18,6 +18,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -90,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/mg_ol_0031.pgc" +#line 17 "app/online/mg_ol_0031.pgc" TX_SERVICE(MG_OL_0031, ctx) @@ -99,6 +100,7 @@ TX_SERVICE(MG_OL_0031, ctx) char key[16]; char won[40]; const char *st_label; + long snap_peer = 0; int rc; tx_log(TX_LOG_INFO, "[MG_OL_0031] 전문 스냅샷 조회 서비스 진입"); @@ -120,6 +122,47 @@ TX_SERVICE(MG_OL_0031, ctx) return; } + /* 2-b) 동일 영업일/동일 상태 동종 건수를 임베디드 SQL 로 집계 (참고정보) */ + { + /* exec sql begin declare section */ + + + + +#line 50 "app/online/mg_ol_0031.pgc" + char h_snap_bd [ 9 ] ; + +#line 51 "app/online/mg_ol_0031.pgc" + char h_snap_st [ 2 ] ; + +#line 52 "app/online/mg_ol_0031.pgc" + long h_snap_peer ; +/* exec sql end declare section */ +#line 53 "app/online/mg_ol_0031.pgc" + + + strncpy(h_snap_bd, rec.biz_date, sizeof(h_snap_bd) - 1); + h_snap_bd[sizeof(h_snap_bd) - 1] = '\0'; + strncpy(h_snap_st, rec.status, sizeof(h_snap_st) - 1); + h_snap_st[sizeof(h_snap_st) - 1] = '\0'; + h_snap_peer = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mg_ledger where biz_date = $1 and status = $2 ", + ECPGt_char,(h_snap_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_snap_st),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_snap_peer),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 65 "app/online/mg_ol_0031.pgc" + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT COUNT mg_ledger snapshot peers"); + h_snap_peer = 0; + } + snap_peer = h_snap_peer; + } + /* 3) 상태코드 -> 표시 라벨 매핑 */ if (strcmp(rec.status, MG_ST_RECV) == 0) st_label = "접수"; @@ -146,6 +189,7 @@ TX_SERVICE(MG_OL_0031, ctx) tx_buf_setlong(ctx->out, "FEE", rec.fee); tx_buf_sets(ctx->out, "STATUS", rec.status); tx_buf_sets(ctx->out, "STATUSLABEL", st_label); + tx_buf_setlong(ctx->out, "PEERCNT", snap_peer); tx_log(TX_LOG_INFO, "[MG_OL_0031] 스냅샷 조회완료 key=%s 상태=%s 금액=%ld 수수료=%ld", key, st_label, rec.amount, rec.fee); diff --git a/app/online/mg_ol_0031.pgc b/app/online/mg_ol_0031.pgc index 522fe9f..7125ee9 100644 --- a/app/online/mg_ol_0031.pgc +++ b/app/online/mg_ol_0031.pgc @@ -10,6 +10,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mg_core.h" @@ -21,6 +22,7 @@ TX_SERVICE(MG_OL_0031, ctx) char key[16]; char won[40]; const char *st_label; + long snap_peer = 0; int rc; tx_log(TX_LOG_INFO, "[MG_OL_0031] 전문 스냅샷 조회 서비스 진입"); @@ -42,6 +44,32 @@ TX_SERVICE(MG_OL_0031, ctx) return; } + /* 2-b) 동일 영업일/동일 상태 동종 건수를 임베디드 SQL 로 집계 (참고정보) */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_snap_bd[9]; + char h_snap_st[2]; + long h_snap_peer; + EXEC SQL END DECLARE SECTION; + + strncpy(h_snap_bd, rec.biz_date, sizeof(h_snap_bd) - 1); + h_snap_bd[sizeof(h_snap_bd) - 1] = '\0'; + strncpy(h_snap_st, rec.status, sizeof(h_snap_st) - 1); + h_snap_st[sizeof(h_snap_st) - 1] = '\0'; + h_snap_peer = 0; + + EXEC SQL SELECT COUNT(*) + INTO :h_snap_peer + FROM mg_ledger + WHERE biz_date = :h_snap_bd + AND status = :h_snap_st; + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT COUNT mg_ledger snapshot peers"); + h_snap_peer = 0; + } + snap_peer = h_snap_peer; + } + /* 3) 상태코드 -> 표시 라벨 매핑 */ if (strcmp(rec.status, MG_ST_RECV) == 0) st_label = "접수"; @@ -68,6 +96,7 @@ TX_SERVICE(MG_OL_0031, ctx) tx_buf_setlong(ctx->out, "FEE", rec.fee); tx_buf_sets(ctx->out, "STATUS", rec.status); tx_buf_sets(ctx->out, "STATUSLABEL", st_label); + tx_buf_setlong(ctx->out, "PEERCNT", snap_peer); tx_log(TX_LOG_INFO, "[MG_OL_0031] 스냅샷 조회완료 key=%s 상태=%s 금액=%ld 수수료=%ld", key, st_label, rec.amount, rec.fee); diff --git a/app/online/mm_ol_0001.c b/app/online/mm_ol_0001.c index 4ea84db..6caef1c 100644 --- a/app/online/mm_ol_0001.c +++ b/app/online/mm_ol_0001.c @@ -12,11 +12,14 @@ * * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 mm 표준 DBIO 를 * 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응) + * 단건 조회에 더해 mm_ledger 원장의 확장필드(카드번호/수수료/최종반영 + * 시각)를 직접 SELECT 하여 응답에 함께 실어 준다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mm_core.h" @@ -89,11 +92,32 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/mm_ol_0001.pgc" +#line 18 "app/online/mm_ol_0001.pgc" TX_SERVICE(MM_OL_0001, ctx) { + /* exec sql begin declare section */ + + + + + +#line 23 "app/online/mm_ol_0001.pgc" + char h_key [ 16 ] ; + +#line 24 "app/online/mm_ol_0001.pgc" + char h_card_no [ 24 ] ; + +#line 25 "app/online/mm_ol_0001.pgc" + long h_fee ; + +#line 26 "app/online/mm_ol_0001.pgc" + char h_upd_ts [ 24 ] ; +/* exec sql end declare section */ +#line 27 "app/online/mm_ol_0001.pgc" + + mm_rec_t rec; char key[16]; int rc; @@ -115,11 +139,42 @@ TX_SERVICE(MM_OL_0001, ctx) return; } + /* 원장 확장필드 직접 조회 (카드번호/수수료/최종반영시각) */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_card_no[0] = '\0'; + h_upd_ts[0] = '\0'; + h_fee = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select card_no , fee , to_char ( upd_ts , 'YYYYMMDDHH24MISS' ) from mm_ledger where key = $1 ", + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_card_no),(long)24,(long)1,(24)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_upd_ts),(long)24,(long)1,(24)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 60 "app/online/mm_ol_0001.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[MM_OL_0001] 확장필드 원장 없음 key=%s", key); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("MM_OL_0001 SELECT mm_ledger ext"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); tx_buf_sets(ctx->out, "STATUS", rec.status); - tx_log(TX_LOG_INFO, "[MM_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); + tx_buf_sets(ctx->out, "CARDNO", h_card_no); + tx_buf_setlong(ctx->out, "FEE", h_fee); + tx_buf_sets(ctx->out, "UPDTS", h_upd_ts); + tx_log(TX_LOG_INFO, "[MM_OL_0001] 조회완료 key=%s amount=%ld fee=%ld", + key, rec.amount, h_fee); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mm_ol_0001.pgc b/app/online/mm_ol_0001.pgc index 0d86141..9b43b3d 100644 --- a/app/online/mm_ol_0001.pgc +++ b/app/online/mm_ol_0001.pgc @@ -4,11 +4,14 @@ * * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 mm 표준 DBIO 를 * 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응) + * 단건 조회에 더해 mm_ledger 원장의 확장필드(카드번호/수수료/최종반영 + * 시각)를 직접 SELECT 하여 응답에 함께 실어 준다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "mm_core.h" @@ -16,6 +19,13 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(MM_OL_0001, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_key[16]; + char h_card_no[24]; + long h_fee; + char h_upd_ts[24]; + EXEC SQL END DECLARE SECTION; + mm_rec_t rec; char key[16]; int rc; @@ -37,11 +47,35 @@ TX_SERVICE(MM_OL_0001, ctx) return; } + /* 원장 확장필드 직접 조회 (카드번호/수수료/최종반영시각) */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_card_no[0] = '\0'; + h_upd_ts[0] = '\0'; + h_fee = 0; + + EXEC SQL SELECT card_no, fee, to_char(upd_ts, 'YYYYMMDDHH24MISS') + INTO :h_card_no, :h_fee, :h_upd_ts + FROM mm_ledger + WHERE key = :h_key; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[MM_OL_0001] 확장필드 원장 없음 key=%s", key); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("MM_OL_0001 SELECT mm_ledger ext"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); tx_buf_sets(ctx->out, "STATUS", rec.status); - tx_log(TX_LOG_INFO, "[MM_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); + tx_buf_sets(ctx->out, "CARDNO", h_card_no); + tx_buf_setlong(ctx->out, "FEE", h_fee); + tx_buf_sets(ctx->out, "UPDTS", h_upd_ts); + tx_log(TX_LOG_INFO, "[MM_OL_0001] 조회완료 key=%s amount=%ld fee=%ld", + key, rec.amount, h_fee); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/mm_ol_0002.c b/app/online/mm_ol_0002.c index 0c96a72..c171f8b 100644 --- a/app/online/mm_ol_0002.c +++ b/app/online/mm_ol_0002.c @@ -154,7 +154,7 @@ TX_SERVICE(MM_OL_0002, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_dup),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 57 "app/online/mm_ol_0002.pgc" +#line 56 "app/online/mm_ol_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -184,7 +184,7 @@ TX_SERVICE(MM_OL_0002, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_reg_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 77 "app/online/mm_ol_0002.pgc" +#line 75 "app/online/mm_ol_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -202,7 +202,7 @@ TX_SERVICE(MM_OL_0002, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_status),(long)2,(long)1,(2)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 89 "app/online/mm_ol_0002.pgc" +#line 86 "app/online/mm_ol_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0002.pgc b/app/online/mm_ol_0002.pgc index e7a41a9..6f5c201 100644 --- a/app/online/mm_ol_0002.pgc +++ b/app/online/mm_ol_0002.pgc @@ -51,8 +51,7 @@ TX_SERVICE(MM_OL_0002, ctx) strncpy(h_status, MM_ST_RECV, sizeof(h_status)); date_today(h_reg_date); - EXEC SQL - SELECT COUNT(*) INTO :h_dup + EXEC SQL SELECT COUNT(*) INTO :h_dup FROM mm_merchant WHERE biz_no = :h_biz_no; @@ -72,8 +71,7 @@ TX_SERVICE(MM_OL_0002, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[MM_OL_0002] tx_begin 경고"); - EXEC SQL - INSERT INTO mm_merchant (merch_id, merch_nm, biz_no, status, reg_date) + EXEC SQL INSERT INTO mm_merchant (merch_id, merch_nm, biz_no, status, reg_date) VALUES (:h_merch_id, :h_merch_nm, :h_biz_no, :h_status, :h_reg_date); if (sqlca.sqlcode != TX_SQL_OK) { @@ -84,8 +82,7 @@ TX_SERVICE(MM_OL_0002, ctx) return; } - EXEC SQL - INSERT INTO mm_merchant_hist (merch_id, chg_type, chg_date, chg_status) + EXEC SQL INSERT INTO mm_merchant_hist (merch_id, chg_type, chg_date, chg_status) VALUES (:h_merch_id, 'I', :h_reg_date, :h_status); if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0003.c b/app/online/mm_ol_0003.c index 296c499..a9884b2 100644 --- a/app/online/mm_ol_0003.c +++ b/app/online/mm_ol_0003.c @@ -157,7 +157,7 @@ TX_SERVICE(MM_OL_0003, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_old_nm),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 58 "app/online/mm_ol_0003.pgc" +#line 57 "app/online/mm_ol_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -185,7 +185,7 @@ TX_SERVICE(MM_OL_0003, ctx) 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_EOIT, ECPGt_EORT);} -#line 81 "app/online/mm_ol_0003.pgc" +#line 79 "app/online/mm_ol_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -207,7 +207,7 @@ TX_SERVICE(MM_OL_0003, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_biz_type),(long)8,(long)1,(8)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 94 "app/online/mm_ol_0003.pgc" +#line 91 "app/online/mm_ol_0003.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0003.pgc b/app/online/mm_ol_0003.pgc index 5961e9a..b8b77d2 100644 --- a/app/online/mm_ol_0003.pgc +++ b/app/online/mm_ol_0003.pgc @@ -52,8 +52,7 @@ TX_SERVICE(MM_OL_0003, ctx) date_today(h_chg_date); /* 존재확인 + 기존 상호 조회 */ - EXEC SQL - SELECT COUNT(*), MAX(merch_nm) INTO :h_cnt, :h_old_nm + EXEC SQL SELECT COUNT(*), MAX(merch_nm) INTO :h_cnt, :h_old_nm FROM mm_merchant WHERE merch_id = :h_merch_id; @@ -73,8 +72,7 @@ TX_SERVICE(MM_OL_0003, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[MM_OL_0003] tx_begin 경고"); - EXEC SQL - UPDATE mm_merchant + EXEC SQL UPDATE mm_merchant SET merch_nm = :h_merch_nm, biz_type = :h_biz_type, upd_date = :h_chg_date @@ -88,8 +86,7 @@ TX_SERVICE(MM_OL_0003, ctx) return; } - EXEC SQL - INSERT INTO mm_merchant_hist + EXEC SQL INSERT INTO mm_merchant_hist (merch_id, chg_type, chg_date, old_nm, new_nm, biz_type) VALUES (:h_merch_id, 'U', :h_chg_date, :h_old_nm, :h_merch_nm, :h_biz_type); diff --git a/app/online/mm_ol_0004.c b/app/online/mm_ol_0004.c index 3c8817a..4557491 100644 --- a/app/online/mm_ol_0004.c +++ b/app/online/mm_ol_0004.c @@ -148,7 +148,7 @@ TX_SERVICE(MM_OL_0004, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_char,(h_cur_st),(long)2,(long)1,(2)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 54 "app/online/mm_ol_0004.pgc" +#line 53 "app/online/mm_ol_0004.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -190,7 +190,7 @@ TX_SERVICE(MM_OL_0004, ctx) 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_EOIT, ECPGt_EORT);} -#line 92 "app/online/mm_ol_0004.pgc" +#line 90 "app/online/mm_ol_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -210,7 +210,7 @@ TX_SERVICE(MM_OL_0004, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_chg_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 105 "app/online/mm_ol_0004.pgc" +#line 102 "app/online/mm_ol_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0004.pgc b/app/online/mm_ol_0004.pgc index aa1abe6..3151823 100644 --- a/app/online/mm_ol_0004.pgc +++ b/app/online/mm_ol_0004.pgc @@ -48,8 +48,7 @@ TX_SERVICE(MM_OL_0004, ctx) date_today(h_chg_date); /* 현재 상태 조회 */ - EXEC SQL - SELECT status INTO :h_cur_st + EXEC SQL SELECT status INTO :h_cur_st FROM mm_merchant WHERE merch_id = :h_merch_id; @@ -85,8 +84,7 @@ TX_SERVICE(MM_OL_0004, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[MM_OL_0004] tx_begin 경고"); - EXEC SQL - UPDATE mm_merchant + EXEC SQL UPDATE mm_merchant SET status = :h_new_st, upd_date = :h_chg_date WHERE merch_id = :h_merch_id; @@ -99,8 +97,7 @@ TX_SERVICE(MM_OL_0004, ctx) return; } - EXEC SQL - INSERT INTO mm_status_hist + EXEC SQL INSERT INTO mm_status_hist (merch_id, prev_status, new_status, chg_date) VALUES (:h_merch_id, :h_cur_st, :h_new_st, :h_chg_date); diff --git a/app/online/mm_ol_0005.c b/app/online/mm_ol_0005.c index f57a205..bda164e 100644 --- a/app/online/mm_ol_0005.c +++ b/app/online/mm_ol_0005.c @@ -162,7 +162,7 @@ TX_SERVICE(MM_OL_0005, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_end),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 59 "app/online/mm_ol_0005.pgc" +#line 58 "app/online/mm_ol_0005.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/mm_ol_0005.pgc b/app/online/mm_ol_0005.pgc index 559d8fc..44d55b5 100644 --- a/app/online/mm_ol_0005.pgc +++ b/app/online/mm_ol_0005.pgc @@ -49,8 +49,7 @@ TX_SERVICE(MM_OL_0005, ctx) date_today(h_today); /* 현재 유효한 수수료율 1건 (rate 는 bp = 0.01% 단위 정수) */ - EXEC SQL - SELECT rate_bp, start_date, end_date + EXEC SQL SELECT rate_bp, start_date, end_date INTO :h_rate_bp, :h_start, :h_end FROM mm_fee_rate WHERE merch_id = :h_merch_id diff --git a/app/online/mm_ol_0006.c b/app/online/mm_ol_0006.c index 05388bb..214fbec 100644 --- a/app/online/mm_ol_0006.c +++ b/app/online/mm_ol_0006.c @@ -173,7 +173,7 @@ TX_SERVICE(MM_OL_0006, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_prod_gb),(long)4,(long)1,(4)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 76 "app/online/mm_ol_0006.pgc" +#line 75 "app/online/mm_ol_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -196,7 +196,7 @@ TX_SERVICE(MM_OL_0006, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_far),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 90 "app/online/mm_ol_0006.pgc" +#line 88 "app/online/mm_ol_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -219,7 +219,7 @@ TX_SERVICE(MM_OL_0006, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_chg_by),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 104 "app/online/mm_ol_0006.pgc" +#line 101 "app/online/mm_ol_0006.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0006.pgc b/app/online/mm_ol_0006.pgc index fdc603c..893bb43 100644 --- a/app/online/mm_ol_0006.pgc +++ b/app/online/mm_ol_0006.pgc @@ -68,8 +68,7 @@ TX_SERVICE(MM_OL_0006, ctx) tx_log(TX_LOG_WARN, "[MM_OL_0006] tx_begin 경고"); /* 기존 유효 rate 종료처리 (없어도 정상) */ - EXEC SQL - UPDATE mm_fee_rate + EXEC SQL UPDATE mm_fee_rate SET end_date = :h_today WHERE merch_id = :h_merch_id AND prod_gb = :h_prod_gb @@ -84,8 +83,7 @@ TX_SERVICE(MM_OL_0006, ctx) } /* 신규 rate INSERT */ - EXEC SQL - INSERT INTO mm_fee_rate + EXEC SQL INSERT INTO mm_fee_rate (merch_id, prod_gb, rate_bp, start_date, end_date) VALUES (:h_merch_id, :h_prod_gb, :h_new_bp, :h_today, :h_far); @@ -98,8 +96,7 @@ TX_SERVICE(MM_OL_0006, ctx) } /* 변경이력 INSERT */ - EXEC SQL - INSERT INTO mm_fee_hist + EXEC SQL INSERT INTO mm_fee_hist (merch_id, prod_gb, rate_bp, apply_date, chg_by) VALUES (:h_merch_id, :h_prod_gb, :h_new_bp, :h_today, :h_chg_by); diff --git a/app/online/mm_ol_0007.c b/app/online/mm_ol_0007.c index 71d43ac..1f3df35 100644 --- a/app/online/mm_ol_0007.c +++ b/app/online/mm_ol_0007.c @@ -149,7 +149,7 @@ TX_SERVICE(MM_OL_0007, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_mon_used),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 50 "app/online/mm_ol_0007.pgc" +#line 49 "app/online/mm_ol_0007.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/mm_ol_0007.pgc b/app/online/mm_ol_0007.pgc index 3528c8d..d861697 100644 --- a/app/online/mm_ol_0007.pgc +++ b/app/online/mm_ol_0007.pgc @@ -43,8 +43,7 @@ TX_SERVICE(MM_OL_0007, ctx) strncpy(h_merch_id, merch_id, sizeof(h_merch_id) - 1); h_merch_id[sizeof(h_merch_id) - 1] = '\0'; - EXEC SQL - SELECT daily_limit, monthly_limit, day_used, mon_used + EXEC SQL SELECT daily_limit, monthly_limit, day_used, mon_used INTO :h_daily, :h_monthly, :h_day_used, :h_mon_used FROM mm_limit WHERE merch_id = :h_merch_id; diff --git a/app/online/mm_ol_0008.c b/app/online/mm_ol_0008.c index 11ab2b8..76c5c03 100644 --- a/app/online/mm_ol_0008.c +++ b/app/online/mm_ol_0008.c @@ -164,7 +164,7 @@ TX_SERVICE(MM_OL_0008, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_old_monthly),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 66 "app/online/mm_ol_0008.pgc" +#line 65 "app/online/mm_ol_0008.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -192,7 +192,7 @@ TX_SERVICE(MM_OL_0008, ctx) 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_EOIT, ECPGt_EORT);} -#line 89 "app/online/mm_ol_0008.pgc" +#line 87 "app/online/mm_ol_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -216,7 +216,7 @@ TX_SERVICE(MM_OL_0008, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_chg_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 103 "app/online/mm_ol_0008.pgc" +#line 100 "app/online/mm_ol_0008.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0008.pgc b/app/online/mm_ol_0008.pgc index 301b663..b5843e7 100644 --- a/app/online/mm_ol_0008.pgc +++ b/app/online/mm_ol_0008.pgc @@ -59,8 +59,7 @@ TX_SERVICE(MM_OL_0008, ctx) date_today(h_chg_date); /* 기존 한도 조회 (존재확인 + 이력용) */ - EXEC SQL - SELECT daily_limit, monthly_limit + EXEC SQL SELECT daily_limit, monthly_limit INTO :h_old_daily, :h_old_monthly FROM mm_limit WHERE merch_id = :h_merch_id; @@ -81,8 +80,7 @@ TX_SERVICE(MM_OL_0008, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[MM_OL_0008] tx_begin 경고"); - EXEC SQL - UPDATE mm_limit + EXEC SQL UPDATE mm_limit SET daily_limit = :h_new_daily, monthly_limit = :h_new_monthly, upd_date = :h_chg_date @@ -96,8 +94,7 @@ TX_SERVICE(MM_OL_0008, ctx) return; } - EXEC SQL - INSERT INTO mm_limit_hist + EXEC SQL INSERT INTO mm_limit_hist (merch_id, old_daily, new_daily, old_monthly, new_monthly, chg_date) VALUES (:h_merch_id, :h_old_daily, :h_new_daily, :h_old_monthly, :h_new_monthly, :h_chg_date); diff --git a/app/online/mm_ol_0009.c b/app/online/mm_ol_0009.c index 8b61872..a780844 100644 --- a/app/online/mm_ol_0009.c +++ b/app/online/mm_ol_0009.c @@ -164,7 +164,7 @@ TX_SERVICE(MM_OL_0009, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_brand),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 65 "app/online/mm_ol_0009.pgc" +#line 64 "app/online/mm_ol_0009.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/mm_ol_0009.pgc b/app/online/mm_ol_0009.pgc index 56d0fcf..d42bd02 100644 --- a/app/online/mm_ol_0009.pgc +++ b/app/online/mm_ol_0009.pgc @@ -58,8 +58,7 @@ TX_SERVICE(MM_OL_0009, ctx) strncpy(h_bin, bin, sizeof(h_bin) - 1); h_bin[sizeof(h_bin) - 1] = '\0'; - EXEC SQL - SELECT issuer_cd, card_gb, valid_yn, brand_nm + EXEC SQL SELECT issuer_cd, card_gb, valid_yn, brand_nm INTO :h_issuer_cd, :h_card_gb, :h_valid_yn, :h_brand FROM mm_card_bin WHERE bin = :h_bin; diff --git a/app/online/mm_ol_0010.c b/app/online/mm_ol_0010.c index dbdf9a2..4ae3a2a 100644 --- a/app/online/mm_ol_0010.c +++ b/app/online/mm_ol_0010.c @@ -182,7 +182,7 @@ TX_SERVICE(MM_OL_0010, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_dup),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 82 "app/online/mm_ol_0010.pgc" +#line 81 "app/online/mm_ol_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -214,7 +214,7 @@ TX_SERVICE(MM_OL_0010, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_reg_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 103 "app/online/mm_ol_0010.pgc" +#line 101 "app/online/mm_ol_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -232,7 +232,7 @@ TX_SERVICE(MM_OL_0010, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_reg_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 116 "app/online/mm_ol_0010.pgc" +#line 113 "app/online/mm_ol_0010.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0010.pgc b/app/online/mm_ol_0010.pgc index b3c3f0c..e6d8694 100644 --- a/app/online/mm_ol_0010.pgc +++ b/app/online/mm_ol_0010.pgc @@ -76,8 +76,7 @@ TX_SERVICE(MM_OL_0010, ctx) date_today(h_reg_date); /* 중복 BIN 체크 */ - EXEC SQL - SELECT COUNT(*) INTO :h_dup + EXEC SQL SELECT COUNT(*) INTO :h_dup FROM mm_card_bin WHERE bin = :h_bin; @@ -97,8 +96,7 @@ TX_SERVICE(MM_OL_0010, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[MM_OL_0010] tx_begin 경고"); - EXEC SQL - INSERT INTO mm_card_bin + EXEC SQL INSERT INTO mm_card_bin (bin, issuer_cd, card_gb, brand_nm, valid_yn, reg_date) VALUES (:h_bin, :h_issuer_cd, :h_card_gb, :h_brand, :h_valid_yn, :h_reg_date); @@ -110,8 +108,7 @@ TX_SERVICE(MM_OL_0010, ctx) return; } - EXEC SQL - INSERT INTO mm_bin_hist + EXEC SQL INSERT INTO mm_bin_hist (bin, chg_type, issuer_cd, chg_date) VALUES (:h_bin, 'I', :h_issuer_cd, :h_reg_date); diff --git a/app/online/mm_ol_0011.c b/app/online/mm_ol_0011.c index ffdb03e..4e73248 100644 --- a/app/online/mm_ol_0011.c +++ b/app/online/mm_ol_0011.c @@ -145,7 +145,7 @@ TX_SERVICE(MM_OL_0011, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_status),(long)2,(long)1,(2)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 48 "app/online/mm_ol_0011.pgc" +#line 47 "app/online/mm_ol_0011.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -167,7 +167,7 @@ TX_SERVICE(MM_OL_0011, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_bin_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 68 "app/online/mm_ol_0011.pgc" +#line 66 "app/online/mm_ol_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { diff --git a/app/online/mm_ol_0011.pgc b/app/online/mm_ol_0011.pgc index a262fae..638c167 100644 --- a/app/online/mm_ol_0011.pgc +++ b/app/online/mm_ol_0011.pgc @@ -41,8 +41,7 @@ TX_SERVICE(MM_OL_0011, ctx) strncpy(h_issuer_cd, issuer_cd, sizeof(h_issuer_cd) - 1); h_issuer_cd[sizeof(h_issuer_cd) - 1] = '\0'; - EXEC SQL - SELECT issuer_nm, settle_bank, status + EXEC SQL SELECT issuer_nm, settle_bank, status INTO :h_issuer_nm, :h_settle_bank, :h_status FROM mm_issuer WHERE issuer_cd = :h_issuer_cd; @@ -61,8 +60,7 @@ TX_SERVICE(MM_OL_0011, ctx) } /* 해당 카드사에 등록된 유효 BIN 건수 집계 */ - EXEC SQL - SELECT COUNT(*) INTO :h_bin_cnt + EXEC SQL SELECT COUNT(*) INTO :h_bin_cnt FROM mm_card_bin WHERE issuer_cd = :h_issuer_cd AND valid_yn = 'Y'; diff --git a/app/online/mm_ol_0012.c b/app/online/mm_ol_0012.c index 1fb3645..67ed337 100644 --- a/app/online/mm_ol_0012.c +++ b/app/online/mm_ol_0012.c @@ -157,7 +157,7 @@ TX_SERVICE(MM_OL_0012, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_dup),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 60 "app/online/mm_ol_0012.pgc" +#line 59 "app/online/mm_ol_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -187,7 +187,7 @@ TX_SERVICE(MM_OL_0012, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_reg_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 81 "app/online/mm_ol_0012.pgc" +#line 79 "app/online/mm_ol_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -205,7 +205,7 @@ TX_SERVICE(MM_OL_0012, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_reg_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 94 "app/online/mm_ol_0012.pgc" +#line 91 "app/online/mm_ol_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0012.pgc b/app/online/mm_ol_0012.pgc index 2e64fe2..787f76b 100644 --- a/app/online/mm_ol_0012.pgc +++ b/app/online/mm_ol_0012.pgc @@ -54,8 +54,7 @@ TX_SERVICE(MM_OL_0012, ctx) date_today(h_reg_date); /* 중복 카드사코드 체크 */ - EXEC SQL - SELECT COUNT(*) INTO :h_dup + EXEC SQL SELECT COUNT(*) INTO :h_dup FROM mm_issuer WHERE issuer_cd = :h_issuer_cd; @@ -75,8 +74,7 @@ TX_SERVICE(MM_OL_0012, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[MM_OL_0012] tx_begin 경고"); - EXEC SQL - INSERT INTO mm_issuer + EXEC SQL INSERT INTO mm_issuer (issuer_cd, issuer_nm, settle_bank, status, reg_date) VALUES (:h_issuer_cd, :h_issuer_nm, :h_settle_bank, :h_status, :h_reg_date); @@ -88,8 +86,7 @@ TX_SERVICE(MM_OL_0012, ctx) return; } - EXEC SQL - INSERT INTO mm_issuer_hist + EXEC SQL INSERT INTO mm_issuer_hist (issuer_cd, chg_type, chg_status, chg_date) VALUES (:h_issuer_cd, 'I', :h_status, :h_reg_date); diff --git a/app/online/mm_ol_0013.c b/app/online/mm_ol_0013.c index 2fbf41d..f449248 100644 --- a/app/online/mm_ol_0013.c +++ b/app/online/mm_ol_0013.c @@ -151,7 +151,7 @@ TX_SERVICE(MM_OL_0013, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_sort_no),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 53 "app/online/mm_ol_0013.pgc" +#line 52 "app/online/mm_ol_0013.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/mm_ol_0013.pgc b/app/online/mm_ol_0013.pgc index 58ab985..ceebccf 100644 --- a/app/online/mm_ol_0013.pgc +++ b/app/online/mm_ol_0013.pgc @@ -45,8 +45,7 @@ TX_SERVICE(MM_OL_0013, ctx) strncpy(h_code, code, sizeof(h_code) - 1); h_code[sizeof(h_code) - 1] = '\0'; - EXEC SQL - SELECT code_nm, use_yn, sort_no + EXEC SQL SELECT code_nm, use_yn, sort_no INTO :h_code_nm, :h_use_yn, :h_sort_no FROM mm_common_code WHERE code_grp = :h_code_grp diff --git a/app/online/mm_ol_0014.c b/app/online/mm_ol_0014.c index 9a300d0..dad76b2 100644 --- a/app/online/mm_ol_0014.c +++ b/app/online/mm_ol_0014.c @@ -169,7 +169,7 @@ TX_SERVICE(MM_OL_0014, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_dup),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 65 "app/online/mm_ol_0014.pgc" +#line 64 "app/online/mm_ol_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -195,7 +195,7 @@ TX_SERVICE(MM_OL_0014, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_max_sort),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 88 "app/online/mm_ol_0014.pgc" +#line 86 "app/online/mm_ol_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -223,7 +223,7 @@ TX_SERVICE(MM_OL_0014, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_reg_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 105 "app/online/mm_ol_0014.pgc" +#line 102 "app/online/mm_ol_0014.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0014.pgc b/app/online/mm_ol_0014.pgc index bc36f02..c13d4f2 100644 --- a/app/online/mm_ol_0014.pgc +++ b/app/online/mm_ol_0014.pgc @@ -58,8 +58,7 @@ TX_SERVICE(MM_OL_0014, ctx) date_today(h_reg_date); /* 그룹+코드 중복체크 */ - EXEC SQL - SELECT COUNT(*) INTO :h_dup + EXEC SQL SELECT COUNT(*) INTO :h_dup FROM mm_common_code WHERE code_grp = :h_code_grp AND code = :h_code; @@ -82,8 +81,7 @@ TX_SERVICE(MM_OL_0014, ctx) h_sort_no = sort_no; } else { h_max_sort = 0; - EXEC SQL - SELECT COALESCE(MAX(sort_no), 0) INTO :h_max_sort + EXEC SQL SELECT COALESCE(MAX(sort_no), 0) INTO :h_max_sort FROM mm_common_code WHERE code_grp = :h_code_grp; @@ -99,8 +97,7 @@ TX_SERVICE(MM_OL_0014, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[MM_OL_0014] tx_begin 경고"); - EXEC SQL - INSERT INTO mm_common_code + EXEC SQL INSERT INTO mm_common_code (code_grp, code, code_nm, use_yn, sort_no, reg_date) VALUES (:h_code_grp, :h_code, :h_code_nm, :h_use_yn, :h_sort_no, :h_reg_date); diff --git a/app/online/mm_ol_0015.c b/app/online/mm_ol_0015.c index 2a00529..bcdf22c 100644 --- a/app/online/mm_ol_0015.c +++ b/app/online/mm_ol_0015.c @@ -146,7 +146,7 @@ TX_SERVICE(MM_OL_0015, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_verify_yn),(long)2,(long)1,(2)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 47 "app/online/mm_ol_0015.pgc" +#line 46 "app/online/mm_ol_0015.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/mm_ol_0015.pgc b/app/online/mm_ol_0015.pgc index fe3f9a4..983f5fb 100644 --- a/app/online/mm_ol_0015.pgc +++ b/app/online/mm_ol_0015.pgc @@ -40,8 +40,7 @@ TX_SERVICE(MM_OL_0015, ctx) strncpy(h_merch_id, merch_id, sizeof(h_merch_id) - 1); h_merch_id[sizeof(h_merch_id) - 1] = '\0'; - EXEC SQL - SELECT bank_cd, acct_no, holder_nm, verify_yn + EXEC SQL SELECT bank_cd, acct_no, holder_nm, verify_yn INTO :h_bank_cd, :h_acct_no, :h_holder_nm, :h_verify_yn FROM mm_merchant_acct WHERE merch_id = :h_merch_id; diff --git a/app/online/mm_ol_0016.c b/app/online/mm_ol_0016.c index ae36d28..4a01280 100644 --- a/app/online/mm_ol_0016.c +++ b/app/online/mm_ol_0016.c @@ -189,7 +189,7 @@ TX_SERVICE(MM_OL_0016, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_old_acct),(long)24,(long)1,(24)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 85 "app/online/mm_ol_0016.pgc" +#line 84 "app/online/mm_ol_0016.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -221,7 +221,7 @@ TX_SERVICE(MM_OL_0016, ctx) 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_EOIT, ECPGt_EORT);} -#line 110 "app/online/mm_ol_0016.pgc" +#line 108 "app/online/mm_ol_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -245,7 +245,7 @@ TX_SERVICE(MM_OL_0016, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_chg_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 124 "app/online/mm_ol_0016.pgc" +#line 121 "app/online/mm_ol_0016.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0016.pgc b/app/online/mm_ol_0016.pgc index 1c7cfa0..e4f7344 100644 --- a/app/online/mm_ol_0016.pgc +++ b/app/online/mm_ol_0016.pgc @@ -78,8 +78,7 @@ TX_SERVICE(MM_OL_0016, ctx) date_today(h_chg_date); /* 기존 계좌 조회 (존재확인 + 이력용) */ - EXEC SQL - SELECT bank_cd, acct_no + EXEC SQL SELECT bank_cd, acct_no INTO :h_old_bank, :h_old_acct FROM mm_merchant_acct WHERE merch_id = :h_merch_id; @@ -100,8 +99,7 @@ TX_SERVICE(MM_OL_0016, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[MM_OL_0016] tx_begin 경고"); - EXEC SQL - UPDATE mm_merchant_acct + EXEC SQL UPDATE mm_merchant_acct SET bank_cd = :h_bank_cd, acct_no = :h_acct_no, holder_nm = :h_holder_nm, @@ -117,8 +115,7 @@ TX_SERVICE(MM_OL_0016, ctx) return; } - EXEC SQL - INSERT INTO mm_acct_hist + EXEC SQL INSERT INTO mm_acct_hist (merch_id, old_bank, old_acct, new_bank, new_acct, chg_date) VALUES (:h_merch_id, :h_old_bank, :h_old_acct, :h_bank_cd, :h_acct_no, :h_chg_date); diff --git a/app/online/mm_ol_0017.c b/app/online/mm_ol_0017.c index 1dcc65c..c2f7d93 100644 --- a/app/online/mm_ol_0017.c +++ b/app/online/mm_ol_0017.c @@ -155,7 +155,7 @@ TX_SERVICE(MM_OL_0017, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_chg_by),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 59 "app/online/mm_ol_0017.pgc" +#line 58 "app/online/mm_ol_0017.pgc" } else { { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select apply_date , rate_bp , chg_by from mm_fee_hist where merch_id = $1 order by apply_date desc , seq_no desc fetch first 1 rows only", @@ -167,7 +167,7 @@ TX_SERVICE(MM_OL_0017, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_chg_by),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 67 "app/online/mm_ol_0017.pgc" +#line 65 "app/online/mm_ol_0017.pgc" } diff --git a/app/online/mm_ol_0017.pgc b/app/online/mm_ol_0017.pgc index 850b23e..1fbf579 100644 --- a/app/online/mm_ol_0017.pgc +++ b/app/online/mm_ol_0017.pgc @@ -49,8 +49,7 @@ TX_SERVICE(MM_OL_0017, ctx) h_prod_gb[sizeof(h_prod_gb) - 1] = '\0'; if (prod_gb[0] != '\0') { - EXEC SQL - SELECT apply_date, rate_bp, chg_by + EXEC SQL SELECT apply_date, rate_bp, chg_by INTO :h_apply_date, :h_rate_bp, :h_chg_by FROM mm_fee_hist WHERE merch_id = :h_merch_id @@ -58,8 +57,7 @@ TX_SERVICE(MM_OL_0017, ctx) ORDER BY apply_date DESC, seq_no DESC FETCH FIRST 1 ROWS ONLY; } else { - EXEC SQL - SELECT apply_date, rate_bp, chg_by + EXEC SQL SELECT apply_date, rate_bp, chg_by INTO :h_apply_date, :h_rate_bp, :h_chg_by FROM mm_fee_hist WHERE merch_id = :h_merch_id diff --git a/app/online/mm_ol_0018.c b/app/online/mm_ol_0018.c index d908fa7..c0e3140 100644 --- a/app/online/mm_ol_0018.c +++ b/app/online/mm_ol_0018.c @@ -145,7 +145,7 @@ TX_SERVICE(MM_OL_0018, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_grade_nm),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 51 "app/online/mm_ol_0018.pgc" +#line 50 "app/online/mm_ol_0018.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -171,7 +171,7 @@ TX_SERVICE(MM_OL_0018, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_sales_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 73 "app/online/mm_ol_0018.pgc" +#line 71 "app/online/mm_ol_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { diff --git a/app/online/mm_ol_0018.pgc b/app/online/mm_ol_0018.pgc index 94093d1..e85ca46 100644 --- a/app/online/mm_ol_0018.pgc +++ b/app/online/mm_ol_0018.pgc @@ -43,8 +43,7 @@ TX_SERVICE(MM_OL_0018, ctx) h_merch_id[sizeof(h_merch_id) - 1] = '\0'; /* 1) 가맹점 등급/등급명 조회 */ - EXEC SQL - SELECT m.grade, g.grade_nm + EXEC SQL SELECT m.grade, g.grade_nm INTO :h_grade, :h_grade_nm FROM mm_merchant m JOIN mm_grade_code g ON g.grade = m.grade @@ -66,8 +65,7 @@ TX_SERVICE(MM_OL_0018, ctx) /* 2) 누적매출 집계(원장). 매출행이 없으면 0 으로 응답 */ h_sales_amt = 0; h_sales_cnt = 0; - EXEC SQL - SELECT COALESCE(SUM(sale_amt), 0), COUNT(*) + EXEC SQL SELECT COALESCE(SUM(sale_amt), 0), COUNT(*) INTO :h_sales_amt, :h_sales_cnt FROM mm_merchant_sales WHERE merch_id = :h_merch_id; diff --git a/app/online/mm_ol_0019.c b/app/online/mm_ol_0019.c index 88f904a..1109d4e 100644 --- a/app/online/mm_ol_0019.c +++ b/app/online/mm_ol_0019.c @@ -155,7 +155,7 @@ TX_SERVICE(MM_OL_0019, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_valid),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 59 "app/online/mm_ol_0019.pgc" +#line 58 "app/online/mm_ol_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -177,7 +177,7 @@ TX_SERVICE(MM_OL_0019, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_char,(h_old_grade),(long)4,(long)1,(4)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 78 "app/online/mm_ol_0019.pgc" +#line 76 "app/online/mm_ol_0019.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -212,7 +212,7 @@ TX_SERVICE(MM_OL_0019, ctx) 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_EOIT, ECPGt_EORT);} -#line 109 "app/online/mm_ol_0019.pgc" +#line 106 "app/online/mm_ol_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -234,7 +234,7 @@ TX_SERVICE(MM_OL_0019, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_oper),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 122 "app/online/mm_ol_0019.pgc" +#line 118 "app/online/mm_ol_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0019.pgc b/app/online/mm_ol_0019.pgc index 1b72cf9..7a1c0dd 100644 --- a/app/online/mm_ol_0019.pgc +++ b/app/online/mm_ol_0019.pgc @@ -52,8 +52,7 @@ TX_SERVICE(MM_OL_0019, ctx) date_today(h_chg_date); /* 1) 신규 등급코드 유효성(사용중 'Y') 확인 */ - EXEC SQL - SELECT COUNT(*) INTO :h_valid + EXEC SQL SELECT COUNT(*) INTO :h_valid FROM mm_grade_code WHERE grade = :h_new_grade AND use_yn = 'Y'; @@ -72,8 +71,7 @@ TX_SERVICE(MM_OL_0019, ctx) } /* 2) 현재 등급 조회(이력용 이전값 확보) */ - EXEC SQL - SELECT grade INTO :h_old_grade + EXEC SQL SELECT grade INTO :h_old_grade FROM mm_merchant WHERE merch_id = :h_merch_id; @@ -102,8 +100,7 @@ TX_SERVICE(MM_OL_0019, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[MM_OL_0019] tx_begin 경고"); - EXEC SQL - UPDATE mm_merchant + EXEC SQL UPDATE mm_merchant SET grade = :h_new_grade, upd_date = :h_chg_date WHERE merch_id = :h_merch_id; @@ -116,8 +113,7 @@ TX_SERVICE(MM_OL_0019, ctx) return; } - EXEC SQL - INSERT INTO mm_grade_hist + EXEC SQL INSERT INTO mm_grade_hist (merch_id, old_grade, new_grade, chg_date, oper) VALUES (:h_merch_id, :h_old_grade, :h_new_grade, :h_chg_date, :h_oper); diff --git a/app/online/mm_ol_0020.c b/app/online/mm_ol_0020.c index ed29dec..1bb9ae2 100644 --- a/app/online/mm_ol_0020.c +++ b/app/online/mm_ol_0020.c @@ -163,7 +163,7 @@ TX_SERVICE(MM_OL_0020, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_char,(h_old_status),(long)2,(long)1,(2)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 63 "app/online/mm_ol_0020.pgc" +#line 62 "app/online/mm_ol_0020.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -192,7 +192,7 @@ TX_SERVICE(MM_OL_0020, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_balance),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 90 "app/online/mm_ol_0020.pgc" +#line 88 "app/online/mm_ol_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -224,7 +224,7 @@ TX_SERVICE(MM_OL_0020, ctx) 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_EOIT, ECPGt_EORT);} -#line 118 "app/online/mm_ol_0020.pgc" +#line 115 "app/online/mm_ol_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -248,7 +248,7 @@ TX_SERVICE(MM_OL_0020, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_reason),(long)64,(long)1,(64)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 132 "app/online/mm_ol_0020.pgc" +#line 128 "app/online/mm_ol_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0020.pgc b/app/online/mm_ol_0020.pgc index ab819e4..f421ba7 100644 --- a/app/online/mm_ol_0020.pgc +++ b/app/online/mm_ol_0020.pgc @@ -57,8 +57,7 @@ TX_SERVICE(MM_OL_0020, ctx) date_today(h_chg_date); /* 1) 현재 상태 확인 (이미 해지면 반려) */ - EXEC SQL - SELECT status INTO :h_old_status + EXEC SQL SELECT status INTO :h_old_status FROM mm_merchant WHERE merch_id = :h_merch_id; @@ -83,8 +82,7 @@ TX_SERVICE(MM_OL_0020, ctx) /* 2) 미정산 잔액 확인 */ h_balance = 0; - EXEC SQL - SELECT COALESCE(SUM(balance), 0) INTO :h_balance + EXEC SQL SELECT COALESCE(SUM(balance), 0) INTO :h_balance FROM mm_settle_balance WHERE merch_id = :h_merch_id AND settle_yn = 'N'; @@ -111,8 +109,7 @@ TX_SERVICE(MM_OL_0020, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[MM_OL_0020] tx_begin 경고"); - EXEC SQL - UPDATE mm_merchant + EXEC SQL UPDATE mm_merchant SET status = :h_new_status, upd_date = :h_chg_date WHERE merch_id = :h_merch_id; @@ -125,8 +122,7 @@ TX_SERVICE(MM_OL_0020, ctx) return; } - EXEC SQL - INSERT INTO mm_status_hist + EXEC SQL INSERT INTO mm_status_hist (merch_id, old_status, new_status, chg_date, oper, reason) VALUES (:h_merch_id, :h_old_status, :h_new_status, :h_chg_date, :h_oper, :h_reason); diff --git a/app/online/mm_ol_0021.c b/app/online/mm_ol_0021.c index 97645fe..ac0a069 100644 --- a/app/online/mm_ol_0021.c +++ b/app/online/mm_ol_0021.c @@ -147,7 +147,7 @@ TX_SERVICE(MM_OL_0021, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_reg_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 48 "app/online/mm_ol_0021.pgc" +#line 47 "app/online/mm_ol_0021.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/mm_ol_0021.pgc b/app/online/mm_ol_0021.pgc index 483bb64..2c7bd93 100644 --- a/app/online/mm_ol_0021.pgc +++ b/app/online/mm_ol_0021.pgc @@ -41,8 +41,7 @@ TX_SERVICE(MM_OL_0021, ctx) strncpy(h_biz_no, biz_no, sizeof(h_biz_no) - 1); h_biz_no[sizeof(h_biz_no) - 1] = '\0'; - EXEC SQL - SELECT merch_id, merch_nm, status, reg_date + EXEC SQL SELECT merch_id, merch_nm, status, reg_date INTO :h_merch_id, :h_merch_nm, :h_status, :h_reg_date FROM mm_merchant WHERE biz_no = :h_biz_no; diff --git a/app/online/mm_ol_0022.c b/app/online/mm_ol_0022.c index cad2902..13faa5b 100644 --- a/app/online/mm_ol_0022.c +++ b/app/online/mm_ol_0022.c @@ -174,7 +174,7 @@ TX_SERVICE(MM_OL_0022, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_dup),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 76 "app/online/mm_ol_0022.pgc" +#line 75 "app/online/mm_ol_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -205,7 +205,7 @@ TX_SERVICE(MM_OL_0022, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_reg_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 98 "app/online/mm_ol_0022.pgc" +#line 96 "app/online/mm_ol_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0022.pgc b/app/online/mm_ol_0022.pgc index 0ae2417..2bf38f1 100644 --- a/app/online/mm_ol_0022.pgc +++ b/app/online/mm_ol_0022.pgc @@ -69,8 +69,7 @@ TX_SERVICE(MM_OL_0022, ctx) date_today(h_reg_date); /* 동일 적용일 중복 이력 확인 */ - EXEC SQL - SELECT COUNT(*) INTO :h_dup + EXEC SQL SELECT COUNT(*) INTO :h_dup FROM mm_fee_hist WHERE merch_id = :h_merch_id AND apply_date = :h_apply_date; @@ -92,8 +91,7 @@ TX_SERVICE(MM_OL_0022, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[MM_OL_0022] tx_begin 경고"); - EXEC SQL - INSERT INTO mm_fee_hist + EXEC SQL INSERT INTO mm_fee_hist (merch_id, apply_date, rate_bp, oper, reg_date) VALUES (:h_merch_id, :h_apply_date, :h_rate_bp, :h_oper, :h_reg_date); diff --git a/app/online/mm_ol_0023.c b/app/online/mm_ol_0023.c index 158cb3d..b91dad6 100644 --- a/app/online/mm_ol_0023.c +++ b/app/online/mm_ol_0023.c @@ -150,7 +150,7 @@ TX_SERVICE(MM_OL_0023, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_oper),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 53 "app/online/mm_ol_0023.pgc" +#line 52 "app/online/mm_ol_0023.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/mm_ol_0023.pgc b/app/online/mm_ol_0023.pgc index e75b80d..0e26cbc 100644 --- a/app/online/mm_ol_0023.pgc +++ b/app/online/mm_ol_0023.pgc @@ -44,8 +44,7 @@ TX_SERVICE(MM_OL_0023, ctx) h_merch_id[sizeof(h_merch_id) - 1] = '\0'; /* 최근 한도변경 1건 (변경일 내림차순 선두) */ - EXEC SQL - SELECT old_limit, new_limit, chg_date, oper + EXEC SQL SELECT old_limit, new_limit, chg_date, oper INTO :h_old_limit, :h_new_limit, :h_chg_date, :h_oper FROM mm_limit_hist WHERE merch_id = :h_merch_id diff --git a/app/online/mm_ol_0024.c b/app/online/mm_ol_0024.c index f60016c..7f6d11c 100644 --- a/app/online/mm_ol_0024.c +++ b/app/online/mm_ol_0024.c @@ -165,7 +165,7 @@ TX_SERVICE(MM_OL_0024, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_use_yn),(long)2,(long)1,(2)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 67 "app/online/mm_ol_0024.pgc" +#line 66 "app/online/mm_ol_0024.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/mm_ol_0024.pgc b/app/online/mm_ol_0024.pgc index eea500c..83108e0 100644 --- a/app/online/mm_ol_0024.pgc +++ b/app/online/mm_ol_0024.pgc @@ -59,8 +59,7 @@ TX_SERVICE(MM_OL_0024, ctx) strncpy(h_bin, bin, sizeof(h_bin) - 1); h_bin[sizeof(h_bin) - 1] = '\0'; - EXEC SQL - SELECT i.issuer_cd, i.issuer_nm, b.card_type, i.use_yn + EXEC SQL SELECT i.issuer_cd, i.issuer_nm, b.card_type, i.use_yn INTO :h_issuer_cd, :h_issuer_nm, :h_card_type, :h_use_yn FROM mm_card_bin b JOIN mm_issuer i ON i.issuer_cd = b.issuer_cd diff --git a/app/online/mm_ol_0025.c b/app/online/mm_ol_0025.c index e881023..bda9db1 100644 --- a/app/online/mm_ol_0025.c +++ b/app/online/mm_ol_0025.c @@ -143,7 +143,7 @@ TX_SERVICE(MM_OL_0025, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_char,(h_issuer_nm),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 49 "app/online/mm_ol_0025.pgc" +#line 48 "app/online/mm_ol_0025.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -166,7 +166,7 @@ TX_SERVICE(MM_OL_0025, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_total_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 69 "app/online/mm_ol_0025.pgc" +#line 67 "app/online/mm_ol_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -185,7 +185,7 @@ TX_SERVICE(MM_OL_0025, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_active_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 84 "app/online/mm_ol_0025.pgc" +#line 81 "app/online/mm_ol_0025.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { diff --git a/app/online/mm_ol_0025.pgc b/app/online/mm_ol_0025.pgc index 5e313f7..fbd77d5 100644 --- a/app/online/mm_ol_0025.pgc +++ b/app/online/mm_ol_0025.pgc @@ -43,8 +43,7 @@ TX_SERVICE(MM_OL_0025, ctx) strncpy(h_st_done, MM_ST_DONE, sizeof(h_st_done)); /* 1) 카드사 마스터 존재 확인 */ - EXEC SQL - SELECT issuer_nm INTO :h_issuer_nm + EXEC SQL SELECT issuer_nm INTO :h_issuer_nm FROM mm_issuer WHERE issuer_cd = :h_issuer_cd; @@ -63,8 +62,7 @@ TX_SERVICE(MM_OL_0025, ctx) /* 2) 소속 가맹점 총수 집계 */ h_total_cnt = 0; - EXEC SQL - SELECT COUNT(*) INTO :h_total_cnt + EXEC SQL SELECT COUNT(*) INTO :h_total_cnt FROM mm_merchant WHERE issuer_cd = :h_issuer_cd; @@ -77,8 +75,7 @@ TX_SERVICE(MM_OL_0025, ctx) /* 3) 정상 상태 가맹점 수 집계 */ h_active_cnt = 0; - EXEC SQL - SELECT COUNT(*) INTO :h_active_cnt + EXEC SQL SELECT COUNT(*) INTO :h_active_cnt FROM mm_merchant WHERE issuer_cd = :h_issuer_cd AND status = :h_st_done; diff --git a/app/online/mm_ol_0026.c b/app/online/mm_ol_0026.c index db422e5..32a4e32 100644 --- a/app/online/mm_ol_0026.c +++ b/app/online/mm_ol_0026.c @@ -138,7 +138,7 @@ TX_SERVICE(MM_OL_0026, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_char,(h_grp_nm),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 47 "app/online/mm_ol_0026.pgc" +#line 46 "app/online/mm_ol_0026.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -164,7 +164,7 @@ TX_SERVICE(MM_OL_0026, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_last_chg),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 70 "app/online/mm_ol_0026.pgc" +#line 68 "app/online/mm_ol_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { diff --git a/app/online/mm_ol_0026.pgc b/app/online/mm_ol_0026.pgc index 8ef1585..4d1460b 100644 --- a/app/online/mm_ol_0026.pgc +++ b/app/online/mm_ol_0026.pgc @@ -41,8 +41,7 @@ TX_SERVICE(MM_OL_0026, ctx) h_grp_cd[sizeof(h_grp_cd) - 1] = '\0'; /* 1) 코드그룹 명칭 확인 */ - EXEC SQL - SELECT grp_nm INTO :h_grp_nm + EXEC SQL SELECT grp_nm INTO :h_grp_nm FROM mm_code_group WHERE grp_cd = :h_grp_cd; @@ -62,8 +61,7 @@ TX_SERVICE(MM_OL_0026, ctx) /* 2) 사용중 코드 건수 + 최신 변경일 집계 */ h_use_cnt = 0; strncpy(h_last_chg, "00000000", sizeof(h_last_chg)); - EXEC SQL - SELECT COUNT(*), COALESCE(MAX(chg_date), '00000000') + EXEC SQL SELECT COUNT(*), COALESCE(MAX(chg_date), '00000000') INTO :h_use_cnt, :h_last_chg FROM mm_common_code WHERE grp_cd = :h_grp_cd diff --git a/app/online/mm_ol_0027.c b/app/online/mm_ol_0027.c index 9857e34..2147e5a 100644 --- a/app/online/mm_ol_0027.c +++ b/app/online/mm_ol_0027.c @@ -182,7 +182,7 @@ TX_SERVICE(MM_OL_0027, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_exist),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 88 "app/online/mm_ol_0027.pgc" +#line 87 "app/online/mm_ol_0027.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -210,7 +210,7 @@ TX_SERVICE(MM_OL_0027, ctx) 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_EOIT, ECPGt_EORT);} -#line 111 "app/online/mm_ol_0027.pgc" +#line 109 "app/online/mm_ol_0027.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -226,7 +226,7 @@ TX_SERVICE(MM_OL_0027, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_chg_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 123 "app/online/mm_ol_0027.pgc" +#line 120 "app/online/mm_ol_0027.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0027.pgc b/app/online/mm_ol_0027.pgc index a75f633..07fa66d 100644 --- a/app/online/mm_ol_0027.pgc +++ b/app/online/mm_ol_0027.pgc @@ -82,8 +82,7 @@ TX_SERVICE(MM_OL_0027, ctx) date_today(h_chg_date); /* 가맹점 존재 확인 */ - EXEC SQL - SELECT COUNT(*) INTO :h_exist + EXEC SQL SELECT COUNT(*) INTO :h_exist FROM mm_merchant WHERE merch_id = :h_merch_id; @@ -103,8 +102,7 @@ TX_SERVICE(MM_OL_0027, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[MM_OL_0027] tx_begin 경고"); - EXEC SQL - UPDATE mm_merchant + EXEC SQL UPDATE mm_merchant SET tel_no = :h_tel_no, email = :h_email, upd_date = :h_chg_date @@ -118,8 +116,7 @@ TX_SERVICE(MM_OL_0027, ctx) return; } - EXEC SQL - INSERT INTO mm_merchant_hist (merch_id, chg_type, chg_date, chg_status) + EXEC SQL INSERT INTO mm_merchant_hist (merch_id, chg_type, chg_date, chg_status) VALUES (:h_merch_id, 'C', :h_chg_date, 'M'); if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0028.c b/app/online/mm_ol_0028.c index 79179b6..997e03a 100644 --- a/app/online/mm_ol_0028.c +++ b/app/online/mm_ol_0028.c @@ -164,7 +164,7 @@ TX_SERVICE(MM_OL_0028, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_char,(h_old_owner),(long)32,(long)1,(32)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 70 "app/online/mm_ol_0028.pgc" +#line 69 "app/online/mm_ol_0028.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -192,7 +192,7 @@ TX_SERVICE(MM_OL_0028, ctx) 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_EOIT, ECPGt_EORT);} -#line 93 "app/online/mm_ol_0028.pgc" +#line 91 "app/online/mm_ol_0028.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -208,7 +208,7 @@ TX_SERVICE(MM_OL_0028, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_chg_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 105 "app/online/mm_ol_0028.pgc" +#line 102 "app/online/mm_ol_0028.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0028.pgc b/app/online/mm_ol_0028.pgc index 75e1f0a..b257742 100644 --- a/app/online/mm_ol_0028.pgc +++ b/app/online/mm_ol_0028.pgc @@ -64,8 +64,7 @@ TX_SERVICE(MM_OL_0028, ctx) date_today(h_chg_date); /* 현재 대표자(이력 참고용) 조회 겸 존재 확인 */ - EXEC SQL - SELECT owner_nm INTO :h_old_owner + EXEC SQL SELECT owner_nm INTO :h_old_owner FROM mm_merchant WHERE merch_id = :h_merch_id; @@ -85,8 +84,7 @@ TX_SERVICE(MM_OL_0028, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[MM_OL_0028] tx_begin 경고"); - EXEC SQL - UPDATE mm_merchant + EXEC SQL UPDATE mm_merchant SET owner_nm = :h_owner_nm, owner_birth = :h_owner_birth, upd_date = :h_chg_date @@ -100,8 +98,7 @@ TX_SERVICE(MM_OL_0028, ctx) return; } - EXEC SQL - INSERT INTO mm_merchant_hist (merch_id, chg_type, chg_date, chg_status) + EXEC SQL INSERT INTO mm_merchant_hist (merch_id, chg_type, chg_date, chg_status) VALUES (:h_merch_id, 'U', :h_chg_date, 'M'); if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0029.c b/app/online/mm_ol_0029.c index 6bd02b6..7344597 100644 --- a/app/online/mm_ol_0029.c +++ b/app/online/mm_ol_0029.c @@ -155,7 +155,7 @@ TX_SERVICE(MM_OL_0029, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_valid),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 59 "app/online/mm_ol_0029.pgc" +#line 58 "app/online/mm_ol_0029.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -177,7 +177,7 @@ TX_SERVICE(MM_OL_0029, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_char,(h_old_cycle),(long)2,(long)1,(2)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 78 "app/online/mm_ol_0029.pgc" +#line 76 "app/online/mm_ol_0029.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -211,7 +211,7 @@ TX_SERVICE(MM_OL_0029, ctx) 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_EOIT, ECPGt_EORT);} -#line 108 "app/online/mm_ol_0029.pgc" +#line 105 "app/online/mm_ol_0029.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -233,7 +233,7 @@ TX_SERVICE(MM_OL_0029, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_oper),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 121 "app/online/mm_ol_0029.pgc" +#line 117 "app/online/mm_ol_0029.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/mm_ol_0029.pgc b/app/online/mm_ol_0029.pgc index 8c19a2a..ded09f3 100644 --- a/app/online/mm_ol_0029.pgc +++ b/app/online/mm_ol_0029.pgc @@ -52,8 +52,7 @@ TX_SERVICE(MM_OL_0029, ctx) date_today(h_chg_date); /* 1) 정산주기코드 유효성 확인 */ - EXEC SQL - SELECT COUNT(*) INTO :h_valid + EXEC SQL SELECT COUNT(*) INTO :h_valid FROM mm_settle_cycle_code WHERE cycle_cd = :h_new_cycle AND use_yn = 'Y'; @@ -72,8 +71,7 @@ TX_SERVICE(MM_OL_0029, ctx) } /* 2) 현재 정산주기 조회 (존재 확인 + 이력 이전값) */ - EXEC SQL - SELECT settle_cycle INTO :h_old_cycle + EXEC SQL SELECT settle_cycle INTO :h_old_cycle FROM mm_merchant WHERE merch_id = :h_merch_id; @@ -101,8 +99,7 @@ TX_SERVICE(MM_OL_0029, ctx) if (tx_begin() != TX_OK) tx_log(TX_LOG_WARN, "[MM_OL_0029] tx_begin 경고"); - EXEC SQL - UPDATE mm_merchant + EXEC SQL UPDATE mm_merchant SET settle_cycle = :h_new_cycle, upd_date = :h_chg_date WHERE merch_id = :h_merch_id; @@ -115,8 +112,7 @@ TX_SERVICE(MM_OL_0029, ctx) return; } - EXEC SQL - INSERT INTO mm_settle_hist + EXEC SQL INSERT INTO mm_settle_hist (merch_id, old_cycle, new_cycle, chg_date, oper) VALUES (:h_merch_id, :h_old_cycle, :h_new_cycle, :h_chg_date, :h_oper); diff --git a/app/online/mm_ol_0030.c b/app/online/mm_ol_0030.c index e46c5a9..89efa12 100644 --- a/app/online/mm_ol_0030.c +++ b/app/online/mm_ol_0030.c @@ -136,7 +136,7 @@ TX_SERVICE(MM_OL_0030, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_upd_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 47 "app/online/mm_ol_0030.pgc" +#line 46 "app/online/mm_ol_0030.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/mm_ol_0030.pgc b/app/online/mm_ol_0030.pgc index f8472b9..1fc9f45 100644 --- a/app/online/mm_ol_0030.pgc +++ b/app/online/mm_ol_0030.pgc @@ -40,8 +40,7 @@ TX_SERVICE(MM_OL_0030, ctx) strncpy(h_merch_id, merch_id, sizeof(h_merch_id) - 1); h_merch_id[sizeof(h_merch_id) - 1] = '\0'; - EXEC SQL - SELECT status, COALESCE(upd_date, reg_date) + EXEC SQL SELECT status, COALESCE(upd_date, reg_date) INTO :h_status, :h_upd_date FROM mm_merchant WHERE merch_id = :h_merch_id; diff --git a/app/online/mm_ol_0031.c b/app/online/mm_ol_0031.c index 2100cd8..a0be9a3 100644 --- a/app/online/mm_ol_0031.c +++ b/app/online/mm_ol_0031.c @@ -148,7 +148,7 @@ TX_SERVICE(MM_OL_0031, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_chg_status),(long)2,(long)1,(2)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 53 "app/online/mm_ol_0031.pgc" +#line 52 "app/online/mm_ol_0031.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -171,7 +171,7 @@ TX_SERVICE(MM_OL_0031, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_hist_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 73 "app/online/mm_ol_0031.pgc" +#line 71 "app/online/mm_ol_0031.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { diff --git a/app/online/mm_ol_0031.pgc b/app/online/mm_ol_0031.pgc index ff14871..b92c800 100644 --- a/app/online/mm_ol_0031.pgc +++ b/app/online/mm_ol_0031.pgc @@ -44,8 +44,7 @@ TX_SERVICE(MM_OL_0031, ctx) h_merch_id[sizeof(h_merch_id) - 1] = '\0'; /* 1) 최근 변경이력 1건 */ - EXEC SQL - SELECT chg_type, chg_date, chg_status + EXEC SQL SELECT chg_type, chg_date, chg_status INTO :h_chg_type, :h_chg_date, :h_chg_status FROM mm_merchant_hist WHERE merch_id = :h_merch_id @@ -67,8 +66,7 @@ TX_SERVICE(MM_OL_0031, ctx) /* 2) 이력 총건수 집계 */ h_hist_cnt = 0; - EXEC SQL - SELECT COUNT(*) INTO :h_hist_cnt + EXEC SQL SELECT COUNT(*) INTO :h_hist_cnt FROM mm_merchant_hist WHERE merch_id = :h_merch_id; diff --git a/app/online/mm_ol_0032.c b/app/online/mm_ol_0032.c index 5d747c4..41f32d8 100644 --- a/app/online/mm_ol_0032.c +++ b/app/online/mm_ol_0032.c @@ -132,7 +132,7 @@ TX_SERVICE(MM_OL_0032, ctx) { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from mm_merchant", ECPGt_EOIT, ECPGt_long,&(h_total_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 39 "app/online/mm_ol_0032.pgc" +#line 38 "app/online/mm_ol_0032.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -149,7 +149,7 @@ TX_SERVICE(MM_OL_0032, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_active_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 53 "app/online/mm_ol_0032.pgc" +#line 51 "app/online/mm_ol_0032.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -166,7 +166,7 @@ TX_SERVICE(MM_OL_0032, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_closed_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 67 "app/online/mm_ol_0032.pgc" +#line 64 "app/online/mm_ol_0032.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { diff --git a/app/online/mm_ol_0032.pgc b/app/online/mm_ol_0032.pgc index 5544cbf..beff5ab 100644 --- a/app/online/mm_ol_0032.pgc +++ b/app/online/mm_ol_0032.pgc @@ -34,8 +34,7 @@ TX_SERVICE(MM_OL_0032, ctx) /* 1) 전체 가맹점 수 */ h_total_cnt = 0; - EXEC SQL - SELECT COUNT(*) INTO :h_total_cnt + EXEC SQL SELECT COUNT(*) INTO :h_total_cnt FROM mm_merchant; if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -47,8 +46,7 @@ TX_SERVICE(MM_OL_0032, ctx) /* 2) 정상 상태 가맹점 수 */ h_active_cnt = 0; - EXEC SQL - SELECT COUNT(*) INTO :h_active_cnt + EXEC SQL SELECT COUNT(*) INTO :h_active_cnt FROM mm_merchant WHERE status = :h_st_done; @@ -61,8 +59,7 @@ TX_SERVICE(MM_OL_0032, ctx) /* 3) 해지 상태 가맹점 수 */ h_closed_cnt = 0; - EXEC SQL - SELECT COUNT(*) INTO :h_closed_cnt + EXEC SQL SELECT COUNT(*) INTO :h_closed_cnt FROM mm_merchant WHERE status = :h_st_fail; diff --git a/app/online/py_ol_0001.c b/app/online/py_ol_0001.c index 2ed137c..7e2cdf7 100644 --- a/app/online/py_ol_0001.c +++ b/app/online/py_ol_0001.c @@ -11,12 +11,14 @@ * py_ol_0001.pgc - 지급 온라인 서비스 (PY_OL_0001) [tier=easy] * * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 py 표준 DBIO 를 - * 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응) + * 통해 처리한 뒤, 지급계좌 마스터(py_account)를 임베디드 조회하여 + * 지급 대상 계좌/은행/예금주를 응답에 실어 반환한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "py_core.h" @@ -89,11 +91,36 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/py_ol_0001.pgc" +#line 17 "app/online/py_ol_0001.pgc" TX_SERVICE(PY_OL_0001, ctx) { + /* exec sql begin declare section */ + + + + + + +#line 22 "app/online/py_ol_0001.pgc" + char h_merch [ 16 ] ; + +#line 23 "app/online/py_ol_0001.pgc" + char h_bank [ 8 ] ; + +#line 24 "app/online/py_ol_0001.pgc" + char h_acct [ 24 ] ; + +#line 25 "app/online/py_ol_0001.pgc" + char h_holder [ 41 ] ; + +#line 26 "app/online/py_ol_0001.pgc" + char h_acct_status [ 2 ] ; +/* exec sql end declare section */ +#line 27 "app/online/py_ol_0001.pgc" + + py_rec_t rec; char key[16]; int rc; @@ -115,11 +142,47 @@ TX_SERVICE(PY_OL_0001, ctx) return; } + /* 가맹점 지급계좌 조회 */ + strncpy(h_merch, rec.merch_id, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + memset(h_bank, 0, sizeof(h_bank)); + memset(h_acct, 0, sizeof(h_acct)); + memset(h_holder, 0, sizeof(h_holder)); + memset(h_acct_status, 0, sizeof(h_acct_status)); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select bank_code , acct_no , holder_name , acct_status from py_account where merch_id = $1 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_bank),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_acct),(long)24,(long)1,(24)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_holder),(long)41,(long)1,(41)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_acct_status),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 61 "app/online/py_ol_0001.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[PY_OL_0001] 지급계좌 미등록 merch=%s", rec.merch_id); + strncpy(h_acct_status, "-", sizeof(h_acct_status) - 1); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT py_account"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); tx_buf_sets(ctx->out, "STATUS", rec.status); - tx_log(TX_LOG_INFO, "[PY_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); + tx_buf_sets(ctx->out, "BANK", h_bank); + tx_buf_sets(ctx->out, "ACCT", h_acct); + tx_buf_sets(ctx->out, "HOLDER", h_holder); + tx_buf_sets(ctx->out, "ACCTSTATUS", h_acct_status); + tx_log(TX_LOG_INFO, "[PY_OL_0001] 조회완료 key=%s amount=%ld acct=%s", + key, rec.amount, h_acct); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/py_ol_0001.pgc b/app/online/py_ol_0001.pgc index fb112f9..baffbc4 100644 --- a/app/online/py_ol_0001.pgc +++ b/app/online/py_ol_0001.pgc @@ -3,12 +3,14 @@ * py_ol_0001.pgc - 지급 온라인 서비스 (PY_OL_0001) [tier=easy] * * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 py 표준 DBIO 를 - * 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응) + * 통해 처리한 뒤, 지급계좌 마스터(py_account)를 임베디드 조회하여 + * 지급 대상 계좌/은행/예금주를 응답에 실어 반환한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "py_core.h" @@ -16,6 +18,14 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(PY_OL_0001, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + char h_bank[8]; + char h_acct[24]; + char h_holder[41]; + char h_acct_status[2]; + EXEC SQL END DECLARE SECTION; + py_rec_t rec; char key[16]; int rc; @@ -37,11 +47,38 @@ TX_SERVICE(PY_OL_0001, ctx) return; } + /* 가맹점 지급계좌 조회 */ + strncpy(h_merch, rec.merch_id, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + memset(h_bank, 0, sizeof(h_bank)); + memset(h_acct, 0, sizeof(h_acct)); + memset(h_holder, 0, sizeof(h_holder)); + memset(h_acct_status, 0, sizeof(h_acct_status)); + + EXEC SQL SELECT bank_code, acct_no, holder_name, acct_status + INTO :h_bank, :h_acct, :h_holder, :h_acct_status + FROM py_account + WHERE merch_id = :h_merch; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[PY_OL_0001] 지급계좌 미등록 merch=%s", rec.merch_id); + strncpy(h_acct_status, "-", sizeof(h_acct_status) - 1); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT py_account"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); tx_buf_sets(ctx->out, "STATUS", rec.status); - tx_log(TX_LOG_INFO, "[PY_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); + tx_buf_sets(ctx->out, "BANK", h_bank); + tx_buf_sets(ctx->out, "ACCT", h_acct); + tx_buf_sets(ctx->out, "HOLDER", h_holder); + tx_buf_sets(ctx->out, "ACCTSTATUS", h_acct_status); + tx_log(TX_LOG_INFO, "[PY_OL_0001] 조회완료 key=%s amount=%ld acct=%s", + key, rec.amount, h_acct); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/py_ol_0003.c b/app/online/py_ol_0003.c index 6a64759..dad97bc 100644 --- a/app/online/py_ol_0003.c +++ b/app/online/py_ol_0003.c @@ -11,7 +11,8 @@ * py_ol_0003.pgc - 지급 계좌검증 연계(tx_call 계좌실명) (PY_OL_0003) [tier=hard] * * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 임베디드 SQL / 표준 - * DBIO / tx_call 로 처리한 뒤 응답 TXBUF 를 구성한다. + * DBIO / tx_call 로 처리한 뒤 응답 TXBUF 를 구성한다. 외부 실명연계 전 + * 지급계좌 마스터(py_account)를 임베디드 조회하여 사전검증한다. */ #include #include @@ -90,11 +91,28 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/py_ol_0003.pgc" +#line 17 "app/online/py_ol_0003.pgc" TX_SERVICE(PY_OL_0003, ctx) { + /* exec sql begin declare section */ + + + + +#line 22 "app/online/py_ol_0003.pgc" + char h_acct [ 24 ] ; + +#line 23 "app/online/py_ol_0003.pgc" + char h_holder [ 41 ] ; + +#line 24 "app/online/py_ol_0003.pgc" + char h_acct_status [ 2 ] ; +/* exec sql end declare section */ +#line 25 "app/online/py_ol_0003.pgc" + + char key[16]; if (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) != TX_OK) { tx_log(TX_LOG_ERROR, "[PY_OL_0003] KEY 누락"); @@ -111,10 +129,54 @@ TX_SERVICE(PY_OL_0003, ctx) return; } + /* 사전검증: 지급계좌 마스터에 등록/정상('N') 여부 확인 */ + strncpy(h_acct, acct, sizeof(h_acct) - 1); + h_acct[sizeof(h_acct) - 1] = '\0'; + memset(h_holder, 0, sizeof(h_holder)); + memset(h_acct_status, 0, sizeof(h_acct_status)); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select holder_name , acct_status from py_account where acct_no = $1 ", + ECPGt_char,(h_acct),(long)24,(long)1,(24)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_holder),(long)41,(long)1,(41)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_acct_status),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 52 "app/online/py_ol_0003.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[PY_OL_0003] 미등록 계좌 acct=%s", acct); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); + tx_buf_sets(ctx->out, "VALID", "N"); + tx_buf_sets(ctx->out, "REASON", "ACCT_NOT_FOUND"); + tx_return(ctx, TX_ENOENT, ctx->out); + return; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT py_account"); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + if (memcmp(h_acct_status, "N", 1) != 0) { + tx_log(TX_LOG_WARN, "[PY_OL_0003] 계좌상태 비정상 acct=%s status=%s", + acct, h_acct_status); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); + tx_buf_sets(ctx->out, "VALID", "N"); + tx_buf_sets(ctx->out, "REASON", "ACCT_INACTIVE"); + tx_return(ctx, TX_FAIL, ctx->out); + return; + } + req = tx_buf_alloc(); if (!req) { tx_return(ctx, TX_ENOMEM, ctx->out); return; } tx_buf_sets(req, "KEY", key); tx_buf_sets(req, "ACCTNO", acct); + tx_buf_sets(req, "HOLDER", h_holder); rc = tx_call("PY_ACCTCHK", req, ctx->out); tx_buf_free(req); @@ -128,7 +190,9 @@ TX_SERVICE(PY_OL_0003, ctx) if (tx_buf_get(ctx->out, "RESPCODE", vresp, sizeof(vresp)) != TX_OK) strcpy(vresp, RESP_OK); + tx_buf_sets(ctx->out, "HOLDER", h_holder); tx_buf_sets(ctx->out, "VALID", (strcmp(vresp, RESP_OK) == 0) ? "Y" : "N"); - tx_log(TX_LOG_INFO, "[PY_OL_0003] 계좌검증 acct=%s resp=%s", acct, vresp); + tx_log(TX_LOG_INFO, "[PY_OL_0003] 계좌검증 acct=%s resp=%s holder=%s", + acct, vresp, h_holder); tx_return(ctx, (strcmp(vresp, RESP_OK) == 0) ? TX_OK : TX_FAIL, ctx->out); } diff --git a/app/online/py_ol_0003.pgc b/app/online/py_ol_0003.pgc index d219a93..70a443c 100644 --- a/app/online/py_ol_0003.pgc +++ b/app/online/py_ol_0003.pgc @@ -3,7 +3,8 @@ * py_ol_0003.pgc - 지급 계좌검증 연계(tx_call 계좌실명) (PY_OL_0003) [tier=hard] * * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 임베디드 SQL / 표준 - * DBIO / tx_call 로 처리한 뒤 응답 TXBUF 를 구성한다. + * DBIO / tx_call 로 처리한 뒤 응답 TXBUF 를 구성한다. 외부 실명연계 전 + * 지급계좌 마스터(py_account)를 임베디드 조회하여 사전검증한다. */ #include #include @@ -17,6 +18,12 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(PY_OL_0003, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_acct[24]; + char h_holder[41]; + char h_acct_status[2]; + EXEC SQL END DECLARE SECTION; + char key[16]; if (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) != TX_OK) { tx_log(TX_LOG_ERROR, "[PY_OL_0003] KEY 누락"); @@ -33,10 +40,49 @@ TX_SERVICE(PY_OL_0003, ctx) return; } + /* 사전검증: 지급계좌 마스터에 등록/정상('N') 여부 확인 */ + strncpy(h_acct, acct, sizeof(h_acct) - 1); + h_acct[sizeof(h_acct) - 1] = '\0'; + memset(h_holder, 0, sizeof(h_holder)); + memset(h_acct_status, 0, sizeof(h_acct_status)); + + EXEC SQL SELECT holder_name, acct_status + INTO :h_holder, :h_acct_status + FROM py_account + WHERE acct_no = :h_acct; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[PY_OL_0003] 미등록 계좌 acct=%s", acct); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); + tx_buf_sets(ctx->out, "VALID", "N"); + tx_buf_sets(ctx->out, "REASON", "ACCT_NOT_FOUND"); + tx_return(ctx, TX_ENOENT, ctx->out); + return; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT py_account"); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + if (memcmp(h_acct_status, "N", 1) != 0) { + tx_log(TX_LOG_WARN, "[PY_OL_0003] 계좌상태 비정상 acct=%s status=%s", + acct, h_acct_status); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); + tx_buf_sets(ctx->out, "VALID", "N"); + tx_buf_sets(ctx->out, "REASON", "ACCT_INACTIVE"); + tx_return(ctx, TX_FAIL, ctx->out); + return; + } + req = tx_buf_alloc(); if (!req) { tx_return(ctx, TX_ENOMEM, ctx->out); return; } tx_buf_sets(req, "KEY", key); tx_buf_sets(req, "ACCTNO", acct); + tx_buf_sets(req, "HOLDER", h_holder); rc = tx_call("PY_ACCTCHK", req, ctx->out); tx_buf_free(req); @@ -50,7 +96,9 @@ TX_SERVICE(PY_OL_0003, ctx) if (tx_buf_get(ctx->out, "RESPCODE", vresp, sizeof(vresp)) != TX_OK) strcpy(vresp, RESP_OK); + tx_buf_sets(ctx->out, "HOLDER", h_holder); tx_buf_sets(ctx->out, "VALID", (strcmp(vresp, RESP_OK) == 0) ? "Y" : "N"); - tx_log(TX_LOG_INFO, "[PY_OL_0003] 계좌검증 acct=%s resp=%s", acct, vresp); + tx_log(TX_LOG_INFO, "[PY_OL_0003] 계좌검증 acct=%s resp=%s holder=%s", + acct, vresp, h_holder); tx_return(ctx, (strcmp(vresp, RESP_OK) == 0) ? TX_OK : TX_FAIL, ctx->out); } diff --git a/app/online/rc_ol_0001.c b/app/online/rc_ol_0001.c index 3f7644a..cec56e1 100644 --- a/app/online/rc_ol_0001.c +++ b/app/online/rc_ol_0001.c @@ -17,6 +17,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -89,7 +90,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/rc_ol_0001.pgc" +#line 16 "app/online/rc_ol_0001.pgc" TX_SERVICE(RC_OL_0001, ctx) @@ -120,6 +121,48 @@ TX_SERVICE(RC_OL_0001, ctx) tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); tx_buf_sets(ctx->out, "STATUS", rec.status); + + /* 원장에서 수수료/영업일을 임베디드 SQL 로 직접 보강 조회 */ + { + /* exec sql begin declare section */ + + + + +#line 50 "app/online/rc_ol_0001.pgc" + char h_rc1_key [ 16 ] ; + +#line 51 "app/online/rc_ol_0001.pgc" + char h_rc1_bd [ 9 ] ; + +#line 52 "app/online/rc_ol_0001.pgc" + long h_rc1_fee ; +/* exec sql end declare section */ +#line 53 "app/online/rc_ol_0001.pgc" + + + strncpy(h_rc1_key, key, sizeof(h_rc1_key) - 1); + h_rc1_key[sizeof(h_rc1_key) - 1] = '\0'; + h_rc1_fee = 0; + h_rc1_bd[0] = '\0'; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select fee , biz_date from rc_ledger where key = $1 ", + ECPGt_char,(h_rc1_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_rc1_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_rc1_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 63 "app/online/rc_ol_0001.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) { + tx_buf_setlong(ctx->out, "FEE", h_rc1_fee); + tx_buf_sets(ctx->out, "BIZDATE", h_rc1_bd); + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger fee/biz_date"); + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0001.pgc b/app/online/rc_ol_0001.pgc index 86e311e..be3f3e8 100644 --- a/app/online/rc_ol_0001.pgc +++ b/app/online/rc_ol_0001.pgc @@ -9,6 +9,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -42,6 +43,32 @@ TX_SERVICE(RC_OL_0001, ctx) tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); tx_buf_sets(ctx->out, "STATUS", rec.status); + + /* 원장에서 수수료/영업일을 임베디드 SQL 로 직접 보강 조회 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_rc1_key[16]; + char h_rc1_bd[9]; + long h_rc1_fee; + EXEC SQL END DECLARE SECTION; + + strncpy(h_rc1_key, key, sizeof(h_rc1_key) - 1); + h_rc1_key[sizeof(h_rc1_key) - 1] = '\0'; + h_rc1_fee = 0; + h_rc1_bd[0] = '\0'; + + EXEC SQL SELECT fee, biz_date + INTO :h_rc1_fee, :h_rc1_bd + FROM rc_ledger + WHERE key = :h_rc1_key; + if (sqlca.sqlcode == TX_SQL_OK) { + tx_buf_setlong(ctx->out, "FEE", h_rc1_fee); + tx_buf_sets(ctx->out, "BIZDATE", h_rc1_bd); + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger fee/biz_date"); + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0002.c b/app/online/rc_ol_0002.c index e160785..c7c8cb1 100644 --- a/app/online/rc_ol_0002.c +++ b/app/online/rc_ol_0002.c @@ -18,6 +18,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -90,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 16 "app/online/rc_ol_0002.pgc" +#line 17 "app/online/rc_ol_0002.pgc" TX_SERVICE(RC_OL_0002, ctx) @@ -150,5 +151,64 @@ TX_SERVICE(RC_OL_0002, ctx) tx_buf_setlong(ctx->out, "DIFF", diff); tx_buf_sets(ctx->out, "STATUS", new_st); tx_buf_sets(ctx->out, "RESULT", (diff == 0) ? "MATCH" : "UNMATCH"); + + /* 승인-매입 대사 결과를 대사이력(rc_match_log)에 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + + + +#line 80 "app/online/rc_ol_0002.pgc" + char h_ml_key [ 16 ] ; + +#line 81 "app/online/rc_ol_0002.pgc" + long h_ml_appr ; + +#line 82 "app/online/rc_ol_0002.pgc" + long h_ml_cap ; + +#line 83 "app/online/rc_ol_0002.pgc" + long h_ml_diff ; + +#line 84 "app/online/rc_ol_0002.pgc" + char h_ml_status [ 2 ] ; +/* exec sql end declare section */ +#line 85 "app/online/rc_ol_0002.pgc" + + + strncpy(h_ml_key, key, sizeof(h_ml_key) - 1); + h_ml_key[sizeof(h_ml_key) - 1] = '\0'; + h_ml_appr = appr_amt; + h_ml_cap = rec.amount; + h_ml_diff = diff; + strncpy(h_ml_status, new_st, sizeof(h_ml_status) - 1); + h_ml_status[sizeof(h_ml_status) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_match_log ( rec_key , appr_amt , cap_amt , diff_amt , new_status ) values ( $1 , $2 , $3 , $4 , $5 )", + ECPGt_char,(h_ml_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_ml_appr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_ml_cap),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_ml_diff),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_ml_status),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 98 "app/online/rc_ol_0002.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_match_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0002.pgc b/app/online/rc_ol_0002.pgc index 816cd77..ec0f18c 100644 --- a/app/online/rc_ol_0002.pgc +++ b/app/online/rc_ol_0002.pgc @@ -10,6 +10,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -72,5 +73,37 @@ TX_SERVICE(RC_OL_0002, ctx) tx_buf_setlong(ctx->out, "DIFF", diff); tx_buf_sets(ctx->out, "STATUS", new_st); tx_buf_sets(ctx->out, "RESULT", (diff == 0) ? "MATCH" : "UNMATCH"); + + /* 승인-매입 대사 결과를 대사이력(rc_match_log)에 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_ml_key[16]; + long h_ml_appr; + long h_ml_cap; + long h_ml_diff; + char h_ml_status[2]; + EXEC SQL END DECLARE SECTION; + + strncpy(h_ml_key, key, sizeof(h_ml_key) - 1); + h_ml_key[sizeof(h_ml_key) - 1] = '\0'; + h_ml_appr = appr_amt; + h_ml_cap = rec.amount; + h_ml_diff = diff; + strncpy(h_ml_status, new_st, sizeof(h_ml_status) - 1); + h_ml_status[sizeof(h_ml_status) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO rc_match_log + (rec_key, appr_amt, cap_amt, diff_amt, new_status) + VALUES (:h_ml_key, :h_ml_appr, :h_ml_cap, :h_ml_diff, :h_ml_status); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_match_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0003.c b/app/online/rc_ol_0003.c index 888be38..781f7f3 100644 --- a/app/online/rc_ol_0003.c +++ b/app/online/rc_ol_0003.c @@ -27,6 +27,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -99,7 +100,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 25 "app/online/rc_ol_0003.pgc" +#line 26 "app/online/rc_ol_0003.pgc" TX_SERVICE(RC_OL_0003, ctx) @@ -194,5 +195,64 @@ TX_SERVICE(RC_OL_0003, ctx) tx_buf_setlong(ctx->out, "GAP", gap); tx_buf_sets(ctx->out, "STATUS", final_st); tx_buf_sets(ctx->out, "RESULT", result); + + /* 매입-입금 대사 결과를 입금대사이력(rc_deposit_log)에 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + + + +#line 124 "app/online/rc_ol_0003.pgc" + char h_dl_key [ 16 ] ; + +#line 125 "app/online/rc_ol_0003.pgc" + long h_dl_net ; + +#line 126 "app/online/rc_ol_0003.pgc" + long h_dl_dep ; + +#line 127 "app/online/rc_ol_0003.pgc" + long h_dl_gap ; + +#line 128 "app/online/rc_ol_0003.pgc" + char h_dl_result [ 12 ] ; +/* exec sql end declare section */ +#line 129 "app/online/rc_ol_0003.pgc" + + + strncpy(h_dl_key, key, sizeof(h_dl_key) - 1); + h_dl_key[sizeof(h_dl_key) - 1] = '\0'; + h_dl_net = net; + h_dl_dep = dep_amt; + h_dl_gap = gap; + strncpy(h_dl_result, result, sizeof(h_dl_result) - 1); + h_dl_result[sizeof(h_dl_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_deposit_log ( rec_key , net_amt , dep_amt , gap_amt , match_result ) values ( $1 , $2 , $3 , $4 , $5 )", + ECPGt_char,(h_dl_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_dl_net),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_dl_dep),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_dl_gap),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_dl_result),(long)12,(long)1,(12)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 142 "app/online/rc_ol_0003.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_deposit_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0003.pgc b/app/online/rc_ol_0003.pgc index 3b544ee..780d138 100644 --- a/app/online/rc_ol_0003.pgc +++ b/app/online/rc_ol_0003.pgc @@ -19,6 +19,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -116,5 +117,37 @@ TX_SERVICE(RC_OL_0003, ctx) tx_buf_setlong(ctx->out, "GAP", gap); tx_buf_sets(ctx->out, "STATUS", final_st); tx_buf_sets(ctx->out, "RESULT", result); + + /* 매입-입금 대사 결과를 입금대사이력(rc_deposit_log)에 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_dl_key[16]; + long h_dl_net; + long h_dl_dep; + long h_dl_gap; + char h_dl_result[12]; + EXEC SQL END DECLARE SECTION; + + strncpy(h_dl_key, key, sizeof(h_dl_key) - 1); + h_dl_key[sizeof(h_dl_key) - 1] = '\0'; + h_dl_net = net; + h_dl_dep = dep_amt; + h_dl_gap = gap; + strncpy(h_dl_result, result, sizeof(h_dl_result) - 1); + h_dl_result[sizeof(h_dl_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO rc_deposit_log + (rec_key, net_amt, dep_amt, gap_amt, match_result) + VALUES (:h_dl_key, :h_dl_net, :h_dl_dep, :h_dl_gap, :h_dl_result); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_deposit_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0004.c b/app/online/rc_ol_0004.c index 13f5b32..f829dee 100644 --- a/app/online/rc_ol_0004.c +++ b/app/online/rc_ol_0004.c @@ -37,6 +37,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -109,7 +110,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 35 "app/online/rc_ol_0004.pgc" +#line 36 "app/online/rc_ol_0004.pgc" TX_SERVICE(RC_OL_0004, ctx) @@ -199,5 +200,57 @@ TX_SERVICE(RC_OL_0004, ctx) tx_buf_setlong(ctx->out, "REMAIN", remain); tx_buf_sets(ctx->out, "STATUS", final_st); tx_buf_sets(ctx->out, "RESULT", result); + + /* 반송 대사 결과를 반송이력(rc_return_log)에 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + + +#line 129 "app/online/rc_ol_0004.pgc" + char h_rl_key [ 16 ] ; + +#line 130 "app/online/rc_ol_0004.pgc" + long h_rl_rtn ; + +#line 131 "app/online/rc_ol_0004.pgc" + long h_rl_remain ; + +#line 132 "app/online/rc_ol_0004.pgc" + char h_rl_result [ 12 ] ; +/* exec sql end declare section */ +#line 133 "app/online/rc_ol_0004.pgc" + + + strncpy(h_rl_key, key, sizeof(h_rl_key) - 1); + h_rl_key[sizeof(h_rl_key) - 1] = '\0'; + h_rl_rtn = rtn_amt; + h_rl_remain = remain; + strncpy(h_rl_result, result, sizeof(h_rl_result) - 1); + h_rl_result[sizeof(h_rl_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_return_log ( rec_key , rtn_amt , remain_amt , return_result ) values ( $1 , $2 , $3 , $4 )", + ECPGt_char,(h_rl_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_rl_rtn),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_rl_remain),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_rl_result),(long)12,(long)1,(12)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 145 "app/online/rc_ol_0004.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_return_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0004.pgc b/app/online/rc_ol_0004.pgc index 71dc663..734c27b 100644 --- a/app/online/rc_ol_0004.pgc +++ b/app/online/rc_ol_0004.pgc @@ -29,6 +29,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -121,5 +122,35 @@ TX_SERVICE(RC_OL_0004, ctx) tx_buf_setlong(ctx->out, "REMAIN", remain); tx_buf_sets(ctx->out, "STATUS", final_st); tx_buf_sets(ctx->out, "RESULT", result); + + /* 반송 대사 결과를 반송이력(rc_return_log)에 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_rl_key[16]; + long h_rl_rtn; + long h_rl_remain; + char h_rl_result[12]; + EXEC SQL END DECLARE SECTION; + + strncpy(h_rl_key, key, sizeof(h_rl_key) - 1); + h_rl_key[sizeof(h_rl_key) - 1] = '\0'; + h_rl_rtn = rtn_amt; + h_rl_remain = remain; + strncpy(h_rl_result, result, sizeof(h_rl_result) - 1); + h_rl_result[sizeof(h_rl_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO rc_return_log + (rec_key, rtn_amt, remain_amt, return_result) + VALUES (:h_rl_key, :h_rl_rtn, :h_rl_remain, :h_rl_result); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_return_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0005.c b/app/online/rc_ol_0005.c index dab209d..6732b69 100644 --- a/app/online/rc_ol_0005.c +++ b/app/online/rc_ol_0005.c @@ -37,6 +37,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -109,7 +110,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 35 "app/online/rc_ol_0005.pgc" +#line 36 "app/online/rc_ol_0005.pgc" #define RC_ROUNDING_TOL 10L /* 반올림 허용 오차(원) */ @@ -191,6 +192,39 @@ TX_SERVICE(RC_OL_0005, ctx) tx_buf_setlong(ctx->out, "ABSDIFF", absd); tx_buf_sets(ctx->out, "CLASS", klass); + /* 참고: 동일 영업일의 불일치('U') 미해소 건수를 임베디드 SQL 로 조회 (read-only) */ + { + /* exec sql begin declare section */ + + + +#line 120 "app/online/rc_ol_0005.pgc" + char h_d5_bd [ 9 ] ; + +#line 121 "app/online/rc_ol_0005.pgc" + long h_d5_peer ; +/* exec sql end declare section */ +#line 122 "app/online/rc_ol_0005.pgc" + + + strncpy(h_d5_bd, rec.biz_date, sizeof(h_d5_bd) - 1); + h_d5_bd[sizeof(h_d5_bd) - 1] = '\0'; + h_d5_peer = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from rc_ledger where biz_date = $1 and status = 'U'", + ECPGt_char,(h_d5_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_d5_peer),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 132 "app/online/rc_ol_0005.pgc" + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger unmatched peers"); + h_d5_peer = 0; + } + tx_buf_setlong(ctx->out, "PEERUNMATCH", h_d5_peer); + } + tx_log(TX_LOG_INFO, "[RC_OL_0005] 검출완료 key=%s CLASS=%s DIFF=%ld ABSDIFF=%ld", key, klass, diff, absd); diff --git a/app/online/rc_ol_0005.pgc b/app/online/rc_ol_0005.pgc index b3dbee2..9bdef65 100644 --- a/app/online/rc_ol_0005.pgc +++ b/app/online/rc_ol_0005.pgc @@ -29,6 +29,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -113,6 +114,29 @@ TX_SERVICE(RC_OL_0005, ctx) tx_buf_setlong(ctx->out, "ABSDIFF", absd); tx_buf_sets(ctx->out, "CLASS", klass); + /* 참고: 동일 영업일의 불일치('U') 미해소 건수를 임베디드 SQL 로 조회 (read-only) */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_d5_bd[9]; + long h_d5_peer; + EXEC SQL END DECLARE SECTION; + + strncpy(h_d5_bd, rec.biz_date, sizeof(h_d5_bd) - 1); + h_d5_bd[sizeof(h_d5_bd) - 1] = '\0'; + h_d5_peer = 0; + + EXEC SQL SELECT COUNT(*) + INTO :h_d5_peer + FROM rc_ledger + WHERE biz_date = :h_d5_bd + AND status = 'U'; + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger unmatched peers"); + h_d5_peer = 0; + } + tx_buf_setlong(ctx->out, "PEERUNMATCH", h_d5_peer); + } + tx_log(TX_LOG_INFO, "[RC_OL_0005] 검출완료 key=%s CLASS=%s DIFF=%ld ABSDIFF=%ld", key, klass, diff, absd); diff --git a/app/online/rc_ol_0006.c b/app/online/rc_ol_0006.c index e10d34e..8d0c439 100644 --- a/app/online/rc_ol_0006.c +++ b/app/online/rc_ol_0006.c @@ -37,6 +37,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -109,7 +110,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 35 "app/online/rc_ol_0006.pgc" +#line 36 "app/online/rc_ol_0006.pgc" TX_SERVICE(RC_OL_0006, ctx) @@ -186,6 +187,42 @@ TX_SERVICE(RC_OL_0006, ctx) tx_buf_setlong(ctx->out, "TOTAL", total); tx_buf_sets(ctx->out, "MISMATCH", mismatch); + /* 원장에서 직접 총건수를 임베디드 SQL 로 재집계하여 교차검증(DBTOTAL) */ + { + /* exec sql begin declare section */ + + + +#line 115 "app/online/rc_ol_0006.pgc" + char h_c6_bd [ 9 ] ; + +#line 116 "app/online/rc_ol_0006.pgc" + long h_c6_total ; +/* exec sql end declare section */ +#line 117 "app/online/rc_ol_0006.pgc" + + + strncpy(h_c6_bd, bizdate, sizeof(h_c6_bd) - 1); + h_c6_bd[sizeof(h_c6_bd) - 1] = '\0'; + h_c6_total = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from rc_ledger where biz_date = $1 ", + ECPGt_char,(h_c6_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_c6_total),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 126 "app/online/rc_ol_0006.pgc" + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger dbtotal"); + h_c6_total = total; + } + tx_buf_setlong(ctx->out, "DBTOTAL", h_c6_total); + if (h_c6_total != total) + tx_log(TX_LOG_WARN, "[RC_OL_0006] 집계 교차검증 상이 wrap=%ld db=%ld", + total, h_c6_total); + } + /* 진행률 참고 로그: (매입확정+정산완료) / 총건수 */ if (total > 0) { long done_cnt = cnt_m + cnt_s; diff --git a/app/online/rc_ol_0006.pgc b/app/online/rc_ol_0006.pgc index cfecc0f..50401a4 100644 --- a/app/online/rc_ol_0006.pgc +++ b/app/online/rc_ol_0006.pgc @@ -29,6 +29,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -108,6 +109,31 @@ TX_SERVICE(RC_OL_0006, ctx) tx_buf_setlong(ctx->out, "TOTAL", total); tx_buf_sets(ctx->out, "MISMATCH", mismatch); + /* 원장에서 직접 총건수를 임베디드 SQL 로 재집계하여 교차검증(DBTOTAL) */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_c6_bd[9]; + long h_c6_total; + EXEC SQL END DECLARE SECTION; + + strncpy(h_c6_bd, bizdate, sizeof(h_c6_bd) - 1); + h_c6_bd[sizeof(h_c6_bd) - 1] = '\0'; + h_c6_total = 0; + + EXEC SQL SELECT COUNT(*) + INTO :h_c6_total + FROM rc_ledger + WHERE biz_date = :h_c6_bd; + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger dbtotal"); + h_c6_total = total; + } + tx_buf_setlong(ctx->out, "DBTOTAL", h_c6_total); + if (h_c6_total != total) + tx_log(TX_LOG_WARN, "[RC_OL_0006] 집계 교차검증 상이 wrap=%ld db=%ld", + total, h_c6_total); + } + /* 진행률 참고 로그: (매입확정+정산완료) / 총건수 */ if (total > 0) { long done_cnt = cnt_m + cnt_s; diff --git a/app/online/rc_ol_0007.c b/app/online/rc_ol_0007.c index 54d91ce..b3381f4 100644 --- a/app/online/rc_ol_0007.c +++ b/app/online/rc_ol_0007.c @@ -39,6 +39,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -111,7 +112,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 37 "app/online/rc_ol_0007.pgc" +#line 38 "app/online/rc_ol_0007.pgc" TX_SERVICE(RC_OL_0007, ctx) @@ -196,5 +197,51 @@ TX_SERVICE(RC_OL_0007, ctx) tx_buf_sets(ctx->out, "NEWSTATUS", RC_ST_RECV); tx_buf_sets(ctx->out, "REASON", reason); tx_buf_sets(ctx->out, "ACTION", "REQUEUE"); + + /* 예외처리(재대사 요청) 이력을 rc_exception_log 에 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + +#line 126 "app/online/rc_ol_0007.pgc" + char h_ex_key [ 16 ] ; + +#line 127 "app/online/rc_ol_0007.pgc" + char h_ex_old [ 2 ] ; + +#line 128 "app/online/rc_ol_0007.pgc" + char h_ex_reason [ 64 ] ; +/* exec sql end declare section */ +#line 129 "app/online/rc_ol_0007.pgc" + + + strncpy(h_ex_key, key, sizeof(h_ex_key) - 1); + h_ex_key[sizeof(h_ex_key) - 1] = '\0'; + strncpy(h_ex_old, old_status, sizeof(h_ex_old) - 1); + h_ex_old[sizeof(h_ex_old) - 1] = '\0'; + strncpy(h_ex_reason, reason, sizeof(h_ex_reason) - 1); + h_ex_reason[sizeof(h_ex_reason) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_exception_log ( rec_key , old_status , reason , action ) values ( $1 , $2 , $3 , 'REQUEUE' )", + ECPGt_char,(h_ex_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_ex_old),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_ex_reason),(long)64,(long)1,(64)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 141 "app/online/rc_ol_0007.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_exception_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0007.pgc b/app/online/rc_ol_0007.pgc index 8f71105..6a679fc 100644 --- a/app/online/rc_ol_0007.pgc +++ b/app/online/rc_ol_0007.pgc @@ -31,6 +31,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -118,5 +119,34 @@ TX_SERVICE(RC_OL_0007, ctx) tx_buf_sets(ctx->out, "NEWSTATUS", RC_ST_RECV); tx_buf_sets(ctx->out, "REASON", reason); tx_buf_sets(ctx->out, "ACTION", "REQUEUE"); + + /* 예외처리(재대사 요청) 이력을 rc_exception_log 에 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_ex_key[16]; + char h_ex_old[2]; + char h_ex_reason[64]; + EXEC SQL END DECLARE SECTION; + + strncpy(h_ex_key, key, sizeof(h_ex_key) - 1); + h_ex_key[sizeof(h_ex_key) - 1] = '\0'; + strncpy(h_ex_old, old_status, sizeof(h_ex_old) - 1); + h_ex_old[sizeof(h_ex_old) - 1] = '\0'; + strncpy(h_ex_reason, reason, sizeof(h_ex_reason) - 1); + h_ex_reason[sizeof(h_ex_reason) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO rc_exception_log + (rec_key, old_status, reason, action) + VALUES (:h_ex_key, :h_ex_old, :h_ex_reason, 'REQUEUE'); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_exception_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0008.c b/app/online/rc_ol_0008.c index 629fd71..8d4c201 100644 --- a/app/online/rc_ol_0008.c +++ b/app/online/rc_ol_0008.c @@ -21,6 +21,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -93,7 +94,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 19 "app/online/rc_ol_0008.pgc" +#line 20 "app/online/rc_ol_0008.pgc" TX_SERVICE(RC_OL_0008, ctx) @@ -161,6 +162,59 @@ TX_SERVICE(RC_OL_0008, ctx) tx_buf_sets(ctx->out, "OLDSTATUS", old_status); tx_buf_sets(ctx->out, "NEWSTATUS", new_status); tx_buf_sets(ctx->out, "RESULT", result); + /* 재대사 처리 이력을 rc_retry_log 에 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + + +#line 90 "app/online/rc_ol_0008.pgc" + char h_rt_key [ 16 ] ; + +#line 91 "app/online/rc_ol_0008.pgc" + char h_rt_old [ 2 ] ; + +#line 92 "app/online/rc_ol_0008.pgc" + char h_rt_new [ 2 ] ; + +#line 93 "app/online/rc_ol_0008.pgc" + char h_rt_result [ 12 ] ; +/* exec sql end declare section */ +#line 94 "app/online/rc_ol_0008.pgc" + + + strncpy(h_rt_key, key, sizeof(h_rt_key) - 1); + h_rt_key[sizeof(h_rt_key) - 1] = '\0'; + strncpy(h_rt_old, old_status, sizeof(h_rt_old) - 1); + h_rt_old[sizeof(h_rt_old) - 1] = '\0'; + strncpy(h_rt_new, new_status, sizeof(h_rt_new) - 1); + h_rt_new[sizeof(h_rt_new) - 1] = '\0'; + strncpy(h_rt_result, result, sizeof(h_rt_result) - 1); + h_rt_result[sizeof(h_rt_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_retry_log ( rec_key , old_status , new_status , retry_result ) values ( $1 , $2 , $3 , $4 )", + ECPGt_char,(h_rt_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_rt_old),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_rt_new),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_rt_result),(long)12,(long)1,(12)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 108 "app/online/rc_ol_0008.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_retry_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0008] 재대사 처리결과 key=%s result=%s", key, result); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/rc_ol_0008.pgc b/app/online/rc_ol_0008.pgc index 3d0d814..0d220d8 100644 --- a/app/online/rc_ol_0008.pgc +++ b/app/online/rc_ol_0008.pgc @@ -13,6 +13,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -83,6 +84,37 @@ TX_SERVICE(RC_OL_0008, ctx) tx_buf_sets(ctx->out, "OLDSTATUS", old_status); tx_buf_sets(ctx->out, "NEWSTATUS", new_status); tx_buf_sets(ctx->out, "RESULT", result); + /* 재대사 처리 이력을 rc_retry_log 에 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_rt_key[16]; + char h_rt_old[2]; + char h_rt_new[2]; + char h_rt_result[12]; + EXEC SQL END DECLARE SECTION; + + strncpy(h_rt_key, key, sizeof(h_rt_key) - 1); + h_rt_key[sizeof(h_rt_key) - 1] = '\0'; + strncpy(h_rt_old, old_status, sizeof(h_rt_old) - 1); + h_rt_old[sizeof(h_rt_old) - 1] = '\0'; + strncpy(h_rt_new, new_status, sizeof(h_rt_new) - 1); + h_rt_new[sizeof(h_rt_new) - 1] = '\0'; + strncpy(h_rt_result, result, sizeof(h_rt_result) - 1); + h_rt_result[sizeof(h_rt_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO rc_retry_log + (rec_key, old_status, new_status, retry_result) + VALUES (:h_rt_key, :h_rt_old, :h_rt_new, :h_rt_result); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_retry_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0008] 재대사 처리결과 key=%s result=%s", key, result); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/rc_ol_0009.c b/app/online/rc_ol_0009.c index 00a2d5b..bc8cb3d 100644 --- a/app/online/rc_ol_0009.c +++ b/app/online/rc_ol_0009.c @@ -21,6 +21,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -93,7 +94,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 19 "app/online/rc_ol_0009.pgc" +#line 20 "app/online/rc_ol_0009.pgc" TX_SERVICE(RC_OL_0009, ctx) @@ -167,6 +168,51 @@ TX_SERVICE(RC_OL_0009, ctx) tx_buf_sets(ctx->out, "NEWSTATUS", new_status); tx_buf_sets(ctx->out, "REASON", reason); tx_buf_sets(ctx->out, "RESULT", result); + /* 보류 처리 이력을 rc_hold_log 에 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + +#line 96 "app/online/rc_ol_0009.pgc" + char h_hd_key [ 16 ] ; + +#line 97 "app/online/rc_ol_0009.pgc" + char h_hd_reason [ 64 ] ; + +#line 98 "app/online/rc_ol_0009.pgc" + char h_hd_result [ 16 ] ; +/* exec sql end declare section */ +#line 99 "app/online/rc_ol_0009.pgc" + + + strncpy(h_hd_key, key, sizeof(h_hd_key) - 1); + h_hd_key[sizeof(h_hd_key) - 1] = '\0'; + strncpy(h_hd_reason, reason, sizeof(h_hd_reason) - 1); + h_hd_reason[sizeof(h_hd_reason) - 1] = '\0'; + strncpy(h_hd_result, result, sizeof(h_hd_result) - 1); + h_hd_result[sizeof(h_hd_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_hold_log ( rec_key , hold_reason , hold_result ) values ( $1 , $2 , $3 )", + ECPGt_char,(h_hd_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_hd_reason),(long)64,(long)1,(64)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_hd_result),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 111 "app/online/rc_ol_0009.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_hold_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0009] 보류 처리결과 key=%s result=%s", key, result); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/rc_ol_0009.pgc b/app/online/rc_ol_0009.pgc index 9b8bdf9..07bc6bd 100644 --- a/app/online/rc_ol_0009.pgc +++ b/app/online/rc_ol_0009.pgc @@ -13,6 +13,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -89,6 +90,34 @@ TX_SERVICE(RC_OL_0009, ctx) tx_buf_sets(ctx->out, "NEWSTATUS", new_status); tx_buf_sets(ctx->out, "REASON", reason); tx_buf_sets(ctx->out, "RESULT", result); + /* 보류 처리 이력을 rc_hold_log 에 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_hd_key[16]; + char h_hd_reason[64]; + char h_hd_result[16]; + EXEC SQL END DECLARE SECTION; + + strncpy(h_hd_key, key, sizeof(h_hd_key) - 1); + h_hd_key[sizeof(h_hd_key) - 1] = '\0'; + strncpy(h_hd_reason, reason, sizeof(h_hd_reason) - 1); + h_hd_reason[sizeof(h_hd_reason) - 1] = '\0'; + strncpy(h_hd_result, result, sizeof(h_hd_result) - 1); + h_hd_result[sizeof(h_hd_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO rc_hold_log + (rec_key, hold_reason, hold_result) + VALUES (:h_hd_key, :h_hd_reason, :h_hd_result); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_hold_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0009] 보류 처리결과 key=%s result=%s", key, result); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/rc_ol_0010.c b/app/online/rc_ol_0010.c index 763a663..7754d72 100644 --- a/app/online/rc_ol_0010.c +++ b/app/online/rc_ol_0010.c @@ -20,6 +20,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -92,7 +93,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 18 "app/online/rc_ol_0010.pgc" +#line 19 "app/online/rc_ol_0010.pgc" TX_SERVICE(RC_OL_0010, ctx) @@ -149,6 +150,37 @@ TX_SERVICE(RC_OL_0010, ctx) tx_buf_sets(ctx->out, "OLDSTATUS", old_status); tx_buf_sets(ctx->out, "NEWSTATUS", new_status); tx_buf_sets(ctx->out, "RESULT", result); + /* 보류해제 시 보류이력(rc_hold_log)의 해당 건을 임베디드 SQL 로 정리(DELETE) */ + if (strcmp(result, "RELEASED") == 0) { + /* exec sql begin declare section */ + + +#line 78 "app/online/rc_ol_0010.pgc" + char h_rel_key [ 16 ] ; +/* exec sql end declare section */ +#line 79 "app/online/rc_ol_0010.pgc" + + + strncpy(h_rel_key, key, sizeof(h_rel_key) - 1); + h_rel_key[sizeof(h_rel_key) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from rc_hold_log where rec_key = $1 ", + ECPGt_char,(h_rel_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 86 "app/online/rc_ol_0010.pgc" + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("DELETE rc_hold_log"); + tx_abort(); + } else { + tx_log(TX_LOG_INFO, "[RC_OL_0010] 보류이력 정리 key=%s 삭제=%ld건", + key, (long)sqlca.sqlerrd[2]); + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0010] 보류해제 처리결과 key=%s result=%s", key, result); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/rc_ol_0010.pgc b/app/online/rc_ol_0010.pgc index 9c21048..cd26481 100644 --- a/app/online/rc_ol_0010.pgc +++ b/app/online/rc_ol_0010.pgc @@ -12,6 +12,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -71,6 +72,29 @@ TX_SERVICE(RC_OL_0010, ctx) tx_buf_sets(ctx->out, "OLDSTATUS", old_status); tx_buf_sets(ctx->out, "NEWSTATUS", new_status); tx_buf_sets(ctx->out, "RESULT", result); + /* 보류해제 시 보류이력(rc_hold_log)의 해당 건을 임베디드 SQL 로 정리(DELETE) */ + if (strcmp(result, "RELEASED") == 0) { + EXEC SQL BEGIN DECLARE SECTION; + char h_rel_key[16]; + EXEC SQL END DECLARE SECTION; + + strncpy(h_rel_key, key, sizeof(h_rel_key) - 1); + h_rel_key[sizeof(h_rel_key) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL DELETE FROM rc_hold_log + WHERE rec_key = :h_rel_key; + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("DELETE rc_hold_log"); + tx_abort(); + } else { + tx_log(TX_LOG_INFO, "[RC_OL_0010] 보류이력 정리 key=%s 삭제=%ld건", + key, (long)sqlca.sqlerrd[2]); + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0010] 보류해제 처리결과 key=%s result=%s", key, result); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/rc_ol_0013.c b/app/online/rc_ol_0013.c index e2a00e8..5d7fc7a 100644 --- a/app/online/rc_ol_0013.c +++ b/app/online/rc_ol_0013.c @@ -29,6 +29,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -101,7 +102,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 27 "app/online/rc_ol_0013.pgc" +#line 28 "app/online/rc_ol_0013.pgc" TX_SERVICE(RC_OL_0013, ctx) @@ -196,5 +197,71 @@ TX_SERVICE(RC_OL_0013, ctx) tx_buf_setlong(ctx->out, "TOL", tol); tx_buf_sets(ctx->out, "RESULT", result); tx_buf_sets(ctx->out, "STATUS", new_st); + + /* 허용오차 판정 이력을 rc_tolerance_log 에 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + + + + +#line 126 "app/online/rc_ol_0013.pgc" + char h_tl_key [ 16 ] ; + +#line 127 "app/online/rc_ol_0013.pgc" + long h_tl_appr ; + +#line 128 "app/online/rc_ol_0013.pgc" + long h_tl_cap ; + +#line 129 "app/online/rc_ol_0013.pgc" + long h_tl_diff ; + +#line 130 "app/online/rc_ol_0013.pgc" + long h_tl_tol ; + +#line 131 "app/online/rc_ol_0013.pgc" + char h_tl_result [ 12 ] ; +/* exec sql end declare section */ +#line 132 "app/online/rc_ol_0013.pgc" + + + strncpy(h_tl_key, key, sizeof(h_tl_key) - 1); + h_tl_key[sizeof(h_tl_key) - 1] = '\0'; + h_tl_appr = appr_amt; + h_tl_cap = rec.amount; + h_tl_diff = diff; + h_tl_tol = tol; + strncpy(h_tl_result, result, sizeof(h_tl_result) - 1); + h_tl_result[sizeof(h_tl_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_tolerance_log ( rec_key , appr_amt , cap_amt , diff_amt , tol_amt , match_result ) values ( $1 , $2 , $3 , $4 , $5 , $6 )", + ECPGt_char,(h_tl_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_tl_appr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_tl_cap),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_tl_diff),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_tl_tol),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_tl_result),(long)12,(long)1,(12)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 146 "app/online/rc_ol_0013.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_tolerance_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0013.pgc b/app/online/rc_ol_0013.pgc index 33aa170..ea56eb2 100644 --- a/app/online/rc_ol_0013.pgc +++ b/app/online/rc_ol_0013.pgc @@ -21,6 +21,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -118,5 +119,39 @@ TX_SERVICE(RC_OL_0013, ctx) tx_buf_setlong(ctx->out, "TOL", tol); tx_buf_sets(ctx->out, "RESULT", result); tx_buf_sets(ctx->out, "STATUS", new_st); + + /* 허용오차 판정 이력을 rc_tolerance_log 에 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_tl_key[16]; + long h_tl_appr; + long h_tl_cap; + long h_tl_diff; + long h_tl_tol; + char h_tl_result[12]; + EXEC SQL END DECLARE SECTION; + + strncpy(h_tl_key, key, sizeof(h_tl_key) - 1); + h_tl_key[sizeof(h_tl_key) - 1] = '\0'; + h_tl_appr = appr_amt; + h_tl_cap = rec.amount; + h_tl_diff = diff; + h_tl_tol = tol; + strncpy(h_tl_result, result, sizeof(h_tl_result) - 1); + h_tl_result[sizeof(h_tl_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO rc_tolerance_log + (rec_key, appr_amt, cap_amt, diff_amt, tol_amt, match_result) + VALUES (:h_tl_key, :h_tl_appr, :h_tl_cap, :h_tl_diff, :h_tl_tol, :h_tl_result); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_tolerance_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0015.c b/app/online/rc_ol_0015.c index 7c1ccbc..0a6bdaa 100644 --- a/app/online/rc_ol_0015.c +++ b/app/online/rc_ol_0015.c @@ -30,6 +30,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -102,7 +103,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 28 "app/online/rc_ol_0015.pgc" +#line 29 "app/online/rc_ol_0015.pgc" TX_SERVICE(RC_OL_0015, ctx) @@ -188,6 +189,48 @@ TX_SERVICE(RC_OL_0015, ctx) tx_buf_setlong(ctx->out, "CNTS", cnt_s); tx_buf_setlong(ctx->out, "TOTALCNT", totalcnt); tx_buf_setlong(ctx->out, "SUMAMT", sumamt); + + /* 원장에서 직접 총건수/총금액을 임베디드 SQL 로 재집계 (DBCNT/DBSUM) */ + { + /* exec sql begin declare section */ + + + + +#line 118 "app/online/rc_ol_0015.pgc" + char h_a15_bd [ 9 ] ; + +#line 119 "app/online/rc_ol_0015.pgc" + long h_a15_cnt ; + +#line 120 "app/online/rc_ol_0015.pgc" + long h_a15_sum ; +/* exec sql end declare section */ +#line 121 "app/online/rc_ol_0015.pgc" + + + strncpy(h_a15_bd, bizdate, sizeof(h_a15_bd) - 1); + h_a15_bd[sizeof(h_a15_bd) - 1] = '\0'; + h_a15_cnt = 0; + h_a15_sum = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) , coalesce ( SUM ( amount ) , 0 ) from rc_ledger where biz_date = $1 ", + ECPGt_char,(h_a15_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_a15_cnt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_a15_sum),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 131 "app/online/rc_ol_0015.pgc" + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger dbcnt/dbsum"); + h_a15_cnt = totalcnt; + h_a15_sum = sumamt; + } + tx_buf_setlong(ctx->out, "DBCNT", h_a15_cnt); + tx_buf_setlong(ctx->out, "DBSUM", h_a15_sum); + } if (totalcnt == 0) tx_log(TX_LOG_INFO, "[RC_OL_0015] 해당 영업일 원장 없음 date=%s", bizdate); diff --git a/app/online/rc_ol_0015.pgc b/app/online/rc_ol_0015.pgc index 4ea2789..252b75a 100644 --- a/app/online/rc_ol_0015.pgc +++ b/app/online/rc_ol_0015.pgc @@ -22,6 +22,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -110,6 +111,32 @@ TX_SERVICE(RC_OL_0015, ctx) tx_buf_setlong(ctx->out, "CNTS", cnt_s); tx_buf_setlong(ctx->out, "TOTALCNT", totalcnt); tx_buf_setlong(ctx->out, "SUMAMT", sumamt); + + /* 원장에서 직접 총건수/총금액을 임베디드 SQL 로 재집계 (DBCNT/DBSUM) */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_a15_bd[9]; + long h_a15_cnt; + long h_a15_sum; + EXEC SQL END DECLARE SECTION; + + strncpy(h_a15_bd, bizdate, sizeof(h_a15_bd) - 1); + h_a15_bd[sizeof(h_a15_bd) - 1] = '\0'; + h_a15_cnt = 0; + h_a15_sum = 0; + + EXEC SQL SELECT COUNT(*), COALESCE(SUM(amount), 0) + INTO :h_a15_cnt, :h_a15_sum + FROM rc_ledger + WHERE biz_date = :h_a15_bd; + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger dbcnt/dbsum"); + h_a15_cnt = totalcnt; + h_a15_sum = sumamt; + } + tx_buf_setlong(ctx->out, "DBCNT", h_a15_cnt); + tx_buf_setlong(ctx->out, "DBSUM", h_a15_sum); + } if (totalcnt == 0) tx_log(TX_LOG_INFO, "[RC_OL_0015] 해당 영업일 원장 없음 date=%s", bizdate); diff --git a/app/online/rc_ol_0016.c b/app/online/rc_ol_0016.c index 339bddf..cc48a3f 100644 --- a/app/online/rc_ol_0016.c +++ b/app/online/rc_ol_0016.c @@ -31,6 +31,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -103,7 +104,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 29 "app/online/rc_ol_0016.pgc" +#line 30 "app/online/rc_ol_0016.pgc" TX_SERVICE(RC_OL_0016, ctx) @@ -198,5 +199,71 @@ TX_SERVICE(RC_OL_0016, ctx) tx_buf_sets(ctx->out, "LEG2", leg2 ? "OK" : "NG"); tx_buf_sets(ctx->out, "RESULT", result); tx_buf_sets(ctx->out, "STATUS", new_st); + + /* 3-way 대사 판정 이력을 rc_3way_log 에 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + + + + +#line 128 "app/online/rc_ol_0016.pgc" + char h_tw_key [ 16 ] ; + +#line 129 "app/online/rc_ol_0016.pgc" + long h_tw_appr ; + +#line 130 "app/online/rc_ol_0016.pgc" + long h_tw_dep ; + +#line 131 "app/online/rc_ol_0016.pgc" + char h_tw_leg1 [ 2 ] ; + +#line 132 "app/online/rc_ol_0016.pgc" + char h_tw_leg2 [ 2 ] ; + +#line 133 "app/online/rc_ol_0016.pgc" + char h_tw_result [ 16 ] ; +/* exec sql end declare section */ +#line 134 "app/online/rc_ol_0016.pgc" + + + strncpy(h_tw_key, key, sizeof(h_tw_key) - 1); + h_tw_key[sizeof(h_tw_key) - 1] = '\0'; + h_tw_appr = appr_amt; + h_tw_dep = dep_amt; + h_tw_leg1[0] = leg1 ? 'Y' : 'N'; h_tw_leg1[1] = '\0'; + h_tw_leg2[0] = leg2 ? 'Y' : 'N'; h_tw_leg2[1] = '\0'; + strncpy(h_tw_result, result, sizeof(h_tw_result) - 1); + h_tw_result[sizeof(h_tw_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_3way_log ( rec_key , appr_amt , dep_amt , leg1_ok , leg2_ok , match_result ) values ( $1 , $2 , $3 , $4 , $5 , $6 )", + ECPGt_char,(h_tw_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_tw_appr),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_tw_dep),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_tw_leg1),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_tw_leg2),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_tw_result),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 148 "app/online/rc_ol_0016.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_3way_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0016.pgc b/app/online/rc_ol_0016.pgc index d31e496..11e78d7 100644 --- a/app/online/rc_ol_0016.pgc +++ b/app/online/rc_ol_0016.pgc @@ -23,6 +23,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -120,5 +121,39 @@ TX_SERVICE(RC_OL_0016, ctx) tx_buf_sets(ctx->out, "LEG2", leg2 ? "OK" : "NG"); tx_buf_sets(ctx->out, "RESULT", result); tx_buf_sets(ctx->out, "STATUS", new_st); + + /* 3-way 대사 판정 이력을 rc_3way_log 에 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_tw_key[16]; + long h_tw_appr; + long h_tw_dep; + char h_tw_leg1[2]; + char h_tw_leg2[2]; + char h_tw_result[16]; + EXEC SQL END DECLARE SECTION; + + strncpy(h_tw_key, key, sizeof(h_tw_key) - 1); + h_tw_key[sizeof(h_tw_key) - 1] = '\0'; + h_tw_appr = appr_amt; + h_tw_dep = dep_amt; + h_tw_leg1[0] = leg1 ? 'Y' : 'N'; h_tw_leg1[1] = '\0'; + h_tw_leg2[0] = leg2 ? 'Y' : 'N'; h_tw_leg2[1] = '\0'; + strncpy(h_tw_result, result, sizeof(h_tw_result) - 1); + h_tw_result[sizeof(h_tw_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO rc_3way_log + (rec_key, appr_amt, dep_amt, leg1_ok, leg2_ok, match_result) + VALUES (:h_tw_key, :h_tw_appr, :h_tw_dep, :h_tw_leg1, :h_tw_leg2, :h_tw_result); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_3way_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0019.c b/app/online/rc_ol_0019.c index 7866124..236f49e 100644 --- a/app/online/rc_ol_0019.c +++ b/app/online/rc_ol_0019.c @@ -29,6 +29,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -101,7 +102,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 27 "app/online/rc_ol_0019.pgc" +#line 28 "app/online/rc_ol_0019.pgc" TX_SERVICE(RC_OL_0019, ctx) @@ -193,6 +194,50 @@ TX_SERVICE(RC_OL_0019, ctx) tx_buf_sets(ctx->out, "NEWSTATUS", RC_ST_SETTLED); tx_buf_sets(ctx->out, "RESULT", "SETTLED"); + /* 정산계 연계 내역을 rc_settle_link 에 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + +#line 122 "app/online/rc_ol_0019.pgc" + char h_sl_key [ 16 ] ; + +#line 123 "app/online/rc_ol_0019.pgc" + char h_sl_merch [ 16 ] ; + +#line 124 "app/online/rc_ol_0019.pgc" + long h_sl_amt ; +/* exec sql end declare section */ +#line 125 "app/online/rc_ol_0019.pgc" + + + strncpy(h_sl_key, key, sizeof(h_sl_key) - 1); + h_sl_key[sizeof(h_sl_key) - 1] = '\0'; + strncpy(h_sl_merch, rec.merch_id, sizeof(h_sl_merch) - 1); + h_sl_merch[sizeof(h_sl_merch) - 1] = '\0'; + h_sl_amt = settle_amt; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_settle_link ( rec_key , merch_id , settle_amt , link_status ) values ( $1 , $2 , $3 , 'L' )", + ECPGt_char,(h_sl_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_sl_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sl_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 136 "app/online/rc_ol_0019.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_settle_link"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0019] 원장반영 완료 key=%s 반영액=%ld 상태=%s->%s", key, settle_amt, RC_ST_DONE, RC_ST_SETTLED); diff --git a/app/online/rc_ol_0019.pgc b/app/online/rc_ol_0019.pgc index e6dc7fb..7451ab8 100644 --- a/app/online/rc_ol_0019.pgc +++ b/app/online/rc_ol_0019.pgc @@ -21,6 +21,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -115,6 +116,33 @@ TX_SERVICE(RC_OL_0019, ctx) tx_buf_sets(ctx->out, "NEWSTATUS", RC_ST_SETTLED); tx_buf_sets(ctx->out, "RESULT", "SETTLED"); + /* 정산계 연계 내역을 rc_settle_link 에 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_sl_key[16]; + char h_sl_merch[16]; + long h_sl_amt; + EXEC SQL END DECLARE SECTION; + + strncpy(h_sl_key, key, sizeof(h_sl_key) - 1); + h_sl_key[sizeof(h_sl_key) - 1] = '\0'; + strncpy(h_sl_merch, rec.merch_id, sizeof(h_sl_merch) - 1); + h_sl_merch[sizeof(h_sl_merch) - 1] = '\0'; + h_sl_amt = settle_amt; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO rc_settle_link + (rec_key, merch_id, settle_amt, link_status) + VALUES (:h_sl_key, :h_sl_merch, :h_sl_amt, 'L'); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_settle_link"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0019] 원장반영 완료 key=%s 반영액=%ld 상태=%s->%s", key, settle_amt, RC_ST_DONE, RC_ST_SETTLED); diff --git a/app/online/rc_ol_0020.c b/app/online/rc_ol_0020.c index e491d44..4bfb2e3 100644 --- a/app/online/rc_ol_0020.c +++ b/app/online/rc_ol_0020.c @@ -31,6 +31,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -103,7 +104,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 29 "app/online/rc_ol_0020.pgc" +#line 30 "app/online/rc_ol_0020.pgc" TX_SERVICE(RC_OL_0020, ctx) @@ -193,6 +194,57 @@ TX_SERVICE(RC_OL_0020, ctx) tx_buf_sets(ctx->out, "STATUS", new_st); tx_buf_sets(ctx->out, "RESULT", result); + /* 부분대사 내역을 rc_partial_log 에 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + + +#line 122 "app/online/rc_ol_0020.pgc" + char h_pl_key [ 16 ] ; + +#line 123 "app/online/rc_ol_0020.pgc" + long h_pl_part ; + +#line 124 "app/online/rc_ol_0020.pgc" + long h_pl_remain ; + +#line 125 "app/online/rc_ol_0020.pgc" + char h_pl_result [ 12 ] ; +/* exec sql end declare section */ +#line 126 "app/online/rc_ol_0020.pgc" + + + strncpy(h_pl_key, key, sizeof(h_pl_key) - 1); + h_pl_key[sizeof(h_pl_key) - 1] = '\0'; + h_pl_part = part_amt; + h_pl_remain = remain; + strncpy(h_pl_result, result, sizeof(h_pl_result) - 1); + h_pl_result[sizeof(h_pl_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_partial_log ( rec_key , part_amt , remain_amt , part_result ) values ( $1 , $2 , $3 , $4 )", + ECPGt_char,(h_pl_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_pl_part),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_pl_remain),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_pl_result),(long)12,(long)1,(12)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 138 "app/online/rc_ol_0020.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_partial_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0020] 부분대사 완료 key=%s 결과=%s 잔여액=%ld 상태=%s", key, result, remain, new_st); diff --git a/app/online/rc_ol_0020.pgc b/app/online/rc_ol_0020.pgc index 9391f19..62ac9fa 100644 --- a/app/online/rc_ol_0020.pgc +++ b/app/online/rc_ol_0020.pgc @@ -23,6 +23,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -115,6 +116,35 @@ TX_SERVICE(RC_OL_0020, ctx) tx_buf_sets(ctx->out, "STATUS", new_st); tx_buf_sets(ctx->out, "RESULT", result); + /* 부분대사 내역을 rc_partial_log 에 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_pl_key[16]; + long h_pl_part; + long h_pl_remain; + char h_pl_result[12]; + EXEC SQL END DECLARE SECTION; + + strncpy(h_pl_key, key, sizeof(h_pl_key) - 1); + h_pl_key[sizeof(h_pl_key) - 1] = '\0'; + h_pl_part = part_amt; + h_pl_remain = remain; + strncpy(h_pl_result, result, sizeof(h_pl_result) - 1); + h_pl_result[sizeof(h_pl_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO rc_partial_log + (rec_key, part_amt, remain_amt, part_result) + VALUES (:h_pl_key, :h_pl_part, :h_pl_remain, :h_pl_result); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_partial_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0020] 부분대사 완료 key=%s 결과=%s 잔여액=%ld 상태=%s", key, result, remain, new_st); diff --git a/app/online/rc_ol_0021.c b/app/online/rc_ol_0021.c index 6b90257..75aedbc 100644 --- a/app/online/rc_ol_0021.c +++ b/app/online/rc_ol_0021.c @@ -30,6 +30,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -102,7 +103,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 28 "app/online/rc_ol_0021.pgc" +#line 29 "app/online/rc_ol_0021.pgc" TX_SERVICE(RC_OL_0021, ctx) @@ -191,6 +192,39 @@ TX_SERVICE(RC_OL_0021, ctx) tx_buf_setlong(ctx->out, "FEEDIFF", fee_diff); tx_buf_sets(ctx->out, "RESULT", result); + /* 참고: 동일 가맹점의 불일치('U') 건수를 임베디드 SQL 로 조회 (read-only) */ + { + /* exec sql begin declare section */ + + + +#line 120 "app/online/rc_ol_0021.pgc" + char h_r21_merch [ 16 ] ; + +#line 121 "app/online/rc_ol_0021.pgc" + long h_r21_cnt ; +/* exec sql end declare section */ +#line 122 "app/online/rc_ol_0021.pgc" + + + strncpy(h_r21_merch, rec.merch_id, sizeof(h_r21_merch) - 1); + h_r21_merch[sizeof(h_r21_merch) - 1] = '\0'; + h_r21_cnt = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from rc_ledger where merch_id = $1 and status = 'U'", + ECPGt_char,(h_r21_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_r21_cnt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 132 "app/online/rc_ol_0021.pgc" + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger merch unmatched"); + h_r21_cnt = 0; + } + tx_buf_setlong(ctx->out, "MERCHUNMATCH", h_r21_cnt); + } + tx_log(TX_LOG_INFO, "[RC_OL_0021] 리포트완료 key=%s 결과=%s 금액차=%ld 수수료차=%ld", key, result, amt_diff, fee_diff); diff --git a/app/online/rc_ol_0021.pgc b/app/online/rc_ol_0021.pgc index c84d30a..3a9d8cf 100644 --- a/app/online/rc_ol_0021.pgc +++ b/app/online/rc_ol_0021.pgc @@ -22,6 +22,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -113,6 +114,29 @@ TX_SERVICE(RC_OL_0021, ctx) tx_buf_setlong(ctx->out, "FEEDIFF", fee_diff); tx_buf_sets(ctx->out, "RESULT", result); + /* 참고: 동일 가맹점의 불일치('U') 건수를 임베디드 SQL 로 조회 (read-only) */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_r21_merch[16]; + long h_r21_cnt; + EXEC SQL END DECLARE SECTION; + + strncpy(h_r21_merch, rec.merch_id, sizeof(h_r21_merch) - 1); + h_r21_merch[sizeof(h_r21_merch) - 1] = '\0'; + h_r21_cnt = 0; + + EXEC SQL SELECT COUNT(*) + INTO :h_r21_cnt + FROM rc_ledger + WHERE merch_id = :h_r21_merch + AND status = 'U'; + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger merch unmatched"); + h_r21_cnt = 0; + } + tx_buf_setlong(ctx->out, "MERCHUNMATCH", h_r21_cnt); + } + tx_log(TX_LOG_INFO, "[RC_OL_0021] 리포트완료 key=%s 결과=%s 금액차=%ld 수수료차=%ld", key, result, amt_diff, fee_diff); diff --git a/app/online/rc_ol_0022.c b/app/online/rc_ol_0022.c index d4b6257..36d7c9c 100644 --- a/app/online/rc_ol_0022.c +++ b/app/online/rc_ol_0022.c @@ -34,6 +34,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -106,7 +107,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 32 "app/online/rc_ol_0022.pgc" +#line 33 "app/online/rc_ol_0022.pgc" TX_SERVICE(RC_OL_0022, ctx) @@ -197,6 +198,64 @@ TX_SERVICE(RC_OL_0022, ctx) tx_buf_sets(ctx->out, "ACTION", action); tx_buf_sets(ctx->out, "STATUS", new_st); + /* 자동보정 판정 이력을 rc_autocorrect_log 에 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + + + +#line 126 "app/online/rc_ol_0022.pgc" + char h_ac_key [ 16 ] ; + +#line 127 "app/online/rc_ol_0022.pgc" + long h_ac_diff ; + +#line 128 "app/online/rc_ol_0022.pgc" + long h_ac_tol ; + +#line 129 "app/online/rc_ol_0022.pgc" + long h_ac_adj ; + +#line 130 "app/online/rc_ol_0022.pgc" + char h_ac_action [ 12 ] ; +/* exec sql end declare section */ +#line 131 "app/online/rc_ol_0022.pgc" + + + strncpy(h_ac_key, key, sizeof(h_ac_key) - 1); + h_ac_key[sizeof(h_ac_key) - 1] = '\0'; + h_ac_diff = diff; + h_ac_tol = tol; + h_ac_adj = adj; + strncpy(h_ac_action, action, sizeof(h_ac_action) - 1); + h_ac_action[sizeof(h_ac_action) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_autocorrect_log ( rec_key , diff_amt , tol_amt , adj_amt , action ) values ( $1 , $2 , $3 , $4 , $5 )", + ECPGt_char,(h_ac_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_ac_diff),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_ac_tol),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_ac_adj),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_ac_action),(long)12,(long)1,(12)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 144 "app/online/rc_ol_0022.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_autocorrect_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0022] 자동보정 완료 key=%s 조치=%s", key, action); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0022.pgc b/app/online/rc_ol_0022.pgc index 9c84f6c..1a075fa 100644 --- a/app/online/rc_ol_0022.pgc +++ b/app/online/rc_ol_0022.pgc @@ -26,6 +26,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -119,6 +120,37 @@ TX_SERVICE(RC_OL_0022, ctx) tx_buf_sets(ctx->out, "ACTION", action); tx_buf_sets(ctx->out, "STATUS", new_st); + /* 자동보정 판정 이력을 rc_autocorrect_log 에 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_ac_key[16]; + long h_ac_diff; + long h_ac_tol; + long h_ac_adj; + char h_ac_action[12]; + EXEC SQL END DECLARE SECTION; + + strncpy(h_ac_key, key, sizeof(h_ac_key) - 1); + h_ac_key[sizeof(h_ac_key) - 1] = '\0'; + h_ac_diff = diff; + h_ac_tol = tol; + h_ac_adj = adj; + strncpy(h_ac_action, action, sizeof(h_ac_action) - 1); + h_ac_action[sizeof(h_ac_action) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO rc_autocorrect_log + (rec_key, diff_amt, tol_amt, adj_amt, action) + VALUES (:h_ac_key, :h_ac_diff, :h_ac_tol, :h_ac_adj, :h_ac_action); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_autocorrect_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0022] 자동보정 완료 key=%s 조치=%s", key, action); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0024.c b/app/online/rc_ol_0024.c index 4287475..e93c7d1 100644 --- a/app/online/rc_ol_0024.c +++ b/app/online/rc_ol_0024.c @@ -22,6 +22,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -94,7 +95,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 20 "app/online/rc_ol_0024.pgc" +#line 21 "app/online/rc_ol_0024.pgc" TX_SERVICE(RC_OL_0024, ctx) @@ -154,5 +155,47 @@ TX_SERVICE(RC_OL_0024, ctx) tx_buf_sets(ctx->out, "STATUS", rec.status); tx_buf_sets(ctx->out, "STAGE", stage); tx_buf_setlong(ctx->out, "PROGRESS", progress); + + /* 상세조회 보강: 원장에서 카드번호/영업일을 임베디드 SQL 로 직접 조회 */ + { + /* exec sql begin declare section */ + + + + +#line 84 "app/online/rc_ol_0024.pgc" + char h_d24_key [ 16 ] ; + +#line 85 "app/online/rc_ol_0024.pgc" + char h_d24_card [ 20 ] ; + +#line 86 "app/online/rc_ol_0024.pgc" + char h_d24_bd [ 9 ] ; +/* exec sql end declare section */ +#line 87 "app/online/rc_ol_0024.pgc" + + + strncpy(h_d24_key, key, sizeof(h_d24_key) - 1); + h_d24_key[sizeof(h_d24_key) - 1] = '\0'; + h_d24_card[0] = '\0'; + h_d24_bd[0] = '\0'; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select card_no , biz_date from rc_ledger where key = $1 ", + ECPGt_char,(h_d24_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_d24_card),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_d24_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 97 "app/online/rc_ol_0024.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) { + tx_buf_sets(ctx->out, "CARDNO", h_d24_card); + tx_buf_sets(ctx->out, "BIZDATE", h_d24_bd); + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger card/biz_date detail"); + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0024.pgc b/app/online/rc_ol_0024.pgc index bfd7a5e..e563383 100644 --- a/app/online/rc_ol_0024.pgc +++ b/app/online/rc_ol_0024.pgc @@ -14,6 +14,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -76,5 +77,31 @@ TX_SERVICE(RC_OL_0024, ctx) tx_buf_sets(ctx->out, "STATUS", rec.status); tx_buf_sets(ctx->out, "STAGE", stage); tx_buf_setlong(ctx->out, "PROGRESS", progress); + + /* 상세조회 보강: 원장에서 카드번호/영업일을 임베디드 SQL 로 직접 조회 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_d24_key[16]; + char h_d24_card[20]; + char h_d24_bd[9]; + EXEC SQL END DECLARE SECTION; + + strncpy(h_d24_key, key, sizeof(h_d24_key) - 1); + h_d24_key[sizeof(h_d24_key) - 1] = '\0'; + h_d24_card[0] = '\0'; + h_d24_bd[0] = '\0'; + + EXEC SQL SELECT card_no, biz_date + INTO :h_d24_card, :h_d24_bd + FROM rc_ledger + WHERE key = :h_d24_key; + if (sqlca.sqlcode == TX_SQL_OK) { + tx_buf_sets(ctx->out, "CARDNO", h_d24_card); + tx_buf_sets(ctx->out, "BIZDATE", h_d24_bd); + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger card/biz_date detail"); + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0025.c b/app/online/rc_ol_0025.c index bc3520b..b52b528 100644 --- a/app/online/rc_ol_0025.c +++ b/app/online/rc_ol_0025.c @@ -22,6 +22,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -94,7 +95,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 20 "app/online/rc_ol_0025.pgc" +#line 21 "app/online/rc_ol_0025.pgc" TX_SERVICE(RC_OL_0025, ctx) @@ -170,5 +171,64 @@ TX_SERVICE(RC_OL_0025, ctx) tx_buf_setlong(ctx->out, "FEEDIFF", feediff); tx_buf_sets(ctx->out, "RESULT", result); tx_buf_sets(ctx->out, "STATUS", new_st); + + /* 수수료 대사 결과를 rc_fee_log 에 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + + + +#line 100 "app/online/rc_ol_0025.pgc" + char h_fl_key [ 16 ] ; + +#line 101 "app/online/rc_ol_0025.pgc" + long h_fl_expfee ; + +#line 102 "app/online/rc_ol_0025.pgc" + long h_fl_fee ; + +#line 103 "app/online/rc_ol_0025.pgc" + long h_fl_diff ; + +#line 104 "app/online/rc_ol_0025.pgc" + char h_fl_result [ 16 ] ; +/* exec sql end declare section */ +#line 105 "app/online/rc_ol_0025.pgc" + + + strncpy(h_fl_key, key, sizeof(h_fl_key) - 1); + h_fl_key[sizeof(h_fl_key) - 1] = '\0'; + h_fl_expfee = expfee; + h_fl_fee = rec.fee; + h_fl_diff = feediff; + strncpy(h_fl_result, result, sizeof(h_fl_result) - 1); + h_fl_result[sizeof(h_fl_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_fee_log ( rec_key , exp_fee , act_fee , fee_diff , fee_result ) values ( $1 , $2 , $3 , $4 , $5 )", + ECPGt_char,(h_fl_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fl_expfee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fl_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fl_diff),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_fl_result),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 118 "app/online/rc_ol_0025.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_fee_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0025.pgc b/app/online/rc_ol_0025.pgc index a168ac5..1e2b29a 100644 --- a/app/online/rc_ol_0025.pgc +++ b/app/online/rc_ol_0025.pgc @@ -14,6 +14,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -92,5 +93,37 @@ TX_SERVICE(RC_OL_0025, ctx) tx_buf_setlong(ctx->out, "FEEDIFF", feediff); tx_buf_sets(ctx->out, "RESULT", result); tx_buf_sets(ctx->out, "STATUS", new_st); + + /* 수수료 대사 결과를 rc_fee_log 에 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_fl_key[16]; + long h_fl_expfee; + long h_fl_fee; + long h_fl_diff; + char h_fl_result[16]; + EXEC SQL END DECLARE SECTION; + + strncpy(h_fl_key, key, sizeof(h_fl_key) - 1); + h_fl_key[sizeof(h_fl_key) - 1] = '\0'; + h_fl_expfee = expfee; + h_fl_fee = rec.fee; + h_fl_diff = feediff; + strncpy(h_fl_result, result, sizeof(h_fl_result) - 1); + h_fl_result[sizeof(h_fl_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO rc_fee_log + (rec_key, exp_fee, act_fee, fee_diff, fee_result) + VALUES (:h_fl_key, :h_fl_expfee, :h_fl_fee, :h_fl_diff, :h_fl_result); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_fee_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0027.c b/app/online/rc_ol_0027.c index cf47fb6..9a781fb 100644 --- a/app/online/rc_ol_0027.c +++ b/app/online/rc_ol_0027.c @@ -32,6 +32,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -104,7 +105,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 30 "app/online/rc_ol_0027.pgc" +#line 31 "app/online/rc_ol_0027.pgc" TX_SERVICE(RC_OL_0027, ctx) @@ -193,6 +194,40 @@ TX_SERVICE(RC_OL_0027, ctx) tx_buf_setlong(ctx->out, "CNTS", cnt_s); tx_buf_setlong(ctx->out, "RECRATE", recrate); tx_buf_setlong(ctx->out, "UNRECRATE", unrecrate); + + /* 대사완료(M,S) 건수를 원장에서 직접 임베디드 SQL 로 집계 (DBRECDONE) */ + { + /* exec sql begin declare section */ + + + +#line 123 "app/online/rc_ol_0027.pgc" + char h_r27_bd [ 9 ] ; + +#line 124 "app/online/rc_ol_0027.pgc" + long h_r27_done ; +/* exec sql end declare section */ +#line 125 "app/online/rc_ol_0027.pgc" + + + strncpy(h_r27_bd, bizdate, sizeof(h_r27_bd) - 1); + h_r27_bd[sizeof(h_r27_bd) - 1] = '\0'; + h_r27_done = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from rc_ledger where biz_date = $1 and status in ( 'M' , 'S' )", + ECPGt_char,(h_r27_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_r27_done),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 135 "app/online/rc_ol_0027.pgc" + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger recdone"); + h_r27_done = recdone; + } + tx_buf_setlong(ctx->out, "DBRECDONE", h_r27_done); + } + tx_log(TX_LOG_INFO, "[RC_OL_0027] 대사율 조회 서비스 정상 종료 date=%s", bizdate); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0027.pgc b/app/online/rc_ol_0027.pgc index d69554a..cc0b149 100644 --- a/app/online/rc_ol_0027.pgc +++ b/app/online/rc_ol_0027.pgc @@ -24,6 +24,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -115,6 +116,30 @@ TX_SERVICE(RC_OL_0027, ctx) tx_buf_setlong(ctx->out, "CNTS", cnt_s); tx_buf_setlong(ctx->out, "RECRATE", recrate); tx_buf_setlong(ctx->out, "UNRECRATE", unrecrate); + + /* 대사완료(M,S) 건수를 원장에서 직접 임베디드 SQL 로 집계 (DBRECDONE) */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_r27_bd[9]; + long h_r27_done; + EXEC SQL END DECLARE SECTION; + + strncpy(h_r27_bd, bizdate, sizeof(h_r27_bd) - 1); + h_r27_bd[sizeof(h_r27_bd) - 1] = '\0'; + h_r27_done = 0; + + EXEC SQL SELECT COUNT(*) + INTO :h_r27_done + FROM rc_ledger + WHERE biz_date = :h_r27_bd + AND status IN ('M', 'S'); + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger recdone"); + h_r27_done = recdone; + } + tx_buf_setlong(ctx->out, "DBRECDONE", h_r27_done); + } + tx_log(TX_LOG_INFO, "[RC_OL_0027] 대사율 조회 서비스 정상 종료 date=%s", bizdate); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/rc_ol_0030.c b/app/online/rc_ol_0030.c index 03123f5..c363272 100644 --- a/app/online/rc_ol_0030.c +++ b/app/online/rc_ol_0030.c @@ -25,6 +25,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -97,7 +98,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 23 "app/online/rc_ol_0030.pgc" +#line 24 "app/online/rc_ol_0030.pgc" TX_SERVICE(RC_OL_0030, ctx) @@ -191,6 +192,51 @@ TX_SERVICE(RC_OL_0030, ctx) tx_buf_sets(ctx->out, "OLDSTATUS", oldstatus); tx_buf_sets(ctx->out, "NEWSTATUS", newstatus); tx_buf_sets(ctx->out, "RESULT", result); + /* 대사 취소 처리 이력을 rc_cancel_log 에 임베디드 SQL 로 적재 */ + { + /* exec sql begin declare section */ + + + + +#line 120 "app/online/rc_ol_0030.pgc" + char h_cl_key [ 16 ] ; + +#line 121 "app/online/rc_ol_0030.pgc" + char h_cl_old [ 2 ] ; + +#line 122 "app/online/rc_ol_0030.pgc" + char h_cl_result [ 12 ] ; +/* exec sql end declare section */ +#line 123 "app/online/rc_ol_0030.pgc" + + + strncpy(h_cl_key, key, sizeof(h_cl_key) - 1); + h_cl_key[sizeof(h_cl_key) - 1] = '\0'; + strncpy(h_cl_old, oldstatus, sizeof(h_cl_old) - 1); + h_cl_old[sizeof(h_cl_old) - 1] = '\0'; + strncpy(h_cl_result, result, sizeof(h_cl_result) - 1); + h_cl_result[sizeof(h_cl_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into rc_cancel_log ( rec_key , old_status , cancel_result ) values ( $1 , $2 , $3 )", + ECPGt_char,(h_cl_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_cl_old),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_cl_result),(long)12,(long)1,(12)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 135 "app/online/rc_ol_0030.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_cancel_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0030] 대사 취소 서비스 종료 key=%s %s→%s 결과=%s", key, oldstatus, newstatus, result); diff --git a/app/online/rc_ol_0030.pgc b/app/online/rc_ol_0030.pgc index ac2abf1..62d9f1e 100644 --- a/app/online/rc_ol_0030.pgc +++ b/app/online/rc_ol_0030.pgc @@ -17,6 +17,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -113,6 +114,34 @@ TX_SERVICE(RC_OL_0030, ctx) tx_buf_sets(ctx->out, "OLDSTATUS", oldstatus); tx_buf_sets(ctx->out, "NEWSTATUS", newstatus); tx_buf_sets(ctx->out, "RESULT", result); + /* 대사 취소 처리 이력을 rc_cancel_log 에 임베디드 SQL 로 적재 */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_cl_key[16]; + char h_cl_old[2]; + char h_cl_result[12]; + EXEC SQL END DECLARE SECTION; + + strncpy(h_cl_key, key, sizeof(h_cl_key) - 1); + h_cl_key[sizeof(h_cl_key) - 1] = '\0'; + strncpy(h_cl_old, oldstatus, sizeof(h_cl_old) - 1); + h_cl_old[sizeof(h_cl_old) - 1] = '\0'; + strncpy(h_cl_result, result, sizeof(h_cl_result) - 1); + h_cl_result[sizeof(h_cl_result) - 1] = '\0'; + + if (tx_begin() == TX_OK) { + EXEC SQL INSERT INTO rc_cancel_log + (rec_key, old_status, cancel_result) + VALUES (:h_cl_key, :h_cl_old, :h_cl_result); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT rc_cancel_log"); + tx_abort(); + } else { + tx_commit(); + } + } + } + tx_log(TX_LOG_INFO, "[RC_OL_0030] 대사 취소 서비스 종료 key=%s %s→%s 결과=%s", key, oldstatus, newstatus, result); diff --git a/app/online/rc_ol_0031.c b/app/online/rc_ol_0031.c index 648cfe2..5703c4a 100644 --- a/app/online/rc_ol_0031.c +++ b/app/online/rc_ol_0031.c @@ -34,6 +34,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -106,7 +107,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 32 "app/online/rc_ol_0031.pgc" +#line 33 "app/online/rc_ol_0031.pgc" TX_SERVICE(RC_OL_0031, ctx) @@ -192,6 +193,40 @@ TX_SERVICE(RC_OL_0031, ctx) tx_buf_setlong(ctx->out, "PROGRESS", progress); tx_buf_setlong(ctx->out, "COMPLETION", completion); tx_buf_setlong(ctx->out, "PENDING", pending); + + /* 잔여 미처리(접수 'R') 건수를 원장에서 직접 임베디드 SQL 로 집계 (DBPENDING) */ + { + /* exec sql begin declare section */ + + + +#line 122 "app/online/rc_ol_0031.pgc" + char h_r31_bd [ 9 ] ; + +#line 123 "app/online/rc_ol_0031.pgc" + long h_r31_pend ; +/* exec sql end declare section */ +#line 124 "app/online/rc_ol_0031.pgc" + + + strncpy(h_r31_bd, bizdate, sizeof(h_r31_bd) - 1); + h_r31_bd[sizeof(h_r31_bd) - 1] = '\0'; + h_r31_pend = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from rc_ledger where biz_date = $1 and status = 'R'", + ECPGt_char,(h_r31_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_r31_pend),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 134 "app/online/rc_ol_0031.pgc" + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger dbpending"); + h_r31_pend = pending; + } + tx_buf_setlong(ctx->out, "DBPENDING", h_r31_pend); + } + tx_log(TX_LOG_INFO, "[RC_OL_0031] 대사 진행률 조회 서비스 정상 종료 date=%s", bizdate); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/rc_ol_0031.pgc b/app/online/rc_ol_0031.pgc index 29e9dd5..3a9d7f8 100644 --- a/app/online/rc_ol_0031.pgc +++ b/app/online/rc_ol_0031.pgc @@ -26,6 +26,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -114,6 +115,30 @@ TX_SERVICE(RC_OL_0031, ctx) tx_buf_setlong(ctx->out, "PROGRESS", progress); tx_buf_setlong(ctx->out, "COMPLETION", completion); tx_buf_setlong(ctx->out, "PENDING", pending); + + /* 잔여 미처리(접수 'R') 건수를 원장에서 직접 임베디드 SQL 로 집계 (DBPENDING) */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_r31_bd[9]; + long h_r31_pend; + EXEC SQL END DECLARE SECTION; + + strncpy(h_r31_bd, bizdate, sizeof(h_r31_bd) - 1); + h_r31_bd[sizeof(h_r31_bd) - 1] = '\0'; + h_r31_pend = 0; + + EXEC SQL SELECT COUNT(*) + INTO :h_r31_pend + FROM rc_ledger + WHERE biz_date = :h_r31_bd + AND status = 'R'; + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger dbpending"); + h_r31_pend = pending; + } + tx_buf_setlong(ctx->out, "DBPENDING", h_r31_pend); + } + tx_log(TX_LOG_INFO, "[RC_OL_0031] 대사 진행률 조회 서비스 정상 종료 date=%s", bizdate); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/rc_ol_0032.c b/app/online/rc_ol_0032.c index a191f82..0204908 100644 --- a/app/online/rc_ol_0032.c +++ b/app/online/rc_ol_0032.c @@ -32,6 +32,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -104,7 +105,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 30 "app/online/rc_ol_0032.pgc" +#line 31 "app/online/rc_ol_0032.pgc" TX_SERVICE(RC_OL_0032, ctx) @@ -191,6 +192,49 @@ TX_SERVICE(RC_OL_0032, ctx) tx_buf_setlong(ctx->out, "SUMAMT", sumamt); tx_buf_setlong(ctx->out, "RECRATE", recrate); tx_buf_sets(ctx->out, "OVERALL", overall); + + /* 원장에서 직접 총건수/총수수료를 임베디드 SQL 로 집계 (DBCNT/FEESUM) */ + { + /* exec sql begin declare section */ + + + + +#line 121 "app/online/rc_ol_0032.pgc" + char h_r32_bd [ 9 ] ; + +#line 122 "app/online/rc_ol_0032.pgc" + long h_r32_cnt ; + +#line 123 "app/online/rc_ol_0032.pgc" + long h_r32_feesum ; +/* exec sql end declare section */ +#line 124 "app/online/rc_ol_0032.pgc" + + + strncpy(h_r32_bd, bizdate, sizeof(h_r32_bd) - 1); + h_r32_bd[sizeof(h_r32_bd) - 1] = '\0'; + h_r32_cnt = 0; + h_r32_feesum = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) , coalesce ( SUM ( fee ) , 0 ) from rc_ledger where biz_date = $1 ", + ECPGt_char,(h_r32_bd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_r32_cnt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_r32_feesum),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 134 "app/online/rc_ol_0032.pgc" + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger dbcnt/feesum"); + h_r32_cnt = total; + h_r32_feesum = 0; + } + tx_buf_setlong(ctx->out, "DBCNT", h_r32_cnt); + tx_buf_setlong(ctx->out, "FEESUM", h_r32_feesum); + } + tx_log(TX_LOG_INFO, "[RC_OL_0032] 대사 요약 리포트 서비스 정상 종료 date=%s 총평=%s 대사율=%ld%%", bizdate, overall, recrate); diff --git a/app/online/rc_ol_0032.pgc b/app/online/rc_ol_0032.pgc index 1f36334..aa12833 100644 --- a/app/online/rc_ol_0032.pgc +++ b/app/online/rc_ol_0032.pgc @@ -24,6 +24,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "rc_core.h" @@ -113,6 +114,33 @@ TX_SERVICE(RC_OL_0032, ctx) tx_buf_setlong(ctx->out, "SUMAMT", sumamt); tx_buf_setlong(ctx->out, "RECRATE", recrate); tx_buf_sets(ctx->out, "OVERALL", overall); + + /* 원장에서 직접 총건수/총수수료를 임베디드 SQL 로 집계 (DBCNT/FEESUM) */ + { + EXEC SQL BEGIN DECLARE SECTION; + char h_r32_bd[9]; + long h_r32_cnt; + long h_r32_feesum; + EXEC SQL END DECLARE SECTION; + + strncpy(h_r32_bd, bizdate, sizeof(h_r32_bd) - 1); + h_r32_bd[sizeof(h_r32_bd) - 1] = '\0'; + h_r32_cnt = 0; + h_r32_feesum = 0; + + EXEC SQL SELECT COUNT(*), COALESCE(SUM(fee), 0) + INTO :h_r32_cnt, :h_r32_feesum + FROM rc_ledger + WHERE biz_date = :h_r32_bd; + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT rc_ledger dbcnt/feesum"); + h_r32_cnt = total; + h_r32_feesum = 0; + } + tx_buf_setlong(ctx->out, "DBCNT", h_r32_cnt); + tx_buf_setlong(ctx->out, "FEESUM", h_r32_feesum); + } + tx_log(TX_LOG_INFO, "[RC_OL_0032] 대사 요약 리포트 서비스 정상 종료 date=%s 총평=%s 대사율=%ld%%", bizdate, overall, recrate); diff --git a/app/online/st_ol_0001.c b/app/online/st_ol_0001.c index 931c556..c8d1b1d 100644 --- a/app/online/st_ol_0001.c +++ b/app/online/st_ol_0001.c @@ -17,6 +17,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,11 +90,32 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0001.pgc" +#line 16 "app/online/st_ol_0001.pgc" TX_SERVICE(ST_OL_0001, ctx) { + /* exec sql begin declare section */ + + + + + +#line 21 "app/online/st_ol_0001.pgc" + char h_merch [ 16 ] ; + +#line 22 "app/online/st_ol_0001.pgc" + char h_merch_name [ 41 ] ; + +#line 23 "app/online/st_ol_0001.pgc" + char h_grade [ 2 ] ; + +#line 24 "app/online/st_ol_0001.pgc" + long h_mdr_bp ; +/* exec sql end declare section */ +#line 25 "app/online/st_ol_0001.pgc" + + st_rec_t rec; char key[16]; int rc; @@ -115,11 +137,43 @@ TX_SERVICE(ST_OL_0001, ctx) return; } + /* 원장 가맹점번호로 가맹점 마스터(등급/기본 MDR요율) 참조 조회 */ + strncpy(h_merch, rec.merch_id, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + memset(h_merch_name, 0, sizeof(h_merch_name)); + memset(h_grade, 0, sizeof(h_grade)); + h_mdr_bp = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select merch_name , grade , mdr_bp from st_merchant where merch_id = $1 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_merch_name),(long)41,(long)1,(41)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_grade),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_mdr_bp),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 58 "app/online/st_ol_0001.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[ST_OL_0001] 가맹점 마스터 없음 merch=%s", rec.merch_id); + strncpy(h_merch_name, "-", sizeof(h_merch_name) - 1); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT st_merchant"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); + tx_buf_sets(ctx->out, "MERCHNAME", h_merch_name); + tx_buf_sets(ctx->out, "GRADE", h_grade); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); + tx_buf_setlong(ctx->out, "MDRBP", h_mdr_bp); tx_buf_sets(ctx->out, "STATUS", rec.status); - tx_log(TX_LOG_INFO, "[ST_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); + tx_log(TX_LOG_INFO, "[ST_OL_0001] 조회완료 key=%s amount=%ld grade=%s", + key, rec.amount, h_grade); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0001.pgc b/app/online/st_ol_0001.pgc index c5cf283..d0c8eb1 100644 --- a/app/online/st_ol_0001.pgc +++ b/app/online/st_ol_0001.pgc @@ -9,6 +9,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -16,6 +17,13 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(ST_OL_0001, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + char h_merch_name[41]; + char h_grade[2]; + long h_mdr_bp; + EXEC SQL END DECLARE SECTION; + st_rec_t rec; char key[16]; int rc; @@ -37,11 +45,36 @@ TX_SERVICE(ST_OL_0001, ctx) return; } + /* 원장 가맹점번호로 가맹점 마스터(등급/기본 MDR요율) 참조 조회 */ + strncpy(h_merch, rec.merch_id, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + memset(h_merch_name, 0, sizeof(h_merch_name)); + memset(h_grade, 0, sizeof(h_grade)); + h_mdr_bp = 0; + + EXEC SQL SELECT merch_name, grade, mdr_bp + INTO :h_merch_name, :h_grade, :h_mdr_bp + FROM st_merchant + WHERE merch_id = :h_merch; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[ST_OL_0001] 가맹점 마스터 없음 merch=%s", rec.merch_id); + strncpy(h_merch_name, "-", sizeof(h_merch_name) - 1); + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT st_merchant"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); + tx_buf_sets(ctx->out, "MERCHNAME", h_merch_name); + tx_buf_sets(ctx->out, "GRADE", h_grade); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); + tx_buf_setlong(ctx->out, "MDRBP", h_mdr_bp); tx_buf_sets(ctx->out, "STATUS", rec.status); - tx_log(TX_LOG_INFO, "[ST_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); + tx_log(TX_LOG_INFO, "[ST_OL_0001] 조회완료 key=%s amount=%ld grade=%s", + key, rec.amount, h_grade); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0002.c b/app/online/st_ol_0002.c index 69ea53b..7267595 100644 --- a/app/online/st_ol_0002.c +++ b/app/online/st_ol_0002.c @@ -17,6 +17,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,15 +90,32 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0002.pgc" +#line 16 "app/online/st_ol_0002.pgc" TX_SERVICE(ST_OL_0002, ctx) { + /* exec sql begin declare section */ + + + + +#line 22 "app/online/st_ol_0002.pgc" + char h_bizdate [ 9 ] ; + +#line 23 "app/online/st_ol_0002.pgc" + long h_daycnt ; + +#line 24 "app/online/st_ol_0002.pgc" + long h_daysum ; +/* exec sql end declare section */ +#line 25 "app/online/st_ol_0002.pgc" + + st_rec_t rec; char key[16], merch[16], bizdate[16]; - long amount = 0, daycnt, daysum = 0; + long amount = 0, daycnt = 0, daysum = 0; int rc; tx_log(TX_LOG_INFO, "[ST_OL_0002] 정산대상 접수 집계 진입"); @@ -118,6 +136,10 @@ TX_SERVICE(ST_OL_0002, ctx) return; } + /* 접수 등록 (표준 DBIO) 를 트랜잭션 경계 안에서 수행 */ + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0002] tx_begin 경고"); + memset(&rec, 0, sizeof(rec)); strncpy(rec.key, key, sizeof(rec.key) - 1); strncpy(rec.merch_id, merch, sizeof(rec.merch_id) - 1); @@ -129,18 +151,40 @@ TX_SERVICE(ST_OL_0002, ctx) rc = st_rec_insert(&rec); if (rc != TX_OK) { tx_log(TX_LOG_ERROR, "[ST_OL_0002] 접수 등록 실패 rc=%d(%s)", rc, tx_strerror(rc)); + tx_abort(); tx_return(ctx, rc, ctx->out); return; } + tx_commit(); - daycnt = st_rec_count(bizdate, ST_ST_RECV); - st_rec_sum(bizdate, &daysum); + /* 당일 접수(status=R) 건수/합계 재집계 (임베디드 집계) */ + strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); + h_bizdate[sizeof(h_bizdate) - 1] = '\0'; + h_daycnt = 0; + h_daysum = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) , coalesce ( sum ( amount ) , 0 ) from st_ledger where biz_date = $1 and status = 'R'", + ECPGt_char,(h_bizdate),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_daycnt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_daysum),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 81 "app/online/st_ol_0002.pgc" + + + if (sqlca.sqlcode == TX_SQL_OK) { + daycnt = h_daycnt; + daysum = h_daysum; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT 당일접수집계"); + } tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "KEY", key); - tx_buf_setlong(ctx->out, "DAYCNT", (daycnt < 0) ? 0 : daycnt); - tx_buf_setlong(ctx->out, "DAYSUM", (daysum < 0) ? 0 : daysum); + tx_buf_setlong(ctx->out, "DAYCNT", daycnt); + tx_buf_setlong(ctx->out, "DAYSUM", daysum); tx_log(TX_LOG_INFO, "[ST_OL_0002] 접수완료 key=%s 당일건수=%ld 당일합=%ld", key, daycnt, daysum); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/st_ol_0002.pgc b/app/online/st_ol_0002.pgc index 2fbf3e9..7a0830c 100644 --- a/app/online/st_ol_0002.pgc +++ b/app/online/st_ol_0002.pgc @@ -9,6 +9,7 @@ #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -17,9 +18,15 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(ST_OL_0002, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_bizdate[9]; + long h_daycnt; + long h_daysum; + EXEC SQL END DECLARE SECTION; + st_rec_t rec; char key[16], merch[16], bizdate[16]; - long amount = 0, daycnt, daysum = 0; + long amount = 0, daycnt = 0, daysum = 0; int rc; tx_log(TX_LOG_INFO, "[ST_OL_0002] 정산대상 접수 집계 진입"); @@ -40,6 +47,10 @@ TX_SERVICE(ST_OL_0002, ctx) return; } + /* 접수 등록 (표준 DBIO) 를 트랜잭션 경계 안에서 수행 */ + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0002] tx_begin 경고"); + memset(&rec, 0, sizeof(rec)); strncpy(rec.key, key, sizeof(rec.key) - 1); strncpy(rec.merch_id, merch, sizeof(rec.merch_id) - 1); @@ -51,18 +62,36 @@ TX_SERVICE(ST_OL_0002, ctx) rc = st_rec_insert(&rec); if (rc != TX_OK) { tx_log(TX_LOG_ERROR, "[ST_OL_0002] 접수 등록 실패 rc=%d(%s)", rc, tx_strerror(rc)); + tx_abort(); tx_return(ctx, rc, ctx->out); return; } + tx_commit(); - daycnt = st_rec_count(bizdate, ST_ST_RECV); - st_rec_sum(bizdate, &daysum); + /* 당일 접수(status=R) 건수/합계 재집계 (임베디드 집계) */ + strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); + h_bizdate[sizeof(h_bizdate) - 1] = '\0'; + h_daycnt = 0; + h_daysum = 0; + + EXEC SQL SELECT count(*), coalesce(sum(amount), 0) + INTO :h_daycnt, :h_daysum + FROM st_ledger + WHERE biz_date = :h_bizdate + AND status = 'R'; + + if (sqlca.sqlcode == TX_SQL_OK) { + daycnt = h_daycnt; + daysum = h_daysum; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT 당일접수집계"); + } tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "KEY", key); - tx_buf_setlong(ctx->out, "DAYCNT", (daycnt < 0) ? 0 : daycnt); - tx_buf_setlong(ctx->out, "DAYSUM", (daysum < 0) ? 0 : daysum); + tx_buf_setlong(ctx->out, "DAYCNT", daycnt); + tx_buf_setlong(ctx->out, "DAYSUM", daysum); tx_log(TX_LOG_INFO, "[ST_OL_0002] 접수완료 key=%s 당일건수=%ld 당일합=%ld", key, daycnt, daysum); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/st_ol_0003.c b/app/online/st_ol_0003.c index 9a8375a..f7ee26d 100644 --- a/app/online/st_ol_0003.c +++ b/app/online/st_ol_0003.c @@ -11,12 +11,14 @@ * st_ol_0003.pgc - 가맹점 할인수수료(MDR) 계산 (ST_OL_0003) [tier=easy] * * 가맹점 거래금액에 MDR(가맹점 할인수수료) 요율(만분율)을 적용하여 - * 수수료와 정산순액(net)을 원단위 반올림으로 산출한다. + * 수수료와 정산순액(net)을 원단위 반올림으로 산출한다. 요율 미입력 시 + * 가맹점 수수료율 마스터(st_fee_rate)에서 계약 요율을 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0003.pgc" +#line 17 "app/online/st_ol_0003.pgc" @@ -103,8 +105,22 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0003, ctx) { + /* exec sql begin declare section */ + + + +#line 31 "app/online/st_ol_0003.pgc" + char h_merch [ 16 ] ; + +#line 32 "app/online/st_ol_0003.pgc" + long h_mdr_bp ; +/* exec sql end declare section */ +#line 33 "app/online/st_ol_0003.pgc" + + char merch[16]; long amount = 0, mdr_bp = 0, fee, net; + const char *rate_src = "INPUT"; tx_log(TX_LOG_INFO, "[ST_OL_0003] MDR 수수료 계산 진입"); @@ -115,6 +131,31 @@ TX_SERVICE(ST_OL_0003, ctx) tx_buf_getlong(ctx->in, "AMOUNT", &amount); tx_buf_getlong(ctx->in, "MDRBP", &mdr_bp); + /* 요율 미입력 시 가맹점 계약요율 조회 */ + if (mdr_bp <= 0) { + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_mdr_bp = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select mdr_bp from st_fee_rate where merch_id = $1 and fee_type = 'MDR'", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_mdr_bp),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 57 "app/online/st_ol_0003.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) { + mdr_bp = h_mdr_bp; + rate_src = "CONTRACT"; + } else if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + mdr_bp = 180; /* 기본 표준요율 1.80% */ + rate_src = "DEFAULT"; + } else { + TX_DBIO_LOG_ERR("SELECT st_fee_rate"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + } + if (!amount_is_valid(amount) || mdr_bp <= 0 || mdr_bp > 10000) { tx_log(TX_LOG_WARN, "[ST_OL_0003] 요율/금액 오류 amount=%ld bp=%ld", amount, mdr_bp); tx_buf_reset(ctx->out); @@ -129,11 +170,12 @@ TX_SERVICE(ST_OL_0003, ctx) tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); + tx_buf_sets(ctx->out, "RATESRC", rate_src); tx_buf_setlong(ctx->out, "AMOUNT", amount); tx_buf_setlong(ctx->out, "MDRBP", mdr_bp); tx_buf_setlong(ctx->out, "FEE", fee); tx_buf_setlong(ctx->out, "NET", net); - tx_log(TX_LOG_INFO, "[ST_OL_0003] MDR 산출 amount=%ld bp=%ld fee=%ld net=%ld", - amount, mdr_bp, fee, net); + tx_log(TX_LOG_INFO, "[ST_OL_0003] MDR 산출 amount=%ld bp=%ld(%s) fee=%ld net=%ld", + amount, mdr_bp, rate_src, fee, net); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0003.pgc b/app/online/st_ol_0003.pgc index 8a0fa68..462761c 100644 --- a/app/online/st_ol_0003.pgc +++ b/app/online/st_ol_0003.pgc @@ -3,12 +3,14 @@ * st_ol_0003.pgc - 가맹점 할인수수료(MDR) 계산 (ST_OL_0003) [tier=easy] * * 가맹점 거래금액에 MDR(가맹점 할인수수료) 요율(만분율)을 적용하여 - * 수수료와 정산순액(net)을 원단위 반올림으로 산출한다. + * 수수료와 정산순액(net)을 원단위 반올림으로 산출한다. 요율 미입력 시 + * 가맹점 수수료율 마스터(st_fee_rate)에서 계약 요율을 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,8 +27,14 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0003, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + long h_mdr_bp; + EXEC SQL END DECLARE SECTION; + char merch[16]; long amount = 0, mdr_bp = 0, fee, net; + const char *rate_src = "INPUT"; tx_log(TX_LOG_INFO, "[ST_OL_0003] MDR 수수료 계산 진입"); @@ -37,6 +45,29 @@ TX_SERVICE(ST_OL_0003, ctx) tx_buf_getlong(ctx->in, "AMOUNT", &amount); tx_buf_getlong(ctx->in, "MDRBP", &mdr_bp); + /* 요율 미입력 시 가맹점 계약요율 조회 */ + if (mdr_bp <= 0) { + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_mdr_bp = 0; + EXEC SQL SELECT mdr_bp + INTO :h_mdr_bp + FROM st_fee_rate + WHERE merch_id = :h_merch + AND fee_type = 'MDR'; + if (sqlca.sqlcode == TX_SQL_OK) { + mdr_bp = h_mdr_bp; + rate_src = "CONTRACT"; + } else if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + mdr_bp = 180; /* 기본 표준요율 1.80% */ + rate_src = "DEFAULT"; + } else { + TX_DBIO_LOG_ERR("SELECT st_fee_rate"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + } + if (!amount_is_valid(amount) || mdr_bp <= 0 || mdr_bp > 10000) { tx_log(TX_LOG_WARN, "[ST_OL_0003] 요율/금액 오류 amount=%ld bp=%ld", amount, mdr_bp); tx_buf_reset(ctx->out); @@ -51,11 +82,12 @@ TX_SERVICE(ST_OL_0003, ctx) tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); + tx_buf_sets(ctx->out, "RATESRC", rate_src); tx_buf_setlong(ctx->out, "AMOUNT", amount); tx_buf_setlong(ctx->out, "MDRBP", mdr_bp); tx_buf_setlong(ctx->out, "FEE", fee); tx_buf_setlong(ctx->out, "NET", net); - tx_log(TX_LOG_INFO, "[ST_OL_0003] MDR 산출 amount=%ld bp=%ld fee=%ld net=%ld", - amount, mdr_bp, fee, net); + tx_log(TX_LOG_INFO, "[ST_OL_0003] MDR 산출 amount=%ld bp=%ld(%s) fee=%ld net=%ld", + amount, mdr_bp, rate_src, fee, net); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0004.c b/app/online/st_ol_0004.c index 86b49c2..7ed6530 100644 --- a/app/online/st_ol_0004.c +++ b/app/online/st_ol_0004.c @@ -11,12 +11,14 @@ * st_ol_0004.pgc - VAN 수수료(건당 정액) 계산 (ST_OL_0004) [tier=hard] * * 승인 건수에 VAN 건당 정액 수수료를 곱하여 총 VAN 수수료를 산출한다. - * 정률 요소가 없는 건당 과금(전표/통신비) 모델. + * 정률 요소가 없는 건당 과금(전표/통신비) 모델. 승인건수 미입력 시 + * 당일 원장(st_ledger)의 실제 승인건수를 집계하여 사용한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,13 +91,34 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0004.pgc" +#line 17 "app/online/st_ol_0004.pgc" TX_SERVICE(ST_OL_0004, ctx) { - char merch[16]; + /* exec sql begin declare section */ + + + + + +#line 23 "app/online/st_ol_0004.pgc" + char h_merch [ 16 ] ; + +#line 24 "app/online/st_ol_0004.pgc" + char h_bizdate [ 9 ] ; + +#line 25 "app/online/st_ol_0004.pgc" + long h_txn_cnt ; + +#line 26 "app/online/st_ol_0004.pgc" + long h_unit_fee ; +/* exec sql end declare section */ +#line 27 "app/online/st_ol_0004.pgc" + + + char merch[16], bizdate[16]; long amount = 0, txn_cnt = 0, unit_fee = 0, van_fee, net; tx_log(TX_LOG_INFO, "[ST_OL_0004] VAN 건당정액 수수료 계산 진입"); @@ -106,8 +129,45 @@ TX_SERVICE(ST_OL_0004, ctx) } tx_buf_getlong(ctx->in, "AMOUNT", &amount); tx_buf_getlong(ctx->in, "TXNCNT", &txn_cnt); - if (tx_buf_getlong(ctx->in, "UNITFEE", &unit_fee) != TX_OK || unit_fee <= 0) - unit_fee = 120; /* VAN 건당 기본 정액 120원 */ + + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + + /* VAN 건당 정액 요율 조회 (없으면 기본 120원) */ + h_unit_fee = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select unit_fee from st_van_fee where merch_id = $1 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_unit_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 49 "app/online/st_ol_0004.pgc" + + if (sqlca.sqlcode == TX_SQL_OK && h_unit_fee > 0) + unit_fee = h_unit_fee; + else if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT st_van_fee"); + if (unit_fee <= 0) + unit_fee = 120; + + /* 승인건수 미입력 시 당일 원장 실제 승인건수 집계 */ + if (txn_cnt <= 0 && + tx_buf_get(ctx->in, "BIZDATE", bizdate, sizeof(bizdate)) == TX_OK && + date_is_valid(bizdate)) { + strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); + h_bizdate[sizeof(h_bizdate) - 1] = '\0'; + h_txn_cnt = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from st_ledger where merch_id = $1 and biz_date = $2 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_bizdate),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_txn_cnt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 68 "app/online/st_ol_0004.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) + txn_cnt = h_txn_cnt; + } if (txn_cnt <= 0) { tx_log(TX_LOG_WARN, "[ST_OL_0004] 승인건수 오류 cnt=%ld", txn_cnt); diff --git a/app/online/st_ol_0004.pgc b/app/online/st_ol_0004.pgc index eaaa598..fa01494 100644 --- a/app/online/st_ol_0004.pgc +++ b/app/online/st_ol_0004.pgc @@ -3,12 +3,14 @@ * st_ol_0004.pgc - VAN 수수료(건당 정액) 계산 (ST_OL_0004) [tier=hard] * * 승인 건수에 VAN 건당 정액 수수료를 곱하여 총 VAN 수수료를 산출한다. - * 정률 요소가 없는 건당 과금(전표/통신비) 모델. + * 정률 요소가 없는 건당 과금(전표/통신비) 모델. 승인건수 미입력 시 + * 당일 원장(st_ledger)의 실제 승인건수를 집계하여 사용한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -17,7 +19,14 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(ST_OL_0004, ctx) { - char merch[16]; + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + char h_bizdate[9]; + long h_txn_cnt; + long h_unit_fee; + EXEC SQL END DECLARE SECTION; + + char merch[16], bizdate[16]; long amount = 0, txn_cnt = 0, unit_fee = 0, van_fee, net; tx_log(TX_LOG_INFO, "[ST_OL_0004] VAN 건당정액 수수료 계산 진입"); @@ -28,8 +37,38 @@ TX_SERVICE(ST_OL_0004, ctx) } tx_buf_getlong(ctx->in, "AMOUNT", &amount); tx_buf_getlong(ctx->in, "TXNCNT", &txn_cnt); - if (tx_buf_getlong(ctx->in, "UNITFEE", &unit_fee) != TX_OK || unit_fee <= 0) - unit_fee = 120; /* VAN 건당 기본 정액 120원 */ + + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + + /* VAN 건당 정액 요율 조회 (없으면 기본 120원) */ + h_unit_fee = 0; + EXEC SQL SELECT unit_fee + INTO :h_unit_fee + FROM st_van_fee + WHERE merch_id = :h_merch; + if (sqlca.sqlcode == TX_SQL_OK && h_unit_fee > 0) + unit_fee = h_unit_fee; + else if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT st_van_fee"); + if (unit_fee <= 0) + unit_fee = 120; + + /* 승인건수 미입력 시 당일 원장 실제 승인건수 집계 */ + if (txn_cnt <= 0 && + tx_buf_get(ctx->in, "BIZDATE", bizdate, sizeof(bizdate)) == TX_OK && + date_is_valid(bizdate)) { + strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); + h_bizdate[sizeof(h_bizdate) - 1] = '\0'; + h_txn_cnt = 0; + EXEC SQL SELECT count(*) + INTO :h_txn_cnt + FROM st_ledger + WHERE merch_id = :h_merch + AND biz_date = :h_bizdate; + if (sqlca.sqlcode == TX_SQL_OK) + txn_cnt = h_txn_cnt; + } if (txn_cnt <= 0) { tx_log(TX_LOG_WARN, "[ST_OL_0004] 승인건수 오류 cnt=%ld", txn_cnt); diff --git a/app/online/st_ol_0005.c b/app/online/st_ol_0005.c index a0e1a03..8b808fa 100644 --- a/app/online/st_ol_0005.c +++ b/app/online/st_ol_0005.c @@ -11,12 +11,14 @@ * st_ol_0005.pgc - 중계 수수료 계산 (ST_OL_0005) [tier=easy] * * 결제 중계사(PG/중계) 수수료 = 정률(만분율) + 건당 정액 합산 모델. - * 정률분과 정액분을 각각 산출하여 합산한다. + * 정률분과 정액분을 각각 산출하여 합산한다. 요율 미입력 시 중계사 + * 수수료 마스터(st_relay_fee)에서 계약 요율/정액을 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0005.pgc" +#line 17 "app/online/st_ol_0005.pgc" @@ -103,6 +105,23 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0005, ctx) { + /* exec sql begin declare section */ + + + + +#line 31 "app/online/st_ol_0005.pgc" + char h_merch [ 16 ] ; + +#line 32 "app/online/st_ol_0005.pgc" + long h_rate_bp ; + +#line 33 "app/online/st_ol_0005.pgc" + long h_flat_fee ; +/* exec sql end declare section */ +#line 34 "app/online/st_ol_0005.pgc" + + char merch[16]; long amount = 0, rate_bp = 0, txn_cnt = 0, flat = 0; long rate_part, flat_part, relay_fee, net; @@ -116,10 +135,37 @@ TX_SERVICE(ST_OL_0005, ctx) tx_buf_getlong(ctx->in, "AMOUNT", &amount); tx_buf_getlong(ctx->in, "RATEBP", &rate_bp); tx_buf_getlong(ctx->in, "TXNCNT", &txn_cnt); - if (tx_buf_getlong(ctx->in, "FLATFEE", &flat) != TX_OK || flat < 0) - flat = 30; /* 중계 건당 기본 30원 */ + tx_buf_getlong(ctx->in, "FLATFEE", &flat); if (txn_cnt <= 0) txn_cnt = 1; + /* 요율/정액 미입력 시 중계사 계약 요율 조회 */ + if (rate_bp <= 0 || flat < 0) { + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_rate_bp = 0; + h_flat_fee = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select rate_bp , flat_fee from st_relay_fee where merch_id = $1 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_rate_bp),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_flat_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 61 "app/online/st_ol_0005.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) { + if (rate_bp <= 0) rate_bp = h_rate_bp; + if (flat < 0) flat = h_flat_fee; + } else if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + if (flat < 0) flat = 30; /* 중계 건당 기본 30원 */ + } else { + TX_DBIO_LOG_ERR("SELECT st_relay_fee"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + } + if (flat < 0) flat = 30; + if (!amount_is_valid(amount) || rate_bp < 0 || rate_bp > 10000) { tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); diff --git a/app/online/st_ol_0005.pgc b/app/online/st_ol_0005.pgc index ad14bf7..902aab2 100644 --- a/app/online/st_ol_0005.pgc +++ b/app/online/st_ol_0005.pgc @@ -3,12 +3,14 @@ * st_ol_0005.pgc - 중계 수수료 계산 (ST_OL_0005) [tier=easy] * * 결제 중계사(PG/중계) 수수료 = 정률(만분율) + 건당 정액 합산 모델. - * 정률분과 정액분을 각각 산출하여 합산한다. + * 정률분과 정액분을 각각 산출하여 합산한다. 요율 미입력 시 중계사 + * 수수료 마스터(st_relay_fee)에서 계약 요율/정액을 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,6 +27,12 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0005, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + long h_rate_bp; + long h_flat_fee; + EXEC SQL END DECLARE SECTION; + char merch[16]; long amount = 0, rate_bp = 0, txn_cnt = 0, flat = 0; long rate_part, flat_part, relay_fee, net; @@ -38,10 +46,32 @@ TX_SERVICE(ST_OL_0005, ctx) tx_buf_getlong(ctx->in, "AMOUNT", &amount); tx_buf_getlong(ctx->in, "RATEBP", &rate_bp); tx_buf_getlong(ctx->in, "TXNCNT", &txn_cnt); - if (tx_buf_getlong(ctx->in, "FLATFEE", &flat) != TX_OK || flat < 0) - flat = 30; /* 중계 건당 기본 30원 */ + tx_buf_getlong(ctx->in, "FLATFEE", &flat); if (txn_cnt <= 0) txn_cnt = 1; + /* 요율/정액 미입력 시 중계사 계약 요율 조회 */ + if (rate_bp <= 0 || flat < 0) { + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_rate_bp = 0; + h_flat_fee = 0; + EXEC SQL SELECT rate_bp, flat_fee + INTO :h_rate_bp, :h_flat_fee + FROM st_relay_fee + WHERE merch_id = :h_merch; + if (sqlca.sqlcode == TX_SQL_OK) { + if (rate_bp <= 0) rate_bp = h_rate_bp; + if (flat < 0) flat = h_flat_fee; + } else if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + if (flat < 0) flat = 30; /* 중계 건당 기본 30원 */ + } else { + TX_DBIO_LOG_ERR("SELECT st_relay_fee"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + } + if (flat < 0) flat = 30; + if (!amount_is_valid(amount) || rate_bp < 0 || rate_bp > 10000) { tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); diff --git a/app/online/st_ol_0006.c b/app/online/st_ol_0006.c index 455759d..fd2a04e 100644 --- a/app/online/st_ol_0006.c +++ b/app/online/st_ol_0006.c @@ -11,12 +11,14 @@ * st_ol_0006.pgc - 정산금 netting 계산 (ST_OL_0006) [tier=easy] * * 매출 - 환불 - 수수료 - 조정 을 상계(netting)하여 최종 지급 정산금을 - * 산출한다. 음수(가맹점 채무) 방향도 부호로 반환한다. + * 산출한다. 음수(가맹점 채무) 방향도 부호로 반환한다. 매출/환불 미입력 + * 시 당일 원장(st_ledger)에서 정산/실패 상태 합계로 대체 집계한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,13 +91,34 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0006.pgc" +#line 17 "app/online/st_ol_0006.pgc" TX_SERVICE(ST_OL_0006, ctx) { - char merch[16]; + /* exec sql begin declare section */ + + + + + +#line 23 "app/online/st_ol_0006.pgc" + char h_merch [ 16 ] ; + +#line 24 "app/online/st_ol_0006.pgc" + char h_bizdate [ 9 ] ; + +#line 25 "app/online/st_ol_0006.pgc" + long h_gross ; + +#line 26 "app/online/st_ol_0006.pgc" + long h_refund ; +/* exec sql end declare section */ +#line 27 "app/online/st_ol_0006.pgc" + + + char merch[16], bizdate[16]; long gross = 0, refund = 0, fee = 0, adj = 0, net; const char *dir; @@ -110,6 +133,35 @@ TX_SERVICE(ST_OL_0006, ctx) tx_buf_getlong(ctx->in, "FEE", &fee); tx_buf_getlong(ctx->in, "ADJ", &adj); + /* 매출/환불 미입력 시 원장에서 상태별 합계로 대체 집계 */ + if ((gross <= 0 || refund <= 0) && + tx_buf_get(ctx->in, "BIZDATE", bizdate, sizeof(bizdate)) == TX_OK && + date_is_valid(bizdate)) { + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); + h_bizdate[sizeof(h_bizdate) - 1] = '\0'; + h_gross = 0; + h_refund = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) filter ( where amount >= 0 ) , 0 ) , coalesce ( - sum ( amount ) filter ( where amount < 0 ) , 0 ) from st_ledger where merch_id = $1 and biz_date = $2 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_bizdate),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_gross),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_refund),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 60 "app/online/st_ol_0006.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) { + if (gross <= 0) gross = h_gross; + if (refund <= 0) refund = h_refund; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT netting 집계"); + } + } + if (gross < 0 || refund < 0 || fee < 0) { tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); diff --git a/app/online/st_ol_0006.pgc b/app/online/st_ol_0006.pgc index 61d6ea4..74bcda8 100644 --- a/app/online/st_ol_0006.pgc +++ b/app/online/st_ol_0006.pgc @@ -3,12 +3,14 @@ * st_ol_0006.pgc - 정산금 netting 계산 (ST_OL_0006) [tier=easy] * * 매출 - 환불 - 수수료 - 조정 을 상계(netting)하여 최종 지급 정산금을 - * 산출한다. 음수(가맹점 채무) 방향도 부호로 반환한다. + * 산출한다. 음수(가맹점 채무) 방향도 부호로 반환한다. 매출/환불 미입력 + * 시 당일 원장(st_ledger)에서 정산/실패 상태 합계로 대체 집계한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -17,7 +19,14 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(ST_OL_0006, ctx) { - char merch[16]; + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + char h_bizdate[9]; + long h_gross; + long h_refund; + EXEC SQL END DECLARE SECTION; + + char merch[16], bizdate[16]; long gross = 0, refund = 0, fee = 0, adj = 0, net; const char *dir; @@ -32,6 +41,31 @@ TX_SERVICE(ST_OL_0006, ctx) tx_buf_getlong(ctx->in, "FEE", &fee); tx_buf_getlong(ctx->in, "ADJ", &adj); + /* 매출/환불 미입력 시 원장에서 상태별 합계로 대체 집계 */ + if ((gross <= 0 || refund <= 0) && + tx_buf_get(ctx->in, "BIZDATE", bizdate, sizeof(bizdate)) == TX_OK && + date_is_valid(bizdate)) { + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); + h_bizdate[sizeof(h_bizdate) - 1] = '\0'; + h_gross = 0; + h_refund = 0; + EXEC SQL SELECT + coalesce(sum(amount) filter (where amount >= 0), 0), + coalesce(-sum(amount) filter (where amount < 0), 0) + INTO :h_gross, :h_refund + FROM st_ledger + WHERE merch_id = :h_merch + AND biz_date = :h_bizdate; + if (sqlca.sqlcode == TX_SQL_OK) { + if (gross <= 0) gross = h_gross; + if (refund <= 0) refund = h_refund; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT netting 집계"); + } + } + if (gross < 0 || refund < 0 || fee < 0) { tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); diff --git a/app/online/st_ol_0007.c b/app/online/st_ol_0007.c index 4987b37..d3cac4f 100644 --- a/app/online/st_ol_0007.c +++ b/app/online/st_ol_0007.c @@ -11,12 +11,14 @@ * st_ol_0007.pgc - 정산 부가세(VAT) 처리 (ST_OL_0007) [tier=medium] * * 수수료(공급가액) 기준 부가세 10% 를 산출한다. 공급가/세액/합계를 - * 원단위 반올림으로 분해하여 세금계산서 항목을 구성한다. + * 원단위 반올림으로 분해하여 세금계산서 항목을 구성하고, 부가세 대장 + * (st_vat_book)에 기표 로그를 적재한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0007.pgc" +#line 17 "app/online/st_ol_0007.pgc" @@ -103,6 +105,27 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0007, ctx) { + /* exec sql begin declare section */ + + + + + +#line 31 "app/online/st_ol_0007.pgc" + char h_merch [ 16 ] ; + +#line 32 "app/online/st_ol_0007.pgc" + long h_supply ; + +#line 33 "app/online/st_ol_0007.pgc" + long h_vat ; + +#line 34 "app/online/st_ol_0007.pgc" + long h_total ; +/* exec sql end declare section */ +#line 35 "app/online/st_ol_0007.pgc" + + char merch[16]; long fee_supply = 0, vat, total; @@ -123,6 +146,38 @@ TX_SERVICE(ST_OL_0007, ctx) vat = st_fee_round(fee_supply, 1000); /* 10% = 1000 만분율 */ total = fee_supply + vat; + /* 부가세 대장 기표 (트랜잭션 경계) */ + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_supply = fee_supply; + h_vat = vat; + h_total = total; + + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0007] tx_begin 경고"); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into st_vat_book ( merch_id , supply_amt , vat_amt , total_amt , book_ts ) values ( $1 , $2 , $3 , $4 , now ( ) )", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_supply),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_vat),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_total),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 70 "app/online/st_ol_0007.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT st_vat_book"); + tx_abort(); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_commit(); + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); diff --git a/app/online/st_ol_0007.pgc b/app/online/st_ol_0007.pgc index 0b417cb..20e6203 100644 --- a/app/online/st_ol_0007.pgc +++ b/app/online/st_ol_0007.pgc @@ -3,12 +3,14 @@ * st_ol_0007.pgc - 정산 부가세(VAT) 처리 (ST_OL_0007) [tier=medium] * * 수수료(공급가액) 기준 부가세 10% 를 산출한다. 공급가/세액/합계를 - * 원단위 반올림으로 분해하여 세금계산서 항목을 구성한다. + * 원단위 반올림으로 분해하여 세금계산서 항목을 구성하고, 부가세 대장 + * (st_vat_book)에 기표 로그를 적재한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,6 +27,13 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0007, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + long h_supply; + long h_vat; + long h_total; + EXEC SQL END DECLARE SECTION; + char merch[16]; long fee_supply = 0, vat, total; @@ -45,6 +54,31 @@ TX_SERVICE(ST_OL_0007, ctx) vat = st_fee_round(fee_supply, 1000); /* 10% = 1000 만분율 */ total = fee_supply + vat; + /* 부가세 대장 기표 (트랜잭션 경계) */ + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_supply = fee_supply; + h_vat = vat; + h_total = total; + + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0007] tx_begin 경고"); + + EXEC SQL INSERT INTO st_vat_book + (merch_id, supply_amt, vat_amt, total_amt, book_ts) + VALUES + (:h_merch, :h_supply, :h_vat, :h_total, now()); + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT st_vat_book"); + tx_abort(); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_commit(); + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); diff --git a/app/online/st_ol_0008.c b/app/online/st_ol_0008.c index 7ac6658..b64514b 100644 --- a/app/online/st_ol_0008.c +++ b/app/online/st_ol_0008.c @@ -11,12 +11,14 @@ * st_ol_0008.pgc - 정산 원천징수 계산 (ST_OL_0008) [tier=easy] * * 사업소득 원천징수 3.3%(소득세 3% + 지방소득세 0.3%) 를 산출하고 - * 원천징수 후 실지급액을 계산한다. + * 원천징수 후 실지급액을 계산한다. 가맹점 세무구분(st_merchant_tax)이 + * 원천징수 비대상이면 세액 0 으로 처리한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0008.pgc" +#line 17 "app/online/st_ol_0008.pgc" @@ -103,8 +105,26 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0008, ctx) { + /* exec sql begin declare section */ + + + + +#line 31 "app/online/st_ol_0008.pgc" + char h_merch [ 16 ] ; + +#line 32 "app/online/st_ol_0008.pgc" + char h_tax_type [ 2 ] ; + +#line 33 "app/online/st_ol_0008.pgc" + long h_income_bp ; +/* exec sql end declare section */ +#line 34 "app/online/st_ol_0008.pgc" + + char merch[16]; - long base = 0, income_tax, local_tax, withhold, payable; + long base = 0, income_tax, local_tax, withhold, payable, income_bp = 300; + const char *tax_type = "B"; tx_log(TX_LOG_INFO, "[ST_OL_0008] 원천징수 계산 진입"); @@ -120,19 +140,47 @@ TX_SERVICE(ST_OL_0008, ctx) return; } - income_tax = st_fee_round(base, 300); /* 소득세 3.0% */ - local_tax = st_fee_round(income_tax, 1000);/* 지방세 = 소득세의 10% */ - withhold = income_tax + local_tax; - payable = base - withhold; + /* 가맹점 세무구분/소득세율 조회 */ + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + memset(h_tax_type, 0, sizeof(h_tax_type)); + h_income_bp = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select tax_type , income_bp from st_merchant_tax where merch_id = $1 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_tax_type),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_income_bp),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 62 "app/online/st_ol_0008.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) { + tax_type = (h_tax_type[0] == 'C') ? "C" : "B"; + if (h_income_bp > 0) income_bp = h_income_bp; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT st_merchant_tax"); + } + + if (strcmp(tax_type, "C") == 0) { + /* 법인(C): 원천징수 비대상 */ + income_tax = 0; + local_tax = 0; + } else { + income_tax = st_fee_round(base, income_bp); /* 소득세 */ + local_tax = st_fee_round(income_tax, 1000); /* 지방세 = 소득세의 10% */ + } + withhold = income_tax + local_tax; + payable = base - withhold; tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); + tx_buf_sets(ctx->out, "TAXTYPE", tax_type); tx_buf_setlong(ctx->out, "INCOMETAX", income_tax); tx_buf_setlong(ctx->out, "LOCALTAX", local_tax); tx_buf_setlong(ctx->out, "WITHHOLD", withhold); tx_buf_setlong(ctx->out, "PAYABLE", payable); - tx_log(TX_LOG_INFO, "[ST_OL_0008] 원천징수 base=%ld 세액=%ld 실지급=%ld", - base, withhold, payable); + tx_log(TX_LOG_INFO, "[ST_OL_0008] 원천징수 base=%ld 세액=%ld 실지급=%ld type=%s", + base, withhold, payable, tax_type); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0008.pgc b/app/online/st_ol_0008.pgc index fb02850..2af1309 100644 --- a/app/online/st_ol_0008.pgc +++ b/app/online/st_ol_0008.pgc @@ -3,12 +3,14 @@ * st_ol_0008.pgc - 정산 원천징수 계산 (ST_OL_0008) [tier=easy] * * 사업소득 원천징수 3.3%(소득세 3% + 지방소득세 0.3%) 를 산출하고 - * 원천징수 후 실지급액을 계산한다. + * 원천징수 후 실지급액을 계산한다. 가맹점 세무구분(st_merchant_tax)이 + * 원천징수 비대상이면 세액 0 으로 처리한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,8 +27,15 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0008, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + char h_tax_type[2]; + long h_income_bp; + EXEC SQL END DECLARE SECTION; + char merch[16]; - long base = 0, income_tax, local_tax, withhold, payable; + long base = 0, income_tax, local_tax, withhold, payable, income_bp = 300; + const char *tax_type = "B"; tx_log(TX_LOG_INFO, "[ST_OL_0008] 원천징수 계산 진입"); @@ -42,19 +51,42 @@ TX_SERVICE(ST_OL_0008, ctx) return; } - income_tax = st_fee_round(base, 300); /* 소득세 3.0% */ - local_tax = st_fee_round(income_tax, 1000);/* 지방세 = 소득세의 10% */ - withhold = income_tax + local_tax; - payable = base - withhold; + /* 가맹점 세무구분/소득세율 조회 */ + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + memset(h_tax_type, 0, sizeof(h_tax_type)); + h_income_bp = 0; + EXEC SQL SELECT tax_type, income_bp + INTO :h_tax_type, :h_income_bp + FROM st_merchant_tax + WHERE merch_id = :h_merch; + if (sqlca.sqlcode == TX_SQL_OK) { + tax_type = (h_tax_type[0] == 'C') ? "C" : "B"; + if (h_income_bp > 0) income_bp = h_income_bp; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT st_merchant_tax"); + } + + if (strcmp(tax_type, "C") == 0) { + /* 법인(C): 원천징수 비대상 */ + income_tax = 0; + local_tax = 0; + } else { + income_tax = st_fee_round(base, income_bp); /* 소득세 */ + local_tax = st_fee_round(income_tax, 1000); /* 지방세 = 소득세의 10% */ + } + withhold = income_tax + local_tax; + payable = base - withhold; tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); + tx_buf_sets(ctx->out, "TAXTYPE", tax_type); tx_buf_setlong(ctx->out, "INCOMETAX", income_tax); tx_buf_setlong(ctx->out, "LOCALTAX", local_tax); tx_buf_setlong(ctx->out, "WITHHOLD", withhold); tx_buf_setlong(ctx->out, "PAYABLE", payable); - tx_log(TX_LOG_INFO, "[ST_OL_0008] 원천징수 base=%ld 세액=%ld 실지급=%ld", - base, withhold, payable); + tx_log(TX_LOG_INFO, "[ST_OL_0008] 원천징수 base=%ld 세액=%ld 실지급=%ld type=%s", + base, withhold, payable, tax_type); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0009.c b/app/online/st_ol_0009.c index 60855f6..6c7b149 100644 --- a/app/online/st_ol_0009.c +++ b/app/online/st_ol_0009.c @@ -11,12 +11,14 @@ * st_ol_0009.pgc - 정산 조정(가감) 처리 (ST_OL_0009) [tier=medium] * * 확정 정산금에 조정사유코드별 가산/차감 조정을 반영한다. - * 차감이 정산금을 초과하면 조정 불가로 반려한다. + * 차감이 정산금을 초과하면 조정 불가로 반려한다. 조정 확정 시 + * 조정이력(st_adjust_hist)에 감사 로그를 적재한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,12 +91,37 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0009.pgc" +#line 17 "app/online/st_ol_0009.pgc" TX_SERVICE(ST_OL_0009, ctx) { + /* exec sql begin declare section */ + + + + + + +#line 23 "app/online/st_ol_0009.pgc" + char h_merch [ 16 ] ; + +#line 24 "app/online/st_ol_0009.pgc" + char h_reason [ 8 ] ; + +#line 25 "app/online/st_ol_0009.pgc" + long h_base ; + +#line 26 "app/online/st_ol_0009.pgc" + long h_adj ; + +#line 27 "app/online/st_ol_0009.pgc" + long h_result ; +/* exec sql end declare section */ +#line 28 "app/online/st_ol_0009.pgc" + + char merch[16], reason[8]; long base = 0, adj = 0, result; int sign; @@ -120,6 +147,40 @@ TX_SERVICE(ST_OL_0009, ctx) } sign = (adj >= 0) ? 1 : -1; + /* 조정이력 적재 (트랜잭션 경계) */ + strncpy(h_merch, merch, sizeof(h_merch) - 1); h_merch[sizeof(h_merch) - 1] = '\0'; + strncpy(h_reason, reason, sizeof(h_reason) - 1); h_reason[sizeof(h_reason) - 1] = '\0'; + h_base = base; + h_adj = adj; + h_result = result; + + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0009] tx_begin 경고"); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into st_adjust_hist ( merch_id , reason_code , base_amt , adj_amt , result_amt , adj_ts ) values ( $1 , $2 , $3 , $4 , $5 , now ( ) )", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_reason),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_base),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_adj),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_result),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 68 "app/online/st_ol_0009.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT st_adjust_hist"); + tx_abort(); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_commit(); + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); diff --git a/app/online/st_ol_0009.pgc b/app/online/st_ol_0009.pgc index 49e7d00..033208f 100644 --- a/app/online/st_ol_0009.pgc +++ b/app/online/st_ol_0009.pgc @@ -3,12 +3,14 @@ * st_ol_0009.pgc - 정산 조정(가감) 처리 (ST_OL_0009) [tier=medium] * * 확정 정산금에 조정사유코드별 가산/차감 조정을 반영한다. - * 차감이 정산금을 초과하면 조정 불가로 반려한다. + * 차감이 정산금을 초과하면 조정 불가로 반려한다. 조정 확정 시 + * 조정이력(st_adjust_hist)에 감사 로그를 적재한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -17,6 +19,14 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(ST_OL_0009, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + char h_reason[8]; + long h_base; + long h_adj; + long h_result; + EXEC SQL END DECLARE SECTION; + char merch[16], reason[8]; long base = 0, adj = 0, result; int sign; @@ -42,6 +52,31 @@ TX_SERVICE(ST_OL_0009, ctx) } sign = (adj >= 0) ? 1 : -1; + /* 조정이력 적재 (트랜잭션 경계) */ + strncpy(h_merch, merch, sizeof(h_merch) - 1); h_merch[sizeof(h_merch) - 1] = '\0'; + strncpy(h_reason, reason, sizeof(h_reason) - 1); h_reason[sizeof(h_reason) - 1] = '\0'; + h_base = base; + h_adj = adj; + h_result = result; + + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0009] tx_begin 경고"); + + EXEC SQL INSERT INTO st_adjust_hist + (merch_id, reason_code, base_amt, adj_amt, result_amt, adj_ts) + VALUES + (:h_merch, :h_reason, :h_base, :h_adj, :h_result, now()); + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT st_adjust_hist"); + tx_abort(); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_commit(); + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); diff --git a/app/online/st_ol_0010.c b/app/online/st_ol_0010.c index 0423b91..c3da407 100644 --- a/app/online/st_ol_0010.c +++ b/app/online/st_ol_0010.c @@ -11,12 +11,14 @@ * st_ol_0010.pgc - 선정산 한도/금액 산정 (ST_OL_0010) [tier=easy] * * 예상 정산순액에 선정산 인출비율을 적용하여 선지급 가능액을 산정하고 - * 선이자(일할)를 차감한 실 선지급액을 산출한다. + * 선이자(일할)를 차감한 실 선지급액을 산출한다. 인출비율/연리 미입력 시 + * 가맹점 선정산 약정(st_advance_policy)에서 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0010.pgc" +#line 17 "app/online/st_ol_0010.pgc" @@ -103,6 +105,23 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0010, ctx) { + /* exec sql begin declare section */ + + + + +#line 31 "app/online/st_ol_0010.pgc" + char h_merch [ 16 ] ; + +#line 32 "app/online/st_ol_0010.pgc" + long h_adv_rate_bp ; + +#line 33 "app/online/st_ol_0010.pgc" + long h_annual_bp ; +/* exec sql end declare section */ +#line 34 "app/online/st_ol_0010.pgc" + + char merch[16]; long expected = 0, advance_rate_bp = 0, days = 0, annual_bp = 0; long advance, interest, payout; @@ -117,9 +136,32 @@ TX_SERVICE(ST_OL_0010, ctx) tx_buf_getlong(ctx->in, "ADVRATE", &advance_rate_bp); tx_buf_getlong(ctx->in, "DAYS", &days); tx_buf_getlong(ctx->in, "ANNUALBP", &annual_bp); + if (days < 0) days = 0; + + /* 선정산 약정 조회 (인출비율/연리) */ + if (advance_rate_bp <= 0 || annual_bp <= 0) { + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_adv_rate_bp = 0; + h_annual_bp = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select advance_rate_bp , annual_bp from st_advance_policy where merch_id = $1 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_adv_rate_bp),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_annual_bp),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 61 "app/online/st_ol_0010.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) { + if (advance_rate_bp <= 0) advance_rate_bp = h_adv_rate_bp; + if (annual_bp <= 0) annual_bp = h_annual_bp; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT st_advance_policy"); + } + } if (advance_rate_bp <= 0 || advance_rate_bp > 10000) advance_rate_bp = 8000; /* 80% */ if (annual_bp <= 0) annual_bp = 700; /* 연 7% */ - if (days < 0) days = 0; if (expected <= 0) { tx_buf_reset(ctx->out); diff --git a/app/online/st_ol_0010.pgc b/app/online/st_ol_0010.pgc index faff6a1..32b8ab9 100644 --- a/app/online/st_ol_0010.pgc +++ b/app/online/st_ol_0010.pgc @@ -3,12 +3,14 @@ * st_ol_0010.pgc - 선정산 한도/금액 산정 (ST_OL_0010) [tier=easy] * * 예상 정산순액에 선정산 인출비율을 적용하여 선지급 가능액을 산정하고 - * 선이자(일할)를 차감한 실 선지급액을 산출한다. + * 선이자(일할)를 차감한 실 선지급액을 산출한다. 인출비율/연리 미입력 시 + * 가맹점 선정산 약정(st_advance_policy)에서 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,6 +27,12 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0010, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + long h_adv_rate_bp; + long h_annual_bp; + EXEC SQL END DECLARE SECTION; + char merch[16]; long expected = 0, advance_rate_bp = 0, days = 0, annual_bp = 0; long advance, interest, payout; @@ -39,9 +47,27 @@ TX_SERVICE(ST_OL_0010, ctx) tx_buf_getlong(ctx->in, "ADVRATE", &advance_rate_bp); tx_buf_getlong(ctx->in, "DAYS", &days); tx_buf_getlong(ctx->in, "ANNUALBP", &annual_bp); + if (days < 0) days = 0; + + /* 선정산 약정 조회 (인출비율/연리) */ + if (advance_rate_bp <= 0 || annual_bp <= 0) { + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_adv_rate_bp = 0; + h_annual_bp = 0; + EXEC SQL SELECT advance_rate_bp, annual_bp + INTO :h_adv_rate_bp, :h_annual_bp + FROM st_advance_policy + WHERE merch_id = :h_merch; + if (sqlca.sqlcode == TX_SQL_OK) { + if (advance_rate_bp <= 0) advance_rate_bp = h_adv_rate_bp; + if (annual_bp <= 0) annual_bp = h_annual_bp; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT st_advance_policy"); + } + } if (advance_rate_bp <= 0 || advance_rate_bp > 10000) advance_rate_bp = 8000; /* 80% */ if (annual_bp <= 0) annual_bp = 700; /* 연 7% */ - if (days < 0) days = 0; if (expected <= 0) { tx_buf_reset(ctx->out); diff --git a/app/online/st_ol_0011.c b/app/online/st_ol_0011.c index e6d627b..ca06416 100644 --- a/app/online/st_ol_0011.c +++ b/app/online/st_ol_0011.c @@ -12,11 +12,13 @@ * * 정산 지급 지연일수에 대한 지연이자(연리 일할)를 산출한다. * 이자 = 원금 x 연리(만분율) x 지연일수 / 365 (원단위 반올림). + * 연리 미입력 시 지연이자 정책(st_delay_policy)에서 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0011.pgc" +#line 17 "app/online/st_ol_0011.pgc" @@ -103,7 +105,20 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0011, ctx) { - char merch[16]; + /* exec sql begin declare section */ + + + +#line 31 "app/online/st_ol_0011.pgc" + char h_grade [ 2 ] ; + +#line 32 "app/online/st_ol_0011.pgc" + long h_annual_bp ; +/* exec sql end declare section */ +#line 33 "app/online/st_ol_0011.pgc" + + + char merch[16], grade[4]; long principal = 0, annual_bp = 0, delay_days = 0, interest, total; tx_log(TX_LOG_INFO, "[ST_OL_0011] 지연정산 이자 계산 진입"); @@ -115,6 +130,26 @@ TX_SERVICE(ST_OL_0011, ctx) tx_buf_getlong(ctx->in, "PRINCIPAL", &principal); tx_buf_getlong(ctx->in, "ANNUALBP", &annual_bp); tx_buf_getlong(ctx->in, "DELAYDAYS", &delay_days); + if (tx_buf_get(ctx->in, "GRADE", grade, sizeof(grade)) != TX_OK) + strncpy(grade, "A", sizeof(grade) - 1); + + /* 등급별 지연이자 연리 조회 */ + if (annual_bp <= 0) { + strncpy(h_grade, grade, sizeof(h_grade) - 1); + h_grade[sizeof(h_grade) - 1] = '\0'; + h_annual_bp = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select annual_bp from st_delay_policy where grade = $1 ", + ECPGt_char,(h_grade),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_annual_bp),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 58 "app/online/st_ol_0011.pgc" + + if (sqlca.sqlcode == TX_SQL_OK && h_annual_bp > 0) + annual_bp = h_annual_bp; + else if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT st_delay_policy"); + } if (annual_bp <= 0) annual_bp = 1500; /* 지연이자 연 15% */ if (principal <= 0 || delay_days < 0) { @@ -131,6 +166,7 @@ TX_SERVICE(ST_OL_0011, ctx) tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); tx_buf_setlong(ctx->out, "PRINCIPAL", principal); + tx_buf_setlong(ctx->out, "ANNUALBP", annual_bp); tx_buf_setlong(ctx->out, "DELAYDAYS", delay_days); tx_buf_setlong(ctx->out, "INTEREST", interest); tx_buf_setlong(ctx->out, "TOTAL", total); diff --git a/app/online/st_ol_0011.pgc b/app/online/st_ol_0011.pgc index 5107edc..58443cb 100644 --- a/app/online/st_ol_0011.pgc +++ b/app/online/st_ol_0011.pgc @@ -4,11 +4,13 @@ * * 정산 지급 지연일수에 대한 지연이자(연리 일할)를 산출한다. * 이자 = 원금 x 연리(만분율) x 지연일수 / 365 (원단위 반올림). + * 연리 미입력 시 지연이자 정책(st_delay_policy)에서 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,7 +27,12 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0011, ctx) { - char merch[16]; + EXEC SQL BEGIN DECLARE SECTION; + char h_grade[2]; + long h_annual_bp; + EXEC SQL END DECLARE SECTION; + + char merch[16], grade[4]; long principal = 0, annual_bp = 0, delay_days = 0, interest, total; tx_log(TX_LOG_INFO, "[ST_OL_0011] 지연정산 이자 계산 진입"); @@ -37,6 +44,23 @@ TX_SERVICE(ST_OL_0011, ctx) tx_buf_getlong(ctx->in, "PRINCIPAL", &principal); tx_buf_getlong(ctx->in, "ANNUALBP", &annual_bp); tx_buf_getlong(ctx->in, "DELAYDAYS", &delay_days); + if (tx_buf_get(ctx->in, "GRADE", grade, sizeof(grade)) != TX_OK) + strncpy(grade, "A", sizeof(grade) - 1); + + /* 등급별 지연이자 연리 조회 */ + if (annual_bp <= 0) { + strncpy(h_grade, grade, sizeof(h_grade) - 1); + h_grade[sizeof(h_grade) - 1] = '\0'; + h_annual_bp = 0; + EXEC SQL SELECT annual_bp + INTO :h_annual_bp + FROM st_delay_policy + WHERE grade = :h_grade; + if (sqlca.sqlcode == TX_SQL_OK && h_annual_bp > 0) + annual_bp = h_annual_bp; + else if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT st_delay_policy"); + } if (annual_bp <= 0) annual_bp = 1500; /* 지연이자 연 15% */ if (principal <= 0 || delay_days < 0) { @@ -53,6 +77,7 @@ TX_SERVICE(ST_OL_0011, ctx) tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); tx_buf_setlong(ctx->out, "PRINCIPAL", principal); + tx_buf_setlong(ctx->out, "ANNUALBP", annual_bp); tx_buf_setlong(ctx->out, "DELAYDAYS", delay_days); tx_buf_setlong(ctx->out, "INTEREST", interest); tx_buf_setlong(ctx->out, "TOTAL", total); diff --git a/app/online/st_ol_0012.c b/app/online/st_ol_0012.c index 711e817..557190a 100644 --- a/app/online/st_ol_0012.c +++ b/app/online/st_ol_0012.c @@ -11,12 +11,14 @@ * st_ol_0012.pgc - 정산 보류/해제 처리 (ST_OL_0012) [tier=easy] * * 정산 원장 건에 대해 지급 보류(HOLD) 또는 보류 해제(RELEASE)를 수행한다. - * 보류는 상태 U, 해제는 상태 R 로 전이한다. + * 보류는 상태 U, 해제는 상태 R 로 전이한다. 상태 전이는 원장(st_ledger)에 + * 직접 임베디드 UPDATE 로 반영하고, 반영 건수를 대조한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,12 +91,33 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0012.pgc" +#line 17 "app/online/st_ol_0012.pgc" TX_SERVICE(ST_OL_0012, ctx) { + /* exec sql begin declare section */ + + + + + +#line 23 "app/online/st_ol_0012.pgc" + char h_key [ 16 ] ; + +#line 24 "app/online/st_ol_0012.pgc" + char h_newst [ 2 ] ; + +#line 25 "app/online/st_ol_0012.pgc" + char h_curst [ 2 ] ; + +#line 26 "app/online/st_ol_0012.pgc" + long h_affected ; +/* exec sql end declare section */ +#line 27 "app/online/st_ol_0012.pgc" + + st_rec_t rec; char key[16], action[12]; const char *newst; @@ -126,17 +149,41 @@ TX_SERVICE(ST_OL_0012, ctx) return; } - rc = st_rec_update_status(key, newst); - if (rc != TX_OK) { - tx_return(ctx, rc, ctx->out); + /* 상태 전이 임베디드 UPDATE (현재 상태와 다를 때만) */ + strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + strncpy(h_newst, newst, sizeof(h_newst) - 1); h_newst[sizeof(h_newst) - 1] = '\0'; + strncpy(h_curst, rec.status, sizeof(h_curst) - 1); h_curst[sizeof(h_curst) - 1] = '\0'; + + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0012] tx_begin 경고"); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_ledger set status = $1 , upd_ts = now ( ) where key = $2 and status <> $3 ", + ECPGt_char,(h_newst),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_newst),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 71 "app/online/st_ol_0012.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE st_ledger 보류/해제"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); return; } + h_affected = sqlca.sqlerrd[2]; + tx_commit(); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "KEY", key); tx_buf_sets(ctx->out, "ACTION", action); + tx_buf_sets(ctx->out, "PREVSTATUS", h_curst); tx_buf_sets(ctx->out, "STATUS", newst); - tx_log(TX_LOG_INFO, "[ST_OL_0012] %s key=%s -> status=%s", action, key, newst); + tx_buf_setlong(ctx->out, "AFFECTED", (long)h_affected); + tx_log(TX_LOG_INFO, "[ST_OL_0012] %s key=%s %s->%s 반영=%ld", + action, key, h_curst, newst, (long)h_affected); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0012.pgc b/app/online/st_ol_0012.pgc index eb6d4e2..7d81a3a 100644 --- a/app/online/st_ol_0012.pgc +++ b/app/online/st_ol_0012.pgc @@ -3,12 +3,14 @@ * st_ol_0012.pgc - 정산 보류/해제 처리 (ST_OL_0012) [tier=easy] * * 정산 원장 건에 대해 지급 보류(HOLD) 또는 보류 해제(RELEASE)를 수행한다. - * 보류는 상태 U, 해제는 상태 R 로 전이한다. + * 보류는 상태 U, 해제는 상태 R 로 전이한다. 상태 전이는 원장(st_ledger)에 + * 직접 임베디드 UPDATE 로 반영하고, 반영 건수를 대조한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -17,6 +19,13 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(ST_OL_0012, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_key[16]; + char h_newst[2]; + char h_curst[2]; + long h_affected; + EXEC SQL END DECLARE SECTION; + st_rec_t rec; char key[16], action[12]; const char *newst; @@ -48,17 +57,36 @@ TX_SERVICE(ST_OL_0012, ctx) return; } - rc = st_rec_update_status(key, newst); - if (rc != TX_OK) { - tx_return(ctx, rc, ctx->out); + /* 상태 전이 임베디드 UPDATE (현재 상태와 다를 때만) */ + strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; + strncpy(h_newst, newst, sizeof(h_newst) - 1); h_newst[sizeof(h_newst) - 1] = '\0'; + strncpy(h_curst, rec.status, sizeof(h_curst) - 1); h_curst[sizeof(h_curst) - 1] = '\0'; + + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0012] tx_begin 경고"); + + EXEC SQL UPDATE st_ledger + SET status = :h_newst, upd_ts = now() + WHERE key = :h_key + AND status <> :h_newst; + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE st_ledger 보류/해제"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); return; } + h_affected = sqlca.sqlerrd[2]; + tx_commit(); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "KEY", key); tx_buf_sets(ctx->out, "ACTION", action); + tx_buf_sets(ctx->out, "PREVSTATUS", h_curst); tx_buf_sets(ctx->out, "STATUS", newst); - tx_log(TX_LOG_INFO, "[ST_OL_0012] %s key=%s -> status=%s", action, key, newst); + tx_buf_setlong(ctx->out, "AFFECTED", (long)h_affected); + tx_log(TX_LOG_INFO, "[ST_OL_0012] %s key=%s %s->%s 반영=%ld", + action, key, h_curst, newst, (long)h_affected); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0013.c b/app/online/st_ol_0013.c index d5820be..263004d 100644 --- a/app/online/st_ol_0013.c +++ b/app/online/st_ol_0013.c @@ -11,12 +11,14 @@ * st_ol_0013.pgc - 정산금 분할(N분할) 계산 (ST_OL_0013) [tier=hard] * * 총 정산금을 N 회차로 균등 분할하되, 원단위 잔여(remainder)를 마지막 - * 회차에 몰아 합계가 원금과 일치하도록 배분한다. + * 회차에 몰아 합계가 원금과 일치하도록 배분한다. 산출된 회차 스케줄을 + * 분할지급 예정(st_installment)에 적재한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,12 +91,33 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0013.pgc" +#line 17 "app/online/st_ol_0013.pgc" TX_SERVICE(ST_OL_0013, ctx) { + /* exec sql begin declare section */ + + + + + +#line 23 "app/online/st_ol_0013.pgc" + char h_merch [ 16 ] ; + +#line 24 "app/online/st_ol_0013.pgc" + long h_seq ; + +#line 25 "app/online/st_ol_0013.pgc" + long h_part_amt ; + +#line 26 "app/online/st_ol_0013.pgc" + long h_total_ins ; +/* exec sql end declare section */ +#line 27 "app/online/st_ol_0013.pgc" + + char merch[16]; long total = 0, parts = 0, base_part, last_part, i, acc = 0; @@ -119,6 +142,63 @@ TX_SERVICE(ST_OL_0013, ctx) acc += base_part; last_part = total - acc; /* 잔여 마지막 회차 흡수 */ + /* 회차 스케줄 적재 (트랜잭션 경계) : 기존 예정 삭제 후 재적재 */ + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0013] tx_begin 경고"); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "delete from st_installment where merch_id = $1 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 60 "app/online/st_ol_0013.pgc" + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("DELETE st_installment"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + for (i = 0; i < parts; i++) { + h_seq = i + 1; + h_part_amt = (i == parts - 1) ? last_part : base_part; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into st_installment ( merch_id , seq_no , part_amt , reg_ts ) values ( $1 , $2 , $3 , now ( ) )", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_seq),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_part_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 74 "app/online/st_ol_0013.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT st_installment"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + } + + /* 적재 검증: 합계 대조 */ + h_total_ins = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( part_amt ) , 0 ) from st_installment where merch_id = $1 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_total_ins),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 88 "app/online/st_ol_0013.pgc" + + if (sqlca.sqlcode != TX_SQL_OK || h_total_ins != total) { + tx_log(TX_LOG_ERROR, "[ST_OL_0013] 분할합 불일치 적재=%ld 원금=%ld", + (long)h_total_ins, total); + tx_abort(); + tx_return(ctx, TX_FAIL, ctx->out); + return; + } + tx_commit(); + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); diff --git a/app/online/st_ol_0013.pgc b/app/online/st_ol_0013.pgc index d6ac9ca..70326b2 100644 --- a/app/online/st_ol_0013.pgc +++ b/app/online/st_ol_0013.pgc @@ -3,12 +3,14 @@ * st_ol_0013.pgc - 정산금 분할(N분할) 계산 (ST_OL_0013) [tier=hard] * * 총 정산금을 N 회차로 균등 분할하되, 원단위 잔여(remainder)를 마지막 - * 회차에 몰아 합계가 원금과 일치하도록 배분한다. + * 회차에 몰아 합계가 원금과 일치하도록 배분한다. 산출된 회차 스케줄을 + * 분할지급 예정(st_installment)에 적재한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -17,6 +19,13 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(ST_OL_0013, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + long h_seq; + long h_part_amt; + long h_total_ins; + EXEC SQL END DECLARE SECTION; + char merch[16]; long total = 0, parts = 0, base_part, last_part, i, acc = 0; @@ -41,6 +50,51 @@ TX_SERVICE(ST_OL_0013, ctx) acc += base_part; last_part = total - acc; /* 잔여 마지막 회차 흡수 */ + /* 회차 스케줄 적재 (트랜잭션 경계) : 기존 예정 삭제 후 재적재 */ + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0013] tx_begin 경고"); + + EXEC SQL DELETE FROM st_installment WHERE merch_id = :h_merch; + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("DELETE st_installment"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + for (i = 0; i < parts; i++) { + h_seq = i + 1; + h_part_amt = (i == parts - 1) ? last_part : base_part; + EXEC SQL INSERT INTO st_installment + (merch_id, seq_no, part_amt, reg_ts) + VALUES + (:h_merch, :h_seq, :h_part_amt, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT st_installment"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + } + + /* 적재 검증: 합계 대조 */ + h_total_ins = 0; + EXEC SQL SELECT coalesce(sum(part_amt), 0) + INTO :h_total_ins + FROM st_installment + WHERE merch_id = :h_merch; + if (sqlca.sqlcode != TX_SQL_OK || h_total_ins != total) { + tx_log(TX_LOG_ERROR, "[ST_OL_0013] 분할합 불일치 적재=%ld 원금=%ld", + (long)h_total_ins, total); + tx_abort(); + tx_return(ctx, TX_FAIL, ctx->out); + return; + } + tx_commit(); + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); diff --git a/app/online/st_ol_0014.c b/app/online/st_ol_0014.c index ec5dc0c..487e9e2 100644 --- a/app/online/st_ol_0014.c +++ b/app/online/st_ol_0014.c @@ -11,12 +11,14 @@ * st_ol_0014.pgc - 일자별 정산 집계 조회 (ST_OL_0014) [tier=easy] * * 지정 영업일의 상태별 건수(R/M/S/U)와 총 거래금액을 집계하여 - * 정산 진행 현황(처리율)을 응답한다. + * 정산 진행 현황(처리율)을 응답한다. 상태별 건수를 단일 임베디드 + * 집계 SQL(FILTER)로 한 번에 산출한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,12 +91,41 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0014.pgc" +#line 17 "app/online/st_ol_0014.pgc" TX_SERVICE(ST_OL_0014, ctx) { + /* exec sql begin declare section */ + + + + + + + +#line 23 "app/online/st_ol_0014.pgc" + char h_bizdate [ 9 ] ; + +#line 24 "app/online/st_ol_0014.pgc" + long h_recv ; + +#line 25 "app/online/st_ol_0014.pgc" + long h_done ; + +#line 26 "app/online/st_ol_0014.pgc" + long h_settled ; + +#line 27 "app/online/st_ol_0014.pgc" + long h_fail ; + +#line 28 "app/online/st_ol_0014.pgc" + long h_sum ; +/* exec sql end declare section */ +#line 29 "app/online/st_ol_0014.pgc" + + char bizdate[16]; long c_recv, c_done, c_settled, c_fail, total = 0, sum = 0; @@ -106,16 +137,38 @@ TX_SERVICE(ST_OL_0014, ctx) return; } - c_recv = st_rec_count(bizdate, ST_ST_RECV); - c_done = st_rec_count(bizdate, ST_ST_DONE); - c_settled = st_rec_count(bizdate, ST_ST_SETTLED); - c_fail = st_rec_count(bizdate, ST_ST_FAIL); - if (c_recv < 0) c_recv = 0; - if (c_done < 0) c_done = 0; - if (c_settled < 0) c_settled = 0; - if (c_fail < 0) c_fail = 0; - total = c_recv + c_done + c_settled + c_fail; - st_rec_sum(bizdate, &sum); + strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); + h_bizdate[sizeof(h_bizdate) - 1] = '\0'; + h_recv = h_done = h_settled = h_fail = h_sum = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) filter ( where status = 'R' ) , count ( * ) filter ( where status = 'M' ) , count ( * ) filter ( where status = 'S' ) , count ( * ) filter ( where status = 'U' ) , coalesce ( sum ( amount ) , 0 ) from st_ledger where biz_date = $1 ", + ECPGt_char,(h_bizdate),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_recv),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_done),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_settled),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fail),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 54 "app/online/st_ol_0014.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT 일자별집계"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + c_recv = h_recv; + c_done = h_done; + c_settled = h_settled; + c_fail = h_fail; + sum = h_sum; + total = c_recv + c_done + c_settled + c_fail; tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); @@ -125,7 +178,7 @@ TX_SERVICE(ST_OL_0014, ctx) tx_buf_setlong(ctx->out, "CSETTLED", c_settled); tx_buf_setlong(ctx->out, "CFAIL", c_fail); tx_buf_setlong(ctx->out, "TOTALCNT", total); - tx_buf_setlong(ctx->out, "SUMAMT", (sum < 0) ? 0 : sum); + tx_buf_setlong(ctx->out, "SUMAMT", sum); tx_log(TX_LOG_INFO, "[ST_OL_0014] 집계 date=%s 총=%ld 완료=%ld 정산=%ld", bizdate, total, c_done, c_settled); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/st_ol_0014.pgc b/app/online/st_ol_0014.pgc index ba893d6..50aa761 100644 --- a/app/online/st_ol_0014.pgc +++ b/app/online/st_ol_0014.pgc @@ -3,12 +3,14 @@ * st_ol_0014.pgc - 일자별 정산 집계 조회 (ST_OL_0014) [tier=easy] * * 지정 영업일의 상태별 건수(R/M/S/U)와 총 거래금액을 집계하여 - * 정산 진행 현황(처리율)을 응답한다. + * 정산 진행 현황(처리율)을 응답한다. 상태별 건수를 단일 임베디드 + * 집계 SQL(FILTER)로 한 번에 산출한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -17,6 +19,15 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(ST_OL_0014, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_bizdate[9]; + long h_recv; + long h_done; + long h_settled; + long h_fail; + long h_sum; + EXEC SQL END DECLARE SECTION; + char bizdate[16]; long c_recv, c_done, c_settled, c_fail, total = 0, sum = 0; @@ -28,16 +39,32 @@ TX_SERVICE(ST_OL_0014, ctx) return; } - c_recv = st_rec_count(bizdate, ST_ST_RECV); - c_done = st_rec_count(bizdate, ST_ST_DONE); - c_settled = st_rec_count(bizdate, ST_ST_SETTLED); - c_fail = st_rec_count(bizdate, ST_ST_FAIL); - if (c_recv < 0) c_recv = 0; - if (c_done < 0) c_done = 0; - if (c_settled < 0) c_settled = 0; - if (c_fail < 0) c_fail = 0; - total = c_recv + c_done + c_settled + c_fail; - st_rec_sum(bizdate, &sum); + strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); + h_bizdate[sizeof(h_bizdate) - 1] = '\0'; + h_recv = h_done = h_settled = h_fail = h_sum = 0; + + EXEC SQL SELECT + count(*) filter (where status = 'R'), + count(*) filter (where status = 'M'), + count(*) filter (where status = 'S'), + count(*) filter (where status = 'U'), + coalesce(sum(amount), 0) + INTO :h_recv, :h_done, :h_settled, :h_fail, :h_sum + FROM st_ledger + WHERE biz_date = :h_bizdate; + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT 일자별집계"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + c_recv = h_recv; + c_done = h_done; + c_settled = h_settled; + c_fail = h_fail; + sum = h_sum; + total = c_recv + c_done + c_settled + c_fail; tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); @@ -47,7 +74,7 @@ TX_SERVICE(ST_OL_0014, ctx) tx_buf_setlong(ctx->out, "CSETTLED", c_settled); tx_buf_setlong(ctx->out, "CFAIL", c_fail); tx_buf_setlong(ctx->out, "TOTALCNT", total); - tx_buf_setlong(ctx->out, "SUMAMT", (sum < 0) ? 0 : sum); + tx_buf_setlong(ctx->out, "SUMAMT", sum); tx_log(TX_LOG_INFO, "[ST_OL_0014] 집계 date=%s 총=%ld 완료=%ld 정산=%ld", bizdate, total, c_done, c_settled); tx_return(ctx, TX_OK, ctx->out); diff --git a/app/online/st_ol_0015.c b/app/online/st_ol_0015.c index f17b766..876e187 100644 --- a/app/online/st_ol_0015.c +++ b/app/online/st_ol_0015.c @@ -11,12 +11,14 @@ * st_ol_0015.pgc - 영업일 지급일(T+n) 산정 (ST_OL_0015) [tier=hard] * * 거래 영업일 기준 T+n 영업일 지급일을 산정한다. 주말/비영업일을 - * 건너뛰며 date_next_business 로 n 영업일을 전진시킨다. + * 건너뛰며 date_next_business 로 n 영업일을 전진시키되, 지정공휴일 + * 달력(st_holiday)에 등록된 날짜는 추가로 건너뛴다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,14 +91,48 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0015.pgc" +#line 17 "app/online/st_ol_0015.pgc" +static int st_is_holiday(const char *ymd) +{ + /* exec sql begin declare section */ + + + +#line 23 "app/online/st_ol_0015.pgc" + char h_ymd [ 9 ] ; + +#line 24 "app/online/st_ol_0015.pgc" + long h_cnt ; +/* exec sql end declare section */ +#line 25 "app/online/st_ol_0015.pgc" + + + strncpy(h_ymd, ymd, sizeof(h_ymd) - 1); + h_ymd[sizeof(h_ymd) - 1] = '\0'; + h_cnt = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) from st_holiday where holiday = $1 ", + ECPGt_char,(h_ymd),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 34 "app/online/st_ol_0015.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT st_holiday"); + return 0; + } + return (h_cnt > 0) ? 1 : 0; +} + TX_SERVICE(ST_OL_0015, ctx) { char bizdate[16], cur[9], nxt[9]; - long nplus = 0, i; + long nplus = 0, i, skipped = 0; tx_log(TX_LOG_INFO, "[ST_OL_0015] 지급일 T+n 산정 진입"); @@ -117,13 +153,22 @@ TX_SERVICE(ST_OL_0015, ctx) return; } strncpy(cur, nxt, sizeof(cur) - 1); + /* 지정공휴일이면 추가 전진 */ + while (st_is_holiday(cur)) { + skipped++; + if (date_next_business(cur, nxt) != 0) + break; + strncpy(cur, nxt, sizeof(cur) - 1); + } } tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "BIZDATE", bizdate); tx_buf_setlong(ctx->out, "NPLUS", nplus); + tx_buf_setlong(ctx->out, "HOLIDAYSKIP", skipped); tx_buf_sets(ctx->out, "PAYDATE", cur); - tx_log(TX_LOG_INFO, "[ST_OL_0015] T+%ld 지급일 %s -> %s", nplus, bizdate, cur); + tx_log(TX_LOG_INFO, "[ST_OL_0015] T+%ld 지급일 %s -> %s (공휴일 %ld회 건너뜀)", + nplus, bizdate, cur, skipped); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0015.pgc b/app/online/st_ol_0015.pgc index 93cbac1..50f8789 100644 --- a/app/online/st_ol_0015.pgc +++ b/app/online/st_ol_0015.pgc @@ -3,22 +3,47 @@ * st_ol_0015.pgc - 영업일 지급일(T+n) 산정 (ST_OL_0015) [tier=hard] * * 거래 영업일 기준 T+n 영업일 지급일을 산정한다. 주말/비영업일을 - * 건너뛰며 date_next_business 로 n 영업일을 전진시킨다. + * 건너뛰며 date_next_business 로 n 영업일을 전진시키되, 지정공휴일 + * 달력(st_holiday)에 등록된 날짜는 추가로 건너뛴다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" EXEC SQL INCLUDE sqlca; +static int st_is_holiday(const char *ymd) +{ + EXEC SQL BEGIN DECLARE SECTION; + char h_ymd[9]; + long h_cnt; + EXEC SQL END DECLARE SECTION; + + strncpy(h_ymd, ymd, sizeof(h_ymd) - 1); + h_ymd[sizeof(h_ymd) - 1] = '\0'; + h_cnt = 0; + + EXEC SQL SELECT count(*) + INTO :h_cnt + FROM st_holiday + WHERE holiday = :h_ymd; + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT st_holiday"); + return 0; + } + return (h_cnt > 0) ? 1 : 0; +} + TX_SERVICE(ST_OL_0015, ctx) { char bizdate[16], cur[9], nxt[9]; - long nplus = 0, i; + long nplus = 0, i, skipped = 0; tx_log(TX_LOG_INFO, "[ST_OL_0015] 지급일 T+n 산정 진입"); @@ -39,13 +64,22 @@ TX_SERVICE(ST_OL_0015, ctx) return; } strncpy(cur, nxt, sizeof(cur) - 1); + /* 지정공휴일이면 추가 전진 */ + while (st_is_holiday(cur)) { + skipped++; + if (date_next_business(cur, nxt) != 0) + break; + strncpy(cur, nxt, sizeof(cur) - 1); + } } tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "BIZDATE", bizdate); tx_buf_setlong(ctx->out, "NPLUS", nplus); + tx_buf_setlong(ctx->out, "HOLIDAYSKIP", skipped); tx_buf_sets(ctx->out, "PAYDATE", cur); - tx_log(TX_LOG_INFO, "[ST_OL_0015] T+%ld 지급일 %s -> %s", nplus, bizdate, cur); + tx_log(TX_LOG_INFO, "[ST_OL_0015] T+%ld 지급일 %s -> %s (공휴일 %ld회 건너뜀)", + nplus, bizdate, cur, skipped); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0016.c b/app/online/st_ol_0016.c index df6efe3..f4dcbf5 100644 --- a/app/online/st_ol_0016.c +++ b/app/online/st_ol_0016.c @@ -11,12 +11,14 @@ * st_ol_0016.pgc - 카드사(발급사) 정산 계산 (ST_OL_0016) [tier=easy] * * 발급 카드사로부터 수취할 정산금 = 매출총액 - 정산수수료(인터체인지). - * 인터체인지 요율(만분율)을 적용해 발급사 정산순액을 산출한다. + * 인터체인지 요율(만분율)을 적용해 발급사 정산순액을 산출한다. 요율 + * 미입력 시 발급사 인터체인지 마스터(st_interchange)에서 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0016.pgc" +#line 17 "app/online/st_ol_0016.pgc" @@ -103,8 +105,22 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0016, ctx) { + /* exec sql begin declare section */ + + + +#line 31 "app/online/st_ol_0016.pgc" + char h_issuer [ 12 ] ; + +#line 32 "app/online/st_ol_0016.pgc" + long h_ic_bp ; +/* exec sql end declare section */ +#line 33 "app/online/st_ol_0016.pgc" + + char issuer[12]; long gross = 0, ic_bp = 0, ic_fee, net; + const char *rate_src = "INPUT"; tx_log(TX_LOG_INFO, "[ST_OL_0016] 카드사 정산 계산 진입"); @@ -114,6 +130,28 @@ TX_SERVICE(ST_OL_0016, ctx) } tx_buf_getlong(ctx->in, "GROSS", &gross); tx_buf_getlong(ctx->in, "ICBP", &ic_bp); + + /* 인터체인지 요율 조회 */ + if (ic_bp <= 0) { + strncpy(h_issuer, issuer, sizeof(h_issuer) - 1); + h_issuer[sizeof(h_issuer) - 1] = '\0'; + h_ic_bp = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select interchange_bp from st_interchange where issuer_code = $1 ", + ECPGt_char,(h_issuer),(long)12,(long)1,(12)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_ic_bp),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 56 "app/online/st_ol_0016.pgc" + + if (sqlca.sqlcode == TX_SQL_OK && h_ic_bp > 0) { + ic_bp = h_ic_bp; + rate_src = "MASTER"; + } else if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + rate_src = "DEFAULT"; + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT st_interchange"); + } + } if (ic_bp <= 0 || ic_bp > 10000) ic_bp = 120; /* 인터체인지 1.2% */ if (gross < 0) { @@ -129,7 +167,9 @@ TX_SERVICE(ST_OL_0016, ctx) tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "ISSUER", issuer); + tx_buf_sets(ctx->out, "RATESRC", rate_src); tx_buf_setlong(ctx->out, "GROSS", gross); + tx_buf_setlong(ctx->out, "ICBP", ic_bp); tx_buf_setlong(ctx->out, "ICFEE", ic_fee); tx_buf_setlong(ctx->out, "NET", net); tx_log(TX_LOG_INFO, "[ST_OL_0016] 카드사 정산 issuer=%s gross=%ld fee=%ld net=%ld", diff --git a/app/online/st_ol_0016.pgc b/app/online/st_ol_0016.pgc index 71adb53..1910b03 100644 --- a/app/online/st_ol_0016.pgc +++ b/app/online/st_ol_0016.pgc @@ -3,12 +3,14 @@ * st_ol_0016.pgc - 카드사(발급사) 정산 계산 (ST_OL_0016) [tier=easy] * * 발급 카드사로부터 수취할 정산금 = 매출총액 - 정산수수료(인터체인지). - * 인터체인지 요율(만분율)을 적용해 발급사 정산순액을 산출한다. + * 인터체인지 요율(만분율)을 적용해 발급사 정산순액을 산출한다. 요율 + * 미입력 시 발급사 인터체인지 마스터(st_interchange)에서 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,8 +27,14 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0016, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_issuer[12]; + long h_ic_bp; + EXEC SQL END DECLARE SECTION; + char issuer[12]; long gross = 0, ic_bp = 0, ic_fee, net; + const char *rate_src = "INPUT"; tx_log(TX_LOG_INFO, "[ST_OL_0016] 카드사 정산 계산 진입"); @@ -36,6 +44,25 @@ TX_SERVICE(ST_OL_0016, ctx) } tx_buf_getlong(ctx->in, "GROSS", &gross); tx_buf_getlong(ctx->in, "ICBP", &ic_bp); + + /* 인터체인지 요율 조회 */ + if (ic_bp <= 0) { + strncpy(h_issuer, issuer, sizeof(h_issuer) - 1); + h_issuer[sizeof(h_issuer) - 1] = '\0'; + h_ic_bp = 0; + EXEC SQL SELECT interchange_bp + INTO :h_ic_bp + FROM st_interchange + WHERE issuer_code = :h_issuer; + if (sqlca.sqlcode == TX_SQL_OK && h_ic_bp > 0) { + ic_bp = h_ic_bp; + rate_src = "MASTER"; + } else if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + rate_src = "DEFAULT"; + } else if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT st_interchange"); + } + } if (ic_bp <= 0 || ic_bp > 10000) ic_bp = 120; /* 인터체인지 1.2% */ if (gross < 0) { @@ -51,7 +78,9 @@ TX_SERVICE(ST_OL_0016, ctx) tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "ISSUER", issuer); + tx_buf_sets(ctx->out, "RATESRC", rate_src); tx_buf_setlong(ctx->out, "GROSS", gross); + tx_buf_setlong(ctx->out, "ICBP", ic_bp); tx_buf_setlong(ctx->out, "ICFEE", ic_fee); tx_buf_setlong(ctx->out, "NET", net); tx_log(TX_LOG_INFO, "[ST_OL_0016] 카드사 정산 issuer=%s gross=%ld fee=%ld net=%ld", diff --git a/app/online/st_ol_0017.c b/app/online/st_ol_0017.c index a022514..1cf1689 100644 --- a/app/online/st_ol_0017.c +++ b/app/online/st_ol_0017.c @@ -11,12 +11,14 @@ * st_ol_0017.pgc - 구간요율 수수료율 적용 (ST_OL_0017) [tier=easy] * * 거래금액 구간(band)별 차등 수수료율(만분율)을 적용하여 수수료를 - * 산출한다. 소액/중액/고액 3구간 슬라브 요율 모델. + * 산출한다. 소액/중액/고액 슬라브 요율 모델. 구간요율표(st_band_rate) + * 를 조회하여 해당 금액이 속한 구간의 요율을 적용한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0017.pgc" +#line 17 "app/online/st_ol_0017.pgc" @@ -103,8 +105,26 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0017, ctx) { + /* exec sql begin declare section */ + + + + +#line 31 "app/online/st_ol_0017.pgc" + long h_amount ; + +#line 32 "app/online/st_ol_0017.pgc" + long h_bp ; + +#line 33 "app/online/st_ol_0017.pgc" + char h_band [ 8 ] ; +/* exec sql end declare section */ +#line 34 "app/online/st_ol_0017.pgc" + + char merch[16]; long amount = 0, bp, fee, net; + char band[8] = "-"; tx_log(TX_LOG_INFO, "[ST_OL_0017] 구간요율 적용 진입"); @@ -120,12 +140,34 @@ TX_SERVICE(ST_OL_0017, ctx) return; } - if (amount < 50000L) - bp = 250; /* 5만원 미만 2.50% */ - else if (amount < 500000L) - bp = 180; /* 50만원 미만 1.80% */ - else - bp = 140; /* 그 이상 1.40% */ + /* 구간요율표에서 금액이 속한 구간 요율 조회 */ + h_amount = amount; + h_bp = 0; + memset(h_band, 0, sizeof(h_band)); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select rate_bp , band_code from st_band_rate where $1 >= lo_amt and $2 < hi_amt", + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + 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_EOIT, + ECPGt_long,&(h_bp),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_band),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 62 "app/online/st_ol_0017.pgc" + + + if (sqlca.sqlcode == TX_SQL_OK && h_bp > 0) { + bp = h_bp; + strncpy(band, h_band, sizeof(band) - 1); + band[sizeof(band) - 1] = '\0'; + } else { + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT st_band_rate"); + /* 미등록 구간 폴백: 내장 슬라브 요율 */ + if (amount < 50000L) { bp = 250; strcpy(band, "LOW"); } + else if (amount < 500000L) { bp = 180; strcpy(band, "MID"); } + else { bp = 140; strcpy(band, "HIGH"); } + } fee = st_fee_round(amount, bp); net = amount - fee; @@ -133,11 +175,12 @@ TX_SERVICE(ST_OL_0017, ctx) tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); + tx_buf_sets(ctx->out, "BAND", band); tx_buf_setlong(ctx->out, "AMOUNT", amount); tx_buf_setlong(ctx->out, "BPUSED", bp); tx_buf_setlong(ctx->out, "FEE", fee); tx_buf_setlong(ctx->out, "NET", net); - tx_log(TX_LOG_INFO, "[ST_OL_0017] 구간요율 amount=%ld bp=%ld fee=%ld", - amount, bp, fee); + tx_log(TX_LOG_INFO, "[ST_OL_0017] 구간요율 amount=%ld band=%s bp=%ld fee=%ld", + amount, band, bp, fee); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0017.pgc b/app/online/st_ol_0017.pgc index d0cf577..5503ea5 100644 --- a/app/online/st_ol_0017.pgc +++ b/app/online/st_ol_0017.pgc @@ -3,12 +3,14 @@ * st_ol_0017.pgc - 구간요율 수수료율 적용 (ST_OL_0017) [tier=easy] * * 거래금액 구간(band)별 차등 수수료율(만분율)을 적용하여 수수료를 - * 산출한다. 소액/중액/고액 3구간 슬라브 요율 모델. + * 산출한다. 소액/중액/고액 슬라브 요율 모델. 구간요율표(st_band_rate) + * 를 조회하여 해당 금액이 속한 구간의 요율을 적용한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,8 +27,15 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0017, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + long h_amount; + long h_bp; + char h_band[8]; + EXEC SQL END DECLARE SECTION; + char merch[16]; long amount = 0, bp, fee, net; + char band[8] = "-"; tx_log(TX_LOG_INFO, "[ST_OL_0017] 구간요율 적용 진입"); @@ -42,12 +51,28 @@ TX_SERVICE(ST_OL_0017, ctx) return; } - if (amount < 50000L) - bp = 250; /* 5만원 미만 2.50% */ - else if (amount < 500000L) - bp = 180; /* 50만원 미만 1.80% */ - else - bp = 140; /* 그 이상 1.40% */ + /* 구간요율표에서 금액이 속한 구간 요율 조회 */ + h_amount = amount; + h_bp = 0; + memset(h_band, 0, sizeof(h_band)); + EXEC SQL SELECT rate_bp, band_code + INTO :h_bp, :h_band + FROM st_band_rate + WHERE :h_amount >= lo_amt + AND :h_amount < hi_amt; + + if (sqlca.sqlcode == TX_SQL_OK && h_bp > 0) { + bp = h_bp; + strncpy(band, h_band, sizeof(band) - 1); + band[sizeof(band) - 1] = '\0'; + } else { + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT st_band_rate"); + /* 미등록 구간 폴백: 내장 슬라브 요율 */ + if (amount < 50000L) { bp = 250; strcpy(band, "LOW"); } + else if (amount < 500000L) { bp = 180; strcpy(band, "MID"); } + else { bp = 140; strcpy(band, "HIGH"); } + } fee = st_fee_round(amount, bp); net = amount - fee; @@ -55,11 +80,12 @@ TX_SERVICE(ST_OL_0017, ctx) tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); + tx_buf_sets(ctx->out, "BAND", band); tx_buf_setlong(ctx->out, "AMOUNT", amount); tx_buf_setlong(ctx->out, "BPUSED", bp); tx_buf_setlong(ctx->out, "FEE", fee); tx_buf_setlong(ctx->out, "NET", net); - tx_log(TX_LOG_INFO, "[ST_OL_0017] 구간요율 amount=%ld bp=%ld fee=%ld", - amount, bp, fee); + tx_log(TX_LOG_INFO, "[ST_OL_0017] 구간요율 amount=%ld band=%s bp=%ld fee=%ld", + amount, band, bp, fee); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0018.c b/app/online/st_ol_0018.c index a0eb409..2818a84 100644 --- a/app/online/st_ol_0018.c +++ b/app/online/st_ol_0018.c @@ -11,12 +11,14 @@ * st_ol_0018.pgc - 정산 상계(offset) 처리 (ST_OL_0018) [tier=medium] * * 가맹점 채권(수취)과 채무(지급)를 상계하여 잔액과 방향을 산출한다. - * 상계 후 잔여채권/잔여채무를 구분해 반환한다. + * 상계 후 잔여채권/잔여채무를 구분해 반환한다. 채권/채무 미입력 시 + * 원장(st_ledger)의 정산완료(S)=채무, 실패/회수(U)=채권으로 집계한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,12 +91,29 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0018.pgc" +#line 17 "app/online/st_ol_0018.pgc" TX_SERVICE(ST_OL_0018, ctx) { + /* exec sql begin declare section */ + + + + +#line 23 "app/online/st_ol_0018.pgc" + char h_merch [ 16 ] ; + +#line 24 "app/online/st_ol_0018.pgc" + long h_recv ; + +#line 25 "app/online/st_ol_0018.pgc" + long h_pay ; +/* exec sql end declare section */ +#line 26 "app/online/st_ol_0018.pgc" + + char merch[16]; long receivable = 0, payable = 0, offset, residual; const char *dir; @@ -107,6 +126,30 @@ TX_SERVICE(ST_OL_0018, ctx) } tx_buf_getlong(ctx->in, "RECEIVABLE", &receivable); tx_buf_getlong(ctx->in, "PAYABLE", &payable); + + /* 미입력 시 원장 상태별 합계로 채권/채무 집계 */ + if (receivable <= 0 && payable <= 0) { + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_recv = 0; + h_pay = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( amount ) filter ( where status = 'U' ) , 0 ) , coalesce ( sum ( amount ) filter ( where status = 'S' ) , 0 ) from st_ledger where merch_id = $1 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_recv),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_pay),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 52 "app/online/st_ol_0018.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) { + receivable = h_recv; + payable = h_pay; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT 상계집계"); + } + } + if (receivable < 0 || payable < 0) { tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); @@ -121,6 +164,8 @@ TX_SERVICE(ST_OL_0018, ctx) tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); + tx_buf_setlong(ctx->out, "RECEIVABLE", receivable); + tx_buf_setlong(ctx->out, "PAYABLE", payable); tx_buf_setlong(ctx->out, "OFFSET", offset); tx_buf_setlong(ctx->out, "RESIDUAL", residual); tx_buf_sets(ctx->out, "DIR", dir); diff --git a/app/online/st_ol_0018.pgc b/app/online/st_ol_0018.pgc index e73ce00..3114d85 100644 --- a/app/online/st_ol_0018.pgc +++ b/app/online/st_ol_0018.pgc @@ -3,12 +3,14 @@ * st_ol_0018.pgc - 정산 상계(offset) 처리 (ST_OL_0018) [tier=medium] * * 가맹점 채권(수취)과 채무(지급)를 상계하여 잔액과 방향을 산출한다. - * 상계 후 잔여채권/잔여채무를 구분해 반환한다. + * 상계 후 잔여채권/잔여채무를 구분해 반환한다. 채권/채무 미입력 시 + * 원장(st_ledger)의 정산완료(S)=채무, 실패/회수(U)=채권으로 집계한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -17,6 +19,12 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(ST_OL_0018, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + long h_recv; + long h_pay; + EXEC SQL END DECLARE SECTION; + char merch[16]; long receivable = 0, payable = 0, offset, residual; const char *dir; @@ -29,6 +37,27 @@ TX_SERVICE(ST_OL_0018, ctx) } tx_buf_getlong(ctx->in, "RECEIVABLE", &receivable); tx_buf_getlong(ctx->in, "PAYABLE", &payable); + + /* 미입력 시 원장 상태별 합계로 채권/채무 집계 */ + if (receivable <= 0 && payable <= 0) { + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_recv = 0; + h_pay = 0; + EXEC SQL SELECT + coalesce(sum(amount) filter (where status = 'U'), 0), + coalesce(sum(amount) filter (where status = 'S'), 0) + INTO :h_recv, :h_pay + FROM st_ledger + WHERE merch_id = :h_merch; + if (sqlca.sqlcode == TX_SQL_OK) { + receivable = h_recv; + payable = h_pay; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT 상계집계"); + } + } + if (receivable < 0 || payable < 0) { tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); @@ -43,6 +72,8 @@ TX_SERVICE(ST_OL_0018, ctx) tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); + tx_buf_setlong(ctx->out, "RECEIVABLE", receivable); + tx_buf_setlong(ctx->out, "PAYABLE", payable); tx_buf_setlong(ctx->out, "OFFSET", offset); tx_buf_setlong(ctx->out, "RESIDUAL", residual); tx_buf_sets(ctx->out, "DIR", dir); diff --git a/app/online/st_ol_0019.c b/app/online/st_ol_0019.c index ee38c8d..a1d5b3b 100644 --- a/app/online/st_ol_0019.c +++ b/app/online/st_ol_0019.c @@ -11,12 +11,14 @@ * st_ol_0019.pgc - 정산 diff 검증(예상 vs 실제) (ST_OL_0019) [tier=easy] * * 표준요율로 재산출한 예상 수수료와 원장에 기록된 실제 수수료의 차이를 - * 검증한다. 허용오차(tolerance)를 넘으면 불일치로 판정한다. + * 검증한다. 허용오차(tolerance)를 넘으면 불일치로 판정한다. 원장 금액/ + * 수수료는 st_ledger 에서 임베디드 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0019.pgc" +#line 17 "app/online/st_ol_0019.pgc" @@ -103,10 +105,26 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0019, ctx) { - st_rec_t rec; + /* exec sql begin declare section */ + + + + +#line 31 "app/online/st_ol_0019.pgc" + char h_key [ 16 ] ; + +#line 32 "app/online/st_ol_0019.pgc" + long h_amount ; + +#line 33 "app/online/st_ol_0019.pgc" + long h_fee ; +/* exec sql end declare section */ +#line 34 "app/online/st_ol_0019.pgc" + + char key[16]; long std_bp = 0, tol = 0, expected, diff; - int rc, mismatch; + int mismatch; tx_log(TX_LOG_INFO, "[ST_OL_0019] 정산 diff 검증 진입"); @@ -119,25 +137,45 @@ TX_SERVICE(ST_OL_0019, ctx) if (std_bp <= 0) std_bp = 180; /* 표준요율 1.80% */ if (tol < 0) tol = 0; - memset(&rec, 0, sizeof(rec)); - rc = st_rec_select(key, &rec); - if (rc != TX_OK) { - tx_return(ctx, rc, ctx->out); + /* 원장 금액/실제수수료 조회 */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_amount = 0; + h_fee = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount , fee from st_ledger where key = $1 ", + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 59 "app/online/st_ol_0019.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[ST_OL_0019] 원장 없음 key=%s", key); + tx_return(ctx, TX_ENOENT, ctx->out); + return; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT st_ledger diff"); + tx_return(ctx, TX_EDB, ctx->out); return; } - expected = st_fee_round(rec.amount, std_bp); - diff = rec.fee - expected; + expected = st_fee_round(h_amount, std_bp); + diff = h_fee - expected; mismatch = ((diff < 0 ? -diff : diff) > tol); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", mismatch ? RESP_INVALID : RESP_OK); tx_buf_sets(ctx->out, "KEY", key); + tx_buf_setlong(ctx->out, "AMOUNT", h_amount); tx_buf_setlong(ctx->out, "EXPECTED", expected); - tx_buf_setlong(ctx->out, "ACTUAL", rec.fee); + tx_buf_setlong(ctx->out, "ACTUAL", h_fee); tx_buf_setlong(ctx->out, "DIFF", diff); tx_buf_sets(ctx->out, "VERDICT", mismatch ? "MISMATCH" : "OK"); tx_log(TX_LOG_INFO, "[ST_OL_0019] diff key=%s 예상=%ld 실제=%ld diff=%ld %s", - key, expected, rec.fee, diff, mismatch ? "불일치" : "일치"); + key, expected, h_fee, diff, mismatch ? "불일치" : "일치"); tx_return(ctx, mismatch ? TX_FAIL : TX_OK, ctx->out); } diff --git a/app/online/st_ol_0019.pgc b/app/online/st_ol_0019.pgc index e86df81..d3dff7d 100644 --- a/app/online/st_ol_0019.pgc +++ b/app/online/st_ol_0019.pgc @@ -3,12 +3,14 @@ * st_ol_0019.pgc - 정산 diff 검증(예상 vs 실제) (ST_OL_0019) [tier=easy] * * 표준요율로 재산출한 예상 수수료와 원장에 기록된 실제 수수료의 차이를 - * 검증한다. 허용오차(tolerance)를 넘으면 불일치로 판정한다. + * 검증한다. 허용오차(tolerance)를 넘으면 불일치로 판정한다. 원장 금액/ + * 수수료는 st_ledger 에서 임베디드 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,10 +27,15 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0019, ctx) { - st_rec_t rec; + EXEC SQL BEGIN DECLARE SECTION; + char h_key[16]; + long h_amount; + long h_fee; + EXEC SQL END DECLARE SECTION; + char key[16]; long std_bp = 0, tol = 0, expected, diff; - int rc, mismatch; + int mismatch; tx_log(TX_LOG_INFO, "[ST_OL_0019] 정산 diff 검증 진입"); @@ -41,25 +48,40 @@ TX_SERVICE(ST_OL_0019, ctx) if (std_bp <= 0) std_bp = 180; /* 표준요율 1.80% */ if (tol < 0) tol = 0; - memset(&rec, 0, sizeof(rec)); - rc = st_rec_select(key, &rec); - if (rc != TX_OK) { - tx_return(ctx, rc, ctx->out); + /* 원장 금액/실제수수료 조회 */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_amount = 0; + h_fee = 0; + EXEC SQL SELECT amount, fee + INTO :h_amount, :h_fee + FROM st_ledger + WHERE key = :h_key; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_log(TX_LOG_WARN, "[ST_OL_0019] 원장 없음 key=%s", key); + tx_return(ctx, TX_ENOENT, ctx->out); + return; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT st_ledger diff"); + tx_return(ctx, TX_EDB, ctx->out); return; } - expected = st_fee_round(rec.amount, std_bp); - diff = rec.fee - expected; + expected = st_fee_round(h_amount, std_bp); + diff = h_fee - expected; mismatch = ((diff < 0 ? -diff : diff) > tol); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", mismatch ? RESP_INVALID : RESP_OK); tx_buf_sets(ctx->out, "KEY", key); + tx_buf_setlong(ctx->out, "AMOUNT", h_amount); tx_buf_setlong(ctx->out, "EXPECTED", expected); - tx_buf_setlong(ctx->out, "ACTUAL", rec.fee); + tx_buf_setlong(ctx->out, "ACTUAL", h_fee); tx_buf_setlong(ctx->out, "DIFF", diff); tx_buf_sets(ctx->out, "VERDICT", mismatch ? "MISMATCH" : "OK"); tx_log(TX_LOG_INFO, "[ST_OL_0019] diff key=%s 예상=%ld 실제=%ld diff=%ld %s", - key, expected, rec.fee, diff, mismatch ? "불일치" : "일치"); + key, expected, h_fee, diff, mismatch ? "불일치" : "일치"); tx_return(ctx, mismatch ? TX_FAIL : TX_OK, ctx->out); } diff --git a/app/online/st_ol_0020.c b/app/online/st_ol_0020.c index b900893..cd29595 100644 --- a/app/online/st_ol_0020.c +++ b/app/online/st_ol_0020.c @@ -11,12 +11,14 @@ * st_ol_0020.pgc - 정산 수수료 재계산 (ST_OL_0020) [tier=medium] * * 원장 건을 조회하여 표준요율로 수수료를 재계산하고, 재계산 전/후 - * 수수료와 정산순액 변동분(delta)을 응답한다. + * 수수료와 정산순액 변동분(delta)을 응답한다. APPLY=Y 이면 재계산 + * 수수료를 원장(st_ledger)에 임베디드 UPDATE 로 반영한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0020.pgc" +#line 17 "app/online/st_ol_0020.pgc" @@ -103,10 +105,34 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0020, ctx) { - st_rec_t rec; - char key[16]; + /* exec sql begin declare section */ + + + + + + +#line 31 "app/online/st_ol_0020.pgc" + char h_key [ 16 ] ; + +#line 32 "app/online/st_ol_0020.pgc" + long h_amount ; + +#line 33 "app/online/st_ol_0020.pgc" + long h_old_fee ; + +#line 34 "app/online/st_ol_0020.pgc" + long h_new_fee ; + +#line 35 "app/online/st_ol_0020.pgc" + long h_affected ; +/* exec sql end declare section */ +#line 36 "app/online/st_ol_0020.pgc" + + + char key[16], apply[4]; long std_bp = 0, new_fee, delta, new_net; - int rc; + int applied = 0; tx_log(TX_LOG_INFO, "[ST_OL_0020] 정산 재계산 진입"); @@ -116,26 +142,70 @@ TX_SERVICE(ST_OL_0020, ctx) } tx_buf_getlong(ctx->in, "STDBP", &std_bp); if (std_bp <= 0) std_bp = 180; + if (tx_buf_get(ctx->in, "APPLY", apply, sizeof(apply)) != TX_OK) + strcpy(apply, "N"); - memset(&rec, 0, sizeof(rec)); - rc = st_rec_select(key, &rec); - if (rc != TX_OK) { - tx_return(ctx, rc, ctx->out); + /* 원장 금액/기존 수수료 조회 */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_amount = 0; + h_old_fee = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount , fee from st_ledger where key = $1 ", + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_amount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_old_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 61 "app/online/st_ol_0020.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_return(ctx, TX_ENOENT, ctx->out); + return; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT st_ledger 재계산"); + tx_return(ctx, TX_EDB, ctx->out); return; } - new_fee = st_fee_round(rec.amount, std_bp); - delta = new_fee - rec.fee; - new_net = rec.amount - new_fee; + new_fee = st_fee_round(h_amount, std_bp); + delta = new_fee - h_old_fee; + new_net = h_amount - new_fee; + + /* APPLY=Y 이면 재계산 수수료 반영 */ + if (strcmp(apply, "Y") == 0 && delta != 0) { + h_new_fee = new_fee; + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0020] tx_begin 경고"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_ledger set fee = $1 , upd_ts = now ( ) where key = $2 ", + ECPGt_long,&(h_new_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 84 "app/online/st_ol_0020.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE st_ledger 수수료반영"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + h_affected = sqlca.sqlerrd[2]; + tx_commit(); + applied = (h_affected > 0); + } tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "KEY", key); - tx_buf_setlong(ctx->out, "OLDFEE", rec.fee); + tx_buf_setlong(ctx->out, "OLDFEE", h_old_fee); tx_buf_setlong(ctx->out, "NEWFEE", new_fee); tx_buf_setlong(ctx->out, "DELTA", delta); tx_buf_setlong(ctx->out, "NEWNET", new_net); - tx_log(TX_LOG_INFO, "[ST_OL_0020] 재계산 key=%s old=%ld new=%ld delta=%ld", - key, rec.fee, new_fee, delta); + tx_buf_sets(ctx->out, "APPLIED", applied ? "Y" : "N"); + tx_log(TX_LOG_INFO, "[ST_OL_0020] 재계산 key=%s old=%ld new=%ld delta=%ld apply=%s", + key, h_old_fee, new_fee, delta, applied ? "Y" : "N"); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0020.pgc b/app/online/st_ol_0020.pgc index 14c8fa4..5b3745f 100644 --- a/app/online/st_ol_0020.pgc +++ b/app/online/st_ol_0020.pgc @@ -3,12 +3,14 @@ * st_ol_0020.pgc - 정산 수수료 재계산 (ST_OL_0020) [tier=medium] * * 원장 건을 조회하여 표준요율로 수수료를 재계산하고, 재계산 전/후 - * 수수료와 정산순액 변동분(delta)을 응답한다. + * 수수료와 정산순액 변동분(delta)을 응답한다. APPLY=Y 이면 재계산 + * 수수료를 원장(st_ledger)에 임베디드 UPDATE 로 반영한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,10 +27,17 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0020, ctx) { - st_rec_t rec; - char key[16]; + EXEC SQL BEGIN DECLARE SECTION; + char h_key[16]; + long h_amount; + long h_old_fee; + long h_new_fee; + long h_affected; + EXEC SQL END DECLARE SECTION; + + char key[16], apply[4]; long std_bp = 0, new_fee, delta, new_net; - int rc; + int applied = 0; tx_log(TX_LOG_INFO, "[ST_OL_0020] 정산 재계산 진입"); @@ -38,26 +47,61 @@ TX_SERVICE(ST_OL_0020, ctx) } tx_buf_getlong(ctx->in, "STDBP", &std_bp); if (std_bp <= 0) std_bp = 180; + if (tx_buf_get(ctx->in, "APPLY", apply, sizeof(apply)) != TX_OK) + strcpy(apply, "N"); - memset(&rec, 0, sizeof(rec)); - rc = st_rec_select(key, &rec); - if (rc != TX_OK) { - tx_return(ctx, rc, ctx->out); + /* 원장 금액/기존 수수료 조회 */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_amount = 0; + h_old_fee = 0; + EXEC SQL SELECT amount, fee + INTO :h_amount, :h_old_fee + FROM st_ledger + WHERE key = :h_key; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_return(ctx, TX_ENOENT, ctx->out); + return; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT st_ledger 재계산"); + tx_return(ctx, TX_EDB, ctx->out); return; } - new_fee = st_fee_round(rec.amount, std_bp); - delta = new_fee - rec.fee; - new_net = rec.amount - new_fee; + new_fee = st_fee_round(h_amount, std_bp); + delta = new_fee - h_old_fee; + new_net = h_amount - new_fee; + + /* APPLY=Y 이면 재계산 수수료 반영 */ + if (strcmp(apply, "Y") == 0 && delta != 0) { + h_new_fee = new_fee; + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0020] tx_begin 경고"); + EXEC SQL UPDATE st_ledger + SET fee = :h_new_fee, upd_ts = now() + WHERE key = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE st_ledger 수수료반영"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + h_affected = sqlca.sqlerrd[2]; + tx_commit(); + applied = (h_affected > 0); + } tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "KEY", key); - tx_buf_setlong(ctx->out, "OLDFEE", rec.fee); + tx_buf_setlong(ctx->out, "OLDFEE", h_old_fee); tx_buf_setlong(ctx->out, "NEWFEE", new_fee); tx_buf_setlong(ctx->out, "DELTA", delta); tx_buf_setlong(ctx->out, "NEWNET", new_net); - tx_log(TX_LOG_INFO, "[ST_OL_0020] 재계산 key=%s old=%ld new=%ld delta=%ld", - key, rec.fee, new_fee, delta); + tx_buf_sets(ctx->out, "APPLIED", applied ? "Y" : "N"); + tx_log(TX_LOG_INFO, "[ST_OL_0020] 재계산 key=%s old=%ld new=%ld delta=%ld apply=%s", + key, h_old_fee, new_fee, delta, applied ? "Y" : "N"); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0021.c b/app/online/st_ol_0021.c index c91ecd4..4d178c0 100644 --- a/app/online/st_ol_0021.c +++ b/app/online/st_ol_0021.c @@ -11,12 +11,14 @@ * st_ol_0021.pgc - 정산 취소 처리 (ST_OL_0021) [tier=easy] * * 정산 원장 건을 취소한다. 이미 정산완료(S) 건은 취소 불가로 반려하고, - * 그 외 상태는 취소(U)로 전이한다. + * 그 외 상태는 취소(U)로 전이한다. 상태 전이는 원장(st_ledger)에 직접 + * 임베디드 UPDATE (정산완료 제외 조건) 로 반영한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,15 +91,30 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0021.pgc" +#line 17 "app/online/st_ol_0021.pgc" TX_SERVICE(ST_OL_0021, ctx) { - st_rec_t rec; + /* exec sql begin declare section */ + + + + +#line 23 "app/online/st_ol_0021.pgc" + char h_key [ 16 ] ; + +#line 24 "app/online/st_ol_0021.pgc" + char h_status [ 2 ] ; + +#line 25 "app/online/st_ol_0021.pgc" + long h_affected ; +/* exec sql end declare section */ +#line 26 "app/online/st_ol_0021.pgc" + + char key[16]; - int rc; tx_log(TX_LOG_INFO, "[ST_OL_0021] 정산 취소 처리 진입"); @@ -106,14 +123,29 @@ TX_SERVICE(ST_OL_0021, ctx) return; } - memset(&rec, 0, sizeof(rec)); - rc = st_rec_select(key, &rec); - if (rc != TX_OK) { - tx_return(ctx, rc, ctx->out); + /* 현재 상태 확인 */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + memset(h_status, 0, sizeof(h_status)); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select status from st_ledger where key = $1 ", + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_status),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 44 "app/online/st_ol_0021.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_return(ctx, TX_ENOENT, ctx->out); + return; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT st_ledger 상태"); + tx_return(ctx, TX_EDB, ctx->out); return; } - if (strcmp(rec.status, ST_ST_SETTLED) == 0) { + if (memcmp(h_status, ST_ST_SETTLED, 1) == 0) { tx_log(TX_LOG_WARN, "[ST_OL_0021] 정산완료 건 취소불가 key=%s", key); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); @@ -122,16 +154,30 @@ TX_SERVICE(ST_OL_0021, ctx) return; } - rc = st_rec_update_status(key, ST_ST_FAIL); - if (rc != TX_OK) { - tx_return(ctx, rc, ctx->out); + /* 취소(U) 전이 - 정산완료 제외 보호조건 */ + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0021] tx_begin 경고"); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_ledger set status = 'U' , upd_ts = now ( ) where key = $1 and status <> 'S'", + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 72 "app/online/st_ol_0021.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE st_ledger 취소"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); return; } + h_affected = sqlca.sqlerrd[2]; + tx_commit(); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "KEY", key); tx_buf_sets(ctx->out, "STATUS", ST_ST_FAIL); - tx_log(TX_LOG_INFO, "[ST_OL_0021] 취소완료 key=%s", key); + tx_buf_setlong(ctx->out, "AFFECTED", (long)h_affected); + tx_log(TX_LOG_INFO, "[ST_OL_0021] 취소완료 key=%s 반영=%ld", key, (long)h_affected); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0021.pgc b/app/online/st_ol_0021.pgc index 8958598..d68f2f3 100644 --- a/app/online/st_ol_0021.pgc +++ b/app/online/st_ol_0021.pgc @@ -3,12 +3,14 @@ * st_ol_0021.pgc - 정산 취소 처리 (ST_OL_0021) [tier=easy] * * 정산 원장 건을 취소한다. 이미 정산완료(S) 건은 취소 불가로 반려하고, - * 그 외 상태는 취소(U)로 전이한다. + * 그 외 상태는 취소(U)로 전이한다. 상태 전이는 원장(st_ledger)에 직접 + * 임베디드 UPDATE (정산완료 제외 조건) 로 반영한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -17,9 +19,13 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(ST_OL_0021, ctx) { - st_rec_t rec; + EXEC SQL BEGIN DECLARE SECTION; + char h_key[16]; + char h_status[2]; + long h_affected; + EXEC SQL END DECLARE SECTION; + char key[16]; - int rc; tx_log(TX_LOG_INFO, "[ST_OL_0021] 정산 취소 처리 진입"); @@ -28,14 +34,26 @@ TX_SERVICE(ST_OL_0021, ctx) return; } - memset(&rec, 0, sizeof(rec)); - rc = st_rec_select(key, &rec); - if (rc != TX_OK) { - tx_return(ctx, rc, ctx->out); + /* 현재 상태 확인 */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + memset(h_status, 0, sizeof(h_status)); + EXEC SQL SELECT status + INTO :h_status + FROM st_ledger + WHERE key = :h_key; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_return(ctx, TX_ENOENT, ctx->out); + return; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT st_ledger 상태"); + tx_return(ctx, TX_EDB, ctx->out); return; } - if (strcmp(rec.status, ST_ST_SETTLED) == 0) { + if (memcmp(h_status, ST_ST_SETTLED, 1) == 0) { tx_log(TX_LOG_WARN, "[ST_OL_0021] 정산완료 건 취소불가 key=%s", key); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); @@ -44,16 +62,29 @@ TX_SERVICE(ST_OL_0021, ctx) return; } - rc = st_rec_update_status(key, ST_ST_FAIL); - if (rc != TX_OK) { - tx_return(ctx, rc, ctx->out); + /* 취소(U) 전이 - 정산완료 제외 보호조건 */ + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0021] tx_begin 경고"); + + EXEC SQL UPDATE st_ledger + SET status = 'U', upd_ts = now() + WHERE key = :h_key + AND status <> 'S'; + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE st_ledger 취소"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); return; } + h_affected = sqlca.sqlerrd[2]; + tx_commit(); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "KEY", key); tx_buf_sets(ctx->out, "STATUS", ST_ST_FAIL); - tx_log(TX_LOG_INFO, "[ST_OL_0021] 취소완료 key=%s", key); + tx_buf_setlong(ctx->out, "AFFECTED", (long)h_affected); + tx_log(TX_LOG_INFO, "[ST_OL_0021] 취소완료 key=%s 반영=%ld", key, (long)h_affected); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0022.c b/app/online/st_ol_0022.c index 4370356..d230ab0 100644 --- a/app/online/st_ol_0022.c +++ b/app/online/st_ol_0022.c @@ -11,12 +11,14 @@ * st_ol_0022.pgc - 정산 통계 조회 (ST_OL_0022) [tier=medium] * * 지정 영업일의 정산 통계를 산출한다. 총건수/정산완료건수 기반 - * 정산완료율(bp) 과 건당 평균 거래금액을 계산한다. + * 정산완료율(bp) 과 건당 평균 거래금액을 계산한다. 통계는 단일 + * 임베디드 집계 SQL(st_ledger)로 산출한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,14 +91,35 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0022.pgc" +#line 17 "app/online/st_ol_0022.pgc" TX_SERVICE(ST_OL_0022, ctx) { + /* exec sql begin declare section */ + + + + + +#line 23 "app/online/st_ol_0022.pgc" + char h_bizdate [ 9 ] ; + +#line 24 "app/online/st_ol_0022.pgc" + long h_total ; + +#line 25 "app/online/st_ol_0022.pgc" + long h_settled ; + +#line 26 "app/online/st_ol_0022.pgc" + long h_sum ; +/* exec sql end declare section */ +#line 27 "app/online/st_ol_0022.pgc" + + char bizdate[16]; - long total, settled, sum = 0, rate_bp = 0, avg = 0; + long total = 0, settled = 0, sum = 0, rate_bp = 0, avg = 0; tx_log(TX_LOG_INFO, "[ST_OL_0022] 정산 통계 조회 진입"); @@ -106,15 +129,30 @@ TX_SERVICE(ST_OL_0022, ctx) return; } - total = st_rec_count(bizdate, ST_ST_RECV) - + st_rec_count(bizdate, ST_ST_DONE) - + st_rec_count(bizdate, ST_ST_SETTLED) - + st_rec_count(bizdate, ST_ST_FAIL); - settled = st_rec_count(bizdate, ST_ST_SETTLED); - if (total < 0) total = 0; - if (settled < 0) settled = 0; - st_rec_sum(bizdate, &sum); - if (sum < 0) sum = 0; + strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); + h_bizdate[sizeof(h_bizdate) - 1] = '\0'; + h_total = h_settled = h_sum = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) , count ( * ) filter ( where status = 'S' ) , coalesce ( sum ( amount ) , 0 ) from st_ledger where biz_date = $1 ", + ECPGt_char,(h_bizdate),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_total),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_settled),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 50 "app/online/st_ol_0022.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT 정산통계"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + total = h_total; + settled = h_settled; + sum = h_sum; if (total > 0) { rate_bp = settled * 10000 / total; diff --git a/app/online/st_ol_0022.pgc b/app/online/st_ol_0022.pgc index 69de96b..991e100 100644 --- a/app/online/st_ol_0022.pgc +++ b/app/online/st_ol_0022.pgc @@ -3,12 +3,14 @@ * st_ol_0022.pgc - 정산 통계 조회 (ST_OL_0022) [tier=medium] * * 지정 영업일의 정산 통계를 산출한다. 총건수/정산완료건수 기반 - * 정산완료율(bp) 과 건당 평균 거래금액을 계산한다. + * 정산완료율(bp) 과 건당 평균 거래금액을 계산한다. 통계는 단일 + * 임베디드 집계 SQL(st_ledger)로 산출한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -17,8 +19,15 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(ST_OL_0022, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_bizdate[9]; + long h_total; + long h_settled; + long h_sum; + EXEC SQL END DECLARE SECTION; + char bizdate[16]; - long total, settled, sum = 0, rate_bp = 0, avg = 0; + long total = 0, settled = 0, sum = 0, rate_bp = 0, avg = 0; tx_log(TX_LOG_INFO, "[ST_OL_0022] 정산 통계 조회 진입"); @@ -28,15 +37,26 @@ TX_SERVICE(ST_OL_0022, ctx) return; } - total = st_rec_count(bizdate, ST_ST_RECV) - + st_rec_count(bizdate, ST_ST_DONE) - + st_rec_count(bizdate, ST_ST_SETTLED) - + st_rec_count(bizdate, ST_ST_FAIL); - settled = st_rec_count(bizdate, ST_ST_SETTLED); - if (total < 0) total = 0; - if (settled < 0) settled = 0; - st_rec_sum(bizdate, &sum); - if (sum < 0) sum = 0; + strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); + h_bizdate[sizeof(h_bizdate) - 1] = '\0'; + h_total = h_settled = h_sum = 0; + + EXEC SQL SELECT + count(*), + count(*) filter (where status = 'S'), + coalesce(sum(amount), 0) + INTO :h_total, :h_settled, :h_sum + FROM st_ledger + WHERE biz_date = :h_bizdate; + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT 정산통계"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + total = h_total; + settled = h_settled; + sum = h_sum; if (total > 0) { rate_bp = settled * 10000 / total; diff --git a/app/online/st_ol_0023.c b/app/online/st_ol_0023.c index f45ed76..4e8dc99 100644 --- a/app/online/st_ol_0023.c +++ b/app/online/st_ol_0023.c @@ -11,12 +11,14 @@ * st_ol_0023.pgc - 정산 이체연계 요청 (ST_OL_0023) [tier=easy] * * 확정 정산금에 대한 은행 이체(펌뱅킹) 연계 요청 전문을 구성한다. - * 계좌/은행/금액 검증 후 이체 요청 식별자를 생성한다. + * 계좌/은행/금액 검증 후 이체 요청 식별자를 생성하고, 이체요청 큐 + * (st_transfer_req)에 REQUESTED 상태로 적재한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,12 +91,37 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0023.pgc" +#line 17 "app/online/st_ol_0023.pgc" TX_SERVICE(ST_OL_0023, ctx) { + /* exec sql begin declare section */ + + + + + + +#line 23 "app/online/st_ol_0023.pgc" + char h_reqid [ 32 ] ; + +#line 24 "app/online/st_ol_0023.pgc" + char h_merch [ 16 ] ; + +#line 25 "app/online/st_ol_0023.pgc" + char h_bank [ 8 ] ; + +#line 26 "app/online/st_ol_0023.pgc" + char h_acct [ 24 ] ; + +#line 27 "app/online/st_ol_0023.pgc" + long h_amount ; +/* exec sql end declare section */ +#line 28 "app/online/st_ol_0023.pgc" + + char merch[16], bank[8], acct[24]; long amount = 0; char reqid[32]; @@ -119,6 +146,40 @@ TX_SERVICE(ST_OL_0023, ctx) snprintf(reqid, sizeof(reqid), "TR%s%03ld", bank, (long)(amount % 1000)); + /* 이체요청 큐 적재 (트랜잭션 경계) */ + strncpy(h_reqid, reqid, sizeof(h_reqid) - 1); h_reqid[sizeof(h_reqid) - 1] = '\0'; + strncpy(h_merch, merch, sizeof(h_merch) - 1); h_merch[sizeof(h_merch) - 1] = '\0'; + strncpy(h_bank, bank, sizeof(h_bank) - 1); h_bank[sizeof(h_bank) - 1] = '\0'; + strncpy(h_acct, acct, sizeof(h_acct) - 1); h_acct[sizeof(h_acct) - 1] = '\0'; + h_amount = amount; + + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0023] tx_begin 경고"); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into st_transfer_req ( req_id , merch_id , bank_code , acct_no , amount , xfer_state , reg_ts ) values ( $1 , $2 , $3 , $4 , $5 , 'REQUESTED' , now ( ) )", + ECPGt_char,(h_reqid),(long)32,(long)1,(32)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_bank),(long)8,(long)1,(8)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_acct),(long)24,(long)1,(24)*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_EOIT, ECPGt_EORT);} +#line 67 "app/online/st_ol_0023.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT st_transfer_req"); + tx_abort(); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_commit(); + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); diff --git a/app/online/st_ol_0023.pgc b/app/online/st_ol_0023.pgc index 84cb0f4..7a9022c 100644 --- a/app/online/st_ol_0023.pgc +++ b/app/online/st_ol_0023.pgc @@ -3,12 +3,14 @@ * st_ol_0023.pgc - 정산 이체연계 요청 (ST_OL_0023) [tier=easy] * * 확정 정산금에 대한 은행 이체(펌뱅킹) 연계 요청 전문을 구성한다. - * 계좌/은행/금액 검증 후 이체 요청 식별자를 생성한다. + * 계좌/은행/금액 검증 후 이체 요청 식별자를 생성하고, 이체요청 큐 + * (st_transfer_req)에 REQUESTED 상태로 적재한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -17,6 +19,14 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(ST_OL_0023, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_reqid[32]; + char h_merch[16]; + char h_bank[8]; + char h_acct[24]; + long h_amount; + EXEC SQL END DECLARE SECTION; + char merch[16], bank[8], acct[24]; long amount = 0; char reqid[32]; @@ -41,6 +51,31 @@ TX_SERVICE(ST_OL_0023, ctx) snprintf(reqid, sizeof(reqid), "TR%s%03ld", bank, (long)(amount % 1000)); + /* 이체요청 큐 적재 (트랜잭션 경계) */ + strncpy(h_reqid, reqid, sizeof(h_reqid) - 1); h_reqid[sizeof(h_reqid) - 1] = '\0'; + strncpy(h_merch, merch, sizeof(h_merch) - 1); h_merch[sizeof(h_merch) - 1] = '\0'; + strncpy(h_bank, bank, sizeof(h_bank) - 1); h_bank[sizeof(h_bank) - 1] = '\0'; + strncpy(h_acct, acct, sizeof(h_acct) - 1); h_acct[sizeof(h_acct) - 1] = '\0'; + h_amount = amount; + + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0023] tx_begin 경고"); + + EXEC SQL INSERT INTO st_transfer_req + (req_id, merch_id, bank_code, acct_no, amount, xfer_state, reg_ts) + VALUES + (:h_reqid, :h_merch, :h_bank, :h_acct, :h_amount, 'REQUESTED', now()); + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT st_transfer_req"); + tx_abort(); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_commit(); + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); diff --git a/app/online/st_ol_0024.c b/app/online/st_ol_0024.c index d830711..285c139 100644 --- a/app/online/st_ol_0024.c +++ b/app/online/st_ol_0024.c @@ -11,12 +11,14 @@ * st_ol_0024.pgc - 정산 리포트 헤더 생성 (ST_OL_0024) [tier=hard] * * 지정 영업일의 정산 리포트 헤더(총건수/총매출/총수수료/총순액)를 - * 집계 구성한다. 수수료는 표준요율로 추정 합산한다. + * 집계 구성한다. 총건수/총매출/실제수수료는 원장(st_ledger) 단일 집계 + * SQL 로 산출하고, 표준요율 추정 수수료와 병기한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0024.pgc" +#line 17 "app/online/st_ol_0024.pgc" @@ -103,8 +105,29 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0024, ctx) { + /* exec sql begin declare section */ + + + + + +#line 31 "app/online/st_ol_0024.pgc" + char h_bizdate [ 9 ] ; + +#line 32 "app/online/st_ol_0024.pgc" + long h_total ; + +#line 33 "app/online/st_ol_0024.pgc" + long h_sum ; + +#line 34 "app/online/st_ol_0024.pgc" + long h_fee ; +/* exec sql end declare section */ +#line 35 "app/online/st_ol_0024.pgc" + + char bizdate[16]; - long total, sum = 0, std_bp = 0, est_fee, net; + long total = 0, sum = 0, actual_fee = 0, std_bp = 0, est_fee, net; tx_log(TX_LOG_INFO, "[ST_OL_0024] 정산 리포트 헤더 생성 진입"); @@ -116,13 +139,30 @@ TX_SERVICE(ST_OL_0024, ctx) tx_buf_getlong(ctx->in, "STDBP", &std_bp); if (std_bp <= 0) std_bp = 180; - total = st_rec_count(bizdate, ST_ST_RECV) - + st_rec_count(bizdate, ST_ST_DONE) - + st_rec_count(bizdate, ST_ST_SETTLED) - + st_rec_count(bizdate, ST_ST_FAIL); - if (total < 0) total = 0; - st_rec_sum(bizdate, &sum); - if (sum < 0) sum = 0; + strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); + h_bizdate[sizeof(h_bizdate) - 1] = '\0'; + h_total = h_sum = h_fee = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select count ( * ) , coalesce ( sum ( amount ) , 0 ) , coalesce ( sum ( fee ) , 0 ) from st_ledger where biz_date = $1 ", + ECPGt_char,(h_bizdate),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_total),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_sum),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 57 "app/online/st_ol_0024.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT 리포트집계"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + total = h_total; + sum = h_sum; + actual_fee = h_fee; est_fee = st_fee_round(sum, std_bp); net = sum - est_fee; @@ -132,9 +172,10 @@ TX_SERVICE(ST_OL_0024, ctx) tx_buf_sets(ctx->out, "REPORTID", bizdate); tx_buf_setlong(ctx->out, "TOTALCNT", total); tx_buf_setlong(ctx->out, "GROSSSUM", sum); + tx_buf_setlong(ctx->out, "ACTUALFEE", actual_fee); tx_buf_setlong(ctx->out, "FEESUM", est_fee); tx_buf_setlong(ctx->out, "NETSUM", net); - tx_log(TX_LOG_INFO, "[ST_OL_0024] 리포트 date=%s 건수=%ld 매출=%ld 수수료=%ld 순액=%ld", - bizdate, total, sum, est_fee, net); + tx_log(TX_LOG_INFO, "[ST_OL_0024] 리포트 date=%s 건수=%ld 매출=%ld 추정수수료=%ld 실제수수료=%ld", + bizdate, total, sum, est_fee, actual_fee); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0024.pgc b/app/online/st_ol_0024.pgc index e28c256..424d09c 100644 --- a/app/online/st_ol_0024.pgc +++ b/app/online/st_ol_0024.pgc @@ -3,12 +3,14 @@ * st_ol_0024.pgc - 정산 리포트 헤더 생성 (ST_OL_0024) [tier=hard] * * 지정 영업일의 정산 리포트 헤더(총건수/총매출/총수수료/총순액)를 - * 집계 구성한다. 수수료는 표준요율로 추정 합산한다. + * 집계 구성한다. 총건수/총매출/실제수수료는 원장(st_ledger) 단일 집계 + * SQL 로 산출하고, 표준요율 추정 수수료와 병기한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,8 +27,15 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0024, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_bizdate[9]; + long h_total; + long h_sum; + long h_fee; + EXEC SQL END DECLARE SECTION; + char bizdate[16]; - long total, sum = 0, std_bp = 0, est_fee, net; + long total = 0, sum = 0, actual_fee = 0, std_bp = 0, est_fee, net; tx_log(TX_LOG_INFO, "[ST_OL_0024] 정산 리포트 헤더 생성 진입"); @@ -38,13 +47,23 @@ TX_SERVICE(ST_OL_0024, ctx) tx_buf_getlong(ctx->in, "STDBP", &std_bp); if (std_bp <= 0) std_bp = 180; - total = st_rec_count(bizdate, ST_ST_RECV) - + st_rec_count(bizdate, ST_ST_DONE) - + st_rec_count(bizdate, ST_ST_SETTLED) - + st_rec_count(bizdate, ST_ST_FAIL); - if (total < 0) total = 0; - st_rec_sum(bizdate, &sum); - if (sum < 0) sum = 0; + strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1); + h_bizdate[sizeof(h_bizdate) - 1] = '\0'; + h_total = h_sum = h_fee = 0; + + EXEC SQL SELECT count(*), coalesce(sum(amount), 0), coalesce(sum(fee), 0) + INTO :h_total, :h_sum, :h_fee + FROM st_ledger + WHERE biz_date = :h_bizdate; + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT 리포트집계"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + total = h_total; + sum = h_sum; + actual_fee = h_fee; est_fee = st_fee_round(sum, std_bp); net = sum - est_fee; @@ -54,9 +73,10 @@ TX_SERVICE(ST_OL_0024, ctx) tx_buf_sets(ctx->out, "REPORTID", bizdate); tx_buf_setlong(ctx->out, "TOTALCNT", total); tx_buf_setlong(ctx->out, "GROSSSUM", sum); + tx_buf_setlong(ctx->out, "ACTUALFEE", actual_fee); tx_buf_setlong(ctx->out, "FEESUM", est_fee); tx_buf_setlong(ctx->out, "NETSUM", net); - tx_log(TX_LOG_INFO, "[ST_OL_0024] 리포트 date=%s 건수=%ld 매출=%ld 수수료=%ld 순액=%ld", - bizdate, total, sum, est_fee, net); + tx_log(TX_LOG_INFO, "[ST_OL_0024] 리포트 date=%s 건수=%ld 매출=%ld 추정수수료=%ld 실제수수료=%ld", + bizdate, total, sum, est_fee, actual_fee); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0025.c b/app/online/st_ol_0025.c index 5a75d0e..125e768 100644 --- a/app/online/st_ol_0025.c +++ b/app/online/st_ol_0025.c @@ -11,12 +11,14 @@ * st_ol_0025.pgc - 정산 원장연계 기표 (ST_OL_0025) [tier=easy] * * 정산 확정건을 회계원장에 연계 기표한다. 차변 미지급금 / 대변 수수료수익 - * + 부가세예수금 으로 분개하여 대차 균형을 검증한다. + * + 부가세예수금 으로 분개하여 대차 균형을 검증하고, 회계전표 + * (st_gl_journal)에 차/대변 분개행을 기표한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0025.pgc" +#line 17 "app/online/st_ol_0025.pgc" @@ -103,6 +105,27 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0025, ctx) { + /* exec sql begin declare section */ + + + + + +#line 31 "app/online/st_ol_0025.pgc" + char h_merch [ 16 ] ; + +#line 32 "app/online/st_ol_0025.pgc" + char h_acct [ 12 ] ; + +#line 33 "app/online/st_ol_0025.pgc" + char h_drcr [ 2 ] ; + +#line 34 "app/online/st_ol_0025.pgc" + long h_amt ; +/* exec sql end declare section */ +#line 35 "app/online/st_ol_0025.pgc" + + char merch[16]; long net = 0, fee = 0, vat, dr, cr; @@ -125,6 +148,67 @@ TX_SERVICE(ST_OL_0025, ctx) dr = net + fee + vat; /* 차변: 미지급금(정산부채) */ cr = net + fee + vat; /* 대변: 예수금 + 수수료수익 + VAT예수금 */ + /* 회계전표 분개 기표 (대차 균형일 때만) */ + if (dr != cr) { + tx_log(TX_LOG_ERROR, "[ST_OL_0025] 대차 불균형 dr=%ld cr=%ld", dr, cr); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_buf_sets(ctx->out, "BALANCED", "N"); + tx_return(ctx, TX_FAIL, ctx->out); + return; + } + + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0025] tx_begin 경고"); + + /* 차변: 미지급금 */ + strncpy(h_acct, "PAYABLE", sizeof(h_acct) - 1); h_acct[sizeof(h_acct) - 1] = '\0'; + strncpy(h_drcr, "D", sizeof(h_drcr) - 1); h_drcr[sizeof(h_drcr) - 1] = '\0'; + h_amt = dr; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into st_gl_journal ( merch_id , acct_code , dr_cr , amount , book_ts ) values ( $1 , $2 , $3 , $4 , now ( ) )", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_acct),(long)12,(long)1,(12)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_drcr),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 82 "app/online/st_ol_0025.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT st_gl_journal 차변"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + /* 대변: 수수료수익 */ + strncpy(h_acct, "FEEREV", sizeof(h_acct) - 1); h_acct[sizeof(h_acct) - 1] = '\0'; + strncpy(h_drcr, "C", sizeof(h_drcr) - 1); h_drcr[sizeof(h_drcr) - 1] = '\0'; + h_amt = cr; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into st_gl_journal ( merch_id , acct_code , dr_cr , amount , book_ts ) values ( $1 , $2 , $3 , $4 , now ( ) )", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_acct),(long)12,(long)1,(12)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_drcr),(long)2,(long)1,(2)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_amt),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 97 "app/online/st_ol_0025.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT st_gl_journal 대변"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_commit(); + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); @@ -132,8 +216,8 @@ TX_SERVICE(ST_OL_0025, ctx) tx_buf_setlong(ctx->out, "CRAMT", cr); tx_buf_setlong(ctx->out, "FEEREV", fee); tx_buf_setlong(ctx->out, "VATPAYABLE", vat); - tx_buf_sets(ctx->out, "BALANCED", (dr == cr) ? "Y" : "N"); - tx_log(TX_LOG_INFO, "[ST_OL_0025] 기표 merch=%s 차변=%ld 대변=%ld 균형=%s", - merch, dr, cr, (dr == cr) ? "Y" : "N"); + tx_buf_sets(ctx->out, "BALANCED", "Y"); + tx_log(TX_LOG_INFO, "[ST_OL_0025] 기표 merch=%s 차변=%ld 대변=%ld 균형=Y", + merch, dr, cr); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0025.pgc b/app/online/st_ol_0025.pgc index 6892726..b323ee3 100644 --- a/app/online/st_ol_0025.pgc +++ b/app/online/st_ol_0025.pgc @@ -3,12 +3,14 @@ * st_ol_0025.pgc - 정산 원장연계 기표 (ST_OL_0025) [tier=easy] * * 정산 확정건을 회계원장에 연계 기표한다. 차변 미지급금 / 대변 수수료수익 - * + 부가세예수금 으로 분개하여 대차 균형을 검증한다. + * + 부가세예수금 으로 분개하여 대차 균형을 검증하고, 회계전표 + * (st_gl_journal)에 차/대변 분개행을 기표한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,6 +27,13 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0025, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + char h_acct[12]; + char h_drcr[2]; + long h_amt; + EXEC SQL END DECLARE SECTION; + char merch[16]; long net = 0, fee = 0, vat, dr, cr; @@ -47,6 +56,53 @@ TX_SERVICE(ST_OL_0025, ctx) dr = net + fee + vat; /* 차변: 미지급금(정산부채) */ cr = net + fee + vat; /* 대변: 예수금 + 수수료수익 + VAT예수금 */ + /* 회계전표 분개 기표 (대차 균형일 때만) */ + if (dr != cr) { + tx_log(TX_LOG_ERROR, "[ST_OL_0025] 대차 불균형 dr=%ld cr=%ld", dr, cr); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_buf_sets(ctx->out, "BALANCED", "N"); + tx_return(ctx, TX_FAIL, ctx->out); + return; + } + + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0025] tx_begin 경고"); + + /* 차변: 미지급금 */ + strncpy(h_acct, "PAYABLE", sizeof(h_acct) - 1); h_acct[sizeof(h_acct) - 1] = '\0'; + strncpy(h_drcr, "D", sizeof(h_drcr) - 1); h_drcr[sizeof(h_drcr) - 1] = '\0'; + h_amt = dr; + EXEC SQL INSERT INTO st_gl_journal + (merch_id, acct_code, dr_cr, amount, book_ts) + VALUES + (:h_merch, :h_acct, :h_drcr, :h_amt, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT st_gl_journal 차변"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + + /* 대변: 수수료수익 */ + strncpy(h_acct, "FEEREV", sizeof(h_acct) - 1); h_acct[sizeof(h_acct) - 1] = '\0'; + strncpy(h_drcr, "C", sizeof(h_drcr) - 1); h_drcr[sizeof(h_drcr) - 1] = '\0'; + h_amt = cr; + EXEC SQL INSERT INTO st_gl_journal + (merch_id, acct_code, dr_cr, amount, book_ts) + VALUES + (:h_merch, :h_acct, :h_drcr, :h_amt, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT st_gl_journal 대변"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_commit(); + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); @@ -54,8 +110,8 @@ TX_SERVICE(ST_OL_0025, ctx) tx_buf_setlong(ctx->out, "CRAMT", cr); tx_buf_setlong(ctx->out, "FEEREV", fee); tx_buf_setlong(ctx->out, "VATPAYABLE", vat); - tx_buf_sets(ctx->out, "BALANCED", (dr == cr) ? "Y" : "N"); - tx_log(TX_LOG_INFO, "[ST_OL_0025] 기표 merch=%s 차변=%ld 대변=%ld 균형=%s", - merch, dr, cr, (dr == cr) ? "Y" : "N"); + tx_buf_sets(ctx->out, "BALANCED", "Y"); + tx_log(TX_LOG_INFO, "[ST_OL_0025] 기표 merch=%s 차변=%ld 대변=%ld 균형=Y", + merch, dr, cr); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0026.c b/app/online/st_ol_0026.c index bd4a40b..377f6b0 100644 --- a/app/online/st_ol_0026.c +++ b/app/online/st_ol_0026.c @@ -11,12 +11,14 @@ * st_ol_0026.pgc - 캐시백/리워드 수수료 계산 (ST_OL_0026) [tier=easy] * * 매출금액에 리워드 적립요율(만분율)을 적용해 캐시백을 산출하되, - * 회차 적립한도(cap)로 상한을 적용한다. + * 회차 적립한도(cap)로 상한을 적용한다. 요율/한도 미입력 시 리워드 + * 정책(st_reward_policy)에서 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0026.pgc" +#line 17 "app/online/st_ol_0026.pgc" @@ -103,6 +105,23 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0026, ctx) { + /* exec sql begin declare section */ + + + + +#line 31 "app/online/st_ol_0026.pgc" + char h_merch [ 16 ] ; + +#line 32 "app/online/st_ol_0026.pgc" + long h_reward_bp ; + +#line 33 "app/online/st_ol_0026.pgc" + long h_cap ; +/* exec sql end declare section */ +#line 34 "app/online/st_ol_0026.pgc" + + char merch[16]; long amount = 0, reward_bp = 0, cap = 0, cashback; @@ -115,6 +134,29 @@ TX_SERVICE(ST_OL_0026, ctx) tx_buf_getlong(ctx->in, "AMOUNT", &amount); tx_buf_getlong(ctx->in, "REWARDBP", &reward_bp); tx_buf_getlong(ctx->in, "CAP", &cap); + + /* 리워드 정책 조회 */ + if (reward_bp <= 0 || cap <= 0) { + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_reward_bp = 0; + h_cap = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select reward_bp , cap_amt from st_reward_policy where merch_id = $1 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_reward_bp),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_cap),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 58 "app/online/st_ol_0026.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) { + if (reward_bp <= 0) reward_bp = h_reward_bp; + if (cap <= 0) cap = h_cap; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT st_reward_policy"); + } + } if (reward_bp <= 0) reward_bp = 100; /* 1% 적립 */ if (cap <= 0) cap = 20000; /* 회차 한도 2만원 */ @@ -132,6 +174,7 @@ TX_SERVICE(ST_OL_0026, ctx) tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); tx_buf_setlong(ctx->out, "AMOUNT", amount); + tx_buf_setlong(ctx->out, "REWARDBP", reward_bp); tx_buf_setlong(ctx->out, "CASHBACK", cashback); tx_buf_setlong(ctx->out, "CAP", cap); tx_log(TX_LOG_INFO, "[ST_OL_0026] 캐시백 amount=%ld bp=%ld cashback=%ld", diff --git a/app/online/st_ol_0026.pgc b/app/online/st_ol_0026.pgc index 53073e8..f36729a 100644 --- a/app/online/st_ol_0026.pgc +++ b/app/online/st_ol_0026.pgc @@ -3,12 +3,14 @@ * st_ol_0026.pgc - 캐시백/리워드 수수료 계산 (ST_OL_0026) [tier=easy] * * 매출금액에 리워드 적립요율(만분율)을 적용해 캐시백을 산출하되, - * 회차 적립한도(cap)로 상한을 적용한다. + * 회차 적립한도(cap)로 상한을 적용한다. 요율/한도 미입력 시 리워드 + * 정책(st_reward_policy)에서 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,6 +27,12 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0026, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + long h_reward_bp; + long h_cap; + EXEC SQL END DECLARE SECTION; + char merch[16]; long amount = 0, reward_bp = 0, cap = 0, cashback; @@ -37,6 +45,24 @@ TX_SERVICE(ST_OL_0026, ctx) tx_buf_getlong(ctx->in, "AMOUNT", &amount); tx_buf_getlong(ctx->in, "REWARDBP", &reward_bp); tx_buf_getlong(ctx->in, "CAP", &cap); + + /* 리워드 정책 조회 */ + if (reward_bp <= 0 || cap <= 0) { + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_reward_bp = 0; + h_cap = 0; + EXEC SQL SELECT reward_bp, cap_amt + INTO :h_reward_bp, :h_cap + FROM st_reward_policy + WHERE merch_id = :h_merch; + if (sqlca.sqlcode == TX_SQL_OK) { + if (reward_bp <= 0) reward_bp = h_reward_bp; + if (cap <= 0) cap = h_cap; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT st_reward_policy"); + } + } if (reward_bp <= 0) reward_bp = 100; /* 1% 적립 */ if (cap <= 0) cap = 20000; /* 회차 한도 2만원 */ @@ -54,6 +80,7 @@ TX_SERVICE(ST_OL_0026, ctx) tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); tx_buf_setlong(ctx->out, "AMOUNT", amount); + tx_buf_setlong(ctx->out, "REWARDBP", reward_bp); tx_buf_setlong(ctx->out, "CASHBACK", cashback); tx_buf_setlong(ctx->out, "CAP", cap); tx_log(TX_LOG_INFO, "[ST_OL_0026] 캐시백 amount=%ld bp=%ld cashback=%ld", diff --git a/app/online/st_ol_0027.c b/app/online/st_ol_0027.c index b88ca04..0a7797d 100644 --- a/app/online/st_ol_0027.c +++ b/app/online/st_ol_0027.c @@ -11,12 +11,14 @@ * st_ol_0027.pgc - 부분취소 정산 반영 (ST_OL_0027) [tier=medium] * * 원거래 부분취소 시 취소금액을 차감한 잔여금액을 산출하고, 수수료를 - * 잔여금액 기준으로 비례 재계산한다. + * 잔여금액 기준으로 비례 재계산한다. KEY 지정 시 원장(st_ledger)의 금액/ + * 수수료를 잔여기준으로 임베디드 UPDATE 로 반영한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0027.pgc" +#line 17 "app/online/st_ol_0027.pgc" @@ -103,8 +105,34 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0027, ctx) { - char merch[16]; + /* exec sql begin declare section */ + + + + + + +#line 31 "app/online/st_ol_0027.pgc" + char h_key [ 16 ] ; + +#line 32 "app/online/st_ol_0027.pgc" + long h_orig ; + +#line 33 "app/online/st_ol_0027.pgc" + long h_remain ; + +#line 34 "app/online/st_ol_0027.pgc" + long h_new_fee ; + +#line 35 "app/online/st_ol_0027.pgc" + long h_affected ; +/* exec sql end declare section */ +#line 36 "app/online/st_ol_0027.pgc" + + + char merch[16], key[16]; long orig = 0, cancel = 0, std_bp = 0, remain, new_fee, fee_refund, orig_fee; + int applied = 0, has_key; tx_log(TX_LOG_INFO, "[ST_OL_0027] 부분취소 정산 반영 진입"); @@ -112,11 +140,30 @@ TX_SERVICE(ST_OL_0027, ctx) tx_return(ctx, TX_EINVAL, ctx->out); return; } + has_key = (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) == TX_OK); tx_buf_getlong(ctx->in, "ORIG", &orig); tx_buf_getlong(ctx->in, "CANCEL", &cancel); tx_buf_getlong(ctx->in, "STDBP", &std_bp); if (std_bp <= 0) std_bp = 180; + /* KEY 지정 시 원장 원금 조회 */ + if (has_key && orig <= 0) { + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_orig = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select amount from st_ledger where key = $1 ", + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_orig),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 62 "app/online/st_ol_0027.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) + orig = h_orig; + else if (sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT st_ledger 부분취소"); + } + if (orig <= 0 || cancel < 0 || cancel > orig) { tx_log(TX_LOG_WARN, "[ST_OL_0027] 취소금액 오류 orig=%ld cancel=%ld", orig, cancel); tx_buf_reset(ctx->out); @@ -130,13 +177,43 @@ TX_SERVICE(ST_OL_0027, ctx) new_fee = st_fee_round(remain, std_bp); fee_refund = orig_fee - new_fee; + /* 원장 잔여금액/수수료 반영 */ + if (has_key) { + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_remain = remain; + h_new_fee = new_fee; + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0027] tx_begin 경고"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_ledger set amount = $1 , fee = $2 , upd_ts = now ( ) where key = $3 ", + ECPGt_long,&(h_remain),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_new_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 92 "app/online/st_ol_0027.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE st_ledger 부분취소"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + h_affected = sqlca.sqlerrd[2]; + tx_commit(); + applied = (h_affected > 0); + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); + tx_buf_setlong(ctx->out, "ORIG", orig); tx_buf_setlong(ctx->out, "REMAIN", remain); tx_buf_setlong(ctx->out, "NEWFEE", new_fee); tx_buf_setlong(ctx->out, "FEEREFUND", fee_refund); - tx_log(TX_LOG_INFO, "[ST_OL_0027] 부분취소 orig=%ld cancel=%ld 잔여=%ld 수수료환급=%ld", - orig, cancel, remain, fee_refund); + tx_buf_sets(ctx->out, "APPLIED", applied ? "Y" : "N"); + tx_log(TX_LOG_INFO, "[ST_OL_0027] 부분취소 orig=%ld cancel=%ld 잔여=%ld 수수료환급=%ld apply=%s", + orig, cancel, remain, fee_refund, applied ? "Y" : "N"); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0027.pgc b/app/online/st_ol_0027.pgc index 525c8f3..3362ea6 100644 --- a/app/online/st_ol_0027.pgc +++ b/app/online/st_ol_0027.pgc @@ -3,12 +3,14 @@ * st_ol_0027.pgc - 부분취소 정산 반영 (ST_OL_0027) [tier=medium] * * 원거래 부분취소 시 취소금액을 차감한 잔여금액을 산출하고, 수수료를 - * 잔여금액 기준으로 비례 재계산한다. + * 잔여금액 기준으로 비례 재계산한다. KEY 지정 시 원장(st_ledger)의 금액/ + * 수수료를 잔여기준으로 임베디드 UPDATE 로 반영한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,8 +27,17 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0027, ctx) { - char merch[16]; + EXEC SQL BEGIN DECLARE SECTION; + char h_key[16]; + long h_orig; + long h_remain; + long h_new_fee; + long h_affected; + EXEC SQL END DECLARE SECTION; + + char merch[16], key[16]; long orig = 0, cancel = 0, std_bp = 0, remain, new_fee, fee_refund, orig_fee; + int applied = 0, has_key; tx_log(TX_LOG_INFO, "[ST_OL_0027] 부분취소 정산 반영 진입"); @@ -34,11 +45,27 @@ TX_SERVICE(ST_OL_0027, ctx) tx_return(ctx, TX_EINVAL, ctx->out); return; } + has_key = (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) == TX_OK); tx_buf_getlong(ctx->in, "ORIG", &orig); tx_buf_getlong(ctx->in, "CANCEL", &cancel); tx_buf_getlong(ctx->in, "STDBP", &std_bp); if (std_bp <= 0) std_bp = 180; + /* KEY 지정 시 원장 원금 조회 */ + if (has_key && orig <= 0) { + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_orig = 0; + EXEC SQL SELECT amount + INTO :h_orig + FROM st_ledger + WHERE key = :h_key; + if (sqlca.sqlcode == TX_SQL_OK) + orig = h_orig; + else if (sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT st_ledger 부분취소"); + } + if (orig <= 0 || cancel < 0 || cancel > orig) { tx_log(TX_LOG_WARN, "[ST_OL_0027] 취소금액 오류 orig=%ld cancel=%ld", orig, cancel); tx_buf_reset(ctx->out); @@ -52,13 +79,37 @@ TX_SERVICE(ST_OL_0027, ctx) new_fee = st_fee_round(remain, std_bp); fee_refund = orig_fee - new_fee; + /* 원장 잔여금액/수수료 반영 */ + if (has_key) { + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + h_remain = remain; + h_new_fee = new_fee; + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0027] tx_begin 경고"); + EXEC SQL UPDATE st_ledger + SET amount = :h_remain, fee = :h_new_fee, upd_ts = now() + WHERE key = :h_key; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE st_ledger 부분취소"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + h_affected = sqlca.sqlerrd[2]; + tx_commit(); + applied = (h_affected > 0); + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); + tx_buf_setlong(ctx->out, "ORIG", orig); tx_buf_setlong(ctx->out, "REMAIN", remain); tx_buf_setlong(ctx->out, "NEWFEE", new_fee); tx_buf_setlong(ctx->out, "FEEREFUND", fee_refund); - tx_log(TX_LOG_INFO, "[ST_OL_0027] 부분취소 orig=%ld cancel=%ld 잔여=%ld 수수료환급=%ld", - orig, cancel, remain, fee_refund); + tx_buf_sets(ctx->out, "APPLIED", applied ? "Y" : "N"); + tx_log(TX_LOG_INFO, "[ST_OL_0027] 부분취소 orig=%ld cancel=%ld 잔여=%ld 수수료환급=%ld apply=%s", + orig, cancel, remain, fee_refund, applied ? "Y" : "N"); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0028.c b/app/online/st_ol_0028.c index 7ffdae4..c68dcfd 100644 --- a/app/online/st_ol_0028.c +++ b/app/online/st_ol_0028.c @@ -11,12 +11,14 @@ * st_ol_0028.pgc - 프로모션 할인 정산 (ST_OL_0028) [tier=easy] * * 프로모션 할인요율(만분율)을 매출에 적용하여 할인액을 산출하되, - * 프로모션 예산 한도(cap)를 상한으로 실 청구금액을 계산한다. + * 프로모션 예산 한도(cap)를 상한으로 실 청구금액을 계산한다. 프로모션 + * 예산 마스터(st_promo)에서 요율/잔여예산을 조회하고 소진분을 차감한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0028.pgc" +#line 17 "app/online/st_ol_0028.pgc" @@ -103,8 +105,34 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0028, ctx) { + /* exec sql begin declare section */ + + + + + + +#line 31 "app/online/st_ol_0028.pgc" + char h_promo [ 12 ] ; + +#line 32 "app/online/st_ol_0028.pgc" + long h_promo_bp ; + +#line 33 "app/online/st_ol_0028.pgc" + long h_remain_budget ; + +#line 34 "app/online/st_ol_0028.pgc" + long h_discount ; + +#line 35 "app/online/st_ol_0028.pgc" + long h_affected ; +/* exec sql end declare section */ +#line 36 "app/online/st_ol_0028.pgc" + + char merch[16], promo[12]; long amount = 0, promo_bp = 0, cap = 0, discount, charged; + int budget_applied = 0; tx_log(TX_LOG_INFO, "[ST_OL_0028] 프로모션 할인 정산 진입"); @@ -117,6 +145,28 @@ TX_SERVICE(ST_OL_0028, ctx) tx_buf_getlong(ctx->in, "AMOUNT", &amount); tx_buf_getlong(ctx->in, "PROMOBP", &promo_bp); tx_buf_getlong(ctx->in, "CAP", &cap); + + /* 프로모션 예산 조회 (요율/잔여예산) */ + strncpy(h_promo, promo, sizeof(h_promo) - 1); + h_promo[sizeof(h_promo) - 1] = '\0'; + h_promo_bp = 0; + h_remain_budget = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select promo_bp , remain_budget from st_promo where promo_code = $1 ", + ECPGt_char,(h_promo),(long)12,(long)1,(12)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_promo_bp),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_remain_budget),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 62 "app/online/st_ol_0028.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) { + if (promo_bp <= 0) promo_bp = h_promo_bp; + if (cap <= 0) cap = h_remain_budget; + budget_applied = 1; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT st_promo"); + } if (promo_bp <= 0) promo_bp = 500; /* 5% 할인 */ if (cap <= 0) cap = 10000; /* 프로모션 상한 1만원 */ @@ -131,6 +181,31 @@ TX_SERVICE(ST_OL_0028, ctx) if (discount > cap) discount = cap; charged = amount - discount; + /* 예산 소진 반영 */ + if (budget_applied && discount > 0) { + h_discount = discount; + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0028] tx_begin 경고"); + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_promo set remain_budget = remain_budget - $1 , upd_ts = now ( ) where promo_code = $2 and remain_budget >= $3 ", + ECPGt_long,&(h_discount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_promo),(long)12,(long)1,(12)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_discount),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 92 "app/online/st_ol_0028.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE st_promo 예산소진"); + tx_abort(); + } else { + h_affected = sqlca.sqlerrd[2]; + tx_commit(); + if (h_affected == 0) + tx_log(TX_LOG_WARN, "[ST_OL_0028] 예산부족 promo=%s", promo); + } + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); diff --git a/app/online/st_ol_0028.pgc b/app/online/st_ol_0028.pgc index 0344dd1..b98f835 100644 --- a/app/online/st_ol_0028.pgc +++ b/app/online/st_ol_0028.pgc @@ -3,12 +3,14 @@ * st_ol_0028.pgc - 프로모션 할인 정산 (ST_OL_0028) [tier=easy] * * 프로모션 할인요율(만분율)을 매출에 적용하여 할인액을 산출하되, - * 프로모션 예산 한도(cap)를 상한으로 실 청구금액을 계산한다. + * 프로모션 예산 한도(cap)를 상한으로 실 청구금액을 계산한다. 프로모션 + * 예산 마스터(st_promo)에서 요율/잔여예산을 조회하고 소진분을 차감한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,8 +27,17 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0028, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_promo[12]; + long h_promo_bp; + long h_remain_budget; + long h_discount; + long h_affected; + EXEC SQL END DECLARE SECTION; + char merch[16], promo[12]; long amount = 0, promo_bp = 0, cap = 0, discount, charged; + int budget_applied = 0; tx_log(TX_LOG_INFO, "[ST_OL_0028] 프로모션 할인 정산 진입"); @@ -39,6 +50,23 @@ TX_SERVICE(ST_OL_0028, ctx) tx_buf_getlong(ctx->in, "AMOUNT", &amount); tx_buf_getlong(ctx->in, "PROMOBP", &promo_bp); tx_buf_getlong(ctx->in, "CAP", &cap); + + /* 프로모션 예산 조회 (요율/잔여예산) */ + strncpy(h_promo, promo, sizeof(h_promo) - 1); + h_promo[sizeof(h_promo) - 1] = '\0'; + h_promo_bp = 0; + h_remain_budget = 0; + EXEC SQL SELECT promo_bp, remain_budget + INTO :h_promo_bp, :h_remain_budget + FROM st_promo + WHERE promo_code = :h_promo; + if (sqlca.sqlcode == TX_SQL_OK) { + if (promo_bp <= 0) promo_bp = h_promo_bp; + if (cap <= 0) cap = h_remain_budget; + budget_applied = 1; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT st_promo"); + } if (promo_bp <= 0) promo_bp = 500; /* 5% 할인 */ if (cap <= 0) cap = 10000; /* 프로모션 상한 1만원 */ @@ -53,6 +81,26 @@ TX_SERVICE(ST_OL_0028, ctx) if (discount > cap) discount = cap; charged = amount - discount; + /* 예산 소진 반영 */ + if (budget_applied && discount > 0) { + h_discount = discount; + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0028] tx_begin 경고"); + EXEC SQL UPDATE st_promo + SET remain_budget = remain_budget - :h_discount, upd_ts = now() + WHERE promo_code = :h_promo + AND remain_budget >= :h_discount; + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE st_promo 예산소진"); + tx_abort(); + } else { + h_affected = sqlca.sqlerrd[2]; + tx_commit(); + if (h_affected == 0) + tx_log(TX_LOG_WARN, "[ST_OL_0028] 예산부족 promo=%s", promo); + } + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); diff --git a/app/online/st_ol_0029.c b/app/online/st_ol_0029.c index 368e4dc..d7d28ae 100644 --- a/app/online/st_ol_0029.c +++ b/app/online/st_ol_0029.c @@ -11,12 +11,14 @@ * st_ol_0029.pgc - 수수료 상/하한(cap/floor) 적용 (ST_OL_0029) [tier=medium] * * 정률 수수료 산출 후 건별 최소수수료(floor)와 최대수수료(cap) 로 - * 클램핑하여 최종 수수료를 확정한다. + * 클램핑하여 최종 수수료를 확정한다. floor/cap 미입력 시 가맹점 수수료 + * 한도 마스터(st_fee_bound)에서 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0029.pgc" +#line 17 "app/online/st_ol_0029.pgc" @@ -103,6 +105,23 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0029, ctx) { + /* exec sql begin declare section */ + + + + +#line 31 "app/online/st_ol_0029.pgc" + char h_merch [ 16 ] ; + +#line 32 "app/online/st_ol_0029.pgc" + long h_floor ; + +#line 33 "app/online/st_ol_0029.pgc" + long h_cap ; +/* exec sql end declare section */ +#line 34 "app/online/st_ol_0029.pgc" + + char merch[16]; long amount = 0, bp = 0, floor = 0, cap = 0, raw, fee; const char *clamp; @@ -118,6 +137,29 @@ TX_SERVICE(ST_OL_0029, ctx) tx_buf_getlong(ctx->in, "FLOOR", &floor); tx_buf_getlong(ctx->in, "CAP", &cap); if (bp <= 0) bp = 180; + + /* 수수료 한도 조회 */ + if (floor <= 0 || cap <= 0) { + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_floor = 0; + h_cap = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select floor_fee , cap_fee from st_fee_bound where merch_id = $1 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_floor),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_cap),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 61 "app/online/st_ol_0029.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) { + if (floor <= 0) floor = h_floor; + if (cap <= 0) cap = h_cap; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT st_fee_bound"); + } + } if (floor <= 0) floor = 100; /* 최소 100원 */ if (cap <= 0) cap = 50000; /* 최대 5만원 */ @@ -137,6 +179,8 @@ TX_SERVICE(ST_OL_0029, ctx) tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); tx_buf_setlong(ctx->out, "RAWFEE", raw); + tx_buf_setlong(ctx->out, "FLOOR", floor); + tx_buf_setlong(ctx->out, "CAP", cap); tx_buf_setlong(ctx->out, "FEE", fee); tx_buf_sets(ctx->out, "CLAMP", clamp); tx_log(TX_LOG_INFO, "[ST_OL_0029] cap/floor raw=%ld fee=%ld clamp=%s", diff --git a/app/online/st_ol_0029.pgc b/app/online/st_ol_0029.pgc index 46865d6..9524adf 100644 --- a/app/online/st_ol_0029.pgc +++ b/app/online/st_ol_0029.pgc @@ -3,12 +3,14 @@ * st_ol_0029.pgc - 수수료 상/하한(cap/floor) 적용 (ST_OL_0029) [tier=medium] * * 정률 수수료 산출 후 건별 최소수수료(floor)와 최대수수료(cap) 로 - * 클램핑하여 최종 수수료를 확정한다. + * 클램핑하여 최종 수수료를 확정한다. floor/cap 미입력 시 가맹점 수수료 + * 한도 마스터(st_fee_bound)에서 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,6 +27,12 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0029, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + long h_floor; + long h_cap; + EXEC SQL END DECLARE SECTION; + char merch[16]; long amount = 0, bp = 0, floor = 0, cap = 0, raw, fee; const char *clamp; @@ -40,6 +48,24 @@ TX_SERVICE(ST_OL_0029, ctx) tx_buf_getlong(ctx->in, "FLOOR", &floor); tx_buf_getlong(ctx->in, "CAP", &cap); if (bp <= 0) bp = 180; + + /* 수수료 한도 조회 */ + if (floor <= 0 || cap <= 0) { + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + h_floor = 0; + h_cap = 0; + EXEC SQL SELECT floor_fee, cap_fee + INTO :h_floor, :h_cap + FROM st_fee_bound + WHERE merch_id = :h_merch; + if (sqlca.sqlcode == TX_SQL_OK) { + if (floor <= 0) floor = h_floor; + if (cap <= 0) cap = h_cap; + } else if (sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT st_fee_bound"); + } + } if (floor <= 0) floor = 100; /* 최소 100원 */ if (cap <= 0) cap = 50000; /* 최대 5만원 */ @@ -59,6 +85,8 @@ TX_SERVICE(ST_OL_0029, ctx) tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); tx_buf_setlong(ctx->out, "RAWFEE", raw); + tx_buf_setlong(ctx->out, "FLOOR", floor); + tx_buf_setlong(ctx->out, "CAP", cap); tx_buf_setlong(ctx->out, "FEE", fee); tx_buf_sets(ctx->out, "CLAMP", clamp); tx_log(TX_LOG_INFO, "[ST_OL_0029] cap/floor raw=%ld fee=%ld clamp=%s", diff --git a/app/online/st_ol_0030.c b/app/online/st_ol_0030.c index 6910bfa..f05666f 100644 --- a/app/online/st_ol_0030.c +++ b/app/online/st_ol_0030.c @@ -12,11 +12,13 @@ * * 외화 매출을 적용환율(1e4 스케일)로 원화 환산한다. 원화 환산액은 * 원단위 미만을 절사하고, 수수료는 환산 후 원화 기준으로 산출한다. + * 환율 미입력 시 통화별 고시환율(st_fx_rate)에서 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0030.pgc" +#line 17 "app/online/st_ol_0030.pgc" @@ -103,6 +105,19 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0030, ctx) { + /* exec sql begin declare section */ + + + +#line 31 "app/online/st_ol_0030.pgc" + char h_cur [ 4 ] ; + +#line 32 "app/online/st_ol_0030.pgc" + long h_rate ; +/* exec sql end declare section */ +#line 33 "app/online/st_ol_0030.pgc" + + char merch[16], cur[4]; long fx_amount = 0, rate = 0, fee_bp = 0, krw, fee, net; @@ -119,6 +134,24 @@ TX_SERVICE(ST_OL_0030, ctx) tx_buf_getlong(ctx->in, "FEEBP", &fee_bp); if (fee_bp <= 0) fee_bp = 200; /* 2% */ + /* 고시환율 조회 (당일 최신 고시) */ + if (rate <= 0) { + strncpy(h_cur, cur, sizeof(h_cur) - 1); + h_cur[sizeof(h_cur) - 1] = '\0'; + h_rate = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select rate_x10000 from st_fx_rate where cur_code = $1 order by quote_ts desc limit 1", + ECPGt_char,(h_cur),(long)4,(long)1,(4)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_rate),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 61 "app/online/st_ol_0030.pgc" + + if (sqlca.sqlcode == TX_SQL_OK && h_rate > 0) + rate = h_rate; + else if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT st_fx_rate"); + } + if (fx_amount <= 0 || rate <= 0) { tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); @@ -134,6 +167,7 @@ TX_SERVICE(ST_OL_0030, ctx) tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); tx_buf_sets(ctx->out, "CUR", cur); + tx_buf_setlong(ctx->out, "RATE", rate); tx_buf_setlong(ctx->out, "KRW", krw); tx_buf_setlong(ctx->out, "FEE", fee); tx_buf_setlong(ctx->out, "NET", net); diff --git a/app/online/st_ol_0030.pgc b/app/online/st_ol_0030.pgc index 7b2bd5b..5840e34 100644 --- a/app/online/st_ol_0030.pgc +++ b/app/online/st_ol_0030.pgc @@ -4,11 +4,13 @@ * * 외화 매출을 적용환율(1e4 스케일)로 원화 환산한다. 원화 환산액은 * 원단위 미만을 절사하고, 수수료는 환산 후 원화 기준으로 산출한다. + * 환율 미입력 시 통화별 고시환율(st_fx_rate)에서 조회한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,6 +27,11 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0030, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_cur[4]; + long h_rate; + EXEC SQL END DECLARE SECTION; + char merch[16], cur[4]; long fx_amount = 0, rate = 0, fee_bp = 0, krw, fee, net; @@ -41,6 +48,23 @@ TX_SERVICE(ST_OL_0030, ctx) tx_buf_getlong(ctx->in, "FEEBP", &fee_bp); if (fee_bp <= 0) fee_bp = 200; /* 2% */ + /* 고시환율 조회 (당일 최신 고시) */ + if (rate <= 0) { + strncpy(h_cur, cur, sizeof(h_cur) - 1); + h_cur[sizeof(h_cur) - 1] = '\0'; + h_rate = 0; + EXEC SQL SELECT rate_x10000 + INTO :h_rate + FROM st_fx_rate + WHERE cur_code = :h_cur + ORDER BY quote_ts DESC + LIMIT 1; + if (sqlca.sqlcode == TX_SQL_OK && h_rate > 0) + rate = h_rate; + else if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT st_fx_rate"); + } + if (fx_amount <= 0 || rate <= 0) { tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); @@ -56,6 +80,7 @@ TX_SERVICE(ST_OL_0030, ctx) tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); tx_buf_sets(ctx->out, "CUR", cur); + tx_buf_setlong(ctx->out, "RATE", rate); tx_buf_setlong(ctx->out, "KRW", krw); tx_buf_setlong(ctx->out, "FEE", fee); tx_buf_setlong(ctx->out, "NET", net); diff --git a/app/online/st_ol_0031.c b/app/online/st_ol_0031.c index d1d8d81..d9f3816 100644 --- a/app/online/st_ol_0031.c +++ b/app/online/st_ol_0031.c @@ -11,12 +11,14 @@ * st_ol_0031.pgc - 정산 확정 처리 (ST_OL_0031) [tier=medium] * * 처리완료(M) 건을 정산완료(S)로 확정 전이한다. 완료 상태가 아닌 건은 - * 확정 불가로 반려한다. + * 확정 불가로 반려한다. 상태 전이는 원장(st_ledger)에 M->S 조건부 + * 임베디드 UPDATE 로 반영한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,15 +91,38 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0031.pgc" +#line 17 "app/online/st_ol_0031.pgc" TX_SERVICE(ST_OL_0031, ctx) { - st_rec_t rec; + /* exec sql begin declare section */ + + + + + + +#line 23 "app/online/st_ol_0031.pgc" + char h_key [ 16 ] ; + +#line 24 "app/online/st_ol_0031.pgc" + char h_status [ 2 ] ; + +#line 25 "app/online/st_ol_0031.pgc" + long h_amount ; + +#line 26 "app/online/st_ol_0031.pgc" + long h_fee ; + +#line 27 "app/online/st_ol_0031.pgc" + long h_affected ; +/* exec sql end declare section */ +#line 28 "app/online/st_ol_0031.pgc" + + char key[16]; - int rc; tx_log(TX_LOG_INFO, "[ST_OL_0031] 정산 확정 처리 진입"); @@ -106,15 +131,36 @@ TX_SERVICE(ST_OL_0031, ctx) return; } - memset(&rec, 0, sizeof(rec)); - rc = st_rec_select(key, &rec); - if (rc != TX_OK) { - tx_return(ctx, rc, ctx->out); + /* 현재 상태/금액 조회 */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + memset(h_status, 0, sizeof(h_status)); + h_amount = 0; + h_fee = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select status , amount , fee from st_ledger where key = $1 ", + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_status),(long)2,(long)1,(2)*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_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 48 "app/online/st_ol_0031.pgc" + + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_return(ctx, TX_ENOENT, ctx->out); + return; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT st_ledger 확정"); + tx_return(ctx, TX_EDB, ctx->out); return; } - if (strcmp(rec.status, ST_ST_DONE) != 0) { - tx_log(TX_LOG_WARN, "[ST_OL_0031] 확정 불가 상태 key=%s st=%s", key, rec.status); + if (memcmp(h_status, ST_ST_DONE, 1) != 0) { + tx_log(TX_LOG_WARN, "[ST_OL_0031] 확정 불가 상태 key=%s st=%s", key, h_status); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); tx_buf_sets(ctx->out, "REASON", "NOT_DONE"); @@ -122,17 +168,38 @@ TX_SERVICE(ST_OL_0031, ctx) return; } - rc = st_rec_update_status(key, ST_ST_SETTLED); - if (rc != TX_OK) { - tx_return(ctx, rc, ctx->out); + /* M -> S 조건부 확정 전이 */ + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0031] tx_begin 경고"); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_ledger set status = 'S' , upd_ts = now ( ) where key = $1 and status = 'M'", + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 76 "app/online/st_ol_0031.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE st_ledger 확정"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); return; } + h_affected = sqlca.sqlerrd[2]; + if (h_affected == 0) { + tx_abort(); + tx_log(TX_LOG_WARN, "[ST_OL_0031] 확정 반영 0건 key=%s", key); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); + tx_return(ctx, TX_FAIL, ctx->out); + return; + } + tx_commit(); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "KEY", key); tx_buf_sets(ctx->out, "STATUS", ST_ST_SETTLED); - tx_buf_setlong(ctx->out, "NET", rec.amount - rec.fee); - tx_log(TX_LOG_INFO, "[ST_OL_0031] 정산확정 key=%s net=%ld", key, rec.amount - rec.fee); + tx_buf_setlong(ctx->out, "NET", h_amount - h_fee); + tx_log(TX_LOG_INFO, "[ST_OL_0031] 정산확정 key=%s net=%ld", key, h_amount - h_fee); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0031.pgc b/app/online/st_ol_0031.pgc index 1cf5265..037d5d6 100644 --- a/app/online/st_ol_0031.pgc +++ b/app/online/st_ol_0031.pgc @@ -3,12 +3,14 @@ * st_ol_0031.pgc - 정산 확정 처리 (ST_OL_0031) [tier=medium] * * 처리완료(M) 건을 정산완료(S)로 확정 전이한다. 완료 상태가 아닌 건은 - * 확정 불가로 반려한다. + * 확정 불가로 반려한다. 상태 전이는 원장(st_ledger)에 M->S 조건부 + * 임베디드 UPDATE 로 반영한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -17,9 +19,15 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(ST_OL_0031, ctx) { - st_rec_t rec; + EXEC SQL BEGIN DECLARE SECTION; + char h_key[16]; + char h_status[2]; + long h_amount; + long h_fee; + long h_affected; + EXEC SQL END DECLARE SECTION; + char key[16]; - int rc; tx_log(TX_LOG_INFO, "[ST_OL_0031] 정산 확정 처리 진입"); @@ -28,15 +36,29 @@ TX_SERVICE(ST_OL_0031, ctx) return; } - memset(&rec, 0, sizeof(rec)); - rc = st_rec_select(key, &rec); - if (rc != TX_OK) { - tx_return(ctx, rc, ctx->out); + /* 현재 상태/금액 조회 */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + memset(h_status, 0, sizeof(h_status)); + h_amount = 0; + h_fee = 0; + EXEC SQL SELECT status, amount, fee + INTO :h_status, :h_amount, :h_fee + FROM st_ledger + WHERE key = :h_key; + + if (sqlca.sqlcode == TX_SQL_NOTFOUND) { + tx_return(ctx, TX_ENOENT, ctx->out); + return; + } + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("SELECT st_ledger 확정"); + tx_return(ctx, TX_EDB, ctx->out); return; } - if (strcmp(rec.status, ST_ST_DONE) != 0) { - tx_log(TX_LOG_WARN, "[ST_OL_0031] 확정 불가 상태 key=%s st=%s", key, rec.status); + if (memcmp(h_status, ST_ST_DONE, 1) != 0) { + tx_log(TX_LOG_WARN, "[ST_OL_0031] 확정 불가 상태 key=%s st=%s", key, h_status); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); tx_buf_sets(ctx->out, "REASON", "NOT_DONE"); @@ -44,17 +66,37 @@ TX_SERVICE(ST_OL_0031, ctx) return; } - rc = st_rec_update_status(key, ST_ST_SETTLED); - if (rc != TX_OK) { - tx_return(ctx, rc, ctx->out); + /* M -> S 조건부 확정 전이 */ + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0031] tx_begin 경고"); + + EXEC SQL UPDATE st_ledger + SET status = 'S', upd_ts = now() + WHERE key = :h_key + AND status = 'M'; + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("UPDATE st_ledger 확정"); + tx_abort(); + tx_return(ctx, TX_EDB, ctx->out); return; } + h_affected = sqlca.sqlerrd[2]; + if (h_affected == 0) { + tx_abort(); + tx_log(TX_LOG_WARN, "[ST_OL_0031] 확정 반영 0건 key=%s", key); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID); + tx_return(ctx, TX_FAIL, ctx->out); + return; + } + tx_commit(); tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "KEY", key); tx_buf_sets(ctx->out, "STATUS", ST_ST_SETTLED); - tx_buf_setlong(ctx->out, "NET", rec.amount - rec.fee); - tx_log(TX_LOG_INFO, "[ST_OL_0031] 정산확정 key=%s net=%ld", key, rec.amount - rec.fee); + tx_buf_setlong(ctx->out, "NET", h_amount - h_fee); + tx_log(TX_LOG_INFO, "[ST_OL_0031] 정산확정 key=%s net=%ld", key, h_amount - h_fee); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0032.c b/app/online/st_ol_0032.c index cc4ec9d..db01f38 100644 --- a/app/online/st_ol_0032.c +++ b/app/online/st_ol_0032.c @@ -11,12 +11,14 @@ * st_ol_0032.pgc - 정산 예치금(보증금) 산정 (ST_OL_0032) [tier=easy] * * 정산순액의 일부를 지급유보(리스크 예치금)로 적립한다. 예치요율 - * (만분율)을 적용하여 예치금과 실지급액을 산출한다. + * (만분율)을 적용하여 예치금과 실지급액을 산출하고, 예치금 원장 + * (st_reserve_book)에 적립 내역을 기표한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/st_ol_0032.pgc" +#line 17 "app/online/st_ol_0032.pgc" @@ -103,8 +105,29 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0032, ctx) { + /* exec sql begin declare section */ + + + + + +#line 31 "app/online/st_ol_0032.pgc" + char h_merch [ 16 ] ; + +#line 32 "app/online/st_ol_0032.pgc" + long h_reserve_bp ; + +#line 33 "app/online/st_ol_0032.pgc" + long h_reserve ; + +#line 34 "app/online/st_ol_0032.pgc" + long h_balance ; +/* exec sql end declare section */ +#line 35 "app/online/st_ol_0032.pgc" + + char merch[16]; - long net = 0, reserve_bp = 0, reserve, payout; + long net = 0, reserve_bp = 0, reserve, payout, balance = 0; tx_log(TX_LOG_INFO, "[ST_OL_0032] 정산 예치금 산정 진입"); @@ -114,7 +137,26 @@ TX_SERVICE(ST_OL_0032, ctx) } tx_buf_getlong(ctx->in, "NET", &net); tx_buf_getlong(ctx->in, "RESERVEBP", &reserve_bp); - if (reserve_bp < 0 || reserve_bp > 10000) reserve_bp = 500; /* 5% 예치 */ + + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + + /* 예치요율 정책 조회 */ + if (reserve_bp <= 0) { + h_reserve_bp = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select reserve_bp from st_reserve_policy where merch_id = $1 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_reserve_bp),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 58 "app/online/st_ol_0032.pgc" + + if (sqlca.sqlcode == TX_SQL_OK && h_reserve_bp >= 0) + reserve_bp = h_reserve_bp; + else if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT st_reserve_policy"); + } + if (reserve_bp <= 0 || reserve_bp > 10000) reserve_bp = 500; /* 5% 예치 */ if (net <= 0) { tx_buf_reset(ctx->out); @@ -126,13 +168,48 @@ TX_SERVICE(ST_OL_0032, ctx) reserve = st_fee_round(net, reserve_bp); payout = net - reserve; + /* 예치금 원장 적립 (트랜잭션 경계) */ + h_reserve = reserve; + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0032] tx_begin 경고"); + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into st_reserve_book ( merch_id , reserve_amt , reg_ts ) values ( $1 , $2 , now ( ) )", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_reserve),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} +#line 84 "app/online/st_ol_0032.pgc" + + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT st_reserve_book"); + tx_abort(); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_commit(); + + /* 누적 예치잔액 재집계 */ + h_balance = 0; + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select coalesce ( sum ( reserve_amt ) , 0 ) from st_reserve_book where merch_id = $1 ", + ECPGt_char,(h_merch),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_long,&(h_balance),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 100 "app/online/st_ol_0032.pgc" + + if (sqlca.sqlcode == TX_SQL_OK) + balance = h_balance; + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); tx_buf_setlong(ctx->out, "NET", net); tx_buf_setlong(ctx->out, "RESERVE", reserve); tx_buf_setlong(ctx->out, "PAYOUT", payout); - tx_log(TX_LOG_INFO, "[ST_OL_0032] 예치금 net=%ld reserve=%ld payout=%ld", - net, reserve, payout); + tx_buf_setlong(ctx->out, "BALANCE", balance); + tx_log(TX_LOG_INFO, "[ST_OL_0032] 예치금 net=%ld reserve=%ld payout=%ld 잔액=%ld", + net, reserve, payout, balance); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/st_ol_0032.pgc b/app/online/st_ol_0032.pgc index 877fc64..1b2dbee 100644 --- a/app/online/st_ol_0032.pgc +++ b/app/online/st_ol_0032.pgc @@ -3,12 +3,14 @@ * st_ol_0032.pgc - 정산 예치금(보증금) 산정 (ST_OL_0032) [tier=easy] * * 정산순액의 일부를 지급유보(리스크 예치금)로 적립한다. 예치요율 - * (만분율)을 적용하여 예치금과 실지급액을 산출한다. + * (만분율)을 적용하여 예치금과 실지급액을 산출하고, 예치금 원장 + * (st_reserve_book)에 적립 내역을 기표한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "st_core.h" @@ -25,8 +27,15 @@ static long st_fee_round(long amount, long rate_bp) TX_SERVICE(ST_OL_0032, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_merch[16]; + long h_reserve_bp; + long h_reserve; + long h_balance; + EXEC SQL END DECLARE SECTION; + char merch[16]; - long net = 0, reserve_bp = 0, reserve, payout; + long net = 0, reserve_bp = 0, reserve, payout, balance = 0; tx_log(TX_LOG_INFO, "[ST_OL_0032] 정산 예치금 산정 진입"); @@ -36,7 +45,23 @@ TX_SERVICE(ST_OL_0032, ctx) } tx_buf_getlong(ctx->in, "NET", &net); tx_buf_getlong(ctx->in, "RESERVEBP", &reserve_bp); - if (reserve_bp < 0 || reserve_bp > 10000) reserve_bp = 500; /* 5% 예치 */ + + strncpy(h_merch, merch, sizeof(h_merch) - 1); + h_merch[sizeof(h_merch) - 1] = '\0'; + + /* 예치요율 정책 조회 */ + if (reserve_bp <= 0) { + h_reserve_bp = 0; + EXEC SQL SELECT reserve_bp + INTO :h_reserve_bp + FROM st_reserve_policy + WHERE merch_id = :h_merch; + if (sqlca.sqlcode == TX_SQL_OK && h_reserve_bp >= 0) + reserve_bp = h_reserve_bp; + else if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) + TX_DBIO_LOG_ERR("SELECT st_reserve_policy"); + } + if (reserve_bp <= 0 || reserve_bp > 10000) reserve_bp = 500; /* 5% 예치 */ if (net <= 0) { tx_buf_reset(ctx->out); @@ -48,13 +73,42 @@ TX_SERVICE(ST_OL_0032, ctx) reserve = st_fee_round(net, reserve_bp); payout = net - reserve; + /* 예치금 원장 적립 (트랜잭션 경계) */ + h_reserve = reserve; + if (tx_begin() != TX_OK) + tx_log(TX_LOG_WARN, "[ST_OL_0032] tx_begin 경고"); + + EXEC SQL INSERT INTO st_reserve_book + (merch_id, reserve_amt, reg_ts) + VALUES + (:h_merch, :h_reserve, now()); + if (sqlca.sqlcode != TX_SQL_OK) { + TX_DBIO_LOG_ERR("INSERT st_reserve_book"); + tx_abort(); + tx_buf_reset(ctx->out); + tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_commit(); + + /* 누적 예치잔액 재집계 */ + h_balance = 0; + EXEC SQL SELECT coalesce(sum(reserve_amt), 0) + INTO :h_balance + FROM st_reserve_book + WHERE merch_id = :h_merch; + if (sqlca.sqlcode == TX_SQL_OK) + balance = h_balance; + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "RESPCODE", RESP_OK); tx_buf_sets(ctx->out, "MERCHID", merch); tx_buf_setlong(ctx->out, "NET", net); tx_buf_setlong(ctx->out, "RESERVE", reserve); tx_buf_setlong(ctx->out, "PAYOUT", payout); - tx_log(TX_LOG_INFO, "[ST_OL_0032] 예치금 net=%ld reserve=%ld payout=%ld", - net, reserve, payout); + tx_buf_setlong(ctx->out, "BALANCE", balance); + tx_log(TX_LOG_INFO, "[ST_OL_0032] 예치금 net=%ld reserve=%ld payout=%ld 잔액=%ld", + net, reserve, payout, balance); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/vl_ol_0001.c b/app/online/vl_ol_0001.c index e0938e2..2de2cd1 100644 --- a/app/online/vl_ol_0001.c +++ b/app/online/vl_ol_0001.c @@ -10,13 +10,15 @@ /* * vl_ol_0001.pgc - 정합성 온라인 서비스 (VL_OL_0001) [tier=easy] * - * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 vl 표준 DBIO 를 - * 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응) + * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 vl 표준 DBIO 로 + * 처리한 뒤, 원장(vl_ledger)을 임베디드 조회하여 수수료/카드번호(마스킹)/ + * 영업일 등 상세 필드를 응답에 함께 실어 반환한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "vl_core.h" @@ -89,11 +91,32 @@ struct sqlca_t *ECPGget_sqlca(void); #endif -#line 15 "app/online/vl_ol_0001.pgc" +#line 17 "app/online/vl_ol_0001.pgc" TX_SERVICE(VL_OL_0001, ctx) { + /* exec sql begin declare section */ + + + + + +#line 22 "app/online/vl_ol_0001.pgc" + char h_key [ 16 ] ; + +#line 23 "app/online/vl_ol_0001.pgc" + char h_card_no [ 20 ] ; + +#line 24 "app/online/vl_ol_0001.pgc" + char h_biz_date [ 9 ] ; + +#line 25 "app/online/vl_ol_0001.pgc" + long h_fee ; +/* exec sql end declare section */ +#line 26 "app/online/vl_ol_0001.pgc" + + vl_rec_t rec; char key[16]; int rc; @@ -115,11 +138,40 @@ TX_SERVICE(VL_OL_0001, ctx) return; } + /* 원장 상세 필드 임베디드 조회 (수수료/카드번호/영업일) */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + memset(h_card_no, 0, sizeof(h_card_no)); + memset(h_biz_date, 0, sizeof(h_biz_date)); + h_fee = 0; + + { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select card_no , biz_date , fee from vl_ledger where key = $1 ", + ECPGt_char,(h_key),(long)16,(long)1,(16)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, + ECPGt_char,(h_card_no),(long)20,(long)1,(20)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_char,(h_biz_date),(long)9,(long)1,(9)*sizeof(char), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, + ECPGt_long,&(h_fee),(long)1,(long)1,sizeof(long), + ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} +#line 59 "app/online/vl_ol_0001.pgc" + + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT vl_ledger"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); + tx_buf_setlong(ctx->out, "FEE", h_fee); + tx_buf_sets(ctx->out, "CARDNO", h_card_no); + tx_buf_sets(ctx->out, "BIZDATE", h_biz_date); tx_buf_sets(ctx->out, "STATUS", rec.status); - tx_log(TX_LOG_INFO, "[VL_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); + tx_log(TX_LOG_INFO, "[VL_OL_0001] 조회완료 key=%s amount=%ld fee=%ld", + key, rec.amount, h_fee); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/vl_ol_0001.pgc b/app/online/vl_ol_0001.pgc index 293d344..6a2f67a 100644 --- a/app/online/vl_ol_0001.pgc +++ b/app/online/vl_ol_0001.pgc @@ -2,13 +2,15 @@ /* * vl_ol_0001.pgc - 정합성 온라인 서비스 (VL_OL_0001) [tier=easy] * - * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 vl 표준 DBIO 를 - * 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응) + * TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 vl 표준 DBIO 로 + * 처리한 뒤, 원장(vl_ledger)을 임베디드 조회하여 수수료/카드번호(마스킹)/ + * 영업일 등 상세 필드를 응답에 함께 실어 반환한다. */ #include #include #include "txcore.h" +#include "txcore_dbio.h" #include "acq_util.h" #include "vl_core.h" @@ -16,6 +18,13 @@ EXEC SQL INCLUDE sqlca; TX_SERVICE(VL_OL_0001, ctx) { + EXEC SQL BEGIN DECLARE SECTION; + char h_key[16]; + char h_card_no[20]; + char h_biz_date[9]; + long h_fee; + EXEC SQL END DECLARE SECTION; + vl_rec_t rec; char key[16]; int rc; @@ -37,11 +46,33 @@ TX_SERVICE(VL_OL_0001, ctx) return; } + /* 원장 상세 필드 임베디드 조회 (수수료/카드번호/영업일) */ + strncpy(h_key, key, sizeof(h_key) - 1); + h_key[sizeof(h_key) - 1] = '\0'; + memset(h_card_no, 0, sizeof(h_card_no)); + memset(h_biz_date, 0, sizeof(h_biz_date)); + h_fee = 0; + + EXEC SQL SELECT card_no, biz_date, fee + INTO :h_card_no, :h_biz_date, :h_fee + FROM vl_ledger + WHERE key = :h_key; + + if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { + TX_DBIO_LOG_ERR("SELECT vl_ledger"); + tx_return(ctx, TX_EDB, ctx->out); + return; + } + tx_buf_reset(ctx->out); tx_buf_sets(ctx->out, "KEY", rec.key); tx_buf_sets(ctx->out, "MERCHID", rec.merch_id); tx_buf_setlong(ctx->out, "AMOUNT", rec.amount); + tx_buf_setlong(ctx->out, "FEE", h_fee); + tx_buf_sets(ctx->out, "CARDNO", h_card_no); + tx_buf_sets(ctx->out, "BIZDATE", h_biz_date); tx_buf_sets(ctx->out, "STATUS", rec.status); - tx_log(TX_LOG_INFO, "[VL_OL_0001] 조회완료 key=%s amount=%ld", key, rec.amount); + tx_log(TX_LOG_INFO, "[VL_OL_0001] 조회완료 key=%s amount=%ld fee=%ld", + key, rec.amount, h_fee); tx_return(ctx, TX_OK, ctx->out); } diff --git a/app/online/vl_ol_0002.c b/app/online/vl_ol_0002.c index 90bedec..510171f 100644 --- a/app/online/vl_ol_0002.c +++ b/app/online/vl_ol_0002.c @@ -195,7 +195,7 @@ TX_SERVICE(VL_OL_0002, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_recv_time),(long)7,(long)1,(7)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 91 "app/online/vl_ol_0002.pgc" +#line 90 "app/online/vl_ol_0002.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/vl_ol_0002.pgc b/app/online/vl_ol_0002.pgc index 42ed7ef..f047ea8 100644 --- a/app/online/vl_ol_0002.pgc +++ b/app/online/vl_ol_0002.pgc @@ -84,8 +84,7 @@ TX_SERVICE(VL_OL_0002, ctx) strncpy(h_recv_time, "000000", sizeof(h_recv_time) - 1); h_recv_time[sizeof(h_recv_time) - 1] = '\0'; - EXEC SQL - INSERT INTO vl_recv_hist + EXEC SQL INSERT INTO vl_recv_hist (recv_key, merch_id, biz_date, recv_amount, recv_status, recv_time) VALUES (:h_key, :h_merch, :h_bizdate, :h_amount, :h_status, :h_recv_time); diff --git a/app/online/vl_ol_0003.c b/app/online/vl_ol_0003.c index bd42ed5..14c9b58 100644 --- a/app/online/vl_ol_0003.c +++ b/app/online/vl_ol_0003.c @@ -146,7 +146,7 @@ TX_SERVICE(VL_OL_0003, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_appr_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 57 "app/online/vl_ol_0003.pgc" +#line 56 "app/online/vl_ol_0003.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0003.pgc b/app/online/vl_ol_0003.pgc index cee6559..db69560 100644 --- a/app/online/vl_ol_0003.pgc +++ b/app/online/vl_ol_0003.pgc @@ -50,8 +50,7 @@ TX_SERVICE(VL_OL_0003, ctx) strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0'; - EXEC SQL - SELECT sale_amount, approval_amount + EXEC SQL SELECT sale_amount, approval_amount INTO :h_sale_amt, :h_appr_amt FROM vl_sale_source WHERE txn_key = :h_key; diff --git a/app/online/vl_ol_0004.c b/app/online/vl_ol_0004.c index 8254d84..e956fbc 100644 --- a/app/online/vl_ol_0004.c +++ b/app/online/vl_ol_0004.c @@ -157,7 +157,7 @@ TX_SERVICE(VL_OL_0004, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_dupcnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 65 "app/online/vl_ol_0004.pgc" +#line 64 "app/online/vl_ol_0004.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0004.pgc b/app/online/vl_ol_0004.pgc index 2448e5f..28112e6 100644 --- a/app/online/vl_ol_0004.pgc +++ b/app/online/vl_ol_0004.pgc @@ -56,8 +56,7 @@ TX_SERVICE(VL_OL_0004, ctx) h_amount = amount; h_dupcnt = 0; - EXEC SQL - SELECT COUNT(*) + EXEC SQL SELECT COUNT(*) INTO :h_dupcnt FROM vl_ledger WHERE card_no = :h_card diff --git a/app/online/vl_ol_0005.c b/app/online/vl_ol_0005.c index 738c25f..fa7034a 100644 --- a/app/online/vl_ol_0005.c +++ b/app/online/vl_ol_0005.c @@ -151,7 +151,7 @@ TX_SERVICE(VL_OL_0005, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_contract_end),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 62 "app/online/vl_ol_0005.pgc" +#line 61 "app/online/vl_ol_0005.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0005.pgc b/app/online/vl_ol_0005.pgc index bfaddf5..cb47c13 100644 --- a/app/online/vl_ol_0005.pgc +++ b/app/online/vl_ol_0005.pgc @@ -55,8 +55,7 @@ TX_SERVICE(VL_OL_0005, ctx) memset(h_status, 0, sizeof(h_status)); memset(h_contract_end, 0, sizeof(h_contract_end)); - EXEC SQL - SELECT merch_status, contract_end + EXEC SQL SELECT merch_status, contract_end INTO :h_status, :h_contract_end FROM mm_merchant WHERE merch_id = :h_merch; diff --git a/app/online/vl_ol_0006.c b/app/online/vl_ol_0006.c index 8f8c800..4c63ab8 100644 --- a/app/online/vl_ol_0006.c +++ b/app/online/vl_ol_0006.c @@ -155,7 +155,7 @@ TX_SERVICE(VL_OL_0006, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_expire_ym),(long)7,(long)1,(7)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 61 "app/online/vl_ol_0006.pgc" +#line 60 "app/online/vl_ol_0006.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0006.pgc b/app/online/vl_ol_0006.pgc index d3c4438..dfb31e4 100644 --- a/app/online/vl_ol_0006.pgc +++ b/app/online/vl_ol_0006.pgc @@ -54,8 +54,7 @@ TX_SERVICE(VL_OL_0006, ctx) memset(h_expire_ym, 0, sizeof(h_expire_ym)); /* 2) BIN 마스터 조회 */ - EXEC SQL - SELECT issuer_code, card_status, expire_ym + EXEC SQL SELECT issuer_code, card_status, expire_ym INTO :h_issuer, :h_card_status, :h_expire_ym FROM vl_card_bin WHERE bin = :h_bin; diff --git a/app/online/vl_ol_0007.c b/app/online/vl_ol_0007.c index be9074a..78de6ae 100644 --- a/app/online/vl_ol_0007.c +++ b/app/online/vl_ol_0007.c @@ -146,7 +146,7 @@ TX_SERVICE(VL_OL_0007, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_appr_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 62 "app/online/vl_ol_0007.pgc" +#line 61 "app/online/vl_ol_0007.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0007.pgc b/app/online/vl_ol_0007.pgc index 0a79d6d..3d664e7 100644 --- a/app/online/vl_ol_0007.pgc +++ b/app/online/vl_ol_0007.pgc @@ -55,8 +55,7 @@ TX_SERVICE(VL_OL_0007, ctx) h_key[sizeof(h_key) - 1] = '\0'; h_appr_amt = 0; - EXEC SQL - SELECT approval_amount + EXEC SQL SELECT approval_amount INTO :h_appr_amt FROM vl_authorized WHERE txn_key = :h_key; diff --git a/app/online/vl_ol_0008.c b/app/online/vl_ol_0008.c index 2616316..78db156 100644 --- a/app/online/vl_ol_0008.c +++ b/app/online/vl_ol_0008.c @@ -145,7 +145,7 @@ TX_SERVICE(VL_OL_0008, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_settle_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 51 "app/online/vl_ol_0008.pgc" +#line 50 "app/online/vl_ol_0008.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0008.pgc b/app/online/vl_ol_0008.pgc index f220b2d..f127a51 100644 --- a/app/online/vl_ol_0008.pgc +++ b/app/online/vl_ol_0008.pgc @@ -44,8 +44,7 @@ TX_SERVICE(VL_OL_0008, ctx) memset(h_biz_date, 0, sizeof(h_biz_date)); memset(h_settle_date, 0, sizeof(h_settle_date)); - EXEC SQL - SELECT txn_date, biz_date, settle_date + EXEC SQL SELECT txn_date, biz_date, settle_date INTO :h_txn_date, :h_biz_date, :h_settle_date FROM vl_date_map WHERE txn_key = :h_key; diff --git a/app/online/vl_ol_0009.c b/app/online/vl_ol_0009.c index 0e4a97a..1197e9b 100644 --- a/app/online/vl_ol_0009.c +++ b/app/online/vl_ol_0009.c @@ -188,7 +188,7 @@ TX_SERVICE(VL_OL_0009, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_missing),(long)128,(long)1,(128)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 99 "app/online/vl_ol_0009.pgc" +#line 98 "app/online/vl_ol_0009.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/vl_ol_0009.pgc b/app/online/vl_ol_0009.pgc index d1d4a3a..2c957c4 100644 --- a/app/online/vl_ol_0009.pgc +++ b/app/online/vl_ol_0009.pgc @@ -92,8 +92,7 @@ TX_SERVICE(VL_OL_0009, ctx) h_missing[sizeof(h_missing) - 1] = '\0'; h_fail_cnt = fail; - EXEC SQL - INSERT INTO vl_field_chk_hist + EXEC SQL INSERT INTO vl_field_chk_hist (chk_key, fail_count, missing_fields) VALUES (:h_key, :h_fail_cnt, :h_missing); diff --git a/app/online/vl_ol_0010.c b/app/online/vl_ol_0010.c index aa6a775..237b949 100644 --- a/app/online/vl_ol_0010.c +++ b/app/online/vl_ol_0010.c @@ -144,7 +144,7 @@ TX_SERVICE(VL_OL_0010, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_code_name),(long)41,(long)1,(41)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 51 "app/online/vl_ol_0010.pgc" +#line 50 "app/online/vl_ol_0010.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0010.pgc b/app/online/vl_ol_0010.pgc index db217d7..b61e91d 100644 --- a/app/online/vl_ol_0010.pgc +++ b/app/online/vl_ol_0010.pgc @@ -43,8 +43,7 @@ TX_SERVICE(VL_OL_0010, ctx) memset(h_use_yn, 0, sizeof(h_use_yn)); memset(h_code_name, 0, sizeof(h_code_name)); - EXEC SQL - SELECT use_yn, code_name + EXEC SQL SELECT use_yn, code_name INTO :h_use_yn, :h_code_name FROM vl_common_code WHERE code_group = :h_grp diff --git a/app/online/vl_ol_0011.c b/app/online/vl_ol_0011.c index 44f2819..7657de6 100644 --- a/app/online/vl_ol_0011.c +++ b/app/online/vl_ol_0011.c @@ -146,7 +146,7 @@ TX_SERVICE(VL_OL_0011, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_appr_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 51 "app/online/vl_ol_0011.pgc" +#line 50 "app/online/vl_ol_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -164,7 +164,7 @@ TX_SERVICE(VL_OL_0011, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_pur_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 65 "app/online/vl_ol_0011.pgc" +#line 63 "app/online/vl_ol_0011.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0011.pgc b/app/online/vl_ol_0011.pgc index 2577834..65f6ce2 100644 --- a/app/online/vl_ol_0011.pgc +++ b/app/online/vl_ol_0011.pgc @@ -44,8 +44,7 @@ TX_SERVICE(VL_OL_0011, ctx) h_appr_amt = 0; h_appr_cnt = 0; h_pur_amt = 0; h_pur_cnt = 0; /* 1) 승인원장 집계 */ - EXEC SQL - SELECT COALESCE(SUM(appr_amount), 0), COUNT(*) + EXEC SQL SELECT COALESCE(SUM(appr_amount), 0), COUNT(*) INTO :h_appr_amt, :h_appr_cnt FROM vl_approval WHERE approval_no = :h_appr_no; @@ -58,8 +57,7 @@ TX_SERVICE(VL_OL_0011, ctx) } /* 2) 매입원장 집계 */ - EXEC SQL - SELECT COALESCE(SUM(purchase_amount), 0), COUNT(*) + EXEC SQL SELECT COALESCE(SUM(purchase_amount), 0), COUNT(*) INTO :h_pur_amt, :h_pur_cnt FROM vl_purchase WHERE approval_no = :h_appr_no; diff --git a/app/online/vl_ol_0012.c b/app/online/vl_ol_0012.c index 9390483..d7154ff 100644 --- a/app/online/vl_ol_0012.c +++ b/app/online/vl_ol_0012.c @@ -149,7 +149,7 @@ TX_SERVICE(VL_OL_0012, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_daily_limit),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 59 "app/online/vl_ol_0012.pgc" +#line 58 "app/online/vl_ol_0012.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -174,7 +174,7 @@ TX_SERVICE(VL_OL_0012, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_used_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 81 "app/online/vl_ol_0012.pgc" +#line 79 "app/online/vl_ol_0012.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0012.pgc b/app/online/vl_ol_0012.pgc index 658ef18..229421c 100644 --- a/app/online/vl_ol_0012.pgc +++ b/app/online/vl_ol_0012.pgc @@ -52,8 +52,7 @@ TX_SERVICE(VL_OL_0012, ctx) h_used_amt = 0; /* 1) 가맹점 일한도 조회 */ - EXEC SQL - SELECT daily_limit + EXEC SQL SELECT daily_limit INTO :h_daily_limit FROM vl_limit WHERE merch_id = :h_merch; @@ -73,8 +72,7 @@ TX_SERVICE(VL_OL_0012, ctx) } /* 2) 당일 누적금액 합산 */ - EXEC SQL - SELECT COALESCE(SUM(amount), 0) + EXEC SQL SELECT COALESCE(SUM(amount), 0) INTO :h_used_amt FROM vl_ledger WHERE merch_id = :h_merch diff --git a/app/online/vl_ol_0013.c b/app/online/vl_ol_0013.c index f904b3b..72de760 100644 --- a/app/online/vl_ol_0013.c +++ b/app/online/vl_ol_0013.c @@ -144,7 +144,7 @@ TX_SERVICE(VL_OL_0013, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_fee_rate),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 60 "app/online/vl_ol_0013.pgc" +#line 59 "app/online/vl_ol_0013.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0013.pgc b/app/online/vl_ol_0013.pgc index 666e300..9343ceb 100644 --- a/app/online/vl_ol_0013.pgc +++ b/app/online/vl_ol_0013.pgc @@ -53,8 +53,7 @@ TX_SERVICE(VL_OL_0013, ctx) h_merch[sizeof(h_merch) - 1] = '\0'; h_fee_rate = 0; - EXEC SQL - SELECT fee_rate_bps + EXEC SQL SELECT fee_rate_bps INTO :h_fee_rate FROM vl_fee_rate WHERE merch_id = :h_merch; diff --git a/app/online/vl_ol_0014.c b/app/online/vl_ol_0014.c index 7b6dc73..7290921 100644 --- a/app/online/vl_ol_0014.c +++ b/app/online/vl_ol_0014.c @@ -139,7 +139,7 @@ TX_SERVICE(VL_OL_0014, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_settle_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 49 "app/online/vl_ol_0014.pgc" +#line 48 "app/online/vl_ol_0014.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { @@ -164,7 +164,7 @@ TX_SERVICE(VL_OL_0014, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_fee_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 70 "app/online/vl_ol_0014.pgc" +#line 68 "app/online/vl_ol_0014.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0014.pgc b/app/online/vl_ol_0014.pgc index a86cfbd..573a44e 100644 --- a/app/online/vl_ol_0014.pgc +++ b/app/online/vl_ol_0014.pgc @@ -42,8 +42,7 @@ TX_SERVICE(VL_OL_0014, ctx) h_settle_amt = 0; h_purchase_amt = 0; h_fee_amt = 0; /* 1) 정산금액 조회 */ - EXEC SQL - SELECT settle_amount + EXEC SQL SELECT settle_amount INTO :h_settle_amt FROM vl_settle WHERE settle_key = :h_settle_key; @@ -63,8 +62,7 @@ TX_SERVICE(VL_OL_0014, ctx) } /* 2) 매입집계(매입액/수수료) 조회 */ - EXEC SQL - SELECT COALESCE(purchase_amount, 0), COALESCE(fee_amount, 0) + EXEC SQL SELECT COALESCE(purchase_amount, 0), COALESCE(fee_amount, 0) INTO :h_purchase_amt, :h_fee_amt FROM vl_purchase_sum WHERE settle_key = :h_settle_key; diff --git a/app/online/vl_ol_0015.c b/app/online/vl_ol_0015.c index 37c4f78..d93b9c6 100644 --- a/app/online/vl_ol_0015.c +++ b/app/online/vl_ol_0015.c @@ -165,7 +165,7 @@ TX_SERVICE(VL_OL_0015, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_agg_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 67 "app/online/vl_ol_0015.pgc" +#line 66 "app/online/vl_ol_0015.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0015.pgc b/app/online/vl_ol_0015.pgc index f30713c..6ddcf98 100644 --- a/app/online/vl_ol_0015.pgc +++ b/app/online/vl_ol_0015.pgc @@ -59,8 +59,7 @@ TX_SERVICE(VL_OL_0015, ctx) h_agg_amount = 0; h_agg_cnt = 0; - EXEC SQL - SELECT applied_yn, agg_amount, agg_count + EXEC SQL SELECT applied_yn, agg_amount, agg_count INTO :h_applied_yn, :h_agg_amount, :h_agg_cnt FROM vl_daily_agg WHERE biz_date = :h_bizdate diff --git a/app/online/vl_ol_0016.c b/app/online/vl_ol_0016.c index 862731a..242e872 100644 --- a/app/online/vl_ol_0016.c +++ b/app/online/vl_ol_0016.c @@ -162,7 +162,7 @@ TX_SERVICE(VL_OL_0016, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_type_name),(long)41,(long)1,(41)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 73 "app/online/vl_ol_0016.pgc" +#line 72 "app/online/vl_ol_0016.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0016.pgc b/app/online/vl_ol_0016.pgc index 02c2efa..e6cde17 100644 --- a/app/online/vl_ol_0016.pgc +++ b/app/online/vl_ol_0016.pgc @@ -66,8 +66,7 @@ TX_SERVICE(VL_OL_0016, ctx) memset(h_use_yn, 0, sizeof(h_use_yn)); memset(h_type_name, 0, sizeof(h_type_name)); - EXEC SQL - SELECT use_yn, type_name + EXEC SQL SELECT use_yn, type_name INTO :h_use_yn, :h_type_name FROM vl_msg_type WHERE msg_type = :h_msg_type; diff --git a/app/online/vl_ol_0017.c b/app/online/vl_ol_0017.c index 90d33fa..17de2d2 100644 --- a/app/online/vl_ol_0017.c +++ b/app/online/vl_ol_0017.c @@ -155,7 +155,7 @@ TX_SERVICE(VL_OL_0017, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_merch_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 65 "app/online/vl_ol_0017.pgc" +#line 64 "app/online/vl_ol_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { @@ -171,7 +171,7 @@ TX_SERVICE(VL_OL_0017, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_issuer_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 79 "app/online/vl_ol_0017.pgc" +#line 77 "app/online/vl_ol_0017.pgc" if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0017.pgc b/app/online/vl_ol_0017.pgc index c8301e7..cce2a2a 100644 --- a/app/online/vl_ol_0017.pgc +++ b/app/online/vl_ol_0017.pgc @@ -58,8 +58,7 @@ TX_SERVICE(VL_OL_0017, ctx) h_issuer_cnt = 0; /* 2) 가맹점 참조 확인 */ - EXEC SQL - SELECT COUNT(*) + EXEC SQL SELECT COUNT(*) INTO :h_merch_cnt FROM mm_merchant WHERE merch_id = :h_merch; @@ -72,8 +71,7 @@ TX_SERVICE(VL_OL_0017, ctx) } /* 3) 발급사(카드사코드) 참조 확인 */ - EXEC SQL - SELECT COUNT(*) + EXEC SQL SELECT COUNT(*) INTO :h_issuer_cnt FROM vl_issuer WHERE issuer_code = :h_issuer; diff --git a/app/online/vl_ol_0018.c b/app/online/vl_ol_0018.c index 8e71c7c..3479d4c 100644 --- a/app/online/vl_ol_0018.c +++ b/app/online/vl_ol_0018.c @@ -151,7 +151,7 @@ TX_SERVICE(VL_OL_0018, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_dupcnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 63 "app/online/vl_ol_0018.pgc" +#line 62 "app/online/vl_ol_0018.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/vl_ol_0018.pgc b/app/online/vl_ol_0018.pgc index 5b20cb6..0f89019 100644 --- a/app/online/vl_ol_0018.pgc +++ b/app/online/vl_ol_0018.pgc @@ -55,8 +55,7 @@ TX_SERVICE(VL_OL_0018, ctx) h_bizdate[sizeof(h_bizdate) - 1] = '\0'; h_dupcnt = 0; - EXEC SQL - SELECT COUNT(*) + EXEC SQL SELECT COUNT(*) INTO :h_dupcnt FROM vl_ledger WHERE approval_no = :h_appr diff --git a/app/online/vl_ol_0019.c b/app/online/vl_ol_0019.c index 2b0df37..9854e0b 100644 --- a/app/online/vl_ol_0019.c +++ b/app/online/vl_ol_0019.c @@ -153,7 +153,7 @@ TX_SERVICE(VL_OL_0019, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_sample),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 65 "app/online/vl_ol_0019.pgc" +#line 64 "app/online/vl_ol_0019.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/vl_ol_0019.pgc b/app/online/vl_ol_0019.pgc index 4c0bb13..52fc5aa 100644 --- a/app/online/vl_ol_0019.pgc +++ b/app/online/vl_ol_0019.pgc @@ -57,8 +57,7 @@ TX_SERVICE(VL_OL_0019, ctx) h_avg_amt = 0; h_sample = 0; - EXEC SQL - SELECT COALESCE(AVG(amount), 0), COUNT(*) + EXEC SQL SELECT COALESCE(AVG(amount), 0), COUNT(*) INTO :h_avg_amt, :h_sample FROM vl_ledger WHERE merch_id = :h_merch diff --git a/app/online/vl_ol_0020.c b/app/online/vl_ol_0020.c index bafa135..6efbed5 100644 --- a/app/online/vl_ol_0020.c +++ b/app/online/vl_ol_0020.c @@ -154,7 +154,7 @@ TX_SERVICE(VL_OL_0020, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 66 "app/online/vl_ol_0020.pgc" +#line 65 "app/online/vl_ol_0020.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/vl_ol_0020.pgc b/app/online/vl_ol_0020.pgc index 771f288..51cfb89 100644 --- a/app/online/vl_ol_0020.pgc +++ b/app/online/vl_ol_0020.pgc @@ -58,8 +58,7 @@ TX_SERVICE(VL_OL_0020, ctx) h_status[sizeof(h_status) - 1] = '\0'; h_cnt = 0; - EXEC SQL - SELECT COUNT(*) + EXEC SQL SELECT COUNT(*) INTO :h_cnt FROM vl_ledger WHERE biz_date = :h_bizdate diff --git a/app/online/vl_ol_0021.c b/app/online/vl_ol_0021.c index 0d951fb..8a9a243 100644 --- a/app/online/vl_ol_0021.c +++ b/app/online/vl_ol_0021.c @@ -140,7 +140,7 @@ TX_SERVICE(VL_OL_0021, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_purch_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 53 "app/online/vl_ol_0021.pgc" +#line 52 "app/online/vl_ol_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -156,7 +156,7 @@ TX_SERVICE(VL_OL_0021, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_long,&(h_settle_sum),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 67 "app/online/vl_ol_0021.pgc" +#line 65 "app/online/vl_ol_0021.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/vl_ol_0021.pgc b/app/online/vl_ol_0021.pgc index 6d6b658..687ef9b 100644 --- a/app/online/vl_ol_0021.pgc +++ b/app/online/vl_ol_0021.pgc @@ -46,8 +46,7 @@ TX_SERVICE(VL_OL_0021, ctx) h_bizdate[sizeof(h_bizdate) - 1] = '\0'; h_purch_sum = 0; - EXEC SQL - SELECT COALESCE(SUM(amount), 0) + EXEC SQL SELECT COALESCE(SUM(amount), 0) INTO :h_purch_sum FROM vl_purchase WHERE biz_date = :h_bizdate; @@ -60,8 +59,7 @@ TX_SERVICE(VL_OL_0021, ctx) } h_settle_sum = 0; - EXEC SQL - SELECT COALESCE(SUM(settle_amt), 0) + EXEC SQL SELECT COALESCE(SUM(settle_amt), 0) INTO :h_settle_sum FROM vl_settle WHERE biz_date = :h_bizdate; diff --git a/app/online/vl_ol_0022.c b/app/online/vl_ol_0022.c index 8cd62ae..d2e8117 100644 --- a/app/online/vl_ol_0022.c +++ b/app/online/vl_ol_0022.c @@ -151,7 +151,7 @@ TX_SERVICE(VL_OL_0022, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_done_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 57 "app/online/vl_ol_0022.pgc" +#line 56 "app/online/vl_ol_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -170,7 +170,7 @@ TX_SERVICE(VL_OL_0022, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_fail_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 73 "app/online/vl_ol_0022.pgc" +#line 71 "app/online/vl_ol_0022.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/vl_ol_0022.pgc b/app/online/vl_ol_0022.pgc index e196059..eaa6b4e 100644 --- a/app/online/vl_ol_0022.pgc +++ b/app/online/vl_ol_0022.pgc @@ -49,8 +49,7 @@ TX_SERVICE(VL_OL_0022, ctx) h_done_cnt = 0; h_done_amt = 0; - EXEC SQL - SELECT COUNT(*), COALESCE(SUM(amount), 0) + EXEC SQL SELECT COUNT(*), COALESCE(SUM(amount), 0) INTO :h_done_cnt, :h_done_amt FROM vl_ledger WHERE merch_id = :h_merch @@ -65,8 +64,7 @@ TX_SERVICE(VL_OL_0022, ctx) h_fail_cnt = 0; h_fail_amt = 0; - EXEC SQL - SELECT COUNT(*), COALESCE(SUM(amount), 0) + EXEC SQL SELECT COUNT(*), COALESCE(SUM(amount), 0) INTO :h_fail_cnt, :h_fail_amt FROM vl_ledger WHERE merch_id = :h_merch diff --git a/app/online/vl_ol_0023.c b/app/online/vl_ol_0023.c index 294612f..fbed2fd 100644 --- a/app/online/vl_ol_0023.c +++ b/app/online/vl_ol_0023.c @@ -158,7 +158,7 @@ TX_SERVICE(VL_OL_0023, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_fail_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 66 "app/online/vl_ol_0023.pgc" +#line 65 "app/online/vl_ol_0023.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/vl_ol_0023.pgc b/app/online/vl_ol_0023.pgc index 00c3aa4..5c5e205 100644 --- a/app/online/vl_ol_0023.pgc +++ b/app/online/vl_ol_0023.pgc @@ -57,8 +57,7 @@ TX_SERVICE(VL_OL_0023, ctx) h_fail_cnt = 0; h_fail_amt = 0; - EXEC SQL - SELECT COUNT(*), COALESCE(SUM(amount), 0) + EXEC SQL SELECT COUNT(*), COALESCE(SUM(amount), 0) INTO :h_fail_cnt, :h_fail_amt FROM vl_ledger WHERE issuer_cd = :h_issuer diff --git a/app/online/vl_ol_0024.c b/app/online/vl_ol_0024.c index 7c37a1b..41f9b03 100644 --- a/app/online/vl_ol_0024.c +++ b/app/online/vl_ol_0024.c @@ -174,7 +174,7 @@ TX_SERVICE(VL_OL_0024, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_appr_date),(long)9,(long)1,(9)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 80 "app/online/vl_ol_0024.pgc" +#line 79 "app/online/vl_ol_0024.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0024.pgc b/app/online/vl_ol_0024.pgc index 882fb91..8ad2da1 100644 --- a/app/online/vl_ol_0024.pgc +++ b/app/online/vl_ol_0024.pgc @@ -73,8 +73,7 @@ TX_SERVICE(VL_OL_0024, ctx) memset(h_appr_date, 0, sizeof(h_appr_date)); h_amount = 0; - EXEC SQL - SELECT merch_id, appr_amount, appr_date + EXEC SQL SELECT merch_id, appr_amount, appr_date INTO :h_merch, :h_amount, :h_appr_date FROM vl_approval WHERE approval_no = :h_appr; diff --git a/app/online/vl_ol_0025.c b/app/online/vl_ol_0025.c index c2804e5..6a57430 100644 --- a/app/online/vl_ol_0025.c +++ b/app/online/vl_ol_0025.c @@ -172,7 +172,7 @@ TX_SERVICE(VL_OL_0025, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_inrange),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 74 "app/online/vl_ol_0025.pgc" +#line 73 "app/online/vl_ol_0025.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0025.pgc b/app/online/vl_ol_0025.pgc index b2ed239..d5e8bd7 100644 --- a/app/online/vl_ol_0025.pgc +++ b/app/online/vl_ol_0025.pgc @@ -66,8 +66,7 @@ TX_SERVICE(VL_OL_0025, ctx) memset(h_txn_date, 0, sizeof(h_txn_date)); h_inrange = 0; - EXEC SQL - SELECT txn_date, + EXEC SQL SELECT txn_date, CASE WHEN txn_date BETWEEN :h_from AND :h_to THEN 1 ELSE 0 END INTO :h_txn_date, :h_inrange FROM vl_ledger diff --git a/app/online/vl_ol_0026.c b/app/online/vl_ol_0026.c index ddf9dda..151afb7 100644 --- a/app/online/vl_ol_0026.c +++ b/app/online/vl_ol_0026.c @@ -153,7 +153,7 @@ TX_SERVICE(VL_OL_0026, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_ledger_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 58 "app/online/vl_ol_0026.pgc" +#line 57 "app/online/vl_ol_0026.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -173,7 +173,7 @@ TX_SERVICE(VL_OL_0026, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_agg_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 74 "app/online/vl_ol_0026.pgc" +#line 72 "app/online/vl_ol_0026.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0026.pgc b/app/online/vl_ol_0026.pgc index 514c9a0..09ee7bb 100644 --- a/app/online/vl_ol_0026.pgc +++ b/app/online/vl_ol_0026.pgc @@ -51,8 +51,7 @@ TX_SERVICE(VL_OL_0026, ctx) /* 원장 상세 합계 */ h_ledger_sum = 0; h_ledger_cnt = 0; - EXEC SQL - SELECT COALESCE(SUM(amount), 0), COUNT(*) + EXEC SQL SELECT COALESCE(SUM(amount), 0), COUNT(*) INTO :h_ledger_sum, :h_ledger_cnt FROM vl_ledger WHERE biz_date = :h_bizdate; @@ -67,8 +66,7 @@ TX_SERVICE(VL_OL_0026, ctx) /* 일집계 테이블 값 */ h_agg_amt = 0; h_agg_cnt = 0; - EXEC SQL - SELECT total_amt, total_cnt + EXEC SQL SELECT total_amt, total_cnt INTO :h_agg_amt, :h_agg_cnt FROM vl_daily_agg WHERE biz_date = :h_bizdate; diff --git a/app/online/vl_ol_0027.c b/app/online/vl_ol_0027.c index aee5197..2222bbd 100644 --- a/app/online/vl_ol_0027.c +++ b/app/online/vl_ol_0027.c @@ -161,7 +161,7 @@ TX_SERVICE(VL_OL_0027, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_src_merch),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 72 "app/online/vl_ol_0027.pgc" +#line 71 "app/online/vl_ol_0027.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0027.pgc b/app/online/vl_ol_0027.pgc index 110d89d..540f4b2 100644 --- a/app/online/vl_ol_0027.pgc +++ b/app/online/vl_ol_0027.pgc @@ -65,8 +65,7 @@ TX_SERVICE(VL_OL_0027, ctx) memset(h_src_merch, 0, sizeof(h_src_merch)); h_src_amt = 0; - EXEC SQL - SELECT src_amount, src_merch_id + EXEC SQL SELECT src_amount, src_merch_id INTO :h_src_amt, :h_src_merch FROM vl_recheck_src WHERE txn_key = :h_key; diff --git a/app/online/vl_ol_0028.c b/app/online/vl_ol_0028.c index 91059b0..8065b5a 100644 --- a/app/online/vl_ol_0028.c +++ b/app/online/vl_ol_0028.c @@ -150,7 +150,7 @@ TX_SERVICE(VL_OL_0028, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_ref_key),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 58 "app/online/vl_ol_0028.pgc" +#line 57 "app/online/vl_ol_0028.pgc" if (sqlca.sqlcode == TX_SQL_NOTFOUND) { diff --git a/app/online/vl_ol_0028.pgc b/app/online/vl_ol_0028.pgc index dfccf78..56c3e9e 100644 --- a/app/online/vl_ol_0028.pgc +++ b/app/online/vl_ol_0028.pgc @@ -49,8 +49,7 @@ TX_SERVICE(VL_OL_0028, ctx) memset(h_reason, 0, sizeof(h_reason)); memset(h_ref_key, 0, sizeof(h_ref_key)); - EXEC SQL - SELECT occur_dt, reason, ref_key + EXEC SQL SELECT occur_dt, reason, ref_key INTO :h_occur_dt, :h_reason, :h_ref_key FROM vl_error_log WHERE err_code = :h_errcode diff --git a/app/online/vl_ol_0029.c b/app/online/vl_ol_0029.c index 1f52070..939f48c 100644 --- a/app/online/vl_ol_0029.c +++ b/app/online/vl_ol_0029.c @@ -165,7 +165,7 @@ TX_SERVICE(VL_OL_0029, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_reason),(long)128,(long)1,(128)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 75 "app/online/vl_ol_0029.pgc" +#line 74 "app/online/vl_ol_0029.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/vl_ol_0029.pgc b/app/online/vl_ol_0029.pgc index 1c98a4e..e988e0d 100644 --- a/app/online/vl_ol_0029.pgc +++ b/app/online/vl_ol_0029.pgc @@ -69,8 +69,7 @@ TX_SERVICE(VL_OL_0029, ctx) strncpy(h_reason, reason, sizeof(h_reason) - 1); h_reason[sizeof(h_reason) - 1] = '\0'; - EXEC SQL - INSERT INTO vl_mismatch_reason + EXEC SQL INSERT INTO vl_mismatch_reason (txn_key, reason_code, reason_txt, reg_dt) VALUES (:h_key, :h_rcode, :h_reason, TO_CHAR(SYSTIMESTAMP, 'YYYYMMDDHH24MISS')); diff --git a/app/online/vl_ol_0030.c b/app/online/vl_ol_0030.c index a8cb4a7..eccd058 100644 --- a/app/online/vl_ol_0030.c +++ b/app/online/vl_ol_0030.c @@ -175,7 +175,7 @@ TX_SERVICE(VL_OL_0030, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_approver),(long)16,(long)1,(16)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 91 "app/online/vl_ol_0030.pgc" +#line 90 "app/online/vl_ol_0030.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/vl_ol_0030.pgc b/app/online/vl_ol_0030.pgc index a36aab8..859c48b 100644 --- a/app/online/vl_ol_0030.pgc +++ b/app/online/vl_ol_0030.pgc @@ -84,8 +84,7 @@ TX_SERVICE(VL_OL_0030, ctx) strncpy(h_approver, approver, sizeof(h_approver) - 1); h_approver[sizeof(h_approver) - 1] = '\0'; - EXEC SQL - INSERT INTO vl_approval_hist + EXEC SQL INSERT INTO vl_approval_hist (txn_key, approver_id, appr_dt, prev_status) VALUES (:h_key, :h_approver, TO_CHAR(SYSTIMESTAMP, 'YYYYMMDDHH24MISS'), 'R'); diff --git a/app/online/vl_ol_0031.c b/app/online/vl_ol_0031.c index 3e743b6..b4887a5 100644 --- a/app/online/vl_ol_0031.c +++ b/app/online/vl_ol_0031.c @@ -189,7 +189,7 @@ TX_SERVICE(VL_OL_0031, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(h_reason),(long)128,(long)1,(128)*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} -#line 100 "app/online/vl_ol_0031.pgc" +#line 99 "app/online/vl_ol_0031.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/vl_ol_0031.pgc b/app/online/vl_ol_0031.pgc index 0a1e48d..9290201 100644 --- a/app/online/vl_ol_0031.pgc +++ b/app/online/vl_ol_0031.pgc @@ -93,8 +93,7 @@ TX_SERVICE(VL_OL_0031, ctx) strncpy(h_reason, reason, sizeof(h_reason) - 1); h_reason[sizeof(h_reason) - 1] = '\0'; - EXEC SQL - INSERT INTO vl_reject_hist + EXEC SQL INSERT INTO vl_reject_hist (txn_key, rejector_id, reject_reason, reject_dt) VALUES (:h_key, :h_rejector, :h_reason, TO_CHAR(SYSTIMESTAMP, 'YYYYMMDDHH24MISS')); diff --git a/app/online/vl_ol_0032.c b/app/online/vl_ol_0032.c index 3bbe2a5..faeda96 100644 --- a/app/online/vl_ol_0032.c +++ b/app/online/vl_ol_0032.c @@ -161,7 +161,7 @@ TX_SERVICE(VL_OL_0032, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_total_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 60 "app/online/vl_ol_0032.pgc" +#line 59 "app/online/vl_ol_0032.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -181,7 +181,7 @@ TX_SERVICE(VL_OL_0032, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_fail_cnt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 78 "app/online/vl_ol_0032.pgc" +#line 76 "app/online/vl_ol_0032.pgc" if (sqlca.sqlcode != TX_SQL_OK) { @@ -201,7 +201,7 @@ TX_SERVICE(VL_OL_0032, ctx) ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_long,&(h_settle_amt),(long)1,(long)1,sizeof(long), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} -#line 94 "app/online/vl_ol_0032.pgc" +#line 91 "app/online/vl_ol_0032.pgc" if (sqlca.sqlcode != TX_SQL_OK) { diff --git a/app/online/vl_ol_0032.pgc b/app/online/vl_ol_0032.pgc index 9408cd3..444597a 100644 --- a/app/online/vl_ol_0032.pgc +++ b/app/online/vl_ol_0032.pgc @@ -53,8 +53,7 @@ TX_SERVICE(VL_OL_0032, ctx) /* 1) 대상 전체 건수/금액 */ h_total_cnt = 0; h_total_amt = 0; - EXEC SQL - SELECT COUNT(*), COALESCE(SUM(amount), 0) + EXEC SQL SELECT COUNT(*), COALESCE(SUM(amount), 0) INTO :h_total_cnt, :h_total_amt FROM vl_ledger WHERE biz_date = :h_bizdate; @@ -69,8 +68,7 @@ TX_SERVICE(VL_OL_0032, ctx) /* 2) 완료/불일치 건수 */ h_done_cnt = 0; h_fail_cnt = 0; - EXEC SQL - SELECT + EXEC SQL SELECT COALESCE(SUM(CASE WHEN status = 'M' THEN 1 ELSE 0 END), 0), COALESCE(SUM(CASE WHEN status = 'U' THEN 1 ELSE 0 END), 0) INTO :h_done_cnt, :h_fail_cnt @@ -87,8 +85,7 @@ TX_SERVICE(VL_OL_0032, ctx) /* 3) 정산 건수/금액 */ h_settle_cnt = 0; h_settle_amt = 0; - EXEC SQL - SELECT COUNT(*), COALESCE(SUM(settle_amt), 0) + EXEC SQL SELECT COUNT(*), COALESCE(SUM(settle_amt), 0) INTO :h_settle_cnt, :h_settle_amt FROM vl_settle WHERE biz_date = :h_bizdate; diff --git a/inventory.json b/inventory.json index ed9edb2..6b961d8 100644 --- a/inventory.json +++ b/inventory.json @@ -628,7 +628,7 @@ "archetype": "batch", "tier": "easy", "path": "app/batch/cm_bt_0015.pgc", - "loc": 103, + "loc": 150, "sqlCount": 7 }, { @@ -826,7 +826,7 @@ "archetype": "batch", "tier": "easy", "path": "app/batch/mg_bt_0005.pgc", - "loc": 111, + "loc": 157, "sqlCount": 7 }, { @@ -1276,7 +1276,7 @@ "archetype": "batch", "tier": "hard", "path": "app/batch/rc_bt_0006.pgc", - "loc": 128, + "loc": 172, "sqlCount": 7 }, { @@ -1672,7 +1672,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/ac_cu_0001.c", - "loc": 37, + "loc": 54, "sqlCount": 0 }, { @@ -1681,7 +1681,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/ac_cu_0002.c", - "loc": 37, + "loc": 44, "sqlCount": 0 }, { @@ -1690,7 +1690,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/ac_cu_0003.c", - "loc": 37, + "loc": 38, "sqlCount": 0 }, { @@ -1699,7 +1699,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/ac_cu_0004.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -1708,7 +1708,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/ac_cu_0005.c", - "loc": 37, + "loc": 56, "sqlCount": 0 }, { @@ -1717,7 +1717,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/ac_cu_0006.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -1726,7 +1726,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/ac_cu_0007.c", - "loc": 37, + "loc": 54, "sqlCount": 0 }, { @@ -1735,7 +1735,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/ac_cu_0008.c", - "loc": 37, + "loc": 57, "sqlCount": 0 }, { @@ -1744,7 +1744,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/ac_cu_0009.c", - "loc": 37, + "loc": 59, "sqlCount": 0 }, { @@ -1753,7 +1753,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/ac_cu_0010.c", - "loc": 37, + "loc": 58, "sqlCount": 0 }, { @@ -1762,7 +1762,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/ac_cu_0011.c", - "loc": 37, + "loc": 50, "sqlCount": 0 }, { @@ -1771,7 +1771,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/au_cu_0001.c", - "loc": 37, + "loc": 58, "sqlCount": 0 }, { @@ -1780,7 +1780,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/au_cu_0002.c", - "loc": 37, + "loc": 50, "sqlCount": 0 }, { @@ -1789,7 +1789,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/au_cu_0003.c", - "loc": 37, + "loc": 54, "sqlCount": 0 }, { @@ -1798,7 +1798,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/au_cu_0004.c", - "loc": 37, + "loc": 44, "sqlCount": 0 }, { @@ -1807,7 +1807,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/au_cu_0005.c", - "loc": 37, + "loc": 38, "sqlCount": 0 }, { @@ -1816,7 +1816,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/au_cu_0006.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -1825,7 +1825,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/au_cu_0007.c", - "loc": 37, + "loc": 56, "sqlCount": 0 }, { @@ -1834,7 +1834,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/au_cu_0008.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -1843,7 +1843,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/au_cu_0009.c", - "loc": 37, + "loc": 54, "sqlCount": 0 }, { @@ -1852,7 +1852,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/au_cu_0010.c", - "loc": 37, + "loc": 57, "sqlCount": 0 }, { @@ -1861,7 +1861,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/au_cu_0011.c", - "loc": 37, + "loc": 59, "sqlCount": 0 }, { @@ -1870,7 +1870,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/cl_cu_0001.c", - "loc": 37, + "loc": 60, "sqlCount": 0 }, { @@ -1879,7 +1879,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/cl_cu_0002.c", - "loc": 37, + "loc": 53, "sqlCount": 0 }, { @@ -1888,7 +1888,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/cl_cu_0003.c", - "loc": 37, + "loc": 50, "sqlCount": 0 }, { @@ -1897,7 +1897,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/cl_cu_0004.c", - "loc": 37, + "loc": 56, "sqlCount": 0 }, { @@ -1906,7 +1906,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/cl_cu_0005.c", - "loc": 37, + "loc": 44, "sqlCount": 0 }, { @@ -1915,7 +1915,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/cl_cu_0006.c", - "loc": 37, + "loc": 43, "sqlCount": 0 }, { @@ -1924,7 +1924,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/cl_cu_0007.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -1933,7 +1933,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/cl_cu_0008.c", - "loc": 37, + "loc": 62, "sqlCount": 0 }, { @@ -1942,7 +1942,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/cl_cu_0009.c", - "loc": 37, + "loc": 48, "sqlCount": 0 }, { @@ -1951,7 +1951,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/cl_cu_0010.c", - "loc": 37, + "loc": 40, "sqlCount": 0 }, { @@ -1960,7 +1960,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/cm_cu_0001.c", - "loc": 37, + "loc": 60, "sqlCount": 0 }, { @@ -1969,7 +1969,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/cm_cu_0002.c", - "loc": 37, + "loc": 53, "sqlCount": 0 }, { @@ -1978,7 +1978,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/cm_cu_0003.c", - "loc": 37, + "loc": 50, "sqlCount": 0 }, { @@ -1987,7 +1987,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/cm_cu_0004.c", - "loc": 37, + "loc": 56, "sqlCount": 0 }, { @@ -1996,7 +1996,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/cm_cu_0005.c", - "loc": 37, + "loc": 44, "sqlCount": 0 }, { @@ -2005,7 +2005,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/cm_cu_0006.c", - "loc": 37, + "loc": 43, "sqlCount": 0 }, { @@ -2014,7 +2014,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/cm_cu_0007.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -2023,7 +2023,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/cm_cu_0008.c", - "loc": 37, + "loc": 62, "sqlCount": 0 }, { @@ -2032,7 +2032,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/cm_cu_0009.c", - "loc": 37, + "loc": 48, "sqlCount": 0 }, { @@ -2041,7 +2041,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/cm_cu_0010.c", - "loc": 37, + "loc": 40, "sqlCount": 0 }, { @@ -2050,7 +2050,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/cm_cu_0011.c", - "loc": 37, + "loc": 64, "sqlCount": 0 }, { @@ -2059,7 +2059,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/lg_cu_0001.c", - "loc": 37, + "loc": 60, "sqlCount": 0 }, { @@ -2068,7 +2068,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/lg_cu_0002.c", - "loc": 37, + "loc": 53, "sqlCount": 0 }, { @@ -2077,7 +2077,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/lg_cu_0003.c", - "loc": 37, + "loc": 50, "sqlCount": 0 }, { @@ -2086,7 +2086,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/lg_cu_0004.c", - "loc": 37, + "loc": 56, "sqlCount": 0 }, { @@ -2095,7 +2095,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/lg_cu_0005.c", - "loc": 37, + "loc": 44, "sqlCount": 0 }, { @@ -2104,7 +2104,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/lg_cu_0006.c", - "loc": 37, + "loc": 43, "sqlCount": 0 }, { @@ -2113,7 +2113,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/lg_cu_0007.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -2122,7 +2122,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/lg_cu_0008.c", - "loc": 37, + "loc": 62, "sqlCount": 0 }, { @@ -2131,7 +2131,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/lg_cu_0009.c", - "loc": 37, + "loc": 48, "sqlCount": 0 }, { @@ -2140,7 +2140,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/lg_cu_0010.c", - "loc": 37, + "loc": 40, "sqlCount": 0 }, { @@ -2149,7 +2149,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/lg_cu_0011.c", - "loc": 37, + "loc": 64, "sqlCount": 0 }, { @@ -2158,7 +2158,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/mg_cu_0001.c", - "loc": 37, + "loc": 57, "sqlCount": 0 }, { @@ -2167,7 +2167,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/mg_cu_0002.c", - "loc": 37, + "loc": 59, "sqlCount": 0 }, { @@ -2176,7 +2176,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/mg_cu_0003.c", - "loc": 37, + "loc": 58, "sqlCount": 0 }, { @@ -2185,7 +2185,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/mg_cu_0004.c", - "loc": 37, + "loc": 50, "sqlCount": 0 }, { @@ -2194,7 +2194,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/mg_cu_0005.c", - "loc": 37, + "loc": 54, "sqlCount": 0 }, { @@ -2203,7 +2203,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/mg_cu_0006.c", - "loc": 37, + "loc": 44, "sqlCount": 0 }, { @@ -2212,7 +2212,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/mg_cu_0007.c", - "loc": 37, + "loc": 38, "sqlCount": 0 }, { @@ -2221,7 +2221,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/mg_cu_0008.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -2230,7 +2230,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/mg_cu_0009.c", - "loc": 37, + "loc": 56, "sqlCount": 0 }, { @@ -2239,7 +2239,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/mg_cu_0010.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -2248,7 +2248,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/mg_cu_0011.c", - "loc": 37, + "loc": 54, "sqlCount": 0 }, { @@ -2257,7 +2257,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/mm_cu_0001.c", - "loc": 37, + "loc": 60, "sqlCount": 0 }, { @@ -2266,7 +2266,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/mm_cu_0002.c", - "loc": 37, + "loc": 53, "sqlCount": 0 }, { @@ -2275,7 +2275,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/mm_cu_0003.c", - "loc": 37, + "loc": 50, "sqlCount": 0 }, { @@ -2284,7 +2284,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/mm_cu_0004.c", - "loc": 37, + "loc": 56, "sqlCount": 0 }, { @@ -2293,7 +2293,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/mm_cu_0005.c", - "loc": 37, + "loc": 44, "sqlCount": 0 }, { @@ -2302,7 +2302,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/mm_cu_0006.c", - "loc": 37, + "loc": 43, "sqlCount": 0 }, { @@ -2311,7 +2311,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/mm_cu_0007.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -2320,7 +2320,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/mm_cu_0008.c", - "loc": 37, + "loc": 62, "sqlCount": 0 }, { @@ -2329,7 +2329,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/mm_cu_0009.c", - "loc": 37, + "loc": 48, "sqlCount": 0 }, { @@ -2338,7 +2338,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/mm_cu_0010.c", - "loc": 37, + "loc": 40, "sqlCount": 0 }, { @@ -2347,7 +2347,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/mm_cu_0011.c", - "loc": 37, + "loc": 64, "sqlCount": 0 }, { @@ -2356,7 +2356,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/py_cu_0001.c", - "loc": 37, + "loc": 60, "sqlCount": 0 }, { @@ -2365,7 +2365,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/py_cu_0002.c", - "loc": 37, + "loc": 53, "sqlCount": 0 }, { @@ -2374,7 +2374,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/py_cu_0003.c", - "loc": 37, + "loc": 50, "sqlCount": 0 }, { @@ -2383,7 +2383,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/py_cu_0004.c", - "loc": 37, + "loc": 56, "sqlCount": 0 }, { @@ -2392,7 +2392,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/py_cu_0005.c", - "loc": 37, + "loc": 44, "sqlCount": 0 }, { @@ -2401,7 +2401,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/py_cu_0006.c", - "loc": 37, + "loc": 43, "sqlCount": 0 }, { @@ -2410,7 +2410,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/py_cu_0007.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -2419,7 +2419,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/py_cu_0008.c", - "loc": 37, + "loc": 62, "sqlCount": 0 }, { @@ -2428,7 +2428,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/py_cu_0009.c", - "loc": 37, + "loc": 48, "sqlCount": 0 }, { @@ -2437,7 +2437,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/py_cu_0010.c", - "loc": 37, + "loc": 40, "sqlCount": 0 }, { @@ -2446,7 +2446,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/py_cu_0011.c", - "loc": 37, + "loc": 64, "sqlCount": 0 }, { @@ -2455,7 +2455,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/rc_cu_0001.c", - "loc": 37, + "loc": 38, "sqlCount": 0 }, { @@ -2464,7 +2464,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/rc_cu_0002.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -2473,7 +2473,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/rc_cu_0003.c", - "loc": 37, + "loc": 56, "sqlCount": 0 }, { @@ -2482,7 +2482,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/rc_cu_0004.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -2491,7 +2491,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/rc_cu_0005.c", - "loc": 37, + "loc": 54, "sqlCount": 0 }, { @@ -2500,7 +2500,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/rc_cu_0006.c", - "loc": 37, + "loc": 57, "sqlCount": 0 }, { @@ -2509,7 +2509,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/rc_cu_0007.c", - "loc": 37, + "loc": 59, "sqlCount": 0 }, { @@ -2518,7 +2518,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/rc_cu_0008.c", - "loc": 37, + "loc": 58, "sqlCount": 0 }, { @@ -2527,7 +2527,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/rc_cu_0009.c", - "loc": 37, + "loc": 50, "sqlCount": 0 }, { @@ -2536,7 +2536,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/rc_cu_0010.c", - "loc": 37, + "loc": 54, "sqlCount": 0 }, { @@ -2545,7 +2545,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/rc_cu_0011.c", - "loc": 37, + "loc": 44, "sqlCount": 0 }, { @@ -2554,7 +2554,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/st_cu_0001.c", - "loc": 37, + "loc": 54, "sqlCount": 0 }, { @@ -2563,7 +2563,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/st_cu_0002.c", - "loc": 37, + "loc": 57, "sqlCount": 0 }, { @@ -2572,7 +2572,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/st_cu_0003.c", - "loc": 37, + "loc": 59, "sqlCount": 0 }, { @@ -2581,7 +2581,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/st_cu_0004.c", - "loc": 37, + "loc": 58, "sqlCount": 0 }, { @@ -2590,7 +2590,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/st_cu_0005.c", - "loc": 37, + "loc": 50, "sqlCount": 0 }, { @@ -2599,7 +2599,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/st_cu_0006.c", - "loc": 37, + "loc": 54, "sqlCount": 0 }, { @@ -2608,7 +2608,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/st_cu_0007.c", - "loc": 37, + "loc": 44, "sqlCount": 0 }, { @@ -2617,7 +2617,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/st_cu_0008.c", - "loc": 37, + "loc": 38, "sqlCount": 0 }, { @@ -2626,7 +2626,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/st_cu_0009.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -2635,7 +2635,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/st_cu_0010.c", - "loc": 37, + "loc": 56, "sqlCount": 0 }, { @@ -2644,7 +2644,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/st_cu_0011.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -2653,7 +2653,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/vl_cu_0001.c", - "loc": 37, + "loc": 56, "sqlCount": 0 }, { @@ -2662,7 +2662,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/vl_cu_0002.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -2671,7 +2671,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/vl_cu_0003.c", - "loc": 37, + "loc": 54, "sqlCount": 0 }, { @@ -2680,7 +2680,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/vl_cu_0004.c", - "loc": 37, + "loc": 57, "sqlCount": 0 }, { @@ -2689,7 +2689,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/vl_cu_0005.c", - "loc": 37, + "loc": 59, "sqlCount": 0 }, { @@ -2698,7 +2698,7 @@ "archetype": "common", "tier": "hard", "path": "app/common/vl_cu_0006.c", - "loc": 37, + "loc": 58, "sqlCount": 0 }, { @@ -2707,7 +2707,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/vl_cu_0007.c", - "loc": 37, + "loc": 50, "sqlCount": 0 }, { @@ -2716,7 +2716,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/vl_cu_0008.c", - "loc": 37, + "loc": 54, "sqlCount": 0 }, { @@ -2725,7 +2725,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/vl_cu_0009.c", - "loc": 37, + "loc": 44, "sqlCount": 0 }, { @@ -2734,7 +2734,7 @@ "archetype": "common", "tier": "easy", "path": "app/common/vl_cu_0010.c", - "loc": 37, + "loc": 38, "sqlCount": 0 }, { @@ -2743,7 +2743,7 @@ "archetype": "common", "tier": "medium", "path": "app/common/vl_cu_0011.c", - "loc": 37, + "loc": 49, "sqlCount": 0 }, { @@ -2761,7 +2761,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/ac_io_0001.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -2770,7 +2770,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/ac_io_0002.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -2779,7 +2779,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/ac_io_0003.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -2788,7 +2788,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/ac_io_0004.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -2797,7 +2797,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/ac_io_0005.pgc", - "loc": 92, + "loc": 105, "sqlCount": 10 }, { @@ -2806,7 +2806,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/ac_io_0006.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -2815,7 +2815,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/ac_io_0007.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -2824,7 +2824,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/ac_io_0008.pgc", - "loc": 92, + "loc": 102, "sqlCount": 10 }, { @@ -2833,7 +2833,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/ac_io_0009.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -2842,7 +2842,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/ac_io_0010.pgc", - "loc": 92, + "loc": 98, "sqlCount": 10 }, { @@ -2851,7 +2851,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/ac_io_0011.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -2860,7 +2860,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/ac_io_0012.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -2869,7 +2869,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/ac_io_0013.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -2878,7 +2878,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/ac_io_0014.pgc", - "loc": 92, + "loc": 103, "sqlCount": 10 }, { @@ -2887,7 +2887,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/ac_io_0015.pgc", - "loc": 92, + "loc": 100, "sqlCount": 10 }, { @@ -2896,7 +2896,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/ac_io_0016.pgc", - "loc": 92, + "loc": 106, "sqlCount": 10 }, { @@ -2905,7 +2905,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/ac_io_0017.pgc", - "loc": 92, + "loc": 104, "sqlCount": 10 }, { @@ -2914,7 +2914,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/ac_io_0018.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -2932,7 +2932,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/ac_io_0020.pgc", - "loc": 92, + "loc": 100, "sqlCount": 10 }, { @@ -2941,7 +2941,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/ac_io_0021.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -2950,7 +2950,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/ac_io_0022.pgc", - "loc": 92, + "loc": 98, "sqlCount": 10 }, { @@ -2959,7 +2959,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/ac_io_0023.pgc", - "loc": 92, + "loc": 91, "sqlCount": 10 }, { @@ -2968,7 +2968,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/ac_io_0024.pgc", - "loc": 92, + "loc": 102, "sqlCount": 10 }, { @@ -2977,7 +2977,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/ac_io_0025.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -2986,7 +2986,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/ac_io_0026.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -2995,7 +2995,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/ac_io_0027.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -3013,7 +3013,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/au_io_0001.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -3022,7 +3022,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/au_io_0002.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -3031,7 +3031,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/au_io_0003.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -3040,7 +3040,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/au_io_0004.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -3049,7 +3049,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/au_io_0005.pgc", - "loc": 92, + "loc": 105, "sqlCount": 10 }, { @@ -3058,7 +3058,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/au_io_0006.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -3067,7 +3067,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/au_io_0007.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -3076,7 +3076,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/au_io_0008.pgc", - "loc": 92, + "loc": 102, "sqlCount": 10 }, { @@ -3085,7 +3085,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/au_io_0009.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -3094,7 +3094,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/au_io_0010.pgc", - "loc": 92, + "loc": 98, "sqlCount": 10 }, { @@ -3103,7 +3103,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/au_io_0011.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -3112,7 +3112,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/au_io_0012.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -3121,7 +3121,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/au_io_0013.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -3130,7 +3130,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/au_io_0014.pgc", - "loc": 92, + "loc": 103, "sqlCount": 10 }, { @@ -3139,7 +3139,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/au_io_0015.pgc", - "loc": 92, + "loc": 100, "sqlCount": 10 }, { @@ -3148,7 +3148,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/au_io_0016.pgc", - "loc": 92, + "loc": 106, "sqlCount": 10 }, { @@ -3157,7 +3157,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/au_io_0017.pgc", - "loc": 92, + "loc": 104, "sqlCount": 10 }, { @@ -3166,7 +3166,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/au_io_0018.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -3184,7 +3184,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/au_io_0020.pgc", - "loc": 92, + "loc": 100, "sqlCount": 10 }, { @@ -3193,7 +3193,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/au_io_0021.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -3202,7 +3202,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/au_io_0022.pgc", - "loc": 92, + "loc": 98, "sqlCount": 10 }, { @@ -3211,7 +3211,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/au_io_0023.pgc", - "loc": 92, + "loc": 91, "sqlCount": 10 }, { @@ -3220,7 +3220,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/au_io_0024.pgc", - "loc": 92, + "loc": 102, "sqlCount": 10 }, { @@ -3229,7 +3229,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/au_io_0025.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -3238,7 +3238,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/au_io_0026.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -3247,7 +3247,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/au_io_0027.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -3265,7 +3265,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cl_io_0001.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -3274,7 +3274,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cl_io_0002.pgc", - "loc": 92, + "loc": 99, "sqlCount": 10 }, { @@ -3283,7 +3283,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/cl_io_0003.pgc", - "loc": 92, + "loc": 106, "sqlCount": 10 }, { @@ -3292,7 +3292,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cl_io_0004.pgc", - "loc": 92, + "loc": 98, "sqlCount": 10 }, { @@ -3310,7 +3310,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cl_io_0006.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -3319,7 +3319,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/cl_io_0007.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -3328,7 +3328,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cl_io_0008.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -3337,7 +3337,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/cl_io_0009.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -3346,7 +3346,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cl_io_0010.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -3355,7 +3355,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cl_io_0011.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -3364,7 +3364,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/cl_io_0012.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -3382,7 +3382,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/cl_io_0014.pgc", - "loc": 92, + "loc": 102, "sqlCount": 10 }, { @@ -3391,7 +3391,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cl_io_0015.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -3400,7 +3400,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/cl_io_0016.pgc", - "loc": 92, + "loc": 98, "sqlCount": 10 }, { @@ -3409,7 +3409,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cl_io_0017.pgc", - "loc": 92, + "loc": 104, "sqlCount": 10 }, { @@ -3418,7 +3418,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/cl_io_0018.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -3427,7 +3427,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cl_io_0019.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -3436,7 +3436,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/cl_io_0020.pgc", - "loc": 92, + "loc": 99, "sqlCount": 10 }, { @@ -3445,7 +3445,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cl_io_0021.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -3454,7 +3454,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cl_io_0022.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -3463,7 +3463,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/cl_io_0023.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -3472,7 +3472,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cl_io_0024.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -3490,7 +3490,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cl_io_0026.pgc", - "loc": 92, + "loc": 101, "sqlCount": 10 }, { @@ -3508,7 +3508,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cm_io_0001.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -3517,7 +3517,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cm_io_0002.pgc", - "loc": 92, + "loc": 99, "sqlCount": 10 }, { @@ -3526,7 +3526,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/cm_io_0003.pgc", - "loc": 92, + "loc": 106, "sqlCount": 10 }, { @@ -3535,7 +3535,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cm_io_0004.pgc", - "loc": 92, + "loc": 98, "sqlCount": 10 }, { @@ -3553,7 +3553,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cm_io_0006.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -3562,7 +3562,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/cm_io_0007.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -3571,7 +3571,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cm_io_0008.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -3580,7 +3580,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/cm_io_0009.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -3589,7 +3589,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cm_io_0010.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -3598,7 +3598,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/cm_io_0011.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -3607,7 +3607,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cm_io_0012.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -3625,7 +3625,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/cm_io_0014.pgc", - "loc": 92, + "loc": 102, "sqlCount": 10 }, { @@ -3634,7 +3634,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cm_io_0015.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -3643,7 +3643,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/cm_io_0016.pgc", - "loc": 92, + "loc": 98, "sqlCount": 10 }, { @@ -3652,7 +3652,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cm_io_0017.pgc", - "loc": 92, + "loc": 104, "sqlCount": 10 }, { @@ -3661,7 +3661,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/cm_io_0018.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -3670,7 +3670,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cm_io_0019.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -3679,7 +3679,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/cm_io_0020.pgc", - "loc": 92, + "loc": 99, "sqlCount": 10 }, { @@ -3688,7 +3688,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cm_io_0021.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -3697,7 +3697,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cm_io_0022.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -3706,7 +3706,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/cm_io_0023.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -3715,7 +3715,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cm_io_0024.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -3733,7 +3733,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/cm_io_0026.pgc", - "loc": 92, + "loc": 101, "sqlCount": 10 }, { @@ -3751,7 +3751,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/lg_io_0001.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -3760,7 +3760,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/lg_io_0002.pgc", - "loc": 92, + "loc": 89, "sqlCount": 10 }, { @@ -3778,7 +3778,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/lg_io_0004.pgc", - "loc": 92, + "loc": 84, "sqlCount": 10 }, { @@ -3787,7 +3787,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/lg_io_0005.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -3796,7 +3796,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/lg_io_0006.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -3805,7 +3805,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/lg_io_0007.pgc", - "loc": 92, + "loc": 85, "sqlCount": 10 }, { @@ -3814,7 +3814,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/lg_io_0008.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -3823,7 +3823,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/lg_io_0009.pgc", - "loc": 92, + "loc": 91, "sqlCount": 10 }, { @@ -3832,7 +3832,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/lg_io_0010.pgc", - "loc": 92, + "loc": 91, "sqlCount": 10 }, { @@ -3841,7 +3841,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/lg_io_0011.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -3850,7 +3850,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/lg_io_0012.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -3859,7 +3859,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/lg_io_0013.pgc", - "loc": 92, + "loc": 85, "sqlCount": 10 }, { @@ -3868,7 +3868,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/lg_io_0014.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -3877,7 +3877,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/lg_io_0015.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -3886,7 +3886,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/lg_io_0016.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -3895,7 +3895,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/lg_io_0017.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -3913,7 +3913,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/lg_io_0019.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -3922,7 +3922,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/lg_io_0020.pgc", - "loc": 92, + "loc": 86, "sqlCount": 10 }, { @@ -3931,7 +3931,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/lg_io_0021.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -3940,7 +3940,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/lg_io_0022.pgc", - "loc": 92, + "loc": 85, "sqlCount": 10 }, { @@ -3949,7 +3949,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/lg_io_0023.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -3958,7 +3958,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/lg_io_0024.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -3967,7 +3967,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/lg_io_0025.pgc", - "loc": 92, + "loc": 87, "sqlCount": 10 }, { @@ -3976,7 +3976,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/lg_io_0026.pgc", - "loc": 92, + "loc": 102, "sqlCount": 10 }, { @@ -3994,7 +3994,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mg_io_0001.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -4003,7 +4003,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/mg_io_0002.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -4012,7 +4012,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mg_io_0003.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -4021,7 +4021,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/mg_io_0004.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -4030,7 +4030,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mg_io_0005.pgc", - "loc": 92, + "loc": 105, "sqlCount": 10 }, { @@ -4039,7 +4039,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/mg_io_0006.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -4048,7 +4048,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mg_io_0007.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -4057,7 +4057,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/mg_io_0008.pgc", - "loc": 92, + "loc": 102, "sqlCount": 10 }, { @@ -4066,7 +4066,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mg_io_0009.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -4075,7 +4075,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/mg_io_0010.pgc", - "loc": 92, + "loc": 98, "sqlCount": 10 }, { @@ -4084,7 +4084,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mg_io_0011.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -4093,7 +4093,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mg_io_0012.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -4102,7 +4102,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/mg_io_0013.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -4111,7 +4111,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mg_io_0014.pgc", - "loc": 92, + "loc": 103, "sqlCount": 10 }, { @@ -4120,7 +4120,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/mg_io_0015.pgc", - "loc": 92, + "loc": 100, "sqlCount": 10 }, { @@ -4129,7 +4129,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mg_io_0016.pgc", - "loc": 92, + "loc": 106, "sqlCount": 10 }, { @@ -4138,7 +4138,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/mg_io_0017.pgc", - "loc": 92, + "loc": 104, "sqlCount": 10 }, { @@ -4147,7 +4147,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mg_io_0018.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -4165,7 +4165,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mg_io_0020.pgc", - "loc": 92, + "loc": 100, "sqlCount": 10 }, { @@ -4174,7 +4174,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mg_io_0021.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -4183,7 +4183,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/mg_io_0022.pgc", - "loc": 92, + "loc": 98, "sqlCount": 10 }, { @@ -4192,7 +4192,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mg_io_0023.pgc", - "loc": 92, + "loc": 91, "sqlCount": 10 }, { @@ -4201,7 +4201,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/mg_io_0024.pgc", - "loc": 92, + "loc": 102, "sqlCount": 10 }, { @@ -4210,7 +4210,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mg_io_0025.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -4219,7 +4219,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/mg_io_0026.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -4228,7 +4228,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mg_io_0027.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -4246,7 +4246,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mm_io_0001.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -4255,7 +4255,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/mm_io_0002.pgc", - "loc": 92, + "loc": 99, "sqlCount": 10 }, { @@ -4264,7 +4264,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mm_io_0003.pgc", - "loc": 92, + "loc": 106, "sqlCount": 10 }, { @@ -4273,7 +4273,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mm_io_0004.pgc", - "loc": 92, + "loc": 98, "sqlCount": 10 }, { @@ -4291,7 +4291,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mm_io_0006.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -4300,7 +4300,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/mm_io_0007.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -4309,7 +4309,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mm_io_0008.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -4318,7 +4318,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/mm_io_0009.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -4327,7 +4327,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mm_io_0010.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -4336,7 +4336,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/mm_io_0011.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -4345,7 +4345,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mm_io_0012.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -4363,7 +4363,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/mm_io_0014.pgc", - "loc": 92, + "loc": 102, "sqlCount": 10 }, { @@ -4372,7 +4372,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mm_io_0015.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -4381,7 +4381,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/mm_io_0016.pgc", - "loc": 92, + "loc": 98, "sqlCount": 10 }, { @@ -4390,7 +4390,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mm_io_0017.pgc", - "loc": 92, + "loc": 104, "sqlCount": 10 }, { @@ -4399,7 +4399,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/mm_io_0018.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -4408,7 +4408,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mm_io_0019.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -4417,7 +4417,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/mm_io_0020.pgc", - "loc": 92, + "loc": 99, "sqlCount": 10 }, { @@ -4426,7 +4426,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mm_io_0021.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -4435,7 +4435,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/mm_io_0022.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -4444,7 +4444,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mm_io_0023.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -4453,7 +4453,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mm_io_0024.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -4471,7 +4471,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/mm_io_0026.pgc", - "loc": 92, + "loc": 101, "sqlCount": 10 }, { @@ -4489,7 +4489,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/py_io_0001.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -4498,7 +4498,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/py_io_0002.pgc", - "loc": 92, + "loc": 89, "sqlCount": 10 }, { @@ -4516,7 +4516,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/py_io_0004.pgc", - "loc": 92, + "loc": 84, "sqlCount": 10 }, { @@ -4525,7 +4525,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/py_io_0005.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -4534,7 +4534,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/py_io_0006.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -4543,7 +4543,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/py_io_0007.pgc", - "loc": 92, + "loc": 85, "sqlCount": 10 }, { @@ -4552,7 +4552,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/py_io_0008.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -4561,7 +4561,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/py_io_0009.pgc", - "loc": 92, + "loc": 91, "sqlCount": 10 }, { @@ -4570,7 +4570,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/py_io_0010.pgc", - "loc": 92, + "loc": 91, "sqlCount": 10 }, { @@ -4579,7 +4579,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/py_io_0011.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -4588,7 +4588,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/py_io_0012.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -4597,7 +4597,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/py_io_0013.pgc", - "loc": 92, + "loc": 85, "sqlCount": 10 }, { @@ -4606,7 +4606,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/py_io_0014.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -4615,7 +4615,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/py_io_0015.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -4624,7 +4624,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/py_io_0016.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -4633,7 +4633,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/py_io_0017.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -4651,7 +4651,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/py_io_0019.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -4660,7 +4660,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/py_io_0020.pgc", - "loc": 92, + "loc": 86, "sqlCount": 10 }, { @@ -4669,7 +4669,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/py_io_0021.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -4678,7 +4678,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/py_io_0022.pgc", - "loc": 92, + "loc": 85, "sqlCount": 10 }, { @@ -4687,7 +4687,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/py_io_0023.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -4696,7 +4696,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/py_io_0024.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -4705,7 +4705,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/py_io_0025.pgc", - "loc": 92, + "loc": 87, "sqlCount": 10 }, { @@ -4714,7 +4714,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/py_io_0026.pgc", - "loc": 92, + "loc": 102, "sqlCount": 10 }, { @@ -4732,7 +4732,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/rc_io_0001.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -4741,7 +4741,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/rc_io_0002.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -4750,7 +4750,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/rc_io_0003.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -4759,7 +4759,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/rc_io_0004.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -4768,7 +4768,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/rc_io_0005.pgc", - "loc": 92, + "loc": 105, "sqlCount": 10 }, { @@ -4777,7 +4777,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/rc_io_0006.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -4786,7 +4786,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/rc_io_0007.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -4795,7 +4795,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/rc_io_0008.pgc", - "loc": 92, + "loc": 102, "sqlCount": 10 }, { @@ -4804,7 +4804,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/rc_io_0009.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -4813,7 +4813,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/rc_io_0010.pgc", - "loc": 92, + "loc": 98, "sqlCount": 10 }, { @@ -4822,7 +4822,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/rc_io_0011.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -4831,7 +4831,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/rc_io_0012.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -4840,7 +4840,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/rc_io_0013.pgc", - "loc": 92, + "loc": 93, "sqlCount": 10 }, { @@ -4849,7 +4849,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/rc_io_0014.pgc", - "loc": 92, + "loc": 103, "sqlCount": 10 }, { @@ -4858,7 +4858,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/rc_io_0015.pgc", - "loc": 92, + "loc": 100, "sqlCount": 10 }, { @@ -4867,7 +4867,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/rc_io_0016.pgc", - "loc": 92, + "loc": 106, "sqlCount": 10 }, { @@ -4876,7 +4876,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/rc_io_0017.pgc", - "loc": 92, + "loc": 104, "sqlCount": 10 }, { @@ -4885,7 +4885,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/rc_io_0018.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -4903,7 +4903,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/rc_io_0020.pgc", - "loc": 92, + "loc": 100, "sqlCount": 10 }, { @@ -4912,7 +4912,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/rc_io_0021.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -4921,7 +4921,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/rc_io_0022.pgc", - "loc": 92, + "loc": 98, "sqlCount": 10 }, { @@ -4930,7 +4930,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/rc_io_0023.pgc", - "loc": 92, + "loc": 91, "sqlCount": 10 }, { @@ -4939,7 +4939,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/rc_io_0024.pgc", - "loc": 92, + "loc": 102, "sqlCount": 10 }, { @@ -4948,7 +4948,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/rc_io_0025.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -4957,7 +4957,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/rc_io_0026.pgc", - "loc": 92, + "loc": 107, "sqlCount": 10 }, { @@ -4975,7 +4975,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/st_io_0001.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -4984,7 +4984,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/st_io_0002.pgc", - "loc": 92, + "loc": 89, "sqlCount": 10 }, { @@ -5002,7 +5002,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/st_io_0004.pgc", - "loc": 92, + "loc": 84, "sqlCount": 10 }, { @@ -5011,7 +5011,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/st_io_0005.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -5020,7 +5020,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/st_io_0006.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -5029,7 +5029,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/st_io_0007.pgc", - "loc": 92, + "loc": 85, "sqlCount": 10 }, { @@ -5038,7 +5038,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/st_io_0008.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -5047,7 +5047,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/st_io_0009.pgc", - "loc": 92, + "loc": 91, "sqlCount": 10 }, { @@ -5056,7 +5056,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/st_io_0010.pgc", - "loc": 92, + "loc": 91, "sqlCount": 10 }, { @@ -5065,7 +5065,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/st_io_0011.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -5074,7 +5074,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/st_io_0012.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -5083,7 +5083,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/st_io_0013.pgc", - "loc": 92, + "loc": 85, "sqlCount": 10 }, { @@ -5092,7 +5092,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/st_io_0014.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -5101,7 +5101,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/st_io_0015.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -5110,7 +5110,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/st_io_0016.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -5119,7 +5119,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/st_io_0017.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -5137,7 +5137,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/st_io_0019.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -5146,7 +5146,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/st_io_0020.pgc", - "loc": 92, + "loc": 86, "sqlCount": 10 }, { @@ -5155,7 +5155,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/st_io_0021.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -5164,7 +5164,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/st_io_0022.pgc", - "loc": 92, + "loc": 85, "sqlCount": 10 }, { @@ -5173,7 +5173,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/st_io_0023.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -5182,7 +5182,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/st_io_0024.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -5191,7 +5191,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/st_io_0025.pgc", - "loc": 92, + "loc": 87, "sqlCount": 10 }, { @@ -5200,7 +5200,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/st_io_0026.pgc", - "loc": 92, + "loc": 102, "sqlCount": 10 }, { @@ -5218,7 +5218,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/vl_io_0001.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -5227,7 +5227,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/vl_io_0002.pgc", - "loc": 92, + "loc": 89, "sqlCount": 10 }, { @@ -5245,7 +5245,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/vl_io_0004.pgc", - "loc": 92, + "loc": 84, "sqlCount": 10 }, { @@ -5254,7 +5254,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/vl_io_0005.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -5263,7 +5263,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/vl_io_0006.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -5272,7 +5272,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/vl_io_0007.pgc", - "loc": 92, + "loc": 85, "sqlCount": 10 }, { @@ -5281,7 +5281,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/vl_io_0008.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -5290,7 +5290,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/vl_io_0009.pgc", - "loc": 92, + "loc": 91, "sqlCount": 10 }, { @@ -5299,7 +5299,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/vl_io_0010.pgc", - "loc": 92, + "loc": 91, "sqlCount": 10 }, { @@ -5308,7 +5308,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/vl_io_0011.pgc", - "loc": 92, + "loc": 90, "sqlCount": 10 }, { @@ -5317,7 +5317,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/vl_io_0012.pgc", - "loc": 92, + "loc": 95, "sqlCount": 10 }, { @@ -5326,7 +5326,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/vl_io_0013.pgc", - "loc": 92, + "loc": 85, "sqlCount": 10 }, { @@ -5335,7 +5335,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/vl_io_0014.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -5344,7 +5344,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/vl_io_0015.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -5353,7 +5353,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/vl_io_0016.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -5362,7 +5362,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/vl_io_0017.pgc", - "loc": 92, + "loc": 96, "sqlCount": 10 }, { @@ -5380,7 +5380,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/vl_io_0019.pgc", - "loc": 92, + "loc": 97, "sqlCount": 10 }, { @@ -5389,7 +5389,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/vl_io_0020.pgc", - "loc": 92, + "loc": 86, "sqlCount": 10 }, { @@ -5398,7 +5398,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/vl_io_0021.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -5407,7 +5407,7 @@ "archetype": "dbio", "tier": "medium", "path": "app/dbio/vl_io_0022.pgc", - "loc": 92, + "loc": 85, "sqlCount": 10 }, { @@ -5416,7 +5416,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/vl_io_0023.pgc", - "loc": 92, + "loc": 88, "sqlCount": 10 }, { @@ -5425,7 +5425,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/vl_io_0024.pgc", - "loc": 92, + "loc": 94, "sqlCount": 10 }, { @@ -5434,7 +5434,7 @@ "archetype": "dbio", "tier": "easy", "path": "app/dbio/vl_io_0025.pgc", - "loc": 92, + "loc": 87, "sqlCount": 10 }, { @@ -5443,7 +5443,7 @@ "archetype": "dbio", "tier": "hard", "path": "app/dbio/vl_io_0026.pgc", - "loc": 92, + "loc": 102, "sqlCount": 10 }, { @@ -5452,7 +5452,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/ac_ol_0001.pgc", - "loc": 122, + "loc": 121, "sqlCount": 1 }, { @@ -5461,7 +5461,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/ac_ol_0002.pgc", - "loc": 141, + "loc": 139, "sqlCount": 1 }, { @@ -5470,7 +5470,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/ac_ol_0003.pgc", - "loc": 143, + "loc": 140, "sqlCount": 1 }, { @@ -5479,7 +5479,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/ac_ol_0004.pgc", - "loc": 126, + "loc": 124, "sqlCount": 1 }, { @@ -5488,7 +5488,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/ac_ol_0005.pgc", - "loc": 120, + "loc": 118, "sqlCount": 1 }, { @@ -5497,7 +5497,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/ac_ol_0006.pgc", - "loc": 150, + "loc": 146, "sqlCount": 1 }, { @@ -5506,7 +5506,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/ac_ol_0007.pgc", - "loc": 129, + "loc": 126, "sqlCount": 1 }, { @@ -5515,7 +5515,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/ac_ol_0008.pgc", - "loc": 132, + "loc": 131, "sqlCount": 1 }, { @@ -5668,7 +5668,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/ac_ol_0025.pgc", - "loc": 126, + "loc": 124, "sqlCount": 1 }, { @@ -5686,7 +5686,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/ac_ol_0027.pgc", - "loc": 122, + "loc": 121, "sqlCount": 1 }, { @@ -5704,7 +5704,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/ac_ol_0029.pgc", - "loc": 123, + "loc": 122, "sqlCount": 1 }, { @@ -5713,7 +5713,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/ac_ol_0030.pgc", - "loc": 149, + "loc": 147, "sqlCount": 1 }, { @@ -5722,7 +5722,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/ac_ol_0031.pgc", - "loc": 128, + "loc": 126, "sqlCount": 1 }, { @@ -5731,7 +5731,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/ac_ol_0032.pgc", - "loc": 130, + "loc": 128, "sqlCount": 1 }, { @@ -5740,7 +5740,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/au_ol_0001.pgc", - "loc": 47, + "loc": 87, "sqlCount": 1 }, { @@ -5803,7 +5803,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/au_ol_0008.pgc", - "loc": 64, + "loc": 144, "sqlCount": 1 }, { @@ -5812,7 +5812,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/au_ol_0009.pgc", - "loc": 61, + "loc": 117, "sqlCount": 1 }, { @@ -6028,7 +6028,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cl_ol_0001.pgc", - "loc": 47, + "loc": 81, "sqlCount": 1 }, { @@ -6154,7 +6154,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cl_ol_0015.pgc", - "loc": 121, + "loc": 155, "sqlCount": 1 }, { @@ -6172,7 +6172,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cl_ol_0017.pgc", - "loc": 122, + "loc": 160, "sqlCount": 1 }, { @@ -6190,7 +6190,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cl_ol_0019.pgc", - "loc": 127, + "loc": 159, "sqlCount": 1 }, { @@ -6226,7 +6226,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/cl_ol_0023.pgc", - "loc": 122, + "loc": 155, "sqlCount": 1 }, { @@ -6244,7 +6244,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/cl_ol_0025.pgc", - "loc": 124, + "loc": 173, "sqlCount": 1 }, { @@ -6298,7 +6298,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cl_ol_0031.pgc", - "loc": 122, + "loc": 159, "sqlCount": 1 }, { @@ -6307,7 +6307,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cm_ol_0001.pgc", - "loc": 76, + "loc": 75, "sqlCount": 1 }, { @@ -6316,7 +6316,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cm_ol_0002.pgc", - "loc": 74, + "loc": 105, "sqlCount": 1 }, { @@ -6325,7 +6325,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/cm_ol_0003.pgc", - "loc": 62, + "loc": 92, "sqlCount": 1 }, { @@ -6334,7 +6334,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cm_ol_0004.pgc", - "loc": 90, + "loc": 127, "sqlCount": 1 }, { @@ -6343,7 +6343,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/cm_ol_0005.pgc", - "loc": 88, + "loc": 87, "sqlCount": 1 }, { @@ -6352,7 +6352,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cm_ol_0006.pgc", - "loc": 114, + "loc": 112, "sqlCount": 1 }, { @@ -6361,7 +6361,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/cm_ol_0007.pgc", - "loc": 119, + "loc": 117, "sqlCount": 1 }, { @@ -6370,7 +6370,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cm_ol_0008.pgc", - "loc": 84, + "loc": 83, "sqlCount": 1 }, { @@ -6379,7 +6379,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/cm_ol_0009.pgc", - "loc": 120, + "loc": 119, "sqlCount": 1 }, { @@ -6397,7 +6397,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/cm_ol_0011.pgc", - "loc": 82, + "loc": 81, "sqlCount": 1 }, { @@ -6406,7 +6406,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cm_ol_0012.pgc", - "loc": 78, + "loc": 77, "sqlCount": 1 }, { @@ -6415,7 +6415,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cm_ol_0013.pgc", - "loc": 75, + "loc": 108, "sqlCount": 1 }, { @@ -6424,7 +6424,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/cm_ol_0014.pgc", - "loc": 65, + "loc": 104, "sqlCount": 1 }, { @@ -6433,7 +6433,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cm_ol_0015.pgc", - "loc": 71, + "loc": 106, "sqlCount": 1 }, { @@ -6442,7 +6442,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/cm_ol_0016.pgc", - "loc": 73, + "loc": 72, "sqlCount": 1 }, { @@ -6460,7 +6460,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/cm_ol_0018.pgc", - "loc": 96, + "loc": 94, "sqlCount": 1 }, { @@ -6469,7 +6469,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cm_ol_0019.pgc", - "loc": 63, + "loc": 93, "sqlCount": 1 }, { @@ -6478,7 +6478,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/cm_ol_0020.pgc", - "loc": 101, + "loc": 130, "sqlCount": 1 }, { @@ -6487,7 +6487,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cm_ol_0021.pgc", - "loc": 102, + "loc": 101, "sqlCount": 1 }, { @@ -6496,7 +6496,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cm_ol_0022.pgc", - "loc": 72, + "loc": 106, "sqlCount": 1 }, { @@ -6505,7 +6505,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/cm_ol_0023.pgc", - "loc": 71, + "loc": 70, "sqlCount": 1 }, { @@ -6514,7 +6514,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cm_ol_0024.pgc", - "loc": 81, + "loc": 80, "sqlCount": 1 }, { @@ -6523,7 +6523,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/cm_ol_0025.pgc", - "loc": 74, + "loc": 73, "sqlCount": 1 }, { @@ -6532,7 +6532,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cm_ol_0026.pgc", - "loc": 116, + "loc": 114, "sqlCount": 1 }, { @@ -6541,7 +6541,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/cm_ol_0027.pgc", - "loc": 92, + "loc": 126, "sqlCount": 1 }, { @@ -6550,7 +6550,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cm_ol_0028.pgc", - "loc": 69, + "loc": 101, "sqlCount": 1 }, { @@ -6559,7 +6559,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/cm_ol_0029.pgc", - "loc": 79, + "loc": 78, "sqlCount": 1 }, { @@ -6568,7 +6568,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/cm_ol_0030.pgc", - "loc": 84, + "loc": 83, "sqlCount": 1 }, { @@ -6577,7 +6577,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/cm_ol_0031.pgc", - "loc": 71, + "loc": 102, "sqlCount": 1 }, { @@ -6586,7 +6586,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/lg_ol_0001.pgc", - "loc": 47, + "loc": 93, "sqlCount": 1 }, { @@ -6595,7 +6595,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/lg_ol_0002.pgc", - "loc": 98, + "loc": 122, "sqlCount": 1 }, { @@ -6874,7 +6874,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mg_ol_0001.pgc", - "loc": 85, + "loc": 115, "sqlCount": 1 }, { @@ -6883,7 +6883,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mg_ol_0002.pgc", - "loc": 98, + "loc": 127, "sqlCount": 1 }, { @@ -6892,7 +6892,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mg_ol_0003.pgc", - "loc": 113, + "loc": 144, "sqlCount": 1 }, { @@ -6901,7 +6901,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mg_ol_0004.pgc", - "loc": 81, + "loc": 110, "sqlCount": 1 }, { @@ -6919,7 +6919,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mg_ol_0006.pgc", - "loc": 88, + "loc": 117, "sqlCount": 1 }, { @@ -6928,7 +6928,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mg_ol_0007.pgc", - "loc": 79, + "loc": 105, "sqlCount": 1 }, { @@ -6937,7 +6937,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/mg_ol_0008.pgc", - "loc": 90, + "loc": 123, "sqlCount": 1 }, { @@ -6955,7 +6955,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/mg_ol_0010.pgc", - "loc": 93, + "loc": 120, "sqlCount": 1 }, { @@ -6964,7 +6964,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mg_ol_0011.pgc", - "loc": 72, + "loc": 100, "sqlCount": 1 }, { @@ -6973,7 +6973,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mg_ol_0012.pgc", - "loc": 109, + "loc": 138, "sqlCount": 1 }, { @@ -6982,7 +6982,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mg_ol_0013.pgc", - "loc": 128, + "loc": 151, "sqlCount": 1 }, { @@ -7000,7 +7000,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mg_ol_0015.pgc", - "loc": 102, + "loc": 137, "sqlCount": 1 }, { @@ -7009,7 +7009,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mg_ol_0016.pgc", - "loc": 77, + "loc": 106, "sqlCount": 1 }, { @@ -7018,7 +7018,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mg_ol_0017.pgc", - "loc": 109, + "loc": 137, "sqlCount": 1 }, { @@ -7027,7 +7027,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mg_ol_0018.pgc", - "loc": 92, + "loc": 125, "sqlCount": 1 }, { @@ -7036,7 +7036,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/mg_ol_0019.pgc", - "loc": 123, + "loc": 154, "sqlCount": 1 }, { @@ -7054,7 +7054,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mg_ol_0021.pgc", - "loc": 72, + "loc": 98, "sqlCount": 1 }, { @@ -7063,7 +7063,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mg_ol_0022.pgc", - "loc": 103, + "loc": 130, "sqlCount": 1 }, { @@ -7072,7 +7072,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mg_ol_0023.pgc", - "loc": 113, + "loc": 111, "sqlCount": 1 }, { @@ -7081,7 +7081,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mg_ol_0024.pgc", - "loc": 97, + "loc": 124, "sqlCount": 1 }, { @@ -7090,7 +7090,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mg_ol_0025.pgc", - "loc": 109, + "loc": 108, "sqlCount": 1 }, { @@ -7099,7 +7099,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mg_ol_0026.pgc", - "loc": 82, + "loc": 109, "sqlCount": 1 }, { @@ -7108,7 +7108,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mg_ol_0027.pgc", - "loc": 79, + "loc": 104, "sqlCount": 1 }, { @@ -7117,7 +7117,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/mg_ol_0028.pgc", - "loc": 101, + "loc": 129, "sqlCount": 1 }, { @@ -7126,7 +7126,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mg_ol_0029.pgc", - "loc": 65, + "loc": 93, "sqlCount": 1 }, { @@ -7135,7 +7135,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/mg_ol_0030.pgc", - "loc": 66, + "loc": 96, "sqlCount": 1 }, { @@ -7144,7 +7144,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mg_ol_0031.pgc", - "loc": 75, + "loc": 104, "sqlCount": 1 }, { @@ -7162,7 +7162,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0001.pgc", - "loc": 47, + "loc": 81, "sqlCount": 1 }, { @@ -7171,7 +7171,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/mm_ol_0002.pgc", - "loc": 108, + "loc": 105, "sqlCount": 1 }, { @@ -7180,7 +7180,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0003.pgc", - "loc": 114, + "loc": 111, "sqlCount": 1 }, { @@ -7189,7 +7189,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0004.pgc", - "loc": 126, + "loc": 123, "sqlCount": 1 }, { @@ -7198,7 +7198,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mm_ol_0005.pgc", - "loc": 90, + "loc": 89, "sqlCount": 1 }, { @@ -7207,7 +7207,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0006.pgc", - "loc": 129, + "loc": 126, "sqlCount": 1 }, { @@ -7216,7 +7216,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mm_ol_0007.pgc", - "loc": 84, + "loc": 83, "sqlCount": 1 }, { @@ -7225,7 +7225,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0008.pgc", - "loc": 126, + "loc": 123, "sqlCount": 1 }, { @@ -7234,7 +7234,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mm_ol_0009.pgc", - "loc": 90, + "loc": 89, "sqlCount": 1 }, { @@ -7243,7 +7243,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0010.pgc", - "loc": 137, + "loc": 134, "sqlCount": 1 }, { @@ -7252,7 +7252,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/mm_ol_0011.pgc", - "loc": 87, + "loc": 85, "sqlCount": 1 }, { @@ -7261,7 +7261,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0012.pgc", - "loc": 116, + "loc": 113, "sqlCount": 1 }, { @@ -7270,7 +7270,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0013.pgc", - "loc": 81, + "loc": 80, "sqlCount": 1 }, { @@ -7279,7 +7279,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mm_ol_0014.pgc", - "loc": 127, + "loc": 124, "sqlCount": 1 }, { @@ -7288,7 +7288,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0015.pgc", - "loc": 72, + "loc": 71, "sqlCount": 1 }, { @@ -7297,7 +7297,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mm_ol_0016.pgc", - "loc": 146, + "loc": 143, "sqlCount": 1 }, { @@ -7306,7 +7306,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0017.pgc", - "loc": 97, + "loc": 95, "sqlCount": 1 }, { @@ -7315,7 +7315,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mm_ol_0018.pgc", - "loc": 95, + "loc": 93, "sqlCount": 1 }, { @@ -7324,7 +7324,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0019.pgc", - "loc": 143, + "loc": 139, "sqlCount": 1 }, { @@ -7333,7 +7333,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/mm_ol_0020.pgc", - "loc": 151, + "loc": 147, "sqlCount": 1 }, { @@ -7342,7 +7342,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0021.pgc", - "loc": 84, + "loc": 83, "sqlCount": 1 }, { @@ -7351,7 +7351,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/mm_ol_0022.pgc", - "loc": 119, + "loc": 117, "sqlCount": 1 }, { @@ -7360,7 +7360,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0023.pgc", - "loc": 83, + "loc": 82, "sqlCount": 1 }, { @@ -7369,7 +7369,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0024.pgc", - "loc": 114, + "loc": 113, "sqlCount": 1 }, { @@ -7378,7 +7378,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mm_ol_0025.pgc", - "loc": 102, + "loc": 99, "sqlCount": 1 }, { @@ -7387,7 +7387,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0026.pgc", - "loc": 91, + "loc": 89, "sqlCount": 1 }, { @@ -7396,7 +7396,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mm_ol_0027.pgc", - "loc": 143, + "loc": 140, "sqlCount": 1 }, { @@ -7405,7 +7405,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0028.pgc", - "loc": 126, + "loc": 123, "sqlCount": 1 }, { @@ -7414,7 +7414,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/mm_ol_0029.pgc", - "loc": 142, + "loc": 138, "sqlCount": 1 }, { @@ -7423,7 +7423,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0030.pgc", - "loc": 82, + "loc": 81, "sqlCount": 1 }, { @@ -7432,7 +7432,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/mm_ol_0031.pgc", - "loc": 105, + "loc": 103, "sqlCount": 1 }, { @@ -7441,7 +7441,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/mm_ol_0032.pgc", - "loc": 84, + "loc": 81, "sqlCount": 1 }, { @@ -7450,7 +7450,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/py_ol_0001.pgc", - "loc": 47, + "loc": 84, "sqlCount": 1 }, { @@ -7468,7 +7468,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/py_ol_0003.pgc", - "loc": 56, + "loc": 104, "sqlCount": 1 }, { @@ -7738,7 +7738,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/rc_ol_0001.pgc", - "loc": 47, + "loc": 74, "sqlCount": 1 }, { @@ -7747,7 +7747,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/rc_ol_0002.pgc", - "loc": 76, + "loc": 109, "sqlCount": 1 }, { @@ -7756,7 +7756,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/rc_ol_0003.pgc", - "loc": 120, + "loc": 153, "sqlCount": 1 }, { @@ -7765,7 +7765,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/rc_ol_0004.pgc", - "loc": 125, + "loc": 156, "sqlCount": 1 }, { @@ -7774,7 +7774,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/rc_ol_0005.pgc", - "loc": 120, + "loc": 144, "sqlCount": 1 }, { @@ -7783,7 +7783,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/rc_ol_0006.pgc", - "loc": 123, + "loc": 149, "sqlCount": 1 }, { @@ -7792,7 +7792,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/rc_ol_0007.pgc", - "loc": 122, + "loc": 152, "sqlCount": 1 }, { @@ -7801,7 +7801,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/rc_ol_0008.pgc", - "loc": 89, + "loc": 121, "sqlCount": 1 }, { @@ -7810,7 +7810,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/rc_ol_0009.pgc", - "loc": 95, + "loc": 124, "sqlCount": 1 }, { @@ -7819,7 +7819,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/rc_ol_0010.pgc", - "loc": 77, + "loc": 101, "sqlCount": 1 }, { @@ -7846,7 +7846,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/rc_ol_0013.pgc", - "loc": 122, + "loc": 157, "sqlCount": 1 }, { @@ -7864,7 +7864,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/rc_ol_0015.pgc", - "loc": 120, + "loc": 147, "sqlCount": 1 }, { @@ -7873,7 +7873,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/rc_ol_0016.pgc", - "loc": 124, + "loc": 159, "sqlCount": 1 }, { @@ -7900,7 +7900,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/rc_ol_0019.pgc", - "loc": 122, + "loc": 150, "sqlCount": 1 }, { @@ -7909,7 +7909,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/rc_ol_0020.pgc", - "loc": 122, + "loc": 152, "sqlCount": 1 }, { @@ -7918,7 +7918,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/rc_ol_0021.pgc", - "loc": 120, + "loc": 144, "sqlCount": 1 }, { @@ -7927,7 +7927,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/rc_ol_0022.pgc", - "loc": 124, + "loc": 156, "sqlCount": 1 }, { @@ -7945,7 +7945,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/rc_ol_0024.pgc", - "loc": 80, + "loc": 107, "sqlCount": 1 }, { @@ -7954,7 +7954,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/rc_ol_0025.pgc", - "loc": 96, + "loc": 129, "sqlCount": 1 }, { @@ -7972,7 +7972,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/rc_ol_0027.pgc", - "loc": 120, + "loc": 145, "sqlCount": 1 }, { @@ -7999,7 +7999,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/rc_ol_0030.pgc", - "loc": 120, + "loc": 149, "sqlCount": 1 }, { @@ -8008,7 +8008,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/rc_ol_0031.pgc", - "loc": 120, + "loc": 145, "sqlCount": 1 }, { @@ -8017,7 +8017,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/rc_ol_0032.pgc", - "loc": 120, + "loc": 148, "sqlCount": 1 }, { @@ -8026,7 +8026,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0001.pgc", - "loc": 47, + "loc": 80, "sqlCount": 1 }, { @@ -8035,7 +8035,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/st_ol_0002.pgc", - "loc": 69, + "loc": 98, "sqlCount": 1 }, { @@ -8044,7 +8044,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0003.pgc", - "loc": 61, + "loc": 93, "sqlCount": 1 }, { @@ -8053,7 +8053,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/st_ol_0004.pgc", - "loc": 55, + "loc": 94, "sqlCount": 1 }, { @@ -8062,7 +8062,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0005.pgc", - "loc": 67, + "loc": 97, "sqlCount": 1 }, { @@ -8071,7 +8071,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0006.pgc", - "loc": 56, + "loc": 90, "sqlCount": 1 }, { @@ -8080,7 +8080,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/st_ol_0007.pgc", - "loc": 57, + "loc": 91, "sqlCount": 1 }, { @@ -8089,7 +8089,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0008.pgc", - "loc": 60, + "loc": 92, "sqlCount": 1 }, { @@ -8098,7 +8098,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/st_ol_0009.pgc", - "loc": 56, + "loc": 91, "sqlCount": 1 }, { @@ -8107,7 +8107,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0010.pgc", - "loc": 66, + "loc": 92, "sqlCount": 1 }, { @@ -8116,7 +8116,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/st_ol_0011.pgc", - "loc": 62, + "loc": 87, "sqlCount": 1 }, { @@ -8125,7 +8125,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0012.pgc", - "loc": 64, + "loc": 92, "sqlCount": 1 }, { @@ -8134,7 +8134,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/st_ol_0013.pgc", - "loc": 54, + "loc": 108, "sqlCount": 1 }, { @@ -8143,7 +8143,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0014.pgc", - "loc": 54, + "loc": 81, "sqlCount": 1 }, { @@ -8152,7 +8152,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/st_ol_0015.pgc", - "loc": 51, + "loc": 85, "sqlCount": 1 }, { @@ -8161,7 +8161,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0016.pgc", - "loc": 60, + "loc": 89, "sqlCount": 1 }, { @@ -8170,7 +8170,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0017.pgc", - "loc": 65, + "loc": 91, "sqlCount": 1 }, { @@ -8179,7 +8179,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/st_ol_0018.pgc", - "loc": 52, + "loc": 83, "sqlCount": 1 }, { @@ -8188,7 +8188,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0019.pgc", - "loc": 65, + "loc": 87, "sqlCount": 1 }, { @@ -8197,7 +8197,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/st_ol_0020.pgc", - "loc": 63, + "loc": 107, "sqlCount": 1 }, { @@ -8206,7 +8206,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0021.pgc", - "loc": 59, + "loc": 90, "sqlCount": 1 }, { @@ -8215,7 +8215,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/st_ol_0022.pgc", - "loc": 56, + "loc": 76, "sqlCount": 1 }, { @@ -8224,7 +8224,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0023.pgc", - "loc": 55, + "loc": 90, "sqlCount": 1 }, { @@ -8233,7 +8233,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/st_ol_0024.pgc", - "loc": 62, + "loc": 82, "sqlCount": 1 }, { @@ -8242,7 +8242,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0025.pgc", - "loc": 61, + "loc": 117, "sqlCount": 1 }, { @@ -8251,7 +8251,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0026.pgc", - "loc": 62, + "loc": 89, "sqlCount": 1 }, { @@ -8260,7 +8260,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/st_ol_0027.pgc", - "loc": 64, + "loc": 115, "sqlCount": 1 }, { @@ -8269,7 +8269,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0028.pgc", - "loc": 65, + "loc": 113, "sqlCount": 1 }, { @@ -8278,7 +8278,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/st_ol_0029.pgc", - "loc": 67, + "loc": 95, "sqlCount": 1 }, { @@ -8287,7 +8287,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0030.pgc", - "loc": 65, + "loc": 90, "sqlCount": 1 }, { @@ -8296,7 +8296,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/st_ol_0031.pgc", - "loc": 60, + "loc": 102, "sqlCount": 1 }, { @@ -8305,7 +8305,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/st_ol_0032.pgc", - "loc": 60, + "loc": 114, "sqlCount": 1 }, { @@ -8314,7 +8314,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0001.pgc", - "loc": 47, + "loc": 78, "sqlCount": 1 }, { @@ -8323,7 +8323,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/vl_ol_0002.pgc", - "loc": 113, + "loc": 112, "sqlCount": 1 }, { @@ -8332,7 +8332,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0003.pgc", - "loc": 93, + "loc": 92, "sqlCount": 1 }, { @@ -8341,7 +8341,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/vl_ol_0004.pgc", - "loc": 94, + "loc": 93, "sqlCount": 1 }, { @@ -8350,7 +8350,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0005.pgc", - "loc": 107, + "loc": 106, "sqlCount": 1 }, { @@ -8359,7 +8359,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/vl_ol_0006.pgc", - "loc": 109, + "loc": 108, "sqlCount": 1 }, { @@ -8368,7 +8368,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0007.pgc", - "loc": 102, + "loc": 101, "sqlCount": 1 }, { @@ -8377,7 +8377,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0008.pgc", - "loc": 99, + "loc": 98, "sqlCount": 1 }, { @@ -8386,7 +8386,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/vl_ol_0009.pgc", - "loc": 127, + "loc": 126, "sqlCount": 1 }, { @@ -8395,7 +8395,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0010.pgc", - "loc": 88, + "loc": 87, "sqlCount": 1 }, { @@ -8404,7 +8404,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/vl_ol_0011.pgc", - "loc": 107, + "loc": 105, "sqlCount": 1 }, { @@ -8413,7 +8413,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0012.pgc", - "loc": 114, + "loc": 112, "sqlCount": 1 }, { @@ -8422,7 +8422,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/vl_ol_0013.pgc", - "loc": 102, + "loc": 101, "sqlCount": 1 }, { @@ -8431,7 +8431,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0014.pgc", - "loc": 111, + "loc": 109, "sqlCount": 1 }, { @@ -8440,7 +8440,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/vl_ol_0015.pgc", - "loc": 115, + "loc": 114, "sqlCount": 1 }, { @@ -8449,7 +8449,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0016.pgc", - "loc": 109, + "loc": 108, "sqlCount": 1 }, { @@ -8458,7 +8458,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0017.pgc", - "loc": 116, + "loc": 114, "sqlCount": 1 }, { @@ -8467,7 +8467,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/vl_ol_0018.pgc", - "loc": 90, + "loc": 89, "sqlCount": 1 }, { @@ -8476,7 +8476,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0019.pgc", - "loc": 107, + "loc": 106, "sqlCount": 1 }, { @@ -8485,7 +8485,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/vl_ol_0020.pgc", - "loc": 92, + "loc": 91, "sqlCount": 1 }, { @@ -8494,7 +8494,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0021.pgc", - "loc": 98, + "loc": 96, "sqlCount": 1 }, { @@ -8503,7 +8503,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/vl_ol_0022.pgc", - "loc": 106, + "loc": 104, "sqlCount": 1 }, { @@ -8512,7 +8512,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0023.pgc", - "loc": 86, + "loc": 85, "sqlCount": 1 }, { @@ -8521,7 +8521,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/vl_ol_0024.pgc", - "loc": 109, + "loc": 108, "sqlCount": 1 }, { @@ -8530,7 +8530,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0025.pgc", - "loc": 107, + "loc": 106, "sqlCount": 1 }, { @@ -8539,7 +8539,7 @@ "archetype": "online", "tier": "hard", "path": "app/online/vl_ol_0026.pgc", - "loc": 124, + "loc": 122, "sqlCount": 1 }, { @@ -8548,7 +8548,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0027.pgc", - "loc": 121, + "loc": 120, "sqlCount": 1 }, { @@ -8557,7 +8557,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0028.pgc", - "loc": 87, + "loc": 86, "sqlCount": 1 }, { @@ -8566,7 +8566,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/vl_ol_0029.pgc", - "loc": 112, + "loc": 111, "sqlCount": 1 }, { @@ -8575,7 +8575,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0030.pgc", - "loc": 119, + "loc": 118, "sqlCount": 1 }, { @@ -8584,7 +8584,7 @@ "archetype": "online", "tier": "medium", "path": "app/online/vl_ol_0031.pgc", - "loc": 128, + "loc": 127, "sqlCount": 1 }, { @@ -8593,7 +8593,7 @@ "archetype": "online", "tier": "easy", "path": "app/online/vl_ol_0032.pgc", - "loc": 125, + "loc": 122, "sqlCount": 1 } ]