Например:
SQL> create table test as
2 select 'empno' column_name, 'p' second_part from dual union all
3 select 'deptno' , 'pt' from dual;
Table created.
SQL> set serveroutput on
SQL> declare
2 first_part varchar2(20) := 'em';
3 l_str varchar2(200);
4 begin
5 select 'update ' || first_part || t.second_part ||
6 ' set comm = -100 where comm is null'
7 into l_str
8 from test t
9 where t.column_name = 'empno';
10
11 dbms_output.put_line(l_str);
12 execute immediate l_str;
13 end;
14 /
update emp set comm = -100 where comm is null
PL/SQL procedure successfully completed.
Результат:
SQL> select empno, ename, comm from emp;
EMPNO ENAME COMM
---------- ---------- ----------
7369 SMITH -100
7499 ALLEN 300
7521 WARD 500
7566 JONES -100
7654 MARTIN 1400
7698 BLAKE -100
7782 CLARK -100
7788 SCOTT -100
7839 KING -100
7844 TURNER 0
7876 ADAMS -100
7900 JAMES -100
7902 FORD -100
7934 MILLER -100
14 rows selected.
SQL>