• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Error in using Temporary tables

 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 68084
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the error message is self-explanatory. You are creating the same table twice (or trying to).
 
Nila dhan
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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.
 
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!