6#include "../../Api.hpp"
7#include "../../SqlBindingTypes.hpp"
8#include "../../SqlError.hpp"
9#include "../Concept.hpp"
10#include "SqlOdbcPrelude.hpp"
29namespace Lightweight::Driver::Odbc
33using NativeStatementHandle = SQLHSTMT;
36using NativeConnectionHandle = SQLHDBC;
39using NativeResult = SQLRETURN;
74 static constexpr SqlDriverId
Id = SqlDriverId::Odbc;
77 static constexpr std::string_view
Name =
"ODBC";
103[[nodiscard]]
inline LIGHTWEIGHT_FORCE_INLINE NativeStatementHandle NativeHandle(
SqlStatement const& stmt)
noexcept;
109[[nodiscard]]
inline LIGHTWEIGHT_FORCE_INLINE NativeConnectionHandle NativeHandle(
SqlConnection const& connection)
noexcept;
112static_assert(std::same_as<SqlColumnIndex, SQLUSMALLINT>,
"SqlColumnIndex must be SQLUSMALLINT");
113static_assert(std::same_as<SqlIndicator, SQLLEN>,
114 "SqlIndicator must be the same type as SQLLEN on this platform; indicators are passed to ODBC by pointer");
115static_assert(SqlNullData == SQL_NULL_DATA);
116static_assert(SqlUnknownParameterType == SQL_UNKNOWN_TYPE);
118static_assert(std::same_as<std::int16_t, SQLSMALLINT>,
"std::int16_t must be SQLSMALLINT");
119static_assert(std::same_as<std::uint16_t, SQLUSMALLINT>,
"std::uint16_t must be SQLUSMALLINT");
120static_assert(std::same_as<std::size_t, SQLULEN>,
"std::size_t must be SQLULEN; string binder sizes are passed to ODBC");
121static_assert(std::to_underlying(SqlResult::Success) == SQL_SUCCESS);
122static_assert(std::to_underlying(SqlResult::SuccessWithInfo) == SQL_SUCCESS_WITH_INFO);
123static_assert(std::to_underlying(SqlResult::StillExecuting) == SQL_STILL_EXECUTING);
124static_assert(std::to_underlying(SqlResult::NeedData) == SQL_NEED_DATA);
125static_assert(std::to_underlying(SqlResult::NoData) == SQL_NO_DATA);
126static_assert(std::to_underlying(SqlResult::ParamDataAvailable) == SQL_PARAM_DATA_AVAILABLE);
127static_assert(std::to_underlying(SqlResult::Error) == SQL_ERROR);
128static_assert(std::to_underlying(SqlResult::InvalidHandle) == SQL_INVALID_HANDLE);
129static_assert(
sizeof(SqlResult) ==
sizeof(SQLRETURN));
130static_assert(std::to_underlying(SqlIsolationMode::ReadUncommitted) == SQL_TXN_READ_UNCOMMITTED);
131static_assert(std::to_underlying(SqlIsolationMode::ReadCommitted) == SQL_TXN_READ_COMMITTED);
132static_assert(std::to_underlying(SqlIsolationMode::RepeatableRead) == SQL_TXN_REPEATABLE_READ);
133static_assert(std::to_underlying(SqlIsolationMode::Serializable) == SQL_TXN_SERIALIZABLE);
136static_assert(std::to_underlying(SqlError::SUCCESS) == SQL_SUCCESS);
137static_assert(std::to_underlying(SqlError::SUCCESS_WITH_INFO) == SQL_SUCCESS_WITH_INFO);
138static_assert(std::to_underlying(SqlError::NODATA) == SQL_NO_DATA);
139static_assert(std::to_underlying(SqlError::FAILURE) == SQL_ERROR);
140static_assert(std::to_underlying(SqlError::INVALID_HANDLE) == SQL_INVALID_HANDLE);
141static_assert(std::to_underlying(SqlError::STILL_EXECUTING) == SQL_STILL_EXECUTING);
142static_assert(std::to_underlying(SqlError::NEED_DATA) == SQL_NEED_DATA);
143static_assert(std::to_underlying(SqlError::PARAM_DATA_AVAILABLE) == SQL_PARAM_DATA_AVAILABLE);
144static_assert(std::to_underlying(SqlError::NO_DATA_FOUND) == SQL_NO_DATA_FOUND);
Represents a connection to a SQL database.
High level API for (prepared) raw SQL statements.
The ODBC driver's connection handle struct.
bool operator==(Connection const &) const =default
Compares the native handles.
SQLHENV env
The native ODBC environment handle; null for a borrowed connection.
SQLHDBC dbc
The native ODBC connection handle.
The ODBC driver: names its handle structs and its driver id.
static constexpr std::string_view Name
The driver's name, as error messages show it.
static constexpr bool StatementsDieWithConnection
static constexpr bool TranscodesNarrowText
static constexpr SqlDriverId Id
The id the tagged handles carry for this driver.
static constexpr bool SupportsParameterArrays
Parameter arrays (SQL_ATTR_PARAMSET_SIZE > 1) execute a whole batch in one SQLExecute.
static constexpr bool SupportsRowArrayFetch
Row arrays (SQL_ATTR_ROW_ARRAY_SIZE > 1 with SQLFetchScroll) fetch a block of rows per call.
static constexpr bool HasCatalogFunctions
The catalog is read with the ODBC catalog functions (SQLTables, SQLColumns, SQLStatistics,...
The ODBC driver's statement handle struct.
SQLHSTMT handle
The native ODBC statement handle.
bool operator==(Statement const &) const =default
Compares the native handles.