/*
 * LIMIT_TEMP.pgc - au 모듈 서비스 LIMIT_TEMP (one service = one file).
 * 임시 한도 상향 (temp_limit 저장 + 당일 상향).
 * Moved verbatim from the former inline au_svr.pgc; runs on the caller's XA
 * branch (no EXEC SQL CONNECT). Advertised by au_svr at tpsvrinit.
 */
#include "LIMIT_TEMP.h"

void LIMIT_TEMP(TPSVCINFO *p)
{
    UBFH *b = (UBFH *)p->data;
    char card[24];
    EXEC SQL BEGIN DECLARE SECTION;
    long h_temp;
    char h_card[24];
    EXEC SQL END DECLARE SECTION;
    gets_(b, T_KEY1, card, sizeof(card));
    h_temp = getl(b, T_AMT1); if (h_temp <= 0) h_temp = 2000000;
    strncpy(h_card, card, sizeof(h_card)-1); h_card[sizeof(h_card)-1] = 0;
    EXEC SQL UPDATE card_limit
        SET temp_limit = :h_temp, daily_limit = daily_limit + :h_temp, updated_at = now()
        WHERE card_no = :h_card;
    if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
    OK(b);
}
