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

Ns_PdDbSpExec

Overview

Execute stored procedure

Syntax

    void Ns_PdDbSpExec(void *handle)

Description

This function executes a stored procedure that has been initialized with Ns_PdDbSpStart and Ns_PdDbSpSetParam.

Psuedo-code Example

    void
    Ns_PdDbSpExec(void *handle)
    {
        DBMSState   *state = (DBMSState *)handle;
        int          retcode;
        int          morep = 1;
        int          restype;
        int          status = NS_ERROR;
        char        *name, *value;
    
        retcode = DBMSSend(state->cmd);
        if (retcode != DBMS_OK) {
            Ns_PdLog(Error, "DbSpExec: DBMSSend() failed.");
            Ns_PdSendException(state->exceptionCode, state->exceptionMsg);

            return;
        }
    
        while (morep &&
               (retcode = DBMSResults(state->cmd, &res_type)) == 
DBMS_OK) {
    
            switch (res_type) {
            case DBMS_ROW_RESULT:
                /*
                 * Rows were returned.
                 */
                morep = 0;
                status = DB_ROWS;
                state->fetchingRows = 1;
                break;
                
            case DBMS_CMD_FAIL:
                if (DBMSCancel(state->cmd) != DBMS_OK) {
                    Ns_PdLog(Error,
                             "DbSpExec: DBMSCancel after DBMS_CMD_FAIL 
failed.");
                    morep = 0;
                }
                break;
    
            case DBMS_STATUS_RESULT:
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */
                 */