#1 2017-12-01 05:03:17

tiger
Member
Registered: 2014-05-14
Posts: 11

How to add sql order by in CreateAndFillPrepareMany

i want to use sql order by in CreateAndFillPrepareMany,but when i do this:
Role := TSQLRole.CreateAndFillPrepareMany(Client,'ID = ? order by DispOrder',[],[aId]);
an error occurred:
20171201 20163660 ERROR     mORMotHttpClient.TSQLHttpClientWinHTTP(01736650) GET root returned 400 (Bad Request) with message  {  "errorCode":400,  "errorText":"Bad Request"  } stack trace API 0064002E 006F3D7B 006FE542 006FF111 006EBE58 006EC0FF 006EB0A6 007FDBE5 0073ECDB
20171201 20163660 EXC       EModelException {"Message":"TSQLRole.CreateAndFillPrepareMany(): FillPrepareMany() failure"} at 006EB0D0  stack trace API 0063E09F 0063E0C8 0040AE7C 77D56D4B 77D56BD7 006EB0D0 007FDBE5 0073ECDB
20171201 20163660 EXC       EModelException {"Message":"TSQLRole.CreateAndFillPrepareMany(): FillPrepareMany() failure"} at 006EB0D0  stack trace API 0063E09F 0063E0C8
20171201 20163660 info      mORMotHttpClient.TSQLHttpClientWinHTTP(01736650) TSQLHttpClientWinHTTP.Destroy
20171201 20163660 EXC       EModelException {"Message":"TSQLRole.CreateAndFillPrepareMany(): FillPrepareMany() failure"} at 006EB0D0  stack trace API 0063E09F 0063E0C8
20171201 20163660 debug     mORMotSQLite3.TSQLRestServerDB(01706750) TSQLRestRoutingREST.Error: {  "errorCode":500,  "error":  {"EModelException":{   "ClassName":"EModelException",   "Address":"006EB0D0 ",   "Message": "TSQLRole.CreateAndFillPrepareMany(): FillPrepareMany() failure"  }}  }
20171201 20163660 srvr      mORMotSQLite3.TSQLRestServerDB(01706750)   GET root/MyApp.GetPermissionTree SOA-Interface -> 500 with outlen=194 in 1595464 us

Offline

#2 2017-12-01 05:13:35

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: How to add sql order by in CreateAndFillPrepareMany

your ORDER BY statement seems to be correct. From the error message I guess it might doesn't related to the ORDER BY clause

Try remove "order by DispOrder" and try again to identify the source of the error first.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#3 2017-12-01 05:25:16

tiger
Member
Registered: 2014-05-14
Posts: 11

Re: How to add sql order by in CreateAndFillPrepareMany

remove "order by DispOrder", it will be ok.

Offline

#4 2017-12-01 05:37:44

tiger
Member
Registered: 2014-05-14
Posts: 11

Re: How to add sql order by in CreateAndFillPrepareMany

20171201 21322244 EXC       ESQLite3Exception {"ErrorCode":1,"SQLite3ErrorCode":"secERROR","Message":"Error SQLITE_ERROR (1) [select A.RowID AID,A.Name A00,A.Memo A01,B.RowID BID,C.RowID CID,C.Name C00,C.Leaf C01,C.View C02,C.IconCls C03,C.Expanded C04,C.RouteId C05,C.ParentId C06,C.DispOrder C07 from Role A,RolePermission B,Permission C where B.Source=A.RowID and B.Dest=C.RowID and (A.ID = ? order by DispOrder)] using 3.20.1 - near \"order\": syntax error, extended_errcode=1"} at 00757916

Offline

#5 2017-12-01 08:44:14

ttomas
Member
Registered: 2013-03-08
Posts: 135

Re: How to add sql order by in CreateAndFillPrepareMany

This is () hack
Role := TSQLRole.CreateAndFillPrepareMany(Client,'ID = ?) order by (DispOrder',[],[aId]);

Offline

#6 2017-12-01 15:05:15

Junior/RO
Member
Registered: 2011-05-13
Posts: 210

Re: How to add sql order by in CreateAndFillPrepareMany

I think that this is a bug

Offline

#7 2017-12-01 19:11:25

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

Re: How to add sql order by in CreateAndFillPrepareMany

Do you think that 'ID = ?' by itself does make sense in the context of TSQLRecordMany?

Offline

#8 2017-12-02 03:23:14

tiger
Member
Registered: 2014-05-14
Posts: 11

Re: How to add sql order by in CreateAndFillPrepareMany

thank @ttomas! it works.

Offline

Board footer

Powered by FluxBB