×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

close teradata connection session to dispose volatile tables

close teradata connection session to dispose volatile tables

close teradata connection session to dispose volatile tables

(OP)
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;
	}
	
	finally
	{
		connection.Close();
                   connection.Dispose();
	}                                                                        
} 

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;
	}
	
                                                                      
} 

RE: close teradata connection session to dispose volatile tables

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

RE: close teradata connection session to dispose volatile tables

(OP)
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 😊

RE: close teradata connection session to dispose volatile tables

And what prevents you from closing the session in C#, i.e. the same thing you do in the other language?

RE: close teradata connection session to dispose volatile tables

(OP)
yeah, I do close the session in C# but it doesn't drop the volatile tables that's the problem

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close