Ejemplo n.º 1
0
void *Statement::createDateArray(int size)
{
    void *result = OCI_DateArrayCreate(this->connection->getOciConnection(), size);
    if(!result){
        throw OciException("Failed to allocate date array");
    }

    return result;
}
Ejemplo n.º 2
0
void BindParXML::init(SqlStatement &stmt)
{
	sword res;
	xmltdo = 0;

	_xmlvaluep = (OCIXMLType**) calloc(_cnt, sizeof(OCIXMLType*));
	_xmlindp = (OCIInd*) calloc(_cnt, sizeof(OCIInd));

//	xmlsize = new ub4 [_cnt];

//	std::cout << "BindParXML::init\n";

	res = OCICALL(OCITypeByName(_stmt._env, _stmt._errh, _stmt._conn._svc_ctx,
	                            (const oratext*)"SYS", strlen("SYS"),
	                            (const oratext*)"XMLTYPE", strlen("XMLTYPE"),
	                            0, 0,
	                            OCI_DURATION_SESSION, OCI_TYPEGET_HEADER,
	                            (OCIType**) &xmltdo
	                           ));
	oci_check_error(__TROTL_HERE__, _stmt._errh, res);

	if(xmltdo == NULL)
		throw OciException(__TROTL_HERE__, "Unknown datatype in the database: SYS.XMLTYPE");

	for(int i=0; i<g_OCIPL_BULK_ROWS; i++)
	{
		_xmlvaluep[i] = NULL;
		_xmlindp[i] = OCI_IND_NULL;
	}
//	for(int i=0; i<_cnt; i++)
//	{
////		xmlsize[i] = 0;
//		res = OCICALL(OCIObjectNew(conn._env,
//				conn._env._errh,
//				conn._svc_ctx,
//				OCI_TYPECODE_OPAQUE,
//				xmltdo,
//				0,
//				OCI_DURATION_SESSION,
//				FALSE,
//				(dvoid **) &xml[i]
//		));
//		oci_check_error(__TROTL_HERE__, conn._env._errh, res);
//	}
}
Ejemplo n.º 3
0
Describe* Describe::createDescription(OciConnection &con, const tstring &objectName)
{
	sword res;
	bool isPublic = false;
	OciDescribe desc(con._env);

	try
	{
		res = OCICALL(OCIDescribeAny(con._svc_ctx, con._env._errh,
		                             (dvoid*)objectName.c_str(),  // objptr (IN) (string containing the name of the object
		                             (ub4)objectName.size(),  // objnm_len (IN)
		                             OCI_OTYPE_NAME,   // objptr_typ (IN) points to the name of a schema object
		                             (ub1)OCI_DEFAULT, // info_level (IN) for future extensions. Pass OCI_DEFAULT.
		                             OCI_PTYPE_UNK,    // OCI_PTYPE_TABLE,  //
		                             desc
		                            ));
		oci_check_error(__TROTL_HERE__, con._env._errh, res);
	}
	catch(OciException const &e)
	{
		if(e.get_code() == 4043)
		{
			sb4 val = -1; // ub2 val = 1; /* size of OCI_ATTR_DESC_PUBLIC is undocumented. */
			desc.set_attribute(OCI_ATTR_DESC_PUBLIC, &val);
			isPublic = true;

			res = OCICALL(OCIDescribeAny(con._svc_ctx, con._env._errh,
			                             (dvoid*)objectName.c_str(),  // objptr (IN) (string containing the name of the object
			                             (ub4)objectName.size(),  // objnm_len (IN)
			                             OCI_OTYPE_NAME,   // objptr_typ (IN) points to the name of a schema object
			                             (ub1)OCI_DEFAULT, // info_level (IN) for future extensions. Pass OCI_DEFAULT.
			                             OCI_PTYPE_UNK,    // OCI_PTYPE_TABLE,  //
			                             desc
			                            ));
			oci_check_error(__TROTL_HERE__, con._env._errh, res);
		}
		else
		{
			throw e;
		}
	};

	OciParam param = desc.get_param();
	ub1 obj_type = param.get_attribute<ub1>(OCI_ATTR_PTYPE);
	switch(obj_type)
	{
	case OCI_PTYPE_SYN:
		return new DescribeSynonym(con, desc, objectName, isPublic);
	case OCI_PTYPE_VIEW:
		return new DescribeView(con, desc, objectName);
	case OCI_PTYPE_TABLE:
		return new DescribeTable(con, desc, objectName);
	case OCI_PTYPE_TYPE:
		return new DescribeType(con, desc, objectName);
	case OCI_PTYPE_SEQ:
		return new DescribeSequence(con, desc, objectName);
	case OCI_PTYPE_PROC:
	case OCI_PTYPE_FUNC:
	case OCI_PTYPE_PKG:
	case OCI_PTYPE_TYPE_ATTR:
	case OCI_PTYPE_TYPE_COLL:
	case OCI_PTYPE_TYPE_METHOD:
	case OCI_PTYPE_COL: // - column of a table or view
	case OCI_PTYPE_ARG: // - argument of a function or procedure
	case OCI_PTYPE_TYPE_ARG: // - argument of a type method
	case OCI_PTYPE_TYPE_RESULT: // - results of a method
	case OCI_PTYPE_LIST: // - column list for tables and views, argument list for functions and procedures, or subprogram list for packages
	case OCI_PTYPE_SCHEMA: // - schema
	case OCI_PTYPE_DATABASE: // - database
	case OCI_PTYPE_UNK: // - unknown schema object
		throw_oci_exception(OciException(__TROTL_HERE__, "Error describing object: %d\n").arg(obj_type));
		//no break here
	default:
		throw_oci_exception(OciException(__TROTL_HERE__, "Error describing object: %d\n").arg(obj_type));
		//no break here
	}
};
Ejemplo n.º 4
0
void DataExportHelper::exportError(const QString &errorMessage)
{
    tableComparisonError("data_export", OciException(errorMessage));
}
Ejemplo n.º 5
0
void Convertor::OnError(const SqlValue &val, BindPar &BP)
{
	throw_oci_exception(OciException(__TROTL_HERE__, "Misssing Conversion(SqlValue to %s%d)\n").arg(BP._type_name).arg(BP.value_sz));
};
Ejemplo n.º 6
0
void ConvertorForRead::Fire(const BindParNumber &BP, SqlInt<double> &BL)
{
	throw_oci_exception(OciException(__TROTL_HERE__, "Conversion from BindParCInt to SqlInt<double> implemented elsewhere"));
};