Board index » delphi » Paramterized Queries - unsupported type

Paramterized Queries - unsupported type

I would like some conclusive answers on whether it is impossible to have
a paramterized query where a parameter is of type ftMemo.

Although it is possible to create a TParam object of type ftMemo it is
impossible to assign data to the TParam object. An error stating that it
is an unsupported type when using the SetData method occurs.

It seems that Parameters are limited to 255 bytes in size. If this is
the case I would like to know why, since it would really be great to be
able to do Insert and Update Queries with Parameters of data type
ftMemo.

If any one out there has an answer to this question I will be eternally
grateful since I have also experienced the problem in VB.

Thanks Cliff Saunders
gerv...@mail.icon.co.za

 

Re:Paramterized Queries - unsupported type


Quote
Cliff Saunders <cl...@corp2.mck.co.za> wrote:
> I would like some conclusive answers on whether it is impossible to have
> a paramterized query where a parameter is of type ftMemo.

In its simplest form, the answer is "No, you cannot".

Quote
> Although it is possible to create a TParam object of type ftMemo it is
> impossible to assign data to the TParam object. An error stating that it
> is an unsupported type when using the SetData method occurs.

Well, you can at runtime, but not at design time. At least, I cannot.
It's the same with ftBytes, ftVarBytes, ftAutoInc, ftBlob, ftGraphic,
ftFmtMemo, ftParadoxOle, ftDBaseOle, ftTypedBinary. I don't think I'm
violating some copyright by reproducing one of the many functions in
the source code for TParam illustrating that:

function TParam.GetDataSize: Word;
begin
  case DataType of
    ftUnknown: DBErrorFmt(SFieldUndefinedType, [Name]);
    ftString: Result := Length(FData) + 1;
    ftBoolean: Result := SizeOf(WordBool);
    ftBCD: Result := SizeOf(FMTBcd);
    ftDateTime,
    ftCurrency,
    ftFloat: Result := SizeOf(Double);
    ftTime,
    ftDate,
    ftAutoInc,
    ftInteger: Result := SizeOf(Integer);
    ftSmallint: Result := SizeOf(SmallInt);
    ftWord: Result := SizeOf(Word);
  else
    DBErrorFmt(SFieldUnsupportedType, [Name]);
  end;
end;

Quote
> It seems that Parameters are limited to 255 bytes in size. If this is

And that's correct too. TParams' ReadBinaryData(Stream: TStream) and
its counterpart WriteBinaryData use a Buffer for the data defined
as... array [0..255] of char.

Quote
> the case I would like to know why, since it would really be great to be
> able to do Insert and Update Queries with Parameters of data type
> ftMemo.
> If any one out there has an answer to this question I will be eternally
> grateful since I have also experienced the problem in VB.

This is Delphi2, btw. With D1, I can imagine that beside this, you hit
the standard limitation on strings. While this is gone now, I tried
using AssignField to set the properties right, then something like
        Query1.Params[0].Text := Memo1.Text;
As Text is of type strings, Params[0].DataType will be set to
ftString. While this compiles OK, it gives a runtime-error "capability
not supported", a conversion error I guess.

I'd like to see it as a bug, but I think they'll yell at you that it's
a feature :-))

Heads up!

Jasper

PS: please take into consideration
- when replying, I just think I know;
- when asking, be sure that I don't.

Other Threads