|
Lightweight 0.20260921.0
|
#include <SqlDynamicNumeric.hpp>
Classes | |
| struct | Literal |
| A decimal column's text, as delivered by a single SQLGetData call. More... | |
Static Public Member Functions | |
| static LIGHTWEIGHT_FORCE_INLINE SQLRETURN | InputParameter (SQLHSTMT stmt, SQLUSMALLINT column, SqlDynamicNumeric const &value, SqlDataBinderCallback &cb) noexcept |
| Binds the value as an input parameter, rendered as an exact decimal literal. | |
| static LIGHTWEIGHT_FORCE_INLINE Literal | ReadLiteral (SQLHSTMT stmt, SQLUSMALLINT column, SQLLEN *indicator, std::span< char > buffer) noexcept |
| static LIGHTWEIGHT_FORCE_INLINE std::optional< SqlDynamicNumeric > | FromColumnLiteral (SQLHSTMT stmt, SQLUSMALLINT column, std::string_view literal) noexcept |
| static LIGHTWEIGHT_FORCE_INLINE SQLRETURN | TryGetColumn (SQLHSTMT stmt, SQLUSMALLINT column, SqlDynamicNumeric *result, SQLLEN *indicator, SqlDataBinderCallback const &) noexcept |
| static LIGHTWEIGHT_FORCE_INLINE SQLRETURN | GetColumn (SQLHSTMT stmt, SQLUSMALLINT column, SqlDynamicNumeric *result, SQLLEN *indicator, SqlDataBinderCallback const &cb) |
| static LIGHTWEIGHT_FORCE_INLINE std::string | Inspect (SqlDynamicNumeric const &value) |
| Renders the value for SQL trace logs. | |
Static Public Attributes | |
| static constexpr auto | ColumnType = SqlColumnTypeDefinitions::Decimal { .precision = 38, .scale = 0 } |
| Widest decimal ODBC admits, so no supported backend can overflow the bind buffer. | |
Binds SqlDynamicNumeric as an exact decimal literal.
Text is deliberately the wire format in both directions. SQL_C_NUMERIC needs the application to publish precision and scale on the descriptor before each call and is honoured inconsistently — the SQL Server driver returns scale-0 values without it and the SQLite driver has no native support at all, which is why SqlDataBinder<SqlNumeric<P, S>> routes both backends around it. Every supported driver converts between a decimal column and its literal exactly, with no binary floating-point step, so this path keeps all digits on all backends.
Definition at line 337 of file SqlDynamicNumeric.hpp.
|
inlinestaticnoexcept |
Binds the value as an input parameter, rendered as an exact decimal literal.
Definition at line 343 of file SqlDynamicNumeric.hpp.
|
inlinestaticnoexcept |
Reads the column's decimal literal into buffer, issuing exactly one SQLGetData.
ODBC allows a second SQLGetData on the same column only while a character or binary value is still being delivered in parts. Once it has arrived in full, a conforming driver answers SQL_NO_DATA — SQL Server's does. So a caller that wants the value exactly and, failing that, approximately must derive both from this one read rather than retrieving the column twice.
| stmt | The ODBC statement handle to read from. |
| column | The 1-based index of the column to read. |
| indicator | Where to report the length; may be null, in which case the length is still needed internally and is discarded afterwards. |
| buffer | Storage for the text; Literal::text points into it, so it must outlive the returned value. 128 bytes is always enough: ODBC caps DECIMAL precision at 38, leaving room for the sign, decimal point, terminator and driver padding. |
Definition at line 399 of file SqlDynamicNumeric.hpp.
|
inlinestaticnoexcept |
Converts a decimal literal into an exact value, using the column's declared precision and scale.
| std::nullopt | The value needs more digits than the unscaled 64-bit carrier holds; see SqlMaxDynamicNumericPrecision. |
Definition at line 439 of file SqlDynamicNumeric.hpp.
References Lightweight::SqlDynamicNumeric::FromString().
|
inlinestaticnoexcept |
Retrieves the column as an exact decimal without throwing, for callers that can degrade.
| SQL_ERROR | The driver truncated the literal, or the value needs more digits than the unscaled 64-bit carrier holds (see SqlMaxDynamicNumericPrecision). No ODBC diagnostic is posted for this — the driver did not fail, the value simply does not fit — so read the return code rather than the statement's last error. GetColumn turns it into a described exception; SqlVariant reuses ReadLiteral and falls back to double instead. |
Definition at line 470 of file SqlDynamicNumeric.hpp.
|
inlinestatic |
Retrieves the column as an exact decimal, preserving every digit the column declares.
| SqlException | When the value cannot be represented exactly. The driver posts no diagnostic in that case — it did not fail — so this synthesizes one rather than letting the caller surface an empty, or worse a stale, error from the handle. |
Definition at line 499 of file SqlDynamicNumeric.hpp.
References Lightweight::SqlErrorInfo::nativeErrorCode.
|
inlinestatic |
Renders the value for SQL trace logs.
Definition at line 519 of file SqlDynamicNumeric.hpp.
References Lightweight::SqlDynamicNumeric::ToString().
|
staticconstexpr |
Widest decimal ODBC admits, so no supported backend can overflow the bind buffer.
Definition at line 340 of file SqlDynamicNumeric.hpp.