Home > Enterprise >  Cannot read temporary tables with IDataReader
Cannot read temporary tables with IDataReader

Time:11-06

Is it possible to read temporary tables using IDataReader? I am connecting to Snowflake through ODBC.

//e.g.
CREATE TEMPORARY TABLE TEMPTABLE1 (ID INT);

sting query = "SELECT * FROM DB1.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'LOCAL TEMPORARY' OR TABLE_TYPE = 'GLOBAL TEMPORARY' OR TABLE_TYPE = 'TEMPORARY' OR TABLE_TYPE = 'VOLATILE'";
using (IDataReader reader = Connection.Query(query, null))
{
    while (reader.Read()) {...}
}

Reader is empty, did I make mistake somewhere, or there is some technical limitations on this one?

CodePudding user response:

You are creating the temporary table and THEN you are connecting with IDataReader afterwards. Thats why you don't see the table - its another session and temporary tables only exist within the session in which they were created.

enter image description here

  • Related