dsd7038
09-19-2003, 07:30 AM
I use the following script to populate all uppercase fields as shown below. However once this script is run once and populates U## fields. If run the second time it will do the same. How can I change the script so that it ignores existing populated U## fields but only populates new U## field names.
cursor get_obj is
select table_name,column_name from user_tab_columns
where column_name like 'U##%';
BEGIN
cursor_id:=dbms_sql.open_cursor;
FOR obj_rec in get_obj LOOP
u_sql := 'UPDATE '||obj_rec.table_name||'SET '||obj_rec.column_name||' = UPPER(' || SUBSTR(obj_rec.column_name, 4) || ')';
dbms_sql.parse(cursor_id,u_sql,1);
dbms_output.put_line(u_sql);
result := dbms_sql.execute(cursor_id);
END LOOP;
dbms_sql.close_cursor(cursor_id);
END;
/
cursor get_obj is
select table_name,column_name from user_tab_columns
where column_name like 'U##%';
BEGIN
cursor_id:=dbms_sql.open_cursor;
FOR obj_rec in get_obj LOOP
u_sql := 'UPDATE '||obj_rec.table_name||'SET '||obj_rec.column_name||' = UPPER(' || SUBSTR(obj_rec.column_name, 4) || ')';
dbms_sql.parse(cursor_id,u_sql,1);
dbms_output.put_line(u_sql);
result := dbms_sql.execute(cursor_id);
END LOOP;
dbms_sql.close_cursor(cursor_id);
END;
/