Thanks Bruce and Steve for the suggestions.Robert ThompsonTTC Inc.219-363-7441
-------- Original message --------From: Steve Sweeney 
<[email protected]> Date: 1/21/25  11:13 PM  (GMT-06:00) To: 
[email protected] Subject: RE: [RBASE-L] - Column definition 

Robert,
 
For 40 years I wanted to write this routine – your post inspired me to try 
something today.
 
WARNING: Before executing the routine below be sure to make a backup of your 
database.  You may also want to run it offline as a test before updating the 
“working” copy of your data.  Fair warning …
😊
 
It seems to work very well on “stand alone” columns – that is, columns that are 
not indexed, not in computed columns, not used in constraints, etc.  If you 
have a simple TEXT column that needs to be expanded
 this routine might do the trick.
 
Steve Sweeney
San Ramon, CA
 
 
-- ExpandTextColWidth.RMD
 
-- NOTE: This is a rather simple routine that will EXPAND the size of TEXT 
"stand alone" columns
-- NOTE: Be sure there are no CONSTRAINTS or COMPUTED COLUMNS or INDEXES as 
these types of columns may require manual changes
 
-- Find the TEXT columns that are used in multiple tables
--SELECT SYS_COLUMN_NAME=50,COUNT(*)=19 AS Number_of_Instances FROM SYS_COLUMNS 
WHERE SYS_TYPE_NAME = 'TEXT' GROUP BY SYS_COLUMN_NAME HAVING COUNT(*) > 1
 
-- Columns will be temporarily renamed as the ALTER TABLE statement expands the 
size
SET V vSYS_COLUMN_PREFIX TEXT = 'Unique123Prefix456'
 
-- Enter the COLUMN NAME you want to expand
SET V vSYS_COLUMN_NAME TEXT = 'CageNum'
 
-- This concatonates the "Prefix" with the "Column Name" to create a temporary 
column name
SET V vtmp_COLUMN_NAME TEXT = (.vSYS_COLUMN_PREFIX + .vSYS_COLUMN_NAME)
 
-- Here is the NEW column width
SET V vSYS_COLUMN_LENGTH INTEGER = 48
 
-- Initialize a variable for the TABLE NAME
SET V vSYS_TABLE_NAME TEXT = NULL
 
-- Cursor to go through each instance of a TableName / ColumnName
DECLARE cColNameCursor CURSOR FOR SELECT 
syst.SYS_TABLE_NAME,sysc.SYS_COLUMN_NAME FROM SYS_COLUMNS sysc , SYS_TABLES 
syst WHERE sysc.SYS_COLUMN_NAME = .vSYS_COLUMN_NAME AND sysc.SYS_TABLE_ID
 = syst.SYS_TABLE_ID
OPEN cColNameCursor
FETCH cColNameCursor INTO vSYS_TABLE_NAME,vSYS_COLUMN_NAME
WHILE SQLCODE <> 100 THEN
  WRITE 'Table:' .vSYS_TABLE_NAME  ,  'Column:' .vSYS_COLUMN_NAME
  ALTER TABLE &vSYS_TABLE_NAME ALTER COLUMN &vSYS_COLUMN_NAME TO 
&vtmp_COLUMN_NAME TEXT &vSYS_COLUMN_LENGTH
  WRITE ' '
 
  FETCH cColNameCursor INTO vSYS_TABLE_NAME,vSYS_COLUMN_NAME
ENDWHILE
 
-- Drop the cursor after execution
DROP CURSOR cColNameCursor
 
-- Rename the "TemporaryColumn" back to the "OriginalColumn"
RENAME COLUMN &vtmp_COLUMN_NAME TO &vSYS_COLUMN_NAME
 
RETURN
 
 


From: [email protected] <[email protected]>
On Behalf Of Bruce Chitiea
Sent: Tuesday, January 21, 2025 3:57 PM
To: [email protected]
Subject: Re: [RBASE-L] - Column definition


 

Robert:


 


The fastest, simplest way to do it is to do an UNLOAD ALL to a text file, then 
modify the column definitions in the text file


 


OUTPUT utility_changeColumnWidth.rmd


UNLOAD ALL 


OUTPUT SCREEN


 


RBEDIT utility_changeColumnWidth.rmd


 


... make all your changes, save, and then:


 


1) Change the extensions of your existing .rx? file e.g: database.rx1.old ... 
.rx4.old


 


2) RUN utility_changeColumnWidth.rmd


 


Done, and, you end up with a free backup of your database.


 


Best, Bruce


 





Bruce A. Chitiea


SafeSectors, Inc.

1142 S Diamond Bar Blvd # 442


Diamond Bar CA 91765-2203


 


[email protected] 



(909) 238-9012 m







 



------ Original Message ------


>From "'Robert Thompson' via RBASE-L" <[email protected]>


To 
[email protected]


Date 1/21/2025 3:48:51 PM


Subject [RBASE-L] - Column definition



 



I have "Column A" defined as TEXT 12 in about 20 tables.   I now need to

expand that to TEXT 25.

I know how to manually make the changes and it is not very efficient, so 
I thought I would ask if there is an option or process that I may have 
missed in some update over the years!

So.... is there a straight forward way of changing a column text length 
definition across the database?

Thanks,

-- 
Robert Thompson
TTC. Inc.


-- 
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
--- 
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to
[email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/rbase-l/ef51c380-731b-4e0e-8b2e-886327601e4f%40comcast.net.
-- 
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
--- 
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to
[email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/rbase-l/em71657adc-3f99-4299-887e-1a6e606134d2%40828a53f2.com.






-- 
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
--- 
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/rbase-l/SN6PR03MB37271D896A55C3B8B118472889E12%40SN6PR03MB3727.namprd03.prod.outlook.com.

-- 
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
--- 
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/rbase-l/aaeRtne3PlzdHaaeVtul1M.1737552020.910be1150dc29959db09fc25e8933ce2.MISSINGID%40comcast.net.

Reply via email to