New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ODBC DirectExec public API #3502
Conversation
Data/ODBC/src/ODBCStatementImpl.cpp
Outdated
auto data=&query.at(0); | ||
SQLCHAR * statementText=reinterpret_cast<unsigned char*>(data); | ||
SQLINTEGER textLength=query.size(); | ||
SQLRETURN rc = SQLExecDirect(_stmt,statementText,textLength); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Add spaces around
=
and after commas. - Better use
query.data()
instead of&query.at(0)
and then there's no need of a separate variable. - Even though it seems you do need to pass a non-const char pointer to
SQLExecDirect
, you don't need it for every possible implementation of this method (e.g. inStatementImpl::execDirectImpl
). So I'd suggest passing it as const reference and only make a copy if needed. *
should be a part of type (so no whitespace before it), as suggested here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- data is non const only since c++17 https://en.cppreference.com/w/cpp/string/basic_string/data
2039682
to
32949be
Compare
430296d
to
a23a419
Compare
a23a419
to
dc6a9c8
Compare
@aleks-f sorry for ping, but are there any chances for this pr? |
@Jihadist yes, but there are still some unanswered questions above |
If you mean async part, I don't know how to implement it. Maybe you can suggest something |
I did suggest something, you just have to read it |
@aleks-f it sounds strange, but I don't see anything |
8c01569
to
094ebfb
Compare
* ODBC sqlDirectExec * doc * Small fix * Fix tabs, add missing const, fix style * Add test case * Small fixes * suggested fix for async * test for returned values
It was a very long story how i couldn't determine why temp tables dont work in Poco between statements (#3499). After all, I compared how Poco use ODBC api and NanoODBC
For 1 single statement Poco call stack (except attrs and some non-related things):
For 1 single statement NanoODBC call stack (except attrs and some non-related things):
Looks like Poco uses only prepared statement while nanodbc calls execute direct every time. I tried to investigate deeper and deeper. If I create temp table with prepared statement, temp table will not be available in the next statement. How it works with sessions but with statements. But if I create temp table with direct execute, it will be available in the statements...
So I tried to add direct execute to Poco but I dont understand well Poco architecture and it needs to change a lot of classes and maybe architecture too. So I create this PR as proposal or draft.
If you provide me some help I'll be very thankful.
Closes #3499
MS mention this in docs https://learn.microsoft.com/en-us/sql/relational-databases/native-client-odbc-queries/executing-statements/prepared-execution?view=sql-server-ver16
Prepared statements cannot be used to create temporary objects on SQL Server.