36 : attachment{&attachment},
37 statusWrapper{attachment.getClient()},
38 calendarConverter{attachment.getClient()},
39 numericConverter{attachment.getClient()}
44 unsigned flags = fb::IStatement::PREPARE_PREFETCH_METADATA;
46 if (
options.getPrefetchLegacyPlan())
47 flags |= fb::IStatement::PREPARE_PREFETCH_LEGACY_PLAN;
50 flags |= fb::IStatement::PREPARE_PREFETCH_DETAILED_PLAN;
52 statementHandle.reset(attachment.
getHandle()->prepare(&statusWrapper, transaction.
getHandle().get(),
55 if (
options.getCursorName().has_value())
56 statementHandle->setCursorName(&statusWrapper,
options.getCursorName()->c_str());
59 cursorFlags = fb::IStatement::CURSOR_TYPE_SCROLLABLE;
61 type =
static_cast<StatementType>(statementHandle->getType(&statusWrapper));
67 throw FbCppException(
"Cannot use SET TRANSACTION command with Statement class. Use Transaction class");
72 "Cannot use COMMIT command with Statement class. Use the commit method from the Transaction class");
77 "Cannot use ROLLBACK command with Statement class. Use the rollback method from the Transaction class");
81 throw FbCppException(
"Unsupported statement type: BLOB segment operations");
88 std::vector<std::byte>& message)
93 message.resize(
metadata->getMessageLength(&statusWrapper));
97 const auto count =
metadata->getCount(&statusWrapper);
98 descriptors.reserve(count);
100 for (
unsigned index = 0
u; index < count; ++index)
105 .scale =
metadata->getScale(&statusWrapper, index),
106 .length =
metadata->getLength(&statusWrapper, index),
109 .isNullable =
static_cast<bool>(
metadata->isNullable(&statusWrapper, index)),
110 .name =
metadata->getField(&statusWrapper, index),
111 .relation =
metadata->getRelation(&statusWrapper, index),
112 .alias =
metadata->getAlias(&statusWrapper, index),
113 .owner =
metadata->getOwner(&statusWrapper, index),
114 .charSetId =
metadata->getCharSet(&statusWrapper, index),
115 .subType =
metadata->getSubType(&statusWrapper, index),
162 message.resize(
metadata->getMessageLength(&statusWrapper));
164 for (
unsigned index = 0
u; index < count; ++index)
175 inMetadata.reset(statementHandle->getInputMetadata(&statusWrapper));
178 outMetadata.reset(statementHandle->getOutputMetadata(&statusWrapper));
181 outRow = std::make_unique<Row>(attachment.
getClient(), outDescriptors, std::span{outMessage});
185 : attachment{o.attachment},
186 statusWrapper{std::move(o.statusWrapper)},
187 calendarConverter{std::move(o.calendarConverter)},
188 numericConverter{std::move(o.numericConverter)},
189 statementHandle{std::move(o.statementHandle)},
190 resultSetHandle{std::move(o.resultSetHandle)},
191 inMetadata{std::move(o.inMetadata)},
192 inDescriptors{std::move(o.inDescriptors)},
193 inMessage{std::move(o.inMessage)},
194 outMetadata{std::move(o.outMetadata)},
195 outDescriptors{std::move(o.outDescriptors)},
196 outMessage{std::move(o.outMessage)},
197 outRow{std::make_unique<Row>(attachment->getClient(), outDescriptors, std::span{outMessage})},
199 cursorFlags{o.cursorFlags}
208 attachment = o.attachment;
209 statusWrapper = std::move(o.statusWrapper);
210 calendarConverter = std::move(o.calendarConverter);
211 numericConverter = std::move(o.numericConverter);
212 statementHandle = std::move(o.statementHandle);
213 resultSetHandle = std::move(o.resultSetHandle);
214 inMetadata = std::move(o.inMetadata);
215 inDescriptors = std::move(o.inDescriptors);
216 inMessage = std::move(o.inMessage);
217 outMetadata = std::move(o.outMetadata);
218 outDescriptors = std::move(o.outDescriptors);
219 outMessage = std::move(o.outMessage);
220 outRow = std::make_unique<Row>(attachment->getClient(), outDescriptors, std::span{outMessage});
222 cursorFlags = o.cursorFlags;
265 resultSetHandle->close(&statusWrapper);
266 resultSetHandle.reset();
281 resultSetHandle.reset(statementHandle->openCursor(&statusWrapper, transaction.
getHandle().get(),
282 inMetadata.get(), inMessage.data(), outMetadata.get(), cursorFlags));
283 return resultSetHandle->fetchNext(&statusWrapper,
outMessageData) == fb::IStatus::RESULT_OK;
286 statementHandle->execute(&statusWrapper, transaction.
getHandle().get(), inMetadata.get(), inMessage.data(),