This is a very handy utility to take care of all instances of format CHAR. It simply changes the format to VARCHAR2.
Under most circumstances, it is wise to use varchar2 instead of char. The object of this article is not to get into a debate about it. If you have a large repository full of CHAR things, you are welcome to use the utilities that follow. There is one for domains, one for attributes and one for columns.
You do not necessarily have to run the utility for attributes. The database design wizard takes care of this for you, i.e. all CHAR attributes will give birth to VARCHAR2 columns. There is one exception though. An attributes defined by a domain whose column format is CHAR results in a CHAR column.
The code that follows can simply be run from SQL*Plus.
Domains SQL*Plus Script
Attributes SQL*Plus Script
Columns SQL*Plus Script
set serveroutput on
set verify off rem ******************************************************
declare
v_app_id number(38);
cursor char_domains (p_app_id number) is
procedure instantiate_messages is
begin -- Get Application ID
-- Initialize API if not already done
-- Set DBMS Output Buffer to Max Size
for cur_char_domain in char_domains(v_app_id) loop
-- Change it to varchar2
-- Validate the update
-- Get feedback
cdapi.close_activity(act_status); -- If the activity did not close successfully,
roll back
-- Otherwise, this must have been an ORACLE SQL
or internal error so
|
set serveroutput on
set verify off rem ****************************************************** rem * rem * This utility replaces CHAR with VARCHAR2 in all attributes rem * of an application in Designer 2000. rem * rem * Written by: H. Deschamps, 7/1/97. rem * Last Modified: 7/1/97. rem ****************************************************** declare
v_app_id number(38);
cursor char_attributes (p_app_id number) is
procedure instantiate_messages is
begin -- Get Application ID
-- Initialize API if not already done
-- Set DBMS Output Buffer to Max Size
for cur_char_attribute in char_attributes(v_app_id) loop
-- Change it to varchar2
-- Validate the update
-- Get feedback
cdapi.close_activity(act_status); -- If the activity did not close successfully,
roll back
-- Otherwise, this must have been an ORACLE SQL
or internal error so
|
set serveroutput on
set verify off rem ****************************************************** rem * rem * This utility replaces CHAR with VARCHAR2 in all columns rem * of an application in Designer 2000. rem * rem * Written by: H. Deschamps, 7/3/97. rem * Last Modified: 7/3/97. rem ****************************************************** declare
v_app_id number(38);
cursor char_columns (p_app_id number) is
procedure instantiate_messages is
begin -- Get Application ID
-- Initialize API if not already done
-- Set DBMS Output Buffer to Max Size
for cur_char_column in char_columns(v_app_id) loop
-- Change it to varchar2
-- Validate the update
-- Get feedback
cdapi.close_activity(act_status); -- If the activity did not close successfully,
roll back
-- Otherwise, this must have been an ORACLE SQL
or internal error so
|
Please send me comments or suggestions: herve@iherve.com