Migrating from ADO to FireDAC - MS SQL Server

Migrating from ADO to FireDAC - MS SQL Server
Yet another tidbit.  Default stored proc parameter sizing.

The old parameter passing to the stored procedures is done with array of const and variants.  No issues with that, until my xml logging feature had the mother of all stack traces, and exceeded 9k bytes in total xml size, upon which the assignment of TFDParam.Value complained that TFDParam.Size was 8002 bytes, and the size of the string was bigger than that.

vtUnicodeString:
begin
   p.DataType := ftString;
   p.Value    := String(ConstParams[ix].VUnicodeString); //Size barf
end;

Quick and dirty fix... For the future, I intend to lose the array of const and move to more explicit parameter encoding.

vtUnicodeString:
begin
   p.DataType := ftString;
   s := String(ConstParams[ix].VUnicodeString);
   len := Length(s) * SizeOf(Char);
   if Len > p.Size  // Autosize for XML
   then p.Size := Len + 2;
   p.Value    := s;
end;

#FireDAC

Comments