How to dynamically change table names in OraclePLSQL statements
How to dynamically change table names in Oracle PL/SQL statements
The younger brother just came into contact with the ORACLE stored procedure and asked me a question. The younger brother wrote a stored procedure to receive a parameter as the table name, then, you can query the content of one field of all records in the table and import it to another table.
Tabname in varchar
V_servicesname tabname. service type % type; -- this variable is used to store the obtained field content, but I do not know how to define it.
Cursor curSort1 is the select service type from tabname order by encoding; -- this statement does not prompt that the table name cannot be found
Create or replace procedure cal (tb varchar2) is
Total pls_integer: = 0;
Type emp_cur is ref cursor;
Open cur for 'select employee_id from '| tb;
Fetch cur into id;
Exit when cur % notfound;
Total: = total + id;