/*
 * cm_param_yes_dbio.pgc - cm 모듈 DB 접근 함수 (cm_param_yes_dbio), archived into libcmdbio.a.
 * ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
 * 파라미터 Y 여부.
 */
#include <string.h>
#include <userlog.h>
#include "cm_param_yes_dbio.h"

int cmdb_param_is_yes(const char *key)
{
    EXEC SQL BEGIN DECLARE SECTION;
    char h_key[32], h_st[16];
    EXEC SQL END DECLARE SECTION;
    strncpy(h_key, key, sizeof(h_key)-1); h_key[sizeof(h_key)-1] = 0;
    EXEC SQL SELECT param_val INTO :h_st FROM cm_param WHERE param_key = :h_key;
    if (sqlca.sqlcode == 100) return -1;
    if (sqlca.sqlcode < 0) return -1;
    if (strcmp(h_st, "Y") == 0) return 1;
    return 0;
}
