#1 2014-07-07 10:15:02

Pyjama
Member
Registered: 2014-07-07
Posts: 9

Delete all entries in table

Hi all,

i just want to delete all entries from the database table by pressing a button. That's why i don't do it manually.

I tried to use the following code:

Client.Delete(Record);

and also

Client.Delete(Record, ID);

and

Client.Delete(Record, 'id=?', ['']);

I get an error which says that the version 'delete' is overload.

Anyone has an idea how i can delete all entries in a table easily with mORMot?

Thanks.

Offline

#2 2014-07-07 12:39:31

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

Re: Delete all entries in table

I recommend do this on the server side (via a service, may be), not on the client side, for safety reasons.

Then you can just execute the following SQL:

Server.Delete(TSQLMyRecordClass, 'id>0');

Offline

#3 2014-07-08 12:33:07

Pyjama
Member
Registered: 2014-07-07
Posts: 9

Re: Delete all entries in table

Thanks, works well.

So I can't use it without any parameters like

Server.Delete(TSQLMyRecordClass);

right?

I always have to insert parameters?

Offline

#4 2014-07-08 15:34:33

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

Re: Delete all entries in table

Yes.

There is no such method like

Server.Delete(TSQLMyRecordClass);

But I suspect that the following works:

Server.Delete(TSQLMyRecordClass, '');

Offline

Board footer

Powered by FluxBB