- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- PL/SQL Variables replacing table name
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2004 01:19 AM
тАО03-25-2004 01:19 AM
I would like to run a select from tablevar where....
Now the table_name is not known in advance so that I would like to use a variable to store the table name.
Using shell language, I would like to have something like:
select * from $tablename where....
How can I do that ?
Thanks !
Mike
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2004 01:32 AM
тАО03-25-2004 01:32 AM
Re: PL/SQL Variables replacing table name
#!/bin/ksh
sqlplus -s $login/$password@$ORACLE_SID << EOF >> $LOG
select * from $table where ....
EOF
in a sql script
select * from &1 where ....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2004 01:37 AM
тАО03-25-2004 01:37 AM
Re: PL/SQL Variables replacing table name
SELECT TABLE_NAME INTO TABLEVAR FROM ALL_ALL_TABLES WHERE...
if I want to use TABLEVAR to reference the table I'm interested in, how can I run
SELECT * FROM TABLEVAR WHERE.... ?
How can I reference TABLEVAR without passing externally the value to &1 ?
Thanks !
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2004 01:45 AM
тАО03-25-2004 01:45 AM
Re: PL/SQL Variables replacing table name
If you can program in PLSQL this is not a big deal.
Regards,
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2004 02:04 AM
тАО03-25-2004 02:04 AM
Re: PL/SQL Variables replacing table name
col table_name new_value my_table
-- This one put the table name in my_table
SELECT table_name FROM tabs WHERE your_condition;
-- This one do the job
SELECT * from &my_table;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2004 03:35 AM
тАО03-25-2004 03:35 AM
Re: PL/SQL Variables replacing table name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2004 08:25 PM
тАО03-25-2004 08:25 PM
Re: PL/SQL Variables replacing table name
Cheers
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2004 08:41 PM
тАО03-25-2004 08:41 PM
Re: PL/SQL Variables replacing table name
SQL>select * from &table;
SQL>save ex01
SQL>@ex01
The system will prompt for the table name.
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2004 10:22 AM
тАО03-29-2004 10:22 AM
Solution--------------------
set serveroutput on
declare
tablename varchar2(20) := 'tableA';
sqlstatement varchar2(100);
tempvar varchar2(10);
begin
sqlstatement:='select count(*) from '||tablename;
execute immediate sqlstatement into tempvar;
dbms_output.put_line('Tempvar '||tempvar);
end;
/
-----------------
Thanks,
Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-29-2004 06:23 PM
тАО03-29-2004 06:23 PM
Re: PL/SQL Variables replacing table name
that's definitely what I was looking for, nice and easy.
I appreciated !
Mike