Subject Re: [firebird-support] fail when checking VarChar variable <> ''
Author Helen Borrie
At 10:08 AM 7/12/2006, you wrote:
>FB 1.5.3.4870
>XP Pro SP2
>
>I have a mysterious failure in an SP when I check if a variable is
>blank.
>
>I get a "arithmetic exception, numeric overflow, or string truncation"
>when I test for InternalMemo <> ''.
>
>InternalMemo is VarChar(2000) and is filled from a memo field like this:
>Select...<field list>
>Coalesce(SubString(O.MEMO_INTERNAL From 1 For 1990),'')
>into ... InternalMemo
>
>Then later in the procedure I check to see if it contains something by:
>if (InternalMemo <> '') then
>...do something
>
>But I get the error at the "If" test
>
>Does this ring any bells with someone? I don't see what I am doing
>wrong.

this:

Coalesce(SubString(O.MEMO_INTERNAL From 1 For 1990),'')
into ... InternalMemo

should be

Coalesce(SubString(O.MEMO_INTERNAL From 1 For 1990),'')
into ... :InternalMemo

Local variables default to character set NONE, so make sure that the
variable is declared with the same character set as the stored data
if the stored data isn't charset NONE...e.g., if your blob is
unicode_fss then your substring could easily overflow a varchar(2000).

./heLen