|
Lightweight 0.20260921.0
|
#include <SqlStatement.hpp>
Public Member Functions | |
| LIGHTWEIGHT_FORCE_INLINE | SqlResultCursor (SqlStatement &stmt) noexcept |
| Constructs a result cursor for the given SQL statement. | |
| SqlResultCursor (SqlResultCursor const &)=delete | |
| SqlResultCursor & | operator= (SqlResultCursor const &)=delete |
| constexpr | SqlResultCursor (SqlResultCursor &&other) noexcept |
| Move constructor. | |
| constexpr SqlResultCursor & | operator= (SqlResultCursor &&other) noexcept |
| Move assignment operator. | |
| LIGHTWEIGHT_FORCE_INLINE size_t | NumRowsAffected () const |
| Retrieves the number of rows affected by the last query. | |
| LIGHTWEIGHT_FORCE_INLINE size_t | NumColumnsAffected () const |
| Retrieves the number of columns affected by the last query. | |
| template<SqlOutputColumnBinder... Args> | |
| LIGHTWEIGHT_FORCE_INLINE void | BindOutputColumns (Args *... args) |
| template<SqlOutputColumnBinder T> | |
| LIGHTWEIGHT_FORCE_INLINE void | BindOutputColumn (SQLUSMALLINT columnIndex, T *arg) |
| Binds a single output column at the given index to store fetched data. | |
| LIGHTWEIGHT_FORCE_INLINE bool | FetchRow () |
| Fetches the next row of the result set. | |
| LIGHTWEIGHT_FORCE_INLINE std::expected< bool, SqlErrorInfo > | TryFetchRow (std::source_location location=std::source_location::current()) noexcept |
| Attempts to fetch the next row, returning an error info on failure instead of throwing. | |
| template<typename... Records> requires (((std::is_class_v<Records> && std::is_aggregate_v<Records>) && ...)) | |
| LIGHTWEIGHT_FORCE_INLINE void | BindOutputColumnsToRecord (Records *... records) |
| Binds the given records to the prepared statement to store the fetched data to. | |
| template<typename Record , typename... ColumnAccessors> | |
| LIGHTWEIGHT_FORCE_INLINE void | FetchAllRowWise (std::vector< Record > &out, std::size_t arrayDepth, ColumnAccessors const &... accessors) |
Fast bulk retrieval: materializes this result set into out via native ODBC row-wise array fetch. Forwards to SqlStatement::FetchAllRowWise; see its contract (eligibility and alignment preconditions are the caller's responsibility). | |
| template<SqlGetColumnNativeType T> | |
| LIGHTWEIGHT_FORCE_INLINE bool | GetColumn (SQLUSMALLINT column, T *result) const |
| template<SqlGetColumnNativeType T> | |
| LIGHTWEIGHT_FORCE_INLINE T | GetColumn (SQLUSMALLINT column) const |
| Retrieves the value of the column at the given index for the currently selected row. | |
| template<SqlGetColumnNativeType T> | |
| LIGHTWEIGHT_FORCE_INLINE std::optional< T > | GetNullableColumn (SQLUSMALLINT column) const |
| template<SqlGetColumnNativeType T> | |
| T | GetColumnOr (SQLUSMALLINT column, T &&defaultValue) const |
| template<SqlGetColumnNativeType T> | |
| LIGHTWEIGHT_FORCE_INLINE T | GetColumn (std::string_view name) const |
| Retrieves the value of the named column for the currently selected row. | |
| template<SqlGetColumnNativeType T> | |
| LIGHTWEIGHT_FORCE_INLINE std::optional< T > | GetNullableColumn (std::string_view name) const |
Retrieves the value of the named column, or std::nullopt if it is NULL. | |
| template<SqlGetColumnNativeType T> | |
| T | GetColumnOr (std::string_view name, T &&defaultValue) const |
Retrieves the value of the named column, or defaultValue if it is NULL. | |
API for reading an SQL query result set.
Definition at line 588 of file SqlStatement.hpp.
|
inlineexplicitnoexcept |
Constructs a result cursor for the given SQL statement.
Definition at line 592 of file SqlStatement.hpp.
|
inlineconstexprnoexcept |
Move constructor.
Definition at line 602 of file SqlStatement.hpp.
|
inline |
Definition at line 619 of file SqlStatement.hpp.
|
inlineconstexprnoexcept |
Move assignment operator.
Definition at line 609 of file SqlStatement.hpp.
|
inline |
Retrieves the number of rows affected by the last query.
Definition at line 629 of file SqlStatement.hpp.
Referenced by Lightweight::DataMapper::Delete().
|
inline |
Retrieves the number of columns affected by the last query.
Definition at line 635 of file SqlStatement.hpp.
Referenced by Lightweight::DataMapper::Query().
|
inline |
Binds the given arguments to the prepared statement to store the fetched data to.
The statement must be prepared before calling this function.
Definition at line 644 of file SqlStatement.hpp.
|
inline |
Binds a single output column at the given index to store fetched data.
Definition at line 651 of file SqlStatement.hpp.
|
inline |
Fetches the next row of the result set.
Definition at line 657 of file SqlStatement.hpp.
Referenced by Lightweight::DataMapper::ConfigureRelationAutoLoading(), and Lightweight::DataMapper::Query().
|
inlinenoexcept |
Attempts to fetch the next row, returning an error info on failure instead of throwing.
Definition at line 663 of file SqlStatement.hpp.
|
inline |
Binds the given records to the prepared statement to store the fetched data to.
Definition at line 672 of file SqlStatement.hpp.
|
inline |
Fast bulk retrieval: materializes this result set into out via native ODBC row-wise array fetch. Forwards to SqlStatement::FetchAllRowWise; see its contract (eligibility and alignment preconditions are the caller's responsibility).
| out | Destination vector; results are appended. |
| arrayDepth | Requested maximum rows per SQLFetchScroll round-trip. |
| accessors | One invocable per result column; accessor(record) yields its mutable value. |
Definition at line 684 of file SqlStatement.hpp.
|
inline |
Retrieves the value of the column at the given index for the currently selected row.
Returns true if the value is not NULL, false otherwise.
Definition at line 695 of file SqlStatement.hpp.
Referenced by Lightweight::DataMapper::ConfigureRelationAutoLoading(), and Lightweight::DataMapper::Query().
|
inline |
Retrieves the value of the column at the given index for the currently selected row.
Definition at line 702 of file SqlStatement.hpp.
|
inline |
Retrieves the value of the column at the given index for the currently selected row.
If the value is NULL, std::nullopt is returned.
Definition at line 711 of file SqlStatement.hpp.
|
inline |
Retrieves the value of the column at the given index for the currently selected row.
If the value is NULL, the given defaultValue is returned.
Definition at line 720 of file SqlStatement.hpp.
|
inline |
Retrieves the value of the named column for the currently selected row.
The name is the one spelled in the query builder that composed this query — a bare column name for Field("x"), the qualified "table.column" for Field({"table", "x"}), or the alias for an aliased projection. Only builder-composed queries carry a mapping.
SQLGetData with SQLSTATE 07009, and addressing columns by name makes it easy to reorder them inadvertently.| name | The column name as spelled in the query builder. |
T. | std::invalid_argument | If no mapping is available, or name is unknown or ambiguous. |
Definition at line 739 of file SqlStatement.hpp.
|
inline |
Retrieves the value of the named column, or std::nullopt if it is NULL.
The name is the one spelled in the query builder that composed this query; only builder-composed queries carry a mapping. Reads must ascend in column order — see the name-taking GetColumn.
| name | The column name as spelled in the query builder. |
T, or std::nullopt if the column is NULL. | std::invalid_argument | If no mapping is available, or name is unknown or ambiguous. |
Definition at line 753 of file SqlStatement.hpp.
|
inline |
Retrieves the value of the named column, or defaultValue if it is NULL.
The name is the one spelled in the query builder that composed this query; only builder-composed queries carry a mapping. Reads must ascend in column order — see the name-taking GetColumn.
| name | The column name as spelled in the query builder. |
| defaultValue | The value to return when the column is NULL. |
T, or defaultValue if the column is NULL. | std::invalid_argument | If no mapping is available, or name is unknown or ambiguous. |
Definition at line 768 of file SqlStatement.hpp.