/*
 * au_auth_type_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_auth_type_dbio), archived into libaudbio.a.
 * ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
 * Shape: count(DISTINCT ...) (당일 사용된 승인유형 가짓수).
 */
#include <string.h>
#include <userlog.h>
#include "au_auth_type_dbio.h"

/* 당일 사용된 승인유형(AUTH/STANDIN/INSTALL/PREAUTH ...) 가짓수. */
long audb_auth_type_variety(const char *bizdate)
{
    EXEC SQL BEGIN DECLARE SECTION;
    char h_bizdate[16];
    long h_v = 0;
    EXEC SQL END DECLARE SECTION;
    strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
    EXEC SQL SELECT count(DISTINCT auth_type) INTO :h_v FROM au_authorization WHERE biz_date = :h_bizdate;
    if (sqlca.sqlcode < 0) return -1;
    return h_v;
}
