1 Reply Latest reply: Apr 5, 2012 7:32 AM by Sudheendra-Oracle RSS

    ORA-21560 - argument 6 is null, invalid, or out of range

    923765
      I am using Oracle 11g 11.2.0.2.0. 64bit.
      I am using OCCI for the communication with oracle.

      Here you have some info: (just a simple example)

      In oracle db:
      create or replace TYPE NAME_TYPE
      AS OBJECT
      (
      name VARCHAR2 (32),
      surenanme VARCHAR2 (32)
      );

      create or replace
      PROCEDURE SetName (x NAME_TYPE) IS
      y NAME_TYPE;
      BEGIN
      y.name := x.name;
      y.surename := x.surename;
      END;

      in the C++ part, something more:
      class SendName : public oracle::occi::PObject
      {
      public:
      OCCI_STD_NAMESPACE::string m_Name;
      OCCI_STD_NAMESPACE::string m_SureName;

      public:
      void* operator new (size_t size);
      void* operator new (size_t size, const oracle::occi::Connection* sess, const OCCI_STD_NAMESPACE::string& table);

      OCCI_STD_NAMESPACE::string getSQLTypeName() const;

      SendName(OCCI_STD_NAMESPACE::string name = "", OCCI_STD_NAMESPACE::string surename = "") : m_Name(name), m_SureName(surename) {}
      SendName(void* ctxOCCI_) : oracle::occi::PObject (ctxOCCI_) {}

      static void readSQL(void ctxOCCI_);
      virtual void readSQL(oracle::occi::AnyData& streamOCCI_);

      static void writeSQL(void objOCCI_, void ctxOCCI_);
      virtual void writeSQL(oracle::occi::AnyData& streamOCCI_);

      virtual void getSQLTypeName(Environment* /*env*/, void** /*schName*/,
      unsigned int& /*schNameLen*/, void** /*typeName*/,
      unsigned int& /*typeNameLen*/) const { }

      };

      void *SendName ::operator new(size_t size)
      {
      return oracle::occi::PObject::operator new(size);
      }

      void SendName ::operator new(size_t size, const oracle::occi::Connection sess, const OCCI_STD_NAMESPACE::string& table)
      {
      return oracle::occi::PObject::operator new(size, sess, table, (char *) "DB.NAME_TYPE");
      }

      OCCI_STD_NAMESPACE::string SendName ::getSQLTypeName() const
      {
      return OCCI_STD_NAMESPACE::string("DB.NAME_TYPE");
      }

      void* SendName ::readSQL(void *ctxOCCI_)
      {
      SendName *objOCCI_ = new SendName (ctxOCCI_);
      oracle::occi::AnyData streamOCCI_(ctxOCCI_);
      try
      {
      if (streamOCCI_.isNull())
      objOCCI_->setNull();
      else
      objOCCI_->readSQL(streamOCCI_);
      }
      catch (oracle::occi::SQLException& excep)
      {
      delete objOCCI_;
      excep.setErrorCtx(ctxOCCI_);
      return (void *)NULL;
      }

      return (void *)objOCCI_;
      }

      void SendName ::readSQL(oracle::occi::AnyData& streamOCCI_)
      {
      m_Name = streamOCCI_.getString();
      m_SureName = streamOCCI_.getString();
      }

      void SendName ::writeSQL(void objectOCCI_, void ctxOCCI_)
      {
      SendName objOCCI_ = (SendName ) objectOCCI_;
      oracle::occi::AnyData streamOCCI_(ctxOCCI_);
      try
      {
      if (objOCCI_->isNull())
      streamOCCI_.setNull();
      else
      objOCCI_->writeSQL(streamOCCI_);
      }
      catch (oracle::occi::SQLException& excep)
      {
      excep.setErrorCtx(ctxOCCI_);
      }

      return;
      }

      void SendName ::writeSQL(oracle::occi::AnyData& streamOCCI_)
      {
      streamOCCI_.setString(m_SID);
      streamOCCI_.setString(m_GID);
      }



      and the "interested" part ...

      SendName *sendName = new SendName("I love you", "if you tell me" );
      Statement* stmt = NULL;
      std::string sql = " BEGIN "
      " SetName(:1); "
      " END; ";

      try
      {
      stmt = m_DB->GetConnection()->createStatement(sql);
      stmt->setObject(1, sendName);
      m_DB->ExecuteUpdate(stmt);
      m_DB->TerminateStatement(stmt);
      }
      catch (SQLException& e)
      {
      std::cout << "SendName - SQLException - failed with: " << e.getMessage().c_str() <<" , error code " <<"(" << e.getErrorCode() << ")\n";
      }
      catch (std::exception& e)
      {
      std::cout << "SendName - exception - failed with: " << e.what() << std::endl;
      }
      catch (...)
      {
      std::cout << "SendName - unknown exception" << std::endl;
      }

      I hope you got enough info.
      When I try to call stmt->setObject(1, sendName); I got exception ora-21560 arg. 6 is null, invalid, or out of range

      What should I do? Has somebody experienced something like this?