How to read varray using OO4O and C++ ?

From: Hans Leirvik <hans.leirvik_at_vianova.no>
Date: Thu, 17 Jun 1999 09:27:01 +0100
Message-ID: <7ka7jf$dua$1_at_elle.eunet.no>



I have problems when trying to access a varray field in a record. Can someone please help me ?

Some pasted lines from my code :

In the funtion below I want to handle the varray data, but how do I access the OraCollection ????
How do I access the varray in the value object blow in the switch statement ?

int GetVarray(OraCollection *c)
{
 if (!c) return -1;
 char s[256];
 sprintf(s,"Varray size = %d", c->GetMaxSize());

 m_list.AddString( s );
 return 0;
}

 OraSession session;
 OraDatabase datab;
 OraDynaset dyn;
 SnapshotID snapshotId;
 OraCollection coll;
 COleException err;
 if (!session.CreateDispatch("OracleInProcServer.XOraSession", &err))   return;
 datab = session.GetOpenDatabase("host","user/password", 0);

 dyn = datab.GetCreateDynaset( "select * from vartab", 0, (VARIANT *)&snapshotId) ;

 OraField field;
 OraFields fields;
 OraParameter pa;

 while (!dyn.GetEof()) // until we’ve gone past all the records

  counter++;
  fields = dyn.GetFields();
  field_count = fields.GetCount();
  for (int c=0; c<field_count; c++){
   value.intVal = c;
   value.vt = VT_I2;

   field = fields.GetItem( value );

   fieldname = field.GetName();
   long field_size = field.GetSize();
   value = field.GetValue();

   long ty = field.GetOraIDataType();
   memset(res,0,sizeof(res));

   switch (ty){
    case ORATYPE_VARRAY : // == 9

     GetVarray( (OraCollection*)value.parray );
     sprintf(res, "VArray");
     break;
    case ORATYPE_TABLE :
     sprintf(res, "Table");
     break;
    case ORATYPE_OTMLAST :
     sprintf(res, "OtmLast");
     break;
    default :
     sprintf( res, "Unknown type = %d", ty);
     break;

   }
}

Thank you
Hans Received on Thu Jun 17 1999 - 10:27:01 CEST

Original text of this message