Exemplo n.º 1
0
/* prepare a cursor; return the ID number of that cursor */
static int
prepareCursor(const char *stmt, bool scrollflag)
{
    struct OCURS *o = findNewCursor();
    stmt = lineFormatStack(stmt, 0, &sqlargs);
    va_end(sqlargs);

    hstmt = o->hstmt;
    if(sql_debug)
	appendFile(sql_debuglog, "new cursor %d", o->cid);
    if(sql_debug2)
	printf("new cursor %d\n", o->cid);
    rc = SQLSetStmtOption(hstmt, SQL_CURSOR_TYPE,
       scrollflag ? SQL_CURSOR_STATIC : SQL_CURSOR_FORWARD_ONLY);
    if(errorTrap(0))
	return -1;

    if(!prepareInternal(stmt))
	return -1;
    o->numrets = rv_numRets;
    memcpy(o->rv_type, rv_type, NUMRETS);
    o->flag = (openfirst ? CURSOR_OPENED : CURSOR_PREPARED);
    o->rownum = 0;
    return o->cid;
}				/* prepareCursor */
Exemplo n.º 2
0
char *
lineFormat(const char *line, ...)
{
    char *s;
    va_list p;
    va_start(p, line);
    s = lineFormatStack(line, 0, &p);
    va_end(p);
    return s;
}				/* lineFormat */
Exemplo n.º 3
0
/* run a stored procedure */
bool
sql_proc(const char *stmt, ...)
{
    bool rowfound;
    va_start(sqlargs, stmt);
    stmt = lineFormatStack(stmt, 0, &sqlargs);
    rowfound = sql_procGo(stmt);
    retsFromOdbc();
    SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
    return rowfound;
}				/* sql_proc */
Exemplo n.º 4
0
/* return true if the row was found */
bool
sql_select(const char *stmt, ...)
{
    bool rowfound;
    va_start(sqlargs, stmt);
    stmt = lineFormatStack(stmt, 0, &sqlargs);
    rowfound = execInternal(stmt, 2);
    retsFromOdbc();
    SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
    return rowfound;
}				/* sql_select */
Exemplo n.º 5
0
/* execute a stand-alone statement with % formatting */
bool
sql_exec(const char *stmt, ...)
{
    bool ok;
    va_start(sqlargs, stmt);
    stmt = lineFormatStack(stmt, 0, &sqlargs);
    ok = execInternal(stmt, 1);
    SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
    exclist = 0;
    va_end(sqlargs);
    return ok;
}				/* sql_exec */
Exemplo n.º 6
0
/* run a stored procedure with one return */
int
sql_procOne(const char *stmt, ...)
{
    bool rowfound;
    va_start(sqlargs, stmt);
    stmt = lineFormatStack(stmt, 0, &sqlargs);
    rowfound = sql_procGo(stmt);
    if(!rowfound) {
	SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
	exclist = 0;
	va_end(sqlargs);
	return 0;
    }
    return oneRetValue(0, 0);
}				/* sql_procOne */
Exemplo n.º 7
0
/* run a select statement with one return value */
int
sql_selectOne(const char *stmt, ...)
{
    bool rowfound;
    va_start(sqlargs, stmt);
    stmt = lineFormatStack(stmt, 0, &sqlargs);
    rowfound = execInternal(stmt, 2);
    if(!rowfound) {
	SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
	exclist = 0;
	va_end(sqlargs);
	return nullint;
    }
    return oneRetValue(0, 0);
}				/* sql_selectOne */