Passing arguments to PL/SQL procedure in Oracle

Hello,

I’m trying to pass arguments to PL/SQL procedure. Database people tole me it have to be the same way as bind variables are called. So I’m trying to execute this:
TString setTimeWindowSQL(“begin data_access.set_time_window(:1, :2); end;”);

     //Set the time window
   TSQLStatement *timeWindowStmt =  sqlData->Statement(setTimeWindowSQL,100);
     timeWindowStmt->SetString(0, "2008-09-11 14:40:00");
     timeWindowStmt->SetString(1, "2008-09-11 14:45:00");
     timeWindowStmt->Process();

And I get:
Error in TOracleStatement::SetString: Code: -1 Msg: Parameters cannot> be set for this statement

This is error message is issued by SetString… I know strings are correct, co what could it be?

Cheers,

         Mariusz

Hi, Mariusz

I already answer somehow on your question via private mail, just repeat it here.

Just not to keep this point open.

After some mails between me and Mariusz we found out, that Mariusz requires stored procedure call, using TSQLStatement class, where user
can set several arguments. Java-based code, which was provided by Mariusz, had look like this:

public static final void setApplicationClientIpHostInfo(Connection
connection, String clientModule, String clientAction,
      String clientIpAddress, String clientHostName, String userName) {
    
    OracleCallableStatement stmt = null;
    
    try {
      stmt = (OracleCallableStatement) connection.prepareCall("BEGIN
big_brother.set_client_ip_host_operation(:p_client_id,
:p_client_application,       
        :p_client_ip, :p_client_host, :p_client_operation); END;");
      
      //Set the bind variable inputs
      stmt.setStringAtName("p_client_id", userName);
      stmt.setStringAtName("p_client_application", clientModule);
      stmt.setStringAtName("p_client_ip", clientIpAddress);
      stmt.setStringAtName("p_client_host", clientHostName);
      stmt.setStringAtName("p_client_operation", clientAction);
      stmt.execute();
      
    } catch (Exception e) {
      LOGGER.error("Could not setApplicationClientIpHostInfo: " +
e.getMessage());
    } finally {
      if (stmt != null) {
        try {
          stmt.close();
        } catch (SQLException sqlEx) {
          LOGGER.error("Could not close stmtSetClientAppInfo: " +
sqlEx.getMessage());
        }
      }
    }
  }

Same functionality one can achieve with ROOT sql classes in the following way:


      ...
      stmt = sql->Statement("BEGIN big_brother.set_client_ip_host_operation(:1, :2, :3, :4, :5); END;");

      // literal arguments were replaced by numbers while OCCI does not support such feature     

      stmt->NextIteration(); 
      stmt->SetString(0, userName);
      stmt->SetString(1, clientModule);
      stmt->SetString(2, clientIpAddress);
      stmt->SetString(3, clientHostName);
      stmt->SetString(4, clientAction);

      stmt->Process();
      ...

Here the crutial point was NextIteration() call. Actually, one can make several iteration before calling Process(), which finally will send complete bunch of actions to Oracle.

Sergey