Subject | Re: [firebird-support] Re: Corrupt database |
---|---|
Author | Helen Borrie |
Post date | 2004-05-01T02:03:08Z |
At 02:40 PM 30/04/2004 +0000, you wrote:
you have a "rogue" character occupying a column that is a foreign key. You
could write a stored procedure that loops through the table as a cursor,
writing the value from the problem column into a variable of the correct
character set.
declare variable fkvalue varchar(n) character set ISO_8859_1;
FOR SELECT PK_PERSONS FROM PERSONS
FOR UPDATE
INTO :FKVALUE
AS CURSOR MYCURSOR
DO
BEGIN
// if it's not Fb 1.5, you'll need to put some do-nothing code in here
END
When the loop encounters the bad character, it will throw the exception you
have seen elsewhere. Use the GDSCODE to trap the faulty value:
WHEN GDSCODE transliteration_failed do
begin
update persons
set pk_persons = null
where current of mycursor;
end
end
If you can't set the value to null (because it is not a nullable column)
then you'll need to prepare a "dummy parent" beforehand, by creating a
master record with a pk value that is empty string. Commit it, of course.
Then your sp can do
set pk_persons = ''
where current of mycursor;
/heLen
>When I iterate a through the PERSONS table (with IBExpert) I get atIf this is related to your previous Restore problem, then it seems likely
>the certain moment the following error:
>
>Arithmic overflow of division by zero has occured
>arithmic exception, numeric overflow or string truncation
>
>Cannot transliterate character between character sets.
>
>Does this means that there is a strange character in a certain
>record? How can I find this record and fix or delete it?
you have a "rogue" character occupying a column that is a foreign key. You
could write a stored procedure that loops through the table as a cursor,
writing the value from the problem column into a variable of the correct
character set.
declare variable fkvalue varchar(n) character set ISO_8859_1;
FOR SELECT PK_PERSONS FROM PERSONS
FOR UPDATE
INTO :FKVALUE
AS CURSOR MYCURSOR
DO
BEGIN
// if it's not Fb 1.5, you'll need to put some do-nothing code in here
END
When the loop encounters the bad character, it will throw the exception you
have seen elsewhere. Use the GDSCODE to trap the faulty value:
WHEN GDSCODE transliteration_failed do
begin
update persons
set pk_persons = null
where current of mycursor;
end
end
If you can't set the value to null (because it is not a nullable column)
then you'll need to prepare a "dummy parent" beforehand, by creating a
master record with a pk value that is empty string. Commit it, of course.
Then your sp can do
set pk_persons = ''
where current of mycursor;
/heLen