/*
 * vl_appr_dbio.pgc - 승인 건수 조회 (매입 대비) (libvldbio.a).
 * ECPG functions; run on the caller's XA branch. No EXEC SQL CONNECT.
 */
#include <string.h>
#include <userlog.h>
#include "vl_appr_dbio.h"

long vldb_appr_count(long pid)
{
    EXEC SQL BEGIN DECLARE SECTION;
    long h_pid = pid, h_cnt;
    EXEC SQL END DECLARE SECTION;
    EXEC SQL SELECT count(*) INTO :h_cnt FROM approval WHERE purchase_id = :h_pid;
    if (sqlca.sqlcode < 0) { userlog("vldb_appr_count FAIL [%d]", sqlca.sqlcode); return -1; }
    return h_cnt;
}
