Subject | Re: Corrupt database |
---|---|
Author | zifnabbe |
Post date | 2004-05-02T12:01:47Z |
Pardon my stupidity, but this is all new to me.
Why is the following stored procedure failing to compile?
declare variable fkvalue varchar(11) character set ASCII;
declare variable x integer;
for select PERSON_ID FROM PERSONS
for update
into :fkvalue
as cursor mycursor
do
begin
/* Procedure Text */
x = 1
end;
when GDSCode transliteration_failed do
begin
update persons
set PERSON_ID = 'XXX'
where current of mycursor;
end;
It tells me that PERSON_ID doesn't exists (while it is a column in
the table). If I use PK_PERSONS I get the same error.
Thanks
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
Why is the following stored procedure failing to compile?
declare variable fkvalue varchar(11) character set ASCII;
declare variable x integer;
for select PERSON_ID FROM PERSONS
for update
into :fkvalue
as cursor mycursor
do
begin
/* Procedure Text */
x = 1
end;
when GDSCode transliteration_failed do
begin
update persons
set PERSON_ID = 'XXX'
where current of mycursor;
end;
It tells me that PERSON_ID doesn't exists (while it is a column in
the table). If I use PK_PERSONS I get the same error.
Thanks
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
> At 02:40 PM 30/04/2004 +0000, you wrote:likely
> >When I iterate a through the PERSONS table (with IBExpert) I get at
> >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?
>
> If this is related to your previous Restore problem, then it seems
> you have a "rogue" character occupying a column that is a foreignkey. You
> could write a stored procedure that loops through the table as acursor,
> writing the value from the problem column into a variable of thecorrect
> character set.code in here
>
> 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
>exception you
> END
>
> When the loop encounters the bad character, it will throw the
> have seen elsewhere. Use the GDSCODE to trap the faulty value:column)
>
> 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
> then you'll need to prepare a "dummy parent" beforehand, bycreating a
> master record with a pk value that is empty string. Commit it, ofcourse.
>
> Then your sp can do
>
> set pk_persons = ''
> where current of mycursor;
>
> /heLen