Below is a firebird SQL script which will help you easily change the charset of all fields in your database.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
execute block returns (fieldname char(1000),fieldlength int) as declare cur cursor for ( select T1.RDB$FIELD_NAME, T1.RDB$FIELD_LENGTH from RDB$FIELDS T1, RDB$RELATION_FIELDS T2 where T1.RDB$FIELD_TYPE = 37 and T2.RDB$VIEW_CONTEXT is null and T1.RDB$FIELD_NAME = T2.RDB$FIELD_SOURCE and T1.RDB$CHARACTER_SET_ID<>4 and not T2.RDB$RELATION_NAME like 'RDB$%' and not T2.RDB$RELATION_NAME like 'MON$%' ); begin open cur; while (1=1) do begin fetch cur into fieldname, fieldlength; update RDB$FIELDS set RDB$CHARACTER_SET_ID = 4, RDB$FIELD_LENGTH = :fieldlength*4, RDB$CHARACTER_LENGTH = :fieldlength where RDB$FIELD_NAME = :fieldname; if (row_count = 0) then leave; suspend; end close cur; end |