oracle11g - Oracle: update table using dynamic column names -


i using oracle 11g. tables include columns name , l_name (lowercase of name column). trying iterate through columns in table space set l_ columns lowercase of respective uppercase columns. here tried:

for in (select table_name user_tables) loop     select substr(column_name,3) bulk collect my_temp_storage user_tab_columns table_name = i.table_name , column_name 'l\_%' escape '\';     j in (select column_name user_tab_columns table_name = i.table_name) loop         k in 1..my_temp_storage.count         loop             if(j.column_name 'l\_%' escape '\' , substr(j.column_name,3) = my_temp_storage(k))                 dbms_output.put_line( 'update ' || i.table_name || ' set ' || j.column_name || ' = lower(' ||my_temp_storage(k)|| ') ' || j.column_name || ' not null');                 execute immediate 'update ' || i.table_name || ' set ' || j.column_name || ' = lower(' ||my_temp_storage(k)|| ') ' || j.column_name || ' not null';             end if;         end loop;     end loop; end loop; 

i storing names of columns in uppercase in my_temp_storage , updating table lower value of columns in my_temp_storage. gave me error saying:

error report - ora-00900: invalid sql statement ora-06512: @ line 8 00900. 00000 -  "invalid sql statement" *cause:     *action:  

but dbms output seemed fine:

`update employee set l_name = lower(name) l_name not null`  

could me way did or other way can done?

the program simplified:

begin     in (select table_name, column_name user_tab_columns                column_name 'l\_%' escape '\')      loop         l_sql := 'update ' || i.table_name || ' set ' || i.column_name                    || ' = lower(' ||substr(i.columm_name,3)                   || ') ' || i.column_name || ' not null';         execute immediate l_sql;     end loop;           end; 

it seems odd database design though. have considered virtual columns, and/or function-based indexes, instead of manually maintained columns?


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -