I want to populate few aa.one, aa.two, aa.three columns from aa table and when I put aa.one = 'abc' in where condition I want to rename these column names as column values will populate. But one thing I don't know what value will populate through out the table
The only way out is dynamic SQL
as you have to compose the whole statement dynamically and run it using execute immediate
.
Note that it is difficult to maintain; might be OK for very simple cases, but for complex queries ... I'd think twice before actually doing something about it.
Something like this:
declare
l_str varchar2(200);
begin
l_str := 'update ' || par_table_name || ' set ' ||
par_column_1 || ' = ' || par_value_1 ||
' where ' || par_column_where_1 || ' = ' || par_column_where_value_1;
execute immediate l_str;
end;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.