2 years ago

#41276

test-img

MoonRaiser

Poco ODBC MS SQL: temp tables

I want to create temp tables and use it later in one session. I can create it, but then when I try to use to I receive:

[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name #my_table

I try the same queries in SSMS and everything works correctly.

For example

...
std::shared_ptr<Poco::Data::Session> session;
...
Poco::Data::Statement createStatement(*session);
createStatement<< create_temp_table_and_insert_into_temp_table;
createStatement.execute();

Poco::Data::Statement insertStatement(*session);
insertStatement<< select_from_temp_table;
insertStatement.execute(); <- exception Invalid object name 

Another example

...
std::shared_ptr<Poco::Data::Session> session;
...
*session.get() << "IF(OBJECT_ID('tempdb..#test') is not null) drop table #test;";
*session.get() << "create table #test (s1 int,s2 int ,s3 int);";
*session.get() << "insert into #test select 1,2,3";
typedef Poco::Tuple<int, int, int> testParam;
std::vector<testParam> testParams;
*session.get() << QString("select * from #test").toStdString(), Poco::Data::Keywords::into(testParams),
            Poco::Data::Keywords::now;

I tried the same with qt odbc driver and queries also work. I also tried Driver={ODBC Driver 17 for SQL Server} and old driver DRIVER={SQL Server} too.

c++

sql-server

odbc

poco-libraries

0 Answers

Your Answer

Accepted video resources