本文整理汇总了C++中Statement::Execute方法的典型用法代码示例。如果您正苦于以下问题:C++ Statement::Execute方法的具体用法?C++ Statement::Execute怎么用?C++ Statement::Execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statement
的用法示例。
在下文中一共展示了Statement::Execute方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Open
bool Database::Open(const std::string &Path)
{
if (Inner != nullptr)
Close();
int Err;
if ((Err = sqlite3_initialize()) != SQLITE_OK)
return LogError(sqlite3_errstr(Err), false);
if (Err = sqlite3_open_v2(Path.c_str(), &Inner, SQLITE_OPEN_READWRITE, nullptr) != SQLITE_OK)
{
if (Err = sqlite3_open_v2(Path.c_str(), &Inner, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, nullptr) != SQLITE_OK)
return LogError(sqlite3_errstr(Err), false);
std::vector<std::string> TableStrings;
TableStrings.push_back(User::CreationString);
TableStrings.push_back(Server::CreationString);
TableStrings.push_back(Chatroom::CreationString);
for (unsigned int x = 0; x < TableStrings.size(); x++)
{
Statement s;
if (!s.Prepare(Inner, TableStrings[x]))
return false;
if (!s.Execute())
return false;
}
}
return true;
}
示例3: InsertServer
bool Database::InsertServer(const Server &Server)
{
const std::string Query = "INSERT OR REPLACE INTO Server VALUES (:IP, :Port, :Family, :Name)";
Statement s;
if (!s.Prepare(Inner, Query))
return false;
if (!s.Bind(":IP", Server.Address.GetPrintableIP()) || !s.Bind(":Port", Server.Address.Port) || !s.Bind(":Family", Server.Address.Family) || !s.Bind(":Name", Server.Name))
return false;
if (!s.Execute())
return false;
return true;
}
示例4: InsertUser
bool Database::InsertUser(const User &User)
{
const std::string Query = "INSERT OR REPLACE INTO User VALUES (:Username, :Password)";
Statement s;
if (!s.Prepare(Inner, Query))
return false;
if (!s.Bind(":Username", User.Username) || !s.Bind(":Password", User.Password))
return false;
if (!s.Execute())
return false;
return true;
}
示例5: TurnOn_SDO_PC_Trigger
void Writer::TurnOn_SDO_PC_Trigger(std::string trigger_name)
{
if (!trigger_name.size()) return;
std::ostringstream oss;
std::string base_table_name = boost::to_upper_copy(getOptions().getValueOrThrow<std::string>("base_table_name"));
oss << "ALTER TRIGGER " << trigger_name << " ENABLE ";
Statement statement = Statement(m_connection->CreateStatement(oss.str().c_str()));
statement->Execute();
}
示例6: 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;
}
示例7: 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;
}
示例8: InsertChatroom
bool Database::InsertChatroom(const Chatroom &Chatroom)
{
const std::string Query = "INSERT OR REPLACE INTO Chatroom VALUES (:Name, :OwnerUsername, :ServerIP, :ServerPort, :ServerFamily, :Password, :Description)";
Statement s;
if (!s.Prepare(Inner, Query))
return false;
if (!s.Bind(":Name", Chatroom.Name) || !s.Bind(":OwnerUsername", Chatroom.OwnerUsername) || !s.Bind(":ServerIP", Chatroom.ServerAddress.GetPrintableIP()) ||
!s.Bind(":ServerPort", Chatroom.ServerAddress.Port) || !s.Bind(":ServerFamily", Chatroom.ServerAddress.Family))
return false;
if (!Chatroom.Password.Null)
{
if (!s.Bind(":Password", Chatroom.Password.Value))
return false;
}
else
{
if (!s.BindNull(":Password"))
return false;
}
if (!Chatroom.Description.Null)
{
if (!s.Bind(":Description", Chatroom.Description.Value))
return false;
}
else
{
if (!s.BindNull(":Description"))
return false;
}
if (!s.Execute())
return false;
return true;
}
示例9: getNextCloud
Statement IteratorBase::getNextCloud(BlockPtr block, boost::int32_t& cloud_id)
{
std::ostringstream select_blocks;
BlockPtr cloud_block = m_reader.getBlock();
Statement cloud_statement = m_reader.getInitialQueryStatement();
cloud_id = cloud_statement->GetInteger(&cloud_block->pc->pc_id);
std::string cloud_table = std::string(cloud_statement->GetString(cloud_block->pc->blk_table));
select_blocks
<< "select T.OBJ_ID, T.BLK_ID, T.BLK_EXTENT, T.NUM_POINTS, T.POINTS from "
<< cloud_table << " T WHERE T.OBJ_ID = "
<< cloud_id;
Statement output = Statement(m_reader.getConnection()->CreateStatement(select_blocks.str().c_str()));
output->Execute(0);
m_reader.defineBlock(output, block);
return output;
}
示例10: CreatePCEntry
//.........这里部分代码省略.........
boost::uint32_t position(0);
pdal::Schema clean_schema;
schema::index_by_index::size_type i(0);
for (i = 0; i < idx.size(); ++i)
{
if (! idx[i].isIgnored())
{
Dimension d(idx[i]);
d.setPosition(position);
// Wipe off parent/child relationships if we're ignoring
// same-named dimensions
d.setParent(boost::uuids::nil_uuid());
clean_schema.appendDimension(d);
position++;
}
}
schema_data = pdal::Schema::to_xml(clean_schema);
} else
{
schema_data = pdal::Schema::to_xml(buffer_schema);
}
char* schema = (char*) malloc(schema_data.size() * sizeof(char) + 1);
strncpy(schema, schema_data.c_str(), schema_data.size());
schema[schema_data.size()] = '\0';
statement->WriteCLob(&schema_locator, schema);
statement->Bind(&schema_locator);
std::ostringstream wkt_s;
if (!m_base_table_boundary_column.empty())
{
if (!FileUtils::fileExists(m_base_table_boundary_wkt))
{
if (!IsValidWKT(m_base_table_boundary_wkt))
{
std::ostringstream oss;
oss << "WKT for base_table_boundary_wkt was not valid and '" << m_base_table_boundary_wkt
<< "' doesn't exist as a file";
throw pdal::pdal_error(oss.str());
}
wkt_s << m_base_table_boundary_wkt;
}
else
{
std::string wkt = LoadSQLData(m_base_table_boundary_wkt);
if (!IsValidWKT(wkt))
{
std::ostringstream oss;
oss << "WKT for base_table_boundary_wkt was from file '" << m_base_table_boundary_wkt
<< "' is not valid";
throw pdal::pdal_error(oss.str());
}
wkt_s << wkt;
}
}
std::string wkt_string = wkt_s.str();
char* wkt = (char*) malloc(wkt_string.size() * sizeof(char)+1);
strncpy(wkt, wkt_string.c_str(), wkt_string.size());
wkt[wkt_string.size()] = '\0';
if (!m_base_table_boundary_column.empty())
{
statement->WriteCLob(&boundary_locator, wkt);
statement->Bind(&boundary_locator);
statement->Bind((int*)&m_srid);
}
try
{
statement->Execute();
}
catch (std::runtime_error const& e)
{
std::ostringstream oss;
oss << "Failed at creating Point Cloud entry into " << m_base_table_name << " table. Does the table exist? " << e.what();
throw pdal_error(oss.str());
}
free(wkt);
try
{
Option& pc_id = getOptions().getOptionByRef("pc_id");
pc_id.setValue(m_pc_id);
}
catch (pdal::option_not_found&)
{
Option pc_id("pc_id", m_pc_id, "Point Cloud Id");
getOptions().add(pc_id);
}
}
示例11: UpdatePCExtent
void Writer::UpdatePCExtent()
{
std::string block_table_name = boost::to_upper_copy(getOptions().getValueOrThrow<std::string>("block_table_name"));
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"));
boost::uint32_t srid = getOptions().getValueOrThrow<boost::uint32_t>("srid");
pdal::Bounds<double> base_table_bounds = getDefaultedOption<pdal::Bounds<double> >("base_table_bounds");
if (base_table_bounds.empty()) base_table_bounds = m_pcExtent;
std::string eleminfo = CreatePCElemInfo();
std::ostringstream s_geom;
boost::uint32_t precision = getDefaultedOption<boost::uint32_t>("stream_output_precision");
s_geom.setf(std::ios_base::fixed, std::ios_base::floatfield);
s_geom.precision(precision);
s_geom << " mdsys.sdo_geometry("<< m_gtype <<", " << srid << ", null,\n"
" mdsys.sdo_elem_info_array"<< eleminfo <<",\n"
" mdsys.sdo_ordinate_array(\n";
s_geom << base_table_bounds.getMinimum(0) << "," << base_table_bounds.getMinimum(1) << ",";
if (m_is3d)
{
s_geom << base_table_bounds.getMinimum(2) << ",";
}
s_geom << base_table_bounds.getMaximum(0) << "," << base_table_bounds.getMaximum(1);
if (m_is3d)
{
s_geom << "," << base_table_bounds.getMaximum(2);
}
s_geom << "))";
std::ostringstream oss;
oss << "UPDATE "<< base_table_name <<
" A SET A." << cloud_column_name <<".PC_EXTENT = " << s_geom.str() <<
" WHERE A.ID = " << getPCID();
Statement statement = Statement(m_connection->CreateStatement(oss.str().c_str()));
try
{
statement->Execute();
}
catch (std::runtime_error const& e)
{
std::ostringstream oss;
oss << "Failed to update cloud extent in '" << base_table_name << "' table with id " << getPCID() << ". Does the table exist? " << std::endl << e.what() << std::endl;
throw std::runtime_error(oss.str());
}
m_connection->Commit();
}
示例12: WriteBlock
//.........这里部分代码省略.........
// :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
OCIArray* sdo_elem_info=0;
m_connection->CreateType(&sdo_elem_info, m_connection->GetElemInfoType());
SetElements(statement, sdo_elem_info);
statement->Bind(&sdo_elem_info, m_connection->GetElemInfoType());
// :8
OCIArray* sdo_ordinates=0;
m_connection->CreateType(&sdo_ordinates, m_connection->GetOrdinateType());
// x0, x1, y0, y1, z0, z1, bUse3d
pdal::Bounds<double> bounds = CalculateBounds(buffer);
SetOrdinates(statement, sdo_ordinates, bounds);
statement->Bind(&sdo_ordinates, m_connection->GetOrdinateType());
// :9
long* p_partition_d = 0;
if (bUsePartition)
{
p_partition_d = (long*) malloc(1 * sizeof(long));
p_partition_d[0] = m_block_table_partition_value;
statement->Bind(p_partition_d);
}
try
{
statement->Execute();
}
catch (std::runtime_error const& e)
{
std::ostringstream oss;
oss << "Failed to insert block # into '" << m_block_table_name << "' table. Does the table exist? " << std::endl << e.what() << std::endl;
throw std::runtime_error(oss.str());
}
oss.str("");
OWStatement::Free(locator, 1);
if (p_pc_id != 0) free(p_pc_id);
if (p_result_id != 0) free(p_result_id);
if (p_num_points != 0) free(p_num_points);
if (p_gtype != 0) free(p_gtype);
if (p_srid != 0) free(p_srid);
if (p_partition_d != 0) free(p_partition_d);
m_connection->DestroyType(&sdo_elem_info);
m_connection->DestroyType(&sdo_ordinates);
return true;
}