An example of how to delete data in an existing Hyper file.
An example of how to delete data in an existing Hyper file.
 
#include <fstream>
#include <iostream>
#include <string>
 
static void copy(const std::string& sourcePath, const std::string& destinationPath) {
   std::ifstream source(sourcePath, std::ios::binary);
   std::ofstream destination(destinationPath, std::ios::binary);
   destination << source.rdbuf();
   source.close();
   destination.close();
}
 
static void runDeleteDataInExistingHyperFile() {
   std::cout << "EXAMPLE - Delete data from an existing Hyper file" << std::endl;
 
   
   
   const std::string pathToSourceDatabase = "data/superstore_sample.hyper";
 
   
   const std::string pathToDatabase = "data/superstore_sample_delete.hyper";
   copy(pathToSourceDatabase, pathToDatabase);
 
   
   
   {
 
      
      {
 
         std::cout << 
"Delete all rows from customer with the name 'Dennis Kane' from table " << 
hyperapi::escapeName(
"Orders") << 
"." << std::endl;
 
         
         int64_t rowCount = connection.executeCommand(
         std::cout << 
"The number of deleted rows in table " << 
hyperapi::escapeName(
"Orders") << 
" is " << rowCount << 
"." << std::endl
 
                   << std::endl;
 
         std::cout << 
"Delete all rows from customer with the name 'Dennis Kane' from table " << 
hyperapi::escapeName(
"Customer") << 
"." << std::endl;
 
         rowCount = connection.executeCommand(
 
         std::cout << "The number of deleted rows in table Customer is " << rowCount << "." << std::endl;
      }
      std::cout << "The connection to the Hyper file has been closed." << std::endl;
   }
   std::cout << "The Hyper Process has been shut down." << std::endl;
}
 
int main() {
   try {
      runDeleteDataInExistingHyperFile();
      return 1;
   }
   return 0;
}
Defines a Hyper connection.
 
Defines an exception object that is thrown on failure by the functions in the Hyper API C++ library.
 
std::string toString() const
Returns a formatted string containing the message and hint of the error and all causes.
 
The main header of the Hyper API for C++.
 
@ SendUsageDataToTableau
Telemetry data will be sent to tableau to help improve the Hyper API.
 
std::string escapeName(string_view input)
Escapes the given string for safe usage in SQL query or command strings as an identifier.
 
std::string escapeStringLiteral(string_view input)
Escapes the given string for safe usage in SQL query or command strings as a string literal.