Topic: SQL*Plus and PL/SQL >> Dynamic Table Name
|
Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property.
You may review the entire Oracle Certification Program Candidate Agreement online Here.
|
|
|
|
| Title: Dynamic Table Name |
| shake |
Posted: Jun 25, 2008 05:53:14 AM |
Total Post: 57
Joined: Jun, 2008
|
Hi... All,
Can I make a select statement which retrieves the data from tables of same structure but different data of varying months?.
For instance, a table with the name Employee_052008 gives the employee information of May month, 2008; Employee_062008 of June 2008, and so on.
The automatic creation of tables of this kind has already been coded. Now I have to generate a report of a month (and year) which is the input from the user. So I need to append this month and year at the last of so called tablename.
I tried in many ways, using PL/SQL as well; but could not find out a solution.
To make it more clear, see the following:
SELECT * FROM Employee_052008;
SELECT * FROM Employee_022007;
SELECT * FROM Employee_012008;
Everything remains the same upto the underscore, then goes dynamically based on the user input.
Solutions are welcomed with thanks in advance.
|
|
|
shake |
| Posted: Jun 30, 2008 08:21:46 AM | |
|
Total Post: 57
Joined: Jun, 2008
|
Solution Found. Using Dynamic SQL along with EXECUTE IMMEDIATE can retrieve data and solve this problem
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |
|
|
|
|
Forum Rules & Description
Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user
|
| |
Get FREE Magazines
|
Top 10 Forum User
|
| Murtuja Khokhar | 843 |
| Mohammed Taj | 746 |
| positive fanatic | 483 |
| Jayanta Sur | 479 |
| Vigyan Kaushik | 386 |
| Gitesh Trivedi | 322 |
| Gopu Gopi | 272 |
| neeraj sharma | 252 |
| Ramesh Jois | 245 |
| Bishal Khetan | 207 |
|
|