We have just upgraded from UDB DB2 V7.2 to UDB DB2 V8.2 fixpack 12.
We're having problems with UDF's that ran successfully under V7.2 but
are now failing with SQL04030N sporatically. Below is a listing of one
of the UDF's and the associated create function. The UDF is written
using Delphi 6. The UDF doesn't fail at the same point each time you
rerun the process. If anybody has had a similar situation, we'd be
more than interested in your resolution.
Thanks
drop function RIGHTJUSTIFY;
create function RIGHTJUSTIFY (varchar(4000))
returns varchar(4000)
external name 'e:\dmisapp\EWA\Common\Bin\dmis_funcs!23'
language c parameter style sql
deterministic fenced
no sql
no external action;
procedure RightJustify(aInStr, aOutStr : pChar; aInNull, aOutNull :
PShort;
aSQLState, aFuncName, aSpecName, aMsgTxt :
pChar); stdcall;
{ Moves all trailing spaces to the front of a string from the tail of
the string.
The length of the string does not change.
eg. RightJustify('3 Spaces ') returns ' 3 Spaces'
}
var
lStr : string;
lCounter : integer;
lTrailingSpaces : integer;
begin
try
if aInNull^ <gi_DB2_NullInd then // Is aInStr NULL
begin
lStr := String(aInStr);
try
lTrailingSpaces := 0; // Nope, then move spaces to front
for lCounter := length(lStr) downto 1 do //count the number
of trailing spaces
begin
if lStr[lCounter] <' ' then
break
else
inc(lTrailingSpaces);
end; //for
if lTrailingSpaces <0 then //if there were trailing spaces
begin
delete(lStr, length(lstr) - lTrailingSpaces + 1,
lTrailingSpaces);
lStr := StringOfChar(' ', lTrailingSpaces) + lStr;
end;
aOutStr := Strcopy(aOutStr, pChar(lStr));
aOutNull^ := gi_DB2_Not_NullInd;
except
aOutNull^ := gi_DB2_NullInd;
end
end
else
aOutNull^ := gi_DB2_NullInd;
except
on E: Exception do
begin
aSQLState := Strcopy(aSQLState, pChar(gs_SQLSTATE_38615));
aMsgTxt := Strcopy(aMsgTxt, pChar(Copy(E.Message,1,70)));
aOutNull^ := gi_DB2_Not_NullInd;
end;
end;
end;