本文整理汇总了C++中Statement::Define方法的典型用法代码示例。如果您正苦于以下问题:C++ Statement::Define方法的具体用法?C++ Statement::Define怎么用?C++ Statement::Define使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statement
的用法示例。
在下文中一共展示了Statement::Define方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShutOff_SDO_PC_Trigger
std::string Writer::ShutOff_SDO_PC_Trigger()
{
std::string base_table_name = boost::to_upper_copy(getOptions().getValueOrThrow<std::string>("base_table_name"));
std::string cloud_column_name = boost::to_upper_copy(getOptions().getValueOrThrow<std::string>("cloud_column_name"));
// Don't monkey with the trigger unless the user says to.
if (!getOptions().getValueOrDefault<bool>("disable_cloud_trigger", false))
return std::string("");
std::ostringstream oss;
char szTrigger[OWNAME] = "";
char szStatus[OWNAME] = "";
oss << "select trigger_name, status from all_triggers where table_name = '" << base_table_name << "' AND TRIGGER_NAME like upper('%%MDTNPC_%%') ";
Statement statement = Statement(m_connection->CreateStatement(oss.str().c_str()));
statement->Define(szTrigger);
statement->Define(szStatus);
statement->Execute();
// Yes, we're assuming there's only one trigger that met these criteria.
if (!strlen(szStatus))
{
// No rows returned, no trigger exists
return std::string("");
}
if (boost::iequals(szStatus, "ENABLED"))
{
oss.str("");
oss << "ALTER TRIGGER " << szTrigger << " DISABLE ";
statement = Statement(m_connection->CreateStatement(oss.str().c_str()));
statement->Execute();
return std::string(szTrigger);
}
else
{
return std::string("");
}
}
示例2: IsGeographic
bool Writer::IsGeographic(boost::int32_t srid)
{
typedef boost::shared_ptr<long> shared_long;
typedef boost::shared_ptr<char> shared_char;
std::ostringstream oss;
// char* kind = (char* ) malloc (OWNAME * sizeof(char));
shared_char kind = boost::shared_ptr<char>(new char[OWNAME]);
oss << "SELECT COORD_REF_SYS_KIND from MDSYS.SDO_COORD_REF_SYSTEM WHERE SRID = :1";
Statement statement = Statement(m_connection->CreateStatement(oss.str().c_str()));
shared_long p_srid = boost::shared_ptr<long>(new long);
*p_srid = srid;
statement->Bind(p_srid.get());
statement->Define(kind.get());
try
{
statement->Execute();
}
catch (pdal_error const& e)
{
std::ostringstream oss;
oss << "Failed to fetch geographicness of srid " << srid << std::endl << e.what() << std::endl;
throw std::runtime_error(oss.str());
}
if (boost::iequals(kind.get(), "GEOGRAPHIC2D"))
{
return true;
}
if (boost::iequals(kind.get(), "GEOGRAPHIC3D"))
{
return true;
}
return false;
}
示例3: BlockTableExists
bool Writer::BlockTableExists()
{
std::ostringstream oss;
std::string block_table_name = getOptions().getValueOrThrow<std::string>("block_table_name");
char szTable[OWNAME]= "";
oss << "select table_name from user_tables";
log()->get(logDEBUG) << "checking for " << block_table_name << " existence ... " ;
Statement statement = Statement(m_connection->CreateStatement(oss.str().c_str()));
// Because of OCIGDALErrorHandler, this is going to throw if there is a
// problem. When it does, the statement should go out of scope and
// be destroyed without leaking.
statement->Define(szTable);
statement->Execute();
log()->get(logDEBUG) << "checking ... " << szTable ;
bool bDidRead(true);
while (bDidRead)
{
log()->get(logDEBUG) << ", " << szTable;
if (boost::iequals(szTable, block_table_name))
{
log()->get(logDEBUG) << " -- '" << block_table_name << "' found." <<std::endl;
return true;
}
bDidRead = statement->Fetch();
}
log()->get(logDEBUG) << " -- '" << block_table_name << "' not found." << std::endl;
return false;
}
示例4: defineBlock
void OciReader::defineBlock(Statement stmt, BlockPtr block) const
{
int iCol = 0;
char szFieldName[OWNAME];
int hType = 0;
int nSize = 0;
int nPrecision = 0;
signed short nScale = 0;
char szTypeName[OWNAME];
while (stmt->GetNextField(iCol, szFieldName, &hType, &nSize,
&nPrecision, &nScale, szTypeName))
{
std::string typeName = Utils::toupper(szTypeName);
std::string fieldName = Utils::toupper(szFieldName);
if (hType == SQLT_NTY && (typeName == "SDO_PC"))
stmt->Define(&(block->pc));
else if (fieldName == "OBJ_ID")
stmt->Define(&(block->obj_id));
else if (fieldName == "BLK_ID")
stmt->Define(&(block->blk_id));
else if (fieldName == "BLK_EXTENT")
stmt->Define(&(block->blk_extent));
else if (fieldName == "BLK_DOMAIN")
stmt->Define(&(block->blk_domain));
else if (fieldName == "PCBLK_MIN_RES")
stmt->Define(&(block->pcblk_min_res));
else if (fieldName == "PCBLK_MAX_RES")
stmt->Define(&(block->pcblk_max_res));
else if (fieldName == "NUM_POINTS")
stmt->Define(&(block->num_points));
else if (fieldName == "NUM_UNSORTED_POINTS")
stmt->Define(&(block->num_unsorted_points));
else if (fieldName == "PT_SORT_DIM")
stmt->Define(&(block->pt_sort_dim));
else if (fieldName == "POINTS")
stmt->Define(&(block->locator));
iCol++;
}
}
示例5: WriteBlock
bool Writer::WriteBlock(PointBuffer const& buffer)
{
bool bUsePartition = m_block_table_partition_column.size() != 0;
// Pluck the block id out of the first point in the buffer
pdal::Schema const& schema = buffer.getSchema();
Dimension const& blockDim = schema.getDimension("BlockID");
boost::int32_t block_id = buffer.getField<boost::int32_t>(blockDim, 0);
std::ostringstream oss;
std::ostringstream partition;
if (bUsePartition)
{
partition << "," << m_block_table_partition_column;
}
oss << "INSERT INTO "<< m_block_table_name <<
"(OBJ_ID, BLK_ID, NUM_POINTS, POINTS, "
"PCBLK_MIN_RES, BLK_EXTENT, PCBLK_MAX_RES, NUM_UNSORTED_POINTS, PT_SORT_DIM";
if (bUsePartition)
oss << partition.str();
oss << ") "
"VALUES ( :1, :2, :3, :4, 1, mdsys.sdo_geometry(:5, :6, null,:7, :8)"
", 1, 0, 1";
if (bUsePartition)
oss << ", :9";
oss <<")";
// TODO: If gotdata == false below, this memory probably leaks --mloskot
OCILobLocator** locator =(OCILobLocator**) VSIMalloc(sizeof(OCILobLocator*) * 1);
Statement statement = Statement(m_connection->CreateStatement(oss.str().c_str()));
long* p_pc_id = (long*) malloc(1 * sizeof(long));
p_pc_id[0] = m_pc_id;
long* p_result_id = (long*) malloc(1 * sizeof(long));
p_result_id[0] = (long)block_id;
long* p_num_points = (long*) malloc(1 * sizeof(long));
p_num_points[0] = (long)buffer.getNumPoints();
// std::cout << "point count on write: " << buffer.getNumPoints() << std::endl;
// :1
statement->Bind(&m_pc_id);
// :2
statement->Bind(p_result_id);
// :3
statement->Bind(p_num_points);
// :4
statement->Define(locator, 1);
// std::vector<liblas::uint8_t> data;
// bool gotdata = GetResultData(result, reader, data, 3);
// if (! gotdata) throw std::runtime_error("unable to fetch point data byte array");
// boost::uint8_t* point_data = buffer.getData(0);
boost::uint8_t* point_data;
boost::uint32_t point_data_length;
boost::uint32_t schema_byte_size;
bool pack = getOptions().getValueOrDefault<bool>("pack_ignored_fields", true);
if (pack)
PackPointData(buffer, &point_data, point_data_length, schema_byte_size);
else
{
point_data = buffer.getData(0);
point_data_length = buffer.getSchema().getByteSize() * buffer.getNumPoints();
}
// statement->Bind((char*)point_data,(long)(buffer.getSchema().getByteSize()*buffer.getNumPoints()));
statement->Bind((char*)point_data,(long)(point_data_length));
// :5
long* p_gtype = (long*) malloc(1 * sizeof(long));
p_gtype[0] = m_gtype;
statement->Bind(p_gtype);
// :6
long* p_srid = 0;
if (m_srid != 0)
{
p_srid = (long*) malloc(1 * sizeof(long));
p_srid[0] = m_srid;
}
statement->Bind(p_srid);
// :7
//.........这里部分代码省略.........