- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Outter Join in IN CLAUSE
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-01-2007 05:18 AM
тАО03-01-2007 05:18 AM
Outter Join in IN CLAUSE
I have the following requirement,
Select empid,empname from emp where
emp id in (E100,E200,E999)
E999 is not present in emp table
Now i need the output like this
E100, Adam
E200, Bob
E999, NA
Above is just an example, originally the "in" list will have like 800-900 items...and that info is not avbl in a oracle table.
PLS HELP.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2007 05:48 AM
тАО03-01-2007 05:48 AM
Re: Outter Join in IN CLAUSE
create temp table empids (temp_id char(4));
insert into empids values("E100");
insert into empids values("E200");
insert into empids values("E999");
...etc...
Select emp.empid, emp.empname
from empids, outer emp
where
emp.emp_id = empids.temp_id
;
I haven't tested it because i'm at home, but I'm fairly confident.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2007 05:54 AM
тАО03-01-2007 05:54 AM
Re: Outter Join in IN CLAUSE
You can also populate the temporary table using a select statement, or an SQL load command if the emp ids are in a file not the database.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2007 06:16 AM
тАО03-01-2007 06:16 AM
Re: Outter Join in IN CLAUSE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2007 10:16 PM
тАО03-01-2007 10:16 PM
Re: Outter Join in IN CLAUSE
once simple example is:
SQL> variable txt varchar2(50);
SQL> column "Name" format a30
SQL> exec :txt := 'Toby,Maxi,Mili,Mini'
PL/SQL procedure successfully completed.
SQL> r
1 with data
2 as
3 (
4 select substr (txt,
5 instr (txt, ',', 1, level ) + 1,
6 instr (txt, ',', 1, level+1) - instr (txt, ',', 1, level) -1
)
7 as token
8 from (select ','||:txt||',' txt from dual)
9 connect by level <= length(:txt)-length(replace(:txt,',',''))+1
10 )
11 select nvl(empname,token) "Name", nvl(to_char(salary),'n/a') "Salary"
12 from data, emp
13* where token=empname (+)
Name Salary
------------------------------ ----------------------------------------
Toby 10000
Mili 11000
Maxi 12000
Mini n/a
SQL>
For your case, you can use the EXTERNAL table feature to achieve the desired results.
hope this helps!
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2007 10:16 PM
тАО03-01-2007 10:16 PM
Re: Outter Join in IN CLAUSE
one simple example is:
SQL> variable txt varchar2(50);
SQL> column "Name" format a30
SQL> exec :txt := 'Toby,Maxi,Mili,Mini'
PL/SQL procedure successfully completed.
SQL> r
1 with data
2 as
3 (
4 select substr (txt,
5 instr (txt, ',', 1, level ) + 1,
6 instr (txt, ',', 1, level+1) - instr (txt, ',', 1, level) -1
)
7 as token
8 from (select ','||:txt||',' txt from dual)
9 connect by level <= length(:txt)-length(replace(:txt,',',''))+1
10 )
11 select nvl(empname,token) "Name", nvl(to_char(salary),'n/a') "Salary"
12 from data, emp
13* where token=empname (+)
Name Salary
------------------------------ ----------------------------------------
Toby 10000
Mili 11000
Maxi 12000
Mini n/a
SQL>
For your case, you can use the EXTERNAL table feature to achieve the desired results.
hope this helps!
yogeeraj