Ns_PdDbSpStart

Name

Ns_PdDbSpStart -- Begin stored procedure definition

Syntax

void Ns_PdDbSpStart (void *handle, char *procname)

Description

This function begins the definition of a stored procedure.

Pseudo-code Example

void
Ns_PdDbSpStart(void *handle, char *procname) {
  DBMSStart   *state = (DBMSState *) handle;
  DBMSRetcode  code;
  /*
   * Create a new stored procedure command if it hasn't been allocated yet
   */
  if (state->cmd == NULL) {
    code = DBMSCmdAlloc(state, &state->cmd);
    if (code == DBMS_ERROR) {
      Ns_PdLog(Error, "DbSpStart: DBMSCmdAlloc() failed.");
      Ns_PdSendException(state->exceptionCode, state->exceptionMsg);
    }
  }
  /*
   * Clear out any existing command structure
   */
  code = DBMSCancel(state);
  if (code != DBMS_OK) {
    Ns_PdLog(Error, "DbSpStart: DBMSCancel() failed.");
    Ns_PdSendException(state->exceptionCode, state->exceptionMsg);
    return;
  }
  /*
   * Set up a new command structure for this stored procedure
   */
  code = DBMSCommand(state->cmd, procname);
  if (tcode != DBMS_OK) {
    Ns_PdLog(Error, "DbSpStart: DBMSCommand() failed.");
    Ns_PdSendException(state->exceptionCode, state->exceptionMsg);
    return;
  }
  Ns_PdSendString(OK_STATUS);
}