#1 2016-05-12 08:54:10

DigDiver
Member
Registered: 2013-04-29
Posts: 137

CreateAndFillPrepare and TRawUTF8DynArray

How to pass TRawUTF8DynArray as a parameter into the CreateAndFillPrepare method?

When I use this code:

json := RawUTF8ArrayToQuotedCSV(TestList);
TestItem := TTestItem.CreateAndFillPrepare(TestServer, 'UserID=? and TestID in ('+json+')',[ID]);

In the server stats too many items like this:

SELECT Fields FROM TestItem WHERE UserID=? and TestID in ('26251f02bf2b21621e5297280109405e','9e138417d45e3861d2e1ced1f1aecd98','85972f9771f0d101e7d23345de9091ca','9e72e03729466b547d2eb0df3284e65e','4c75495f5c3594366bb81db8cd92430a','a42e97f22fcf092a2d90a0dfa35f7a5c','b4ad5bd3207cdfab4292be0fd9e6078d','aa73aa046427e8e4579dcb40677a3b26','d1cf8af213338a6a9f4a20f39be61199','e006e51d831d310e5d9d4a0b82dffb67'): {...

I wold like to see

SELECT Fields FROM TestItem WHERE UserID=? and TestID in (?)

Offline

#2 2016-05-12 16:03:02

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,666
Website

Re: CreateAndFillPrepare and TRawUTF8DynArray

TestID in (?) is supported only on some databases, when binding a cursor as parameter.

Currently, this is not handled by the ORM, since it is not a feature available on all databases.
And, in fact, the number of items in the "in (...,...,...)" clause is a lot varying from one DB to another.

So as a workaround, you may execute several TTestItem.CreateAndFillPrepare requests in a loop, using only a small amount of items within the "in (...)" clause each time.

Offline

Board footer

Powered by FluxBB