Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

close teradata connection session to dispose volatile tables

Status
Not open for further replies.

peac3

Technical User
Jan 17, 2009
226
AU
Hi,

I have simple c# codes as below about executing the creation of some volatile tables in Teradata.
In Teradata, Volatile tables only remain within a session hence I would like to dispose of them to clear up memory before creating other volatile tables.

Code:
using (var connection = new TdConnection(TDconnString))
{
	try
	{
		connection.Open();
															   
		query = @"
			CREATE MULTISET VOLATILE TABLE V1 AS (                   
				SEL 
				*                             
				FROM TABLE

			)WITH DATA ON COMMIT PRESERVE ROWS;                                                                        
		   ";
		   
	   var command = new TdCommand(query, connection);            
	   command.ExecuteNonQuery();            
	}	   
															   
	catch (Exception ex)
	{
		Console.WriteLine(ex.Message);
		throw;
	}
	
[highlight #FCE94F]	finally
	{
[/highlight]		connection.Close();
                   connection.Dispose();
[highlight #FCE94F]	}[/highlight]                                                                        
}

The codes below don't work as table V1 already exists...
Code:
using (var connection = new TdConnection(TDconnString))
{
	try
	{
		connection.Open();
															   
		query = @"
			CREATE MULTISET VOLATILE TABLE V1 AS (                   
				SEL 
				*                             
				FROM TABLE

			)WITH DATA ON COMMIT PRESERVE ROWS;                                                                        
		   ";
		   
	   var command = new TdCommand(query, connection);            
	   command.ExecuteNonQuery();            
	}	   
															   
	catch (Exception ex)
	{
		Console.WriteLine(ex.Message);
		throw;
	}
	
                                                                      
}

 
And what prevents you from executing a DROP TABLE statement to dispose of the volatile table?
 
Hello mikrom,

I am using drop tables as a workaround but we use quite number of volatile tables hence the codes look a bit messy.

In other language, we drop volatile tables by closing the session which looks simpler and more elegant 😊
 
And what prevents you from closing the session in C#, i.e. the same thing you do in the other language?
 
yeah, I do close the session in C# but it doesn't drop the volatile tables that's the problem
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top