0

In my activepivot solution, I have a store containing the desk and the currency for each trade.

For example:

  • 1, eur, DeskA, 10
  • 2, eur, DeskB, 18
  • 3, gbp, DeskA, 17
  • 4, usd, DeskA, 54

I have a lot of queries where I want to find all the records that contain deskA and a particular but changing currency.

To execute those three queries :

  • DeskA, eur
  • DeskA, usd
  • DeskA, gbp

I would use a prepared statement to avoid parsing the query many times. Is there any equivalent in activepivot ?

Jack
  • 145
  • 1
  • 1
  • 11

1 Answers1

0

This is how you can define the precompiled query

IRecordQuery query = new RecordQuery("storeName", Equal("attributeUsedForSearchHere").parametrized(0), Arrays.asList("attribute2", "attribute3", "attribute4"));
compiledQuery = datastore.getQueryManager().compile(query);

This is how you can execute it

ICursor cursor = datastore.getQueryManager().execute(compiledQuery , new Object[] { valueOfAttributeUsedForSearchHere} );

basically above you use attributeUsedForSearchHere as an attribute that you'll use for search based on an equal condition; of course you may have several attributes.

then once the query is executed you can read the other attributes (attribute2, 3 and 4) like follows:

cursor.getRecord().read("attribute2")
jolivier
  • 7,380
  • 3
  • 29
  • 47
tuxmobil
  • 238
  • 3
  • 10