#1 2014-05-10 01:52:39

dansot
Member
Registered: 2012-11-12
Posts: 25

translate SQL statement

How would I represent this in MORMot (SQLite3)?

UPDATE info SET b=true WHERE a=1;

Right now I'm doing a CreateAndFillPrepare and then looping through the result set and updating each record.  I'm just checking to see if there is a method I am missing.

Offline

#2 2014-05-10 12:56:29

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

Re: translate SQL statement

In fact, such a feature did exist at low-level (via EngineUpdateField abstract methods), but not at high-level

I have just added TSQLRest.UpdateField() overloaded methods to update a single field in a record.
See http://synopse.info/fossil/info/d2aaf10a69

You could now write either:

  Client.UpdateField(TSQLRecordInfo,'a',1,'b',true);       // with variant
  Client.UpdateField(TSQLRecordInfo,'a',[1],'b',[true]);  // with a parameter array

Offline

#3 2014-05-10 23:23:06

dansot
Member
Registered: 2012-11-12
Posts: 25

Re: translate SQL statement

Thanks!

Offline

#4 2014-05-11 07:19:02

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

Re: translate SQL statement

Note this method will work for SQL backends (SQLite3, Oracle, PostgreSQL, MSSQL, MySQL, and others) but also for in-memory TObjectList (without SQL) and also for MongoDB (with its proper syntax).

Offline

Board footer

Powered by FluxBB