[ Previous ] [ Contents ] [ Index ] [ Next ]

Ns_PdDbExec

Overview

Execute a SQL query

Syntax

    void Ns_PdDbExec(char *handle, char *sql);

Description

This function executes a SQL query. If the SQL is executed successfully, this function should call Ns_PdSendString with OK_STATUS followed by either Ns_PdSendString(EXEC_RET_ROWS) or Ns_PdSendString(EXEC_RET_DML), depending on whether the SQL returned rows or was a DML statement. On failure, the function should use Ns_PdSendException to return an error.

Psuedo-code Example

    /* Things italicized would be your DBMS-specific structures and 
calls. */
    void
    Ns_PdDbExec(void *handle, char *sql)
    {
        DBMSState       *state = (DBMSState *) handle;
        int             execRet;
        Ns_PdLog(Trace, "exec(%s):", sql);
        execRet = DBMSExec(state, sql);
        if (execRet == NS_ERROR) {
            Ns_PdSendException(state->exceptionCode, 
    state->exceptionMsg);
        } else {
            Ns_PdSendString(OK_STATUS);
            execRet == DB_ROWS ? Ns_PdSendString(EXEC_RET_ROWS) : 
Ns_PdSendString(EXEC_RET_DML);
        }
    }

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1996 America Online, Inc.