wood burning stoves 2.0*
The moose likes JDBC and the fly likes Error in using Temporary tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Error in using Temporary tables" Watch "Error in using Temporary tables" New topic
Author

Error in using Temporary tables

Nila dhan
Ranch Hand

Joined: Sep 15, 2005
Posts: 160
I am creating temporary tables in Sybase database for my application.
The query is getting executed without any issues for the first time. But when I refresh the output page, which implicily hits the server with another rquest, I get the following error

Cannot create temporary table '#TEMPTABLE'. Prefix name '#TEMPTABLE'' is already in use by another temporary table '#TEMPTABLE'.

Please suggest..

Thanks in advance
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
I think the error message is self-explanatory. You are creating the same table twice (or trying to).
Nila dhan
Ranch Hand

Joined: Sep 15, 2005
Posts: 160
Yes, the error message is self-explanatory. My requirement is to create the temporary table only if it doesnt exist already.

Is there any check that can be performed to find if the table already exists ? If so, how to perform the check ?
Nila dhan
Ranch Hand

Joined: Sep 15, 2005
Posts: 160
Yes, the error message is self-explanatory. My requirement is to create the temporary table only if it doesnt exist already.

Is there any check that can be performed to find if the table already exists ? If so, how to perform the check ?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


Yes, the error message is self-explanatory. My requirement is to create the temporary table only if it doesnt exist already.

Is there any check that can be performed to find if the table already exists ? If so, how to perform the check ?

Temporary tables in Sybase are per session, so one way is to open a new connection.

The other is to interogate the database catalog to see if the current table aleady exists. You can do this using database specific T-SQL, e.g. :

Not 100% sure this will work on Sybase, my T-SQL experience is all SQL Server, but you get the gist.

You can also do this in JDBC via DatabaseMetaData. Have a look at the methods that class gives you.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in using Temporary tables