I need to replace the Table1\'s filed values from Table2\'s values while select query.
Eg:
Table1:
Org Permission
--------------
In Oracle you can run this PL/SQL block and it will do all the work:
begin
for x in (
select permission, descr from table2
) loop
update table1 set permission = replace(permission, x.permission, x.descr);
end loop;
commit;
end
/
I used this script to create a schema:
create table table1(
org varchar2(100),
permission varchar2(1000)
);
create table table2(
permission varchar2(100),
descr varchar2(1000)
);
insert into table1(org, permission) values ('Company1', '1,3,7');
insert into table1(org, permission) values ('Company2', '1,3,8');
insert into table2(permission, descr) values ('1', 'Read');
insert into table2(permission, descr) values ('7', 'Execute');
insert into table2(permission, descr) values ('8', 'Delete');