|
-
I have to agree with the guys who replied your post,
but I know how difficult to propose changes to management here in our place.
I have a dirty but somehow nifty approach to solve your problem.
As what Jeff mentioned it is import to have keys in both tables,
I don't want to explain the script 'cause it's so basic. Your last step will be on how to tackle the records from both tables that wasn't included in the view if there is.
Hope this can help Ate.
SCRIPT:
SQL> create table emp(empname varchar2(35), emp_id number(4) not null);
Table created.
SQL> create table loans_table(fullname varchar2(30), loan_id number(4) not null)
SQL> /
Table created.
SQL> insert into emp values('TOM WELLING', 100);
1 row created.
SQL> ED
Wrote file afiedt.buf
1* insert into emp values('SCOTT WILSON', 101)
SQL> /
1 row created.
SQL> insert into LOANS_TABLE values('WELLING, TOM',2001);
1 row created.
SQL> ed
Wrote file afiedt.buf
1* insert into LOANS_TABLE values('WILSON, SCOTT',2002)
SQL> /
1 row created.
SQL> COMMIT;
SQL> SELECT * FROM EMP;
EMPNAME EMP_ID
----------------------------------- ----------
TOM WELLING 100
SCOTT WILSON 101
SQL> SELECT * FROM LOANS_TABLE
2 ;
FULLNAME LOAN_ID
------------------------------ ----------
WELLING, TOM 2001
WILSON, SCOTT 2002
CREATE VIEW LOAN_EMP_V AS SELECT LTRIM(SUBSTR(FULLNAME,INSTR(FULLNAME,',',1)+1,LENGTH(FULLNAME)
SUBSTR(FULLNAME,1, INSTR(FULLNAME,',',1)-1) FULLNAME, LOAN_ID
FROM LOANS_TABLE
/
SQL> SELECT * FROM LOAN_EMP_V;
FULLNAME LOAN_ID
------------------------------------------------------------- ----------
TOM WELLING 2001
SCOTT WILSON 2002
SQL> col fullname format a30
SQL> l
1 select emp_id, fullname, loan_id
2 from emp, loan_emp_v
3* where empname = fullname
SQL> /
EMP_ID FULLNAME LOAN_ID
---------- ------------------------------ ----------
101 SCOTT WILSON 2002
100 TOM WELLING 2001
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|