fb-cpp 0.0.2
A modern C++ wrapper for the Firebird database API
Loading...
Searching...
No Matches
Statement.h
1/*
2 * MIT License
3 *
4 * Copyright (c) 2025 Adriano dos Santos Fernandes
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25#ifndef FBCPP_STATEMENT_H
26#define FBCPP_STATEMENT_H
27
28#include "config.h"
29#include "fb-cpp-export.h"
30#include "fb-api.h"
31#include "types.h"
32#include "Blob.h"
33#include "Array.h"
34#include "Client.h"
35#include "Row.h"
36#include "StatementOptions.h"
37#include "NumericConverter.h"
38#include "CalendarConverter.h"
39#include "Descriptor.h"
40#include "impl/ParameterSetter.h"
41#include "SmartPtrs.h"
42#include "Exception.h"
43#include "StructBinding.h"
44#include "VariantTypeTraits.h"
45#include <charconv>
46#include <cerrno>
47#include <cstdlib>
48#include <limits>
49#include <memory>
50#include <optional>
51#include <stdexcept>
52#include <span>
53#include <string>
54#include <string_view>
55#include <type_traits>
56#include <vector>
57#include <cassert>
58#include <cmath>
59#include <cstddef>
60#include <cstdint>
61
62#if FB_CPP_USE_BOOST_MULTIPRECISION != 0
63#include <boost/multiprecision/cpp_int.hpp>
64#include <boost/multiprecision/cpp_dec_float.hpp>
65#endif
66
67#if FB_CPP_USE_BOOST_DECIMAL != 0
68#include <boost/decimal.hpp>
69#endif
70
74namespace fbcpp
75{
76 class Attachment;
77 class Transaction;
78
82 enum class StatementType : unsigned
83 {
87 SELECT = isc_info_sql_stmt_select,
91 INSERT = isc_info_sql_stmt_insert,
95 UPDATE = isc_info_sql_stmt_update,
99 DELETE = isc_info_sql_stmt_delete,
103 DDL = isc_info_sql_stmt_ddl,
107 GET_SEGMENT = isc_info_sql_stmt_get_segment,
111 PUT_SEGMENT = isc_info_sql_stmt_put_segment,
115 EXEC_PROCEDURE = isc_info_sql_stmt_exec_procedure,
119 START_TRANSACTION = isc_info_sql_stmt_start_trans,
123 COMMIT = isc_info_sql_stmt_commit,
127 ROLLBACK = isc_info_sql_stmt_rollback,
131 SELECT_FOR_UPDATE = isc_info_sql_stmt_select_for_upd,
135 SET_GENERATOR = isc_info_sql_stmt_set_generator,
139 SAVEPOINT = isc_info_sql_stmt_savepoint,
140 };
141
145 class FB_CPP_EXPORT Statement final : private impl::ParameterSetter<Statement, false>
146 {
147 friend class RowSet;
148 friend class impl::ParameterSetter<Statement, false>;
149
150 public:
158 explicit Statement(Attachment& attachment, Transaction& transaction, std::string_view sql,
159 const StatementOptions& options = {});
160
164 Statement(Statement&& o) noexcept;
165
172 Statement& operator=(Statement&& o) noexcept;
173
174 Statement(const Statement&) = delete;
175 Statement& operator=(const Statement&) = delete;
176
180 ~Statement() noexcept
181 {
182 if (isValid())
183 {
184 try
185 {
186 free();
187 }
188 catch (...)
189 {
190 // swallow
191 }
192 }
193 }
194
195 public:
201
206 {
207 return *attachment;
208 }
209
213 bool isValid() noexcept
214 {
215 return statementHandle != nullptr;
216 }
217
224 bool hasCurrentRow() const noexcept
225 {
226 return currentRow;
227 }
228
234 {
235 return statementHandle;
236 }
237
243 {
244 return resultSetHandle;
245 }
246
251 {
252 return inMetadata;
253 }
254
258 std::vector<std::byte>& getInputMessage() noexcept
259 {
260 return inMessage;
261 }
262
267 {
268 return outMetadata;
269 }
270
274 std::vector<std::byte>& getOutputMessage() noexcept
275 {
276 return outMessage;
277 }
278
283 {
284 return type;
285 }
286
290
296
300 const std::vector<Descriptor>& getInputDescriptors() noexcept
301 {
302 return inDescriptors;
303 }
304
308 const std::vector<Descriptor>& getOutputDescriptors() noexcept
309 {
310 return outDescriptors;
311 }
312
316
320 void free();
321
325 std::string getLegacyPlan();
326
330 std::string getPlan();
331
337 bool execute(Transaction& transaction);
338
342
346 bool fetchNext();
347
351 bool fetchPrior();
352
356 bool fetchFirst();
357
361 bool fetchLast();
362
366 bool fetchAbsolute(unsigned position);
367
371 bool fetchRelative(int offset);
372
376
380 using impl::ParameterSetter<Statement, false>::clearParameters;
381 using impl::ParameterSetter<Statement, false>::set;
382 using impl::ParameterSetter<Statement, false>::setBlobId;
383 using impl::ParameterSetter<Statement, false>::setArrayId;
384 using impl::ParameterSetter<Statement, false>::setBool;
385 using impl::ParameterSetter<Statement, false>::setBytes;
386 using impl::ParameterSetter<Statement, false>::setDate;
387 using impl::ParameterSetter<Statement, false>::setDouble;
388 using impl::ParameterSetter<Statement, false>::setFloat;
389 using impl::ParameterSetter<Statement, false>::setInt16;
390 using impl::ParameterSetter<Statement, false>::setInt32;
391 using impl::ParameterSetter<Statement, false>::setInt64;
392 using impl::ParameterSetter<Statement, false>::setNull;
393 using impl::ParameterSetter<Statement, false>::setOpaqueDate;
394 using impl::ParameterSetter<Statement, false>::setOpaqueDecFloat16;
395 using impl::ParameterSetter<Statement, false>::setOpaqueDecFloat34;
396 using impl::ParameterSetter<Statement, false>::setOpaqueInt128;
397 using impl::ParameterSetter<Statement, false>::setOpaqueTime;
398 using impl::ParameterSetter<Statement, false>::setOpaqueTimeTz;
399 using impl::ParameterSetter<Statement, false>::setOpaqueTimestamp;
400 using impl::ParameterSetter<Statement, false>::setOpaqueTimestampTz;
401 using impl::ParameterSetter<Statement, false>::setScaledInt16;
402 using impl::ParameterSetter<Statement, false>::setScaledInt32;
403 using impl::ParameterSetter<Statement, false>::setScaledInt64;
404 using impl::ParameterSetter<Statement, false>::setScaledOpaqueInt128;
405 using impl::ParameterSetter<Statement, false>::setString;
406 using impl::ParameterSetter<Statement, false>::setTime;
407 using impl::ParameterSetter<Statement, false>::setTimeTz;
408 using impl::ParameterSetter<Statement, false>::setTimestamp;
409 using impl::ParameterSetter<Statement, false>::setTimestampTz;
410
411#if FB_CPP_USE_BOOST_MULTIPRECISION != 0
412 using impl::ParameterSetter<Statement, false>::setBoostDecFloat16;
413 using impl::ParameterSetter<Statement, false>::setBoostDecFloat34;
414 using impl::ParameterSetter<Statement, false>::setBoostInt128;
415 using impl::ParameterSetter<Statement, false>::setScaledBoostInt128;
416#endif
417
418#if FB_CPP_USE_BOOST_DECIMAL != 0
419 using impl::ParameterSetter<Statement, false>::setBoostDecimal128;
420 using impl::ParameterSetter<Statement, false>::setBoostDecimal32;
421 using impl::ParameterSetter<Statement, false>::setBoostDecimal64;
422#endif
423
427
431
435 bool isNull(unsigned index)
436 {
437 assert(isValid());
438 return outRow->isNull(index);
439 }
440
444 std::optional<bool> getBool(unsigned index)
445 {
446 assert(isValid());
447 return outRow->getBool(index);
448 }
449
453 std::optional<std::int16_t> getInt16(unsigned index)
454 {
455 assert(isValid());
456 return outRow->getInt16(index);
457 }
458
462 std::optional<ScaledInt16> getScaledInt16(unsigned index)
463 {
464 assert(isValid());
465 return outRow->getScaledInt16(index);
466 }
467
471 std::optional<std::int32_t> getInt32(unsigned index)
472 {
473 assert(isValid());
474 return outRow->getInt32(index);
475 }
476
480 std::optional<ScaledInt32> getScaledInt32(unsigned index)
481 {
482 assert(isValid());
483 return outRow->getScaledInt32(index);
484 }
485
489 std::optional<std::int64_t> getInt64(unsigned index)
490 {
491 assert(isValid());
492 return outRow->getInt64(index);
493 }
494
498 std::optional<ScaledInt64> getScaledInt64(unsigned index)
499 {
500 assert(isValid());
501 return outRow->getScaledInt64(index);
502 }
503
507 std::optional<ScaledOpaqueInt128> getScaledOpaqueInt128(unsigned index)
508 {
509 assert(isValid());
510 return outRow->getScaledOpaqueInt128(index);
511 }
512
513#if FB_CPP_USE_BOOST_MULTIPRECISION != 0
517 std::optional<BoostInt128> getBoostInt128(unsigned index)
518 {
519 assert(isValid());
520 return outRow->getBoostInt128(index);
521 }
522
526 std::optional<ScaledBoostInt128> getScaledBoostInt128(unsigned index)
527 {
528 assert(isValid());
529 return outRow->getScaledBoostInt128(index);
530 }
531#endif
532
536 std::optional<float> getFloat(unsigned index)
537 {
538 assert(isValid());
539 return outRow->getFloat(index);
540 }
541
545 std::optional<double> getDouble(unsigned index)
546 {
547 assert(isValid());
548 return outRow->getDouble(index);
549 }
550
554 std::optional<OpaqueDecFloat16> getOpaqueDecFloat16(unsigned index)
555 {
556 assert(isValid());
557 return outRow->getOpaqueDecFloat16(index);
558 }
559
560#if FB_CPP_USE_BOOST_MULTIPRECISION != 0
564 std::optional<BoostDecFloat16> getBoostDecFloat16(unsigned index)
565 {
566 assert(isValid());
567 return outRow->getBoostDecFloat16(index);
568 }
569#endif
570
571#if FB_CPP_USE_BOOST_DECIMAL != 0
575 std::optional<BoostDecimal32> getBoostDecimal32(unsigned index)
576 {
577 assert(isValid());
578 return outRow->getBoostDecimal32(index);
579 }
580
584 std::optional<BoostDecimal64> getBoostDecimal64(unsigned index)
585 {
586 assert(isValid());
587 return outRow->getBoostDecimal64(index);
588 }
589#endif
590
594 std::optional<OpaqueDecFloat34> getOpaqueDecFloat34(unsigned index)
595 {
596 assert(isValid());
597 return outRow->getOpaqueDecFloat34(index);
598 }
599
600#if FB_CPP_USE_BOOST_MULTIPRECISION != 0
604 std::optional<BoostDecFloat34> getBoostDecFloat34(unsigned index)
605 {
606 assert(isValid());
607 return outRow->getBoostDecFloat34(index);
608 }
609#endif
610
611#if FB_CPP_USE_BOOST_DECIMAL != 0
615 std::optional<BoostDecimal128> getBoostDecimal128(unsigned index)
616 {
617 assert(isValid());
618 return outRow->getBoostDecimal128(index);
619 }
620#endif
621
625 std::optional<Date> getDate(unsigned index)
626 {
627 assert(isValid());
628 return outRow->getDate(index);
629 }
630
634 std::optional<OpaqueDate> getOpaqueDate(unsigned index)
635 {
636 assert(isValid());
637 return outRow->getOpaqueDate(index);
638 }
639
643 std::optional<Time> getTime(unsigned index)
644 {
645 assert(isValid());
646 return outRow->getTime(index);
647 }
648
652 std::optional<OpaqueTime> getOpaqueTime(unsigned index)
653 {
654 assert(isValid());
655 return outRow->getOpaqueTime(index);
656 }
657
661 std::optional<Timestamp> getTimestamp(unsigned index)
662 {
663 assert(isValid());
664 return outRow->getTimestamp(index);
665 }
666
670 std::optional<OpaqueTimestamp> getOpaqueTimestamp(unsigned index)
671 {
672 assert(isValid());
673 return outRow->getOpaqueTimestamp(index);
674 }
675
679 std::optional<TimeTz> getTimeTz(unsigned index)
680 {
681 assert(isValid());
682 return outRow->getTimeTz(index);
683 }
684
688 std::optional<OpaqueTimeTz> getOpaqueTimeTz(unsigned index)
689 {
690 assert(isValid());
691 return outRow->getOpaqueTimeTz(index);
692 }
693
697 std::optional<TimestampTz> getTimestampTz(unsigned index)
698 {
699 assert(isValid());
700 return outRow->getTimestampTz(index);
701 }
702
706 std::optional<OpaqueTimestampTz> getOpaqueTimestampTz(unsigned index)
707 {
708 assert(isValid());
709 return outRow->getOpaqueTimestampTz(index);
710 }
711
715 std::optional<BlobId> getBlobId(unsigned index)
716 {
717 assert(isValid());
718 return outRow->getBlobId(index);
719 }
720
724 std::optional<ArrayId> getArrayId(unsigned index)
725 {
726 assert(isValid());
727 return outRow->getArrayId(index);
728 }
729
733 std::optional<std::string> getString(unsigned index)
734 {
735 assert(isValid());
736 return outRow->getString(index);
737 }
738
742 std::optional<std::vector<std::byte>> getBytes(unsigned index)
743 {
744 assert(isValid());
745 return outRow->getBytes(index);
746 }
747
751
755 template <typename T>
756 T get(unsigned index)
757 {
758 assert(isValid());
759 return outRow->get<T>(index);
760 }
761
769 template <Aggregate T>
770 T get()
771 {
772 assert(isValid());
773 return outRow->get<T>();
774 }
775
783 template <TupleLike T>
784 T get()
785 {
786 assert(isValid());
787 return outRow->get<T>();
788 }
789
798 template <VariantLike V>
799 V get(unsigned index)
800 {
801 assert(isValid());
802 return outRow->get<V>(index);
803 }
804
805 private:
806 const std::vector<Descriptor>& getSetterDescriptors() const noexcept
807 {
808 return inDescriptors;
809 }
810
811 std::vector<std::byte>& getSetterMessage() noexcept
812 {
813 return inMessage;
814 }
815
816 Client& getSetterClient() noexcept
817 {
818 return getClient();
819 }
820
821 void validateSetter() const noexcept
822 {
823 assert(statementHandle != nullptr);
824 }
825
826 Client& getClient() noexcept;
827
828 void clearCurrentRow() noexcept
829 {
830 currentRow = false;
831 }
832
833 private:
834 Attachment* attachment;
835 impl::StatusWrapper statusWrapper;
836 impl::CalendarConverter calendarConverter;
837 impl::NumericConverter numericConverter;
838 FbRef<fb::IStatement> statementHandle;
839 FbRef<fb::IResultSet> resultSetHandle;
840 FbRef<fb::IMessageMetadata> inMetadata;
841 std::vector<Descriptor> inDescriptors;
842 std::vector<std::byte> inMessage;
843 FbRef<fb::IMessageMetadata> outMetadata;
844 std::vector<Descriptor> outDescriptors;
845 std::vector<std::byte> outMessage;
846 std::unique_ptr<Row> outRow;
847 StatementType type;
848 unsigned cursorFlags = 0;
849 bool currentRow = false;
850 };
851
856
857 template <>
858 inline std::optional<bool> Statement::get<std::optional<bool>>(unsigned index)
859 {
860 return getBool(index);
861 }
862
863 template <>
864 inline std::optional<BlobId> Statement::get<std::optional<BlobId>>(unsigned index)
865 {
866 return getBlobId(index);
867 }
868
869 template <>
870 inline std::optional<ArrayId> Statement::get<std::optional<ArrayId>>(unsigned index)
871 {
872 return getArrayId(index);
873 }
874
875 template <>
876 inline std::optional<std::int16_t> Statement::get<std::optional<std::int16_t>>(unsigned index)
877 {
878 return getInt16(index);
879 }
880
881 template <>
882 inline std::optional<ScaledInt16> Statement::get<std::optional<ScaledInt16>>(unsigned index)
883 {
884 return getScaledInt16(index);
885 }
886
887 template <>
888 inline std::optional<std::int32_t> Statement::get<std::optional<std::int32_t>>(unsigned index)
889 {
890 return getInt32(index);
891 }
892
893 template <>
894 inline std::optional<ScaledInt32> Statement::get<std::optional<ScaledInt32>>(unsigned index)
895 {
896 return getScaledInt32(index);
897 }
898
899 template <>
900 inline std::optional<std::int64_t> Statement::get<std::optional<std::int64_t>>(unsigned index)
901 {
902 return getInt64(index);
903 }
904
905 template <>
906 inline std::optional<ScaledInt64> Statement::get<std::optional<ScaledInt64>>(unsigned index)
907 {
908 return getScaledInt64(index);
909 }
910
911 template <>
912 inline std::optional<ScaledOpaqueInt128> Statement::get<std::optional<ScaledOpaqueInt128>>(unsigned index)
913 {
914 return getScaledOpaqueInt128(index);
915 }
916
917#if FB_CPP_USE_BOOST_MULTIPRECISION != 0
918 template <>
919 inline std::optional<BoostInt128> Statement::get<std::optional<BoostInt128>>(unsigned index)
920 {
921 return getBoostInt128(index);
922 }
923
924 template <>
925 inline std::optional<ScaledBoostInt128> Statement::get<std::optional<ScaledBoostInt128>>(unsigned index)
926 {
927 return getScaledBoostInt128(index);
928 }
929#endif
930
931 template <>
932 inline std::optional<float> Statement::get<std::optional<float>>(unsigned index)
933 {
934 return getFloat(index);
935 }
936
937 template <>
938 inline std::optional<double> Statement::get<std::optional<double>>(unsigned index)
939 {
940 return getDouble(index);
941 }
942
943 template <>
944 inline std::optional<OpaqueDecFloat16> Statement::get<std::optional<OpaqueDecFloat16>>(unsigned index)
945 {
946 return getOpaqueDecFloat16(index);
947 }
948
949#if FB_CPP_USE_BOOST_MULTIPRECISION != 0
950 template <>
951 inline std::optional<BoostDecFloat16> Statement::get<std::optional<BoostDecFloat16>>(unsigned index)
952 {
953 return getBoostDecFloat16(index);
954 }
955#endif
956
957#if FB_CPP_USE_BOOST_DECIMAL != 0
958 template <>
959 inline std::optional<BoostDecimal32> Statement::get<std::optional<BoostDecimal32>>(unsigned index)
960 {
961 return getBoostDecimal32(index);
962 }
963
964 template <>
965 inline std::optional<BoostDecimal64> Statement::get<std::optional<BoostDecimal64>>(unsigned index)
966 {
967 return getBoostDecimal64(index);
968 }
969#endif
970
971 template <>
972 inline std::optional<OpaqueDecFloat34> Statement::get<std::optional<OpaqueDecFloat34>>(unsigned index)
973 {
974 return getOpaqueDecFloat34(index);
975 }
976
977#if FB_CPP_USE_BOOST_MULTIPRECISION != 0
978 template <>
979 inline std::optional<BoostDecFloat34> Statement::get<std::optional<BoostDecFloat34>>(unsigned index)
980 {
981 return getBoostDecFloat34(index);
982 }
983#endif
984
985#if FB_CPP_USE_BOOST_DECIMAL != 0
986 template <>
987 inline std::optional<BoostDecimal128> Statement::get<std::optional<BoostDecimal128>>(unsigned index)
988 {
989 return getBoostDecimal128(index);
990 }
991#endif
992
993 template <>
994 inline std::optional<Date> Statement::get<std::optional<Date>>(unsigned index)
995 {
996 return getDate(index);
997 }
998
999 template <>
1000 inline std::optional<OpaqueDate> Statement::get<std::optional<OpaqueDate>>(unsigned index)
1001 {
1002 return getOpaqueDate(index);
1003 }
1004
1005 template <>
1006 inline std::optional<Time> Statement::get<std::optional<Time>>(unsigned index)
1007 {
1008 return getTime(index);
1009 }
1010
1011 template <>
1012 inline std::optional<OpaqueTime> Statement::get<std::optional<OpaqueTime>>(unsigned index)
1013 {
1014 return getOpaqueTime(index);
1015 }
1016
1017 template <>
1018 inline std::optional<OpaqueTimestamp> Statement::get<std::optional<OpaqueTimestamp>>(unsigned index)
1019 {
1020 return getOpaqueTimestamp(index);
1021 }
1022
1023 template <>
1024 inline std::optional<Timestamp> Statement::get<std::optional<Timestamp>>(unsigned index)
1025 {
1026 return getTimestamp(index);
1027 }
1028
1029 template <>
1030 inline std::optional<TimeTz> Statement::get<std::optional<TimeTz>>(unsigned index)
1031 {
1032 return getTimeTz(index);
1033 }
1034
1035 template <>
1036 inline std::optional<OpaqueTimeTz> Statement::get<std::optional<OpaqueTimeTz>>(unsigned index)
1037 {
1038 return getOpaqueTimeTz(index);
1039 }
1040
1041 template <>
1042 inline std::optional<TimestampTz> Statement::get<std::optional<TimestampTz>>(unsigned index)
1043 {
1044 return getTimestampTz(index);
1045 }
1046
1047 template <>
1048 inline std::optional<OpaqueTimestampTz> Statement::get<std::optional<OpaqueTimestampTz>>(unsigned index)
1049 {
1050 return getOpaqueTimestampTz(index);
1051 }
1052
1053 template <>
1054 inline std::optional<std::string> Statement::get<std::optional<std::string>>(unsigned index)
1055 {
1056 return getString(index);
1057 }
1058
1059 template <>
1060 inline std::optional<std::vector<std::byte>> Statement::get<std::optional<std::vector<std::byte>>>(unsigned index)
1061 {
1062 return getBytes(index);
1063 }
1064
1068} // namespace fbcpp
1069
1070
1071#endif // FBCPP_STATEMENT_H
Represents a connection to a Firebird database.
Definition Attachment.h:220
Reference-counted smart pointer for Firebird objects using addRef/release semantics.
Definition SmartPtrs.h:70
A disconnected buffer of rows fetched from a Statement's result set.
Definition RowSet.h:57
Represents options used when preparing a Statement.
Prepares, executes, and fetches SQL statements against a Firebird attachment.
Definition Statement.h:146
std::optional< std::vector< std::byte > > getBytes(unsigned index)
Reads a text or varying column as its raw bytes.
Definition Statement.h:742
V get(unsigned index)
Retrieves a column value as a user-defined variant type.
Definition Statement.h:799
bool hasCurrentRow() const noexcept
Returns whether the statement is positioned on a current output row.
Definition Statement.h:224
std::optional< ArrayId > getArrayId(unsigned index)
Reads an array identifier column.
Definition Statement.h:724
std::optional< OpaqueTime > getOpaqueTime(unsigned index)
Reads a raw time-of-day column in Firebird's representation.
Definition Statement.h:652
std::optional< OpaqueDecFloat34 > getOpaqueDecFloat34(unsigned index)
Reads a Firebird 34-digit decimal floating-point column.
Definition Statement.h:594
std::vector< std::byte > & getOutputMessage() noexcept
Provides direct access to the raw output message buffer.
Definition Statement.h:274
const std::vector< Descriptor > & getInputDescriptors() noexcept
Provides cached descriptors for each input column.
Definition Statement.h:300
const std::vector< Descriptor > & getOutputDescriptors() noexcept
Provides cached descriptors for each output column.
Definition Statement.h:308
bool isValid() noexcept
Returns whether the Statement object is valid.
Definition Statement.h:213
StatementType getType() noexcept
Returns the type classification reported by the server.
Definition Statement.h:282
std::optional< TimeTz > getTimeTz(unsigned index)
Reads a time-of-day column with timezone.
Definition Statement.h:679
std::optional< BoostDecFloat34 > getBoostDecFloat34(unsigned index)
Reads a Boost-based 34-digit decimal floating-point column.
Definition Statement.h:604
std::optional< Time > getTime(unsigned index)
Reads a time-of-day column without timezone.
Definition Statement.h:643
std::optional< Date > getDate(unsigned index)
Reads a date column.
Definition Statement.h:625
FbRef< fb::IResultSet > getResultSetHandle() noexcept
Provides access to the underlying Firebird currently open result set handle, if any.
Definition Statement.h:242
bool isNull(unsigned index)
Reports whether the most recently fetched row has a null at the given column.
Definition Statement.h:435
std::optional< OpaqueDate > getOpaqueDate(unsigned index)
Reads a raw date column in Firebird's representation.
Definition Statement.h:634
T get()
Retrieves all output columns into a user-defined aggregate struct.
Definition Statement.h:770
std::optional< std::int64_t > getInt64(unsigned index)
Reads a 64-bit signed integer column.
Definition Statement.h:489
FbRef< fb::IStatement > getStatementHandle() noexcept
Provides direct access to the underlying Firebird statement handle.
Definition Statement.h:233
std::optional< ScaledInt32 > getScaledInt32(unsigned index)
Reads a scaled 32-bit signed integer column.
Definition Statement.h:480
std::optional< float > getFloat(unsigned index)
Reads a single precision floating-point column.
Definition Statement.h:536
std::optional< double > getDouble(unsigned index)
Reads a double precision floating-point column.
Definition Statement.h:545
std::optional< OpaqueTimestampTz > getOpaqueTimestampTz(unsigned index)
Reads a raw timestamp-with-time-zone column in Firebird's representation.
Definition Statement.h:706
std::optional< ScaledInt16 > getScaledInt16(unsigned index)
Reads a scaled 16-bit signed integer column.
Definition Statement.h:462
std::optional< BlobId > getBlobId(unsigned index)
Reads a blob identifier column.
Definition Statement.h:715
std::optional< ScaledOpaqueInt128 > getScaledOpaqueInt128(unsigned index)
Reads a Firebird scaled 128-bit integer column.
Definition Statement.h:507
FbRef< fb::IMessageMetadata > getOutputMetadata() noexcept
Returns the metadata describing columns produced by the statement.
Definition Statement.h:266
std::optional< OpaqueTimeTz > getOpaqueTimeTz(unsigned index)
Reads a raw time-of-day column with timezone in Firebird's representation.
Definition Statement.h:688
std::optional< std::string > getString(unsigned index)
Reads a textual column, applying number-to-string conversions when needed.
Definition Statement.h:733
std::optional< std::int32_t > getInt32(unsigned index)
Reads a 32-bit signed integer column.
Definition Statement.h:471
FbRef< fb::IMessageMetadata > getInputMetadata() noexcept
Returns the metadata describing prepared input parameters.
Definition Statement.h:250
~Statement() noexcept
Releases resources; ignores failures to keep destructor noexcept.
Definition Statement.h:180
std::optional< ScaledBoostInt128 > getScaledBoostInt128(unsigned index)
Reads a scaled Boost 128-bit integer column.
Definition Statement.h:526
T get(unsigned index)
Retrieves a column using the most appropriate typed accessor specialization.
Definition Statement.h:756
std::optional< BoostInt128 > getBoostInt128(unsigned index)
Reads a Boost 128-bit integer column.
Definition Statement.h:517
std::optional< bool > getBool(unsigned index)
Reads a boolean column from the current row.
Definition Statement.h:444
std::optional< BoostDecimal32 > getBoostDecimal32(unsigned index)
Reads a Boost.Decimal 7-digit decimal floating-point column.
Definition Statement.h:575
std::optional< OpaqueTimestamp > getOpaqueTimestamp(unsigned index)
Reads a raw timestamp column in Firebird's representation.
Definition Statement.h:670
Attachment & getAttachment() noexcept
Returns the Attachment object reference used to create this Statement.
Definition Statement.h:205
std::optional< BoostDecimal64 > getBoostDecimal64(unsigned index)
Reads a Boost.Decimal 16-digit decimal floating-point column.
Definition Statement.h:584
std::optional< std::int16_t > getInt16(unsigned index)
Reads a 16-bit signed integer column.
Definition Statement.h:453
std::optional< TimestampTz > getTimestampTz(unsigned index)
Reads a timestamp-with-time-zone column.
Definition Statement.h:697
std::vector< std::byte > & getInputMessage() noexcept
Provides direct access to the raw input message buffer.
Definition Statement.h:258
std::optional< OpaqueDecFloat16 > getOpaqueDecFloat16(unsigned index)
Reads a Firebird 16-digit decimal floating-point column.
Definition Statement.h:554
std::optional< Timestamp > getTimestamp(unsigned index)
Reads a timestamp column without timezone.
Definition Statement.h:661
std::optional< BoostDecFloat16 > getBoostDecFloat16(unsigned index)
Reads a Boost-based 16-digit decimal floating-point column.
Definition Statement.h:564
std::optional< ScaledInt64 > getScaledInt64(unsigned index)
Reads a scaled 64-bit signed integer column.
Definition Statement.h:498
std::optional< BoostDecimal128 > getBoostDecimal128(unsigned index)
Reads a Boost.Decimal 34-digit decimal floating-point column.
Definition Statement.h:615
Represents a transaction in one or more Firebird databases.
fb-cpp namespace.
Definition Array.h:43
StatementType
Distinguishes the semantic category of the prepared SQL statement.
Definition Statement.h:83
@ SAVEPOINT
Statement manages a savepoint.
@ PUT_SEGMENT
Statement writes a blob segment - legacy feature.
@ UPDATE
Server classified the statement as an UPDATE.
@ COMMIT
Statement commits a transaction.
@ ROLLBACK
Statement rolls back a transaction.
@ EXEC_PROCEDURE
Statement executes a stored procedure.
@ DELETE
Server classified the statement as a DELETE.
@ DDL
Statement performs data definition operations.
@ GET_SEGMENT
Statement reads a blob segment - legacy feature.
@ INSERT
Server classified the statement as an INSERT.
@ SELECT
Server classified the statement as a SELECT.
@ SET_GENERATOR
Statement sets a generator (sequence) value.
@ START_TRANSACTION
Statement starts a new transaction.
@ SELECT_FOR_UPDATE
Cursor-based SELECT that allows updates.