/*
 * vl_format_dbio.pgc - 가맹점ID 형식 위반 건수 (길이) (libvldbio.a).
 * ECPG functions; run on the caller's XA branch. No EXEC SQL CONNECT.
 */
#include <string.h>
#include <userlog.h>
#include "vl_format_dbio.h"

long vldb_bad_format_count(void)
{
    EXEC SQL BEGIN DECLARE SECTION;
    long h_cnt;
    EXEC SQL END DECLARE SECTION;
    EXEC SQL SELECT count(*) INTO :h_cnt FROM merchant
        WHERE length(merchant_id) < 4 OR length(merchant_id) > 16;
    if (sqlca.sqlcode < 0) { userlog("vldb_bad_format_count FAIL [%d]", sqlca.sqlcode); return -1; }
    return h_cnt;
}
