This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes creating table and  appending current date in table name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "creating table and  appending current date in table name" Watch "creating table and  appending current date in table name" New topic
Author

creating table and appending current date in table name

nishant vaishnaw
Greenhorn

Joined: Feb 27, 2013
Posts: 22
Hi ,

Iam using below code to creating table and appending current date in table name,But it's giving error :

COLUMN today_col NEW_VALUE today;
SELECT TO_CHAR ( SYSDATE, 'DDMMYYYY') AS today_col FROM dual;
CREATE TABLE VALID_NUMBE_&today AS (SELECT * FROM VALID_NUMBER);

it giving error "object allready exist"
Please guide hw we can clear the variable value before declaring.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10171
    
    8

Please do take out time to CarefullyChooseOneForum
This forum is for Tomcat questions. Moving...


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

I personally would use PL/SQL, not SQL*plus scripts, for this kind of functionality. Probably a stored procedure that would check that the table doesn't exist yet and then created it. The SQL*plus scripting language makes it quite difficult to correctly catch and handle all kinds of possible errors.

In Oracle, it is not quite common to create daily tables. Partitioning is usually used for that, which allows practically the same functionality without exposing the fact that the table is physically organized on daily basis to the application(s). However, partitioning is a feature that has to be bought extra, you can see whether it is supported in your database by running:
 
 
subject: creating table and appending current date in table name
 
Similar Threads
Log file created but datepattern is not getting appended
how to insert a current date into the databse colunm using hybernate ?
Bug in JDBC ? Simple Select statement not returning a resultSet
iBATIS appends String to table name
java.util.Date to java.sql.Date