/*
 * vl_status_query_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_status_query_dbio.h"

int vldb_purchase_status(long pid, char *status_out)
{
    EXEC SQL BEGIN DECLARE SECTION;
    long h_pid = pid; char h_status[8];
    EXEC SQL END DECLARE SECTION;
    EXEC SQL SELECT status INTO :h_status FROM purchase WHERE purchase_id = :h_pid;
    if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) { userlog("vldb_purchase_status FAIL [%d]", sqlca.sqlcode); return -1; }
    strncpy(status_out, h_status, 7); status_out[7] = 0;
    return 0;
}
