#1 Re: mORMot 1 » Question about RESTful ORM Server » 2014-11-20 20:40:15

No real need for that for examples, for real applications you are just few steps away from real Windows Service.
The most simplistic approach to show and test some functionality is to do console applications, which do not have GUI overhead.
Console application is the most "natural" way to code and test prototype which could be later "wrapped as real" Windows Service.
You can even leave them as that and run them from Windows scheduler...

#2 Re: mORMot 1 » Failed tests when running "TestSQL3" » 2014-11-19 03:35:58

For URI problem you can read this explanation.

I did not test this TestSQL3Register on Windows 8, but if it fails, then run it from administrator console (Win button + X -> Command Prompt (Admin)).
This helped me when I registered custom URI via netsh with http.sys for some .NET application.

#3 Re: mORMot 1 » Should I use mORMot Framework? » 2014-11-18 14:01:09

restneophyte wrote:

We are thinking of using Amazon S3 for our data storage and a SQLite database.

If I understand correctly you want to host SQLite database in Amazon S3? This is not possible, because you have no live control of backend database, you just use HTTP API to manipulate data and this could be done with any application which is capable to communicate via HTTP.

If you want to have all control of your software and database then Amazon EC2 service is for you.
If you want to have remotely real (RDBMS) database (MS SQL, MySQL...) with native access then you use Amazon RDS service.

In each three options you can use capabilities of "ordinary" Delphi libraries or use mORMot libraries (best for full EC2 solution).

#4 Re: mORMot 1 » hello world mustache » 2014-05-08 19:52:47

You are simply the best smile. I like your comparison and explanation about what really matters, real application versus some "academic calculation" as is Mandelbrot computation...

#5 Re: mORMot 1 » OFF-TOPIC: Merry christmas... » 2013-12-26 11:47:08

Vesel Božič (one day to late smile) in srečno novo leto 2014.

#6 Re: Low level and performance » RLINK32 alternative? » 2013-11-20 21:27:14

Hm, maybe combination of both (RC + translate on demand) would worked with some "load trick", because translations should be on one place and here will be used for i18n Sisulizer solution (which natively works via resource strings).

In my personal projects I already use your implementation of i18n with success smile, but this badly written (not by me smile) huge application is "my daily work"...

Thanks for tips, based on them I have some new ideas smile.

P.S.: I think that moving resourcestring in several pas units will not help, because in the end is all put in one DRC file and after that it fails.

#7 Low level and performance » RLINK32 alternative? » 2013-11-20 21:07:27

Leander007
Replies: 2

Hi,
does anybody knows RLINK32.DLL alternative (maybe patched one) or maybe who knows detailed info about E2161 Error: RLINK32: Too many resources to handle.
On net there is no "real answer or solution" about this problem, beside "refactor your code to use DLL-s".
After reading post on qc.embarcadero.com, I'm not sure is RLINK32 buggy or what? Is there some known workaround if you don't have possibility to do huge refactoring of program?

In my case we have huge legacy application with lost of 3rd components, which outputs ~90 MB executable (build with Delphi 2007). Application was localized with in-house solution, which replaced const texts in pas files, so rebuild of it was needed for each localization on proper PC (different code page).

Now I tried to replace all const declarations to resourcestring (> 7500) to use other localization tool and this error happens.
It is really frustrating because there is not known limit (at least not publicly) about resources.
Message "Too many resources to handle" does not help at all. What that means? Count of resources, size of all resources?
Is this limitation of RLINK32 or WINDOWS PE or is this just plain bug "living" in RLINK32?

Does anybody knows something about this issue, any help is appreciated?

#8 Re: mORMot 1 » Newbie coming from RtcSdk/Datasnap » 2013-11-05 19:17:36

Hi,
there is a lot of topics with headline "Newbie..." or something similar, so gather knowledge using search on this forum.
This kind of question has been asked many times.

Second, look through samples in source code and try it out.

#9 Re: mORMot 1 » Compress a File » 2013-03-11 19:23:31

Look at example "06 - Remote JSON REST Service".

#10 Re: mORMot 1 » How to clone mORMot repository? » 2013-02-23 21:57:51

Cloning is not allowed, you must download zip and sync it to your favorite source control (fossil, subversion, git...).
I'm doing this way.

#11 Re: mORMot 1 » Too many : ( ) : params » 2013-02-19 12:53:11

At SynCommons.pas you have

MAX_SQLFIELDS = 64;

Change this value according to this text:

MAX_SQLFIELDS default is still 64, but can now be set to any value (64,
128, 192 and 256 have optimized fast code) so that you can have any number
of fields in a Table

#12 Re: mORMot 1 » Suggestions for improvement » 2013-02-18 19:58:28

I can share your thoughts about frustration that some code is hard to understand and that it lacks "full blown tutorial examples", but you must understand that this is 99.99% work of single person (Arnaud and he missed to point this out smile) and that majority is done in his spare time.
If you take into consideration that this framework is evolving very fast (sometime I get feeling that to fast smile), it is hard to cope with all subtasks at once (examples, unit tests, documentation).
Community (we all in this forum) which test mORMot on daily bases (e.g. they use it in "production code"), could help with this.


P.S.: I have done real world application with mORMot successfully, but it is based on out of date version (more then year) of the library and I must "teach myself again" to return on current track (I was out for a while) smile.

mORMot is very much alive and kicking beast smile.

#13 mORMot 1 » mORMot and AnyDAC » 2013-02-06 10:51:49

Leander007
Replies: 4

Embarcadero bought AnyDAC.
Maybe would be fine to have a "wrapper" to this "DB universal layer" in future too.
I hope that AnyDAC would be available to Delphi Pro users too (Marco Cantu words about that:"we are trying to be a little more flexible in terms SKUs and versions"), to be really useful.
I only don't know what will happen with FPC/Lazarus support (Delphi does not compile for Linux yet)?!

#15 Re: PDF Engine » How to draw a line below table header » 2012-11-29 14:49:16

Please look first report example in MainDemo (SQLite3/Samples/MainDemo) at procedure TFileRibbon.CreateReport in FileClient.pas.
Play a little bit with TGDIPages properties and methods. That way you will quickly see what is possible "out of the box".

#16 Re: PDF Engine » Page counter » 2012-11-12 19:46:55

Hi, You should use:

AddPagesToFooterAt('Page %d/%d',RightMarginPos);

#17 Re: mORMot 1 » Main Demo error » 2012-10-09 16:59:34

carlos wrote:

also, Where do I get the SQLite obj files?

You can build it from sources with C compiler (e.g. c.bat uses bcc32) or download stable version of mORMot from "Downloads" which includes compiled obj files.

#18 Re: mORMot 1 » Memory leak using interface implementation ISQLDBRows and SQLite3 » 2012-09-20 12:08:40

Sorry for bothering you, that was my mistake smile.
I know when the interface goes out of scope.
I didn't really look the source code about relationship between locDB and rows (in this case).
So I didn't realized importance of "destruction" sequence.

#19 mORMot 1 » Memory leak using interface implementation ISQLDBRows and SQLite3 » 2012-09-20 09:44:24

Leander007
Replies: 2

Hi, I noticed that interface implementation of next code produces memory leaks:

var
  locDB: TSQLDBConnectionProperties;
  sql: RawUtf8;
  rows: ISQLDBRows;
begin
  locDB := TSQLDBSQLite3ConnectionProperties.Create(StringToUTF8('someDB.db'),'','','');
  try
    sql := 'select someColumn from someTable where...';
    rows := locDB.Execute(sql,[]);//* produces memory leak    
    while rows.Step do //* and each step produces memory leak too
    begin
	  (...)
    end;   
  finally
    locDB.Free;
  end;
end;

and this does not:

var
  locDB: TSQLDBConnectionProperties;
  sql: RawUtf8;
  rows: TSQLDBStatement;
begin
  locDB := TSQLDBSQLite3ConnectionProperties.Create(StringToUTF8('someDB.db'),'','','');
  try
    sql := 'select someColumn from someTable where...';
    rows := locDB.NewThreadSafeStatement;
    try
      rows.Execute(SQL,true);
      while rows.Step do
      begin
	(...)
      end;
    finally
      rows.Free;
    end;
  finally
    locDB.Free;
  end;
end;

#20 Re: mORMot 1 » Generating mORMot PDF documentation » 2012-09-05 08:57:32

Of course it is, but you must bring it to "life" SynProject (or download zip file), which does it smile.

#21 Re: Delphi » "Trop c'est trop" - No Client-Server for XE3 PRO users » 2012-08-29 17:48:44

I read the forum and people are untitled to be angry, with all WinRT mess (Microsoft "super idea") I was reading about few days ago, now Embercadero wants to win in stupidity (greed has no limits and no brain).

I'm already "mini supporting" Lazarus-FPC team (I bought the book "Lazarus the complete guide" smile) even I don't use it already (I just tested it).
Do you have any plans to officially (not just partially) support mORMot for FPC? I believe that first target would be the Windows and that won't be so hard. Harder would be for Linux, which is very interesting target (as you already said it) for server part.

#22 Re: Delphi » xxm: an alternative platform to build dynamic websites with Delphi » 2012-08-29 10:37:06

I have thoughts about "pascal web collaboration" too, but for different aspects of usage.

1. You may translate your whole pascal code to the javascript+html+css, but this limits you to specific applications (maybe with PhoneGap you can go further).
2. You may have server and client written in pascal (Delphi, Lazarus-FPC), but client is translated to "web languages" (javascript...). Here you can have two ways of implementation scenarios: first both server and client (GUI) live on same machine as one logical application (in FPC case you can port this to many platforms, e.g. game on Android, ) and second as true client/server model where you need live connection to the Internet.
3. Write both parts in native way (server in pascal and client in "web languages") and glue them together with some prepared library (communicating objects written in pascal and javascript). Even without "glue library" this "old fashion" approach is not so missed for huge projects, where you don't want to mix presentation and business layer. Sometimes is better (for better control) to write "web code" at your favorite editor (or full blown IDE) and prepare some javascript to interact server data (mORMot JSON) with client GUI.

I really don't know what is best, but for my opinion there is no clean winner for all cases.

In case of web application frameworks we can take this link as starting point.
I did not test neither of this frameworks yet in sense ease of development and customizations, performance... Takes time to do that for all of them (list is growing every year) smile.

OP4JS is now SmartMobileStudio (no real business demos on their page, just "games"), Morfik looks bigger every day, uniGUI and p2js look very nice for business applications (uniGUI demos, p2js demo).

@ab: Why did you choose SmartMobileStudio in favorite to others (which are mostly not payable at "start")?

#23 Re: Low level and performance » Circular reference and zeroing weak pointers » 2012-06-22 12:11:36

This code (direct casting of interface to TObject):

{$ifdef UNICODE}
    result := aValue as TObject; // slower but always working
{$else}

from SQLite3Commons.pas at

function ObjectFromInterface(const aValue: IInterface): TObject;

does not compile for Delphi 2009.

See at this stackoverflow issue.
The user said that Hallvard's hack was not working with him, but I tested your hack with Delphi 2009 and it seems that it works, so the define should be changed for Delphi 2009 as it is for older Delphi compilers.

#24 Re: mORMot 1 » tsqltable, tdate and localization » 2012-05-17 10:04:59

1. If you use "real localization" (e.g. multi language support), then you should follow the localization rules (resourcestrings...) and use SQLite3i18n unit and proper functions from it. Then you have many possibilities to set the current language and the regular formating (windows regional settings) will be used automatically (as already said by Arnaud), if you don't provide other option.

2. If you don't use "real localization", but hard coded one, then you may use TSQLTable.ExpandAsString function (which is used e.g. by TSQLTableToGrid), which in turn uses i18nDateText function. And to this function (which is in SynCommons unit) you can assign your custom implementation.

In 1. case assignment of i18nDateText is already done behind the scene, you must just set the current language, so usage of e.g. TSQLTableToGrid will be already in localized form.

#25 Re: mORMot 1 » tsqltable, tdate and localization » 2012-05-16 17:03:13

As already said you should assign i18nDateText global function with your implementation. If you use SQLite3i18n unit then this is relevant for you (extracted commented code from source):
   

    /// format string used to convert a date value to a text
    // - the expected format is the one used by the FormatDateTime() function
    // - the current system format, depending on the current language, is used,
    // then overriden by a DateFmt= entry in the .msg file content
    DateFmt: string;
    /// format string used to convert a time value to a text
    // - the expected format is the one used by the FormatDateTime() function
    // - the current system format, depending on the current language, is used,
    // then overriden by a TimeFmt= entry in the .msg file content
    TimeFmt: string;
    /// format string used to convert a date and time value to a text
    // - the expected format is the one used by the FormatDateTime() function
    // - the current system format, depending on the current language, is used,
    // then overriden by a DateTimeFmt= entry in the .msg file content
    DateTimeFmt: string;
   

#26 Re: mORMot 1 » Messenging between Apps » 2012-05-15 15:55:06

The simplest solution is via SOA way.
You can look how is done at sample 06 - Remote JSON REST Service or 14 - Interface based services.

#27 Re: mORMot 1 » sample 10 - background http service » 2012-04-12 10:57:28

This is more or less the same stuff (about core functionality) as Arnaud implementation of service when you use global assign of service handler (what I explained in previous posts).
But this is done in procedural way.
Nice for quick and dirty job, but I liked more when this is wrapped (and easily enhanced) in class smile.

#28 Re: mORMot 1 » sample 10 - background http service » 2012-04-11 08:53:34

As I see you reverted again to the "unsafe version" (my opinion, because your example app and my example app without global assignment do not work properly on my computer).
Definitely some user will ask for solution again.

It would be better to at least put the safe version code in comments (e.g. If it does not work uncomment this...).

#29 Re: mORMot 1 » sample 10 - background http service » 2012-04-11 08:30:53

This is the most "dangerous case" when something is working in one situation and not for other.
Implementation with pure pascal (no assembler magic) is just playing safe and works in all cases.

#31 Re: mORMot 1 » sample 10 - background http service » 2012-04-11 07:34:58

ab wrote:

In fact, the error was that there was already a property of TService named SERVICENAME (ServiceName).

I didn't notice this smile. For me it looked better anyway, because I don't care about old compilers smile.

ab wrote:

In fact, the trick of ServiceControlHandler() with a global was not even necessary.

For me it was necessary because stopping of service didn't worked well  (didn't worked at all) as I said already.

#32 Re: mORMot 1 » How can I convert my server console application in a service? » 2012-04-10 21:21:15

Arnaud missed the first problem with constants (is not yet corrected in source, all my changes are not there), so if you made corrections as I suggested (http://synopse.info/forum/viewtopic.php?pid=3683#p3683) then it must worked .
Esmondb obviously did follow both suggestions (I'm using this as daily practice, so it is WORKING).
I'm repeating myself to often smile.

#33 Re: mORMot 1 » sample 10 - background http service » 2012-04-10 21:07:54

Arnaud, I saw your corrections of code, but this was not enough in my case (and I think in many other cases too, newer compilers).
I don't know why, but global constants (line 50) SERVICENAME and SERVICEDISPLAYNAME where not set (they were blank '') on class creation, so I moved them to the class section as already discussed and this works well (they are set as expected):

TSQLite3HttpService = class(TService)
  public
    const
    SERVICENAME = 'mORMotHttpServerService';
    SERVICEDISPLAYNAME = 'mORMot Http Server Service';
  var
(...)
if param='/install' then
          TServiceController.CreateNewService('','',TSQLite3HttpService.SERVICENAME,
              TSQLite3HttpService.SERVICEDISPLAYNAME, paramstr(0),'','','','',

#34 Re: mORMot 1 » sample 10 - background http service » 2012-04-10 11:08:40

This was already discussed and I did provide solution. I think Arnaud missed this answer and did not yet integrate this in source.

#35 Re: mORMot 1 » How to properly create a database model ? » 2012-04-03 11:01:34

Yes, MainDemo is not ok as is for Delphi 2009, see the workaround.

Summarized info about my personal experience about mORMot "usability" in general and from commercial point of view.

#36 Re: mORMot 1 » UpdateFromServer use » 2012-03-04 11:20:16

As I know it is not yet implemented, look here for similar question,answer.

I needed too some small "update on retrieved data" (changing inner JSON content), so I changed the source (in not universal, nasty way) a little bit to do that smile, but I'm waiting too for the official implementation by Arnaud.

#37 Re: mORMot 1 » Comparison between commercial apps » 2012-03-01 10:48:33

You're welcome smile.

If you really like to type (opposite to drag&drop smile), then surely you like low level stuff too, this is heavily used in mORMot core.
So enjoy learning it smile.

#38 Re: mORMot 1 » Comparison between commercial apps » 2012-03-01 10:28:06

If you like to be in control then mORMot is surely for you and if you wish to learn "some tricks" then you are again on the right road smile.
I'm too just "an user" (I contribute for now only found bugs or corrections of bugs) of this framework and is really nice when you have a need for SOA approach, but not very good at GUI (VCL) part.
I made my own "smart grid", which has been project for itself, so it is not really good think if you are in hurry (learning this framework through commercial project), you will burn yourself, I'm almost 99.999% sure smile.
But if you have time to learn, don't hesitate with mORMot.
Project is more or less stabile, but because it's evolving "beast" new bugs could be introduced, that is logical.

My personal project does not use encryption, so I can't tell you about that.
But I'm heavily using threads, COM ports, mORMot ORM part (strong typed objects) and table part (TSQLTable), named pipes, i18n, compression, windows services, reporting (PDF)...

...and it works very well. If I find the bug I try to correct and report it, or at least report it.
At first I found a lot smaller bugs, but now product is more stabile and bugs are not any more so common (at least in core part).
In commercial projects when I find some version of mORMot stabile I stick with it (if I don't need new features of course) and testing new checkins only on "test polygon".

#39 Re: mORMot 1 » Comparison between commercial apps » 2012-03-01 09:54:02

By the way, DISQLite3 could be bought with sources too, price is 299.99 €.
This can be too much for hobbyist, but if you are in commercial world and your existing application heavily relay on DISQLite3 is worth buying it with sources. 


Just my opinion smile.

#40 Re: mORMot 1 » Comparison between commercial apps » 2012-03-01 09:47:58

Hello, see this post.

Major drawback (for you) can be absence of TDataSet approach, which is available in DISLite3 product.
mORMot is much larger "beast" but with totally different approaches which is best for building huge and "difficult" (SOA) applications (which in turn have long development cycle anyway).

#41 Re: mORMot 1 » How can I convert my server console application in a service? » 2012-02-29 14:19:24

This was tested with current code as basis and compiled with Delphi 2009, running on Vista smile.

#42 Re: mORMot 1 » How can I convert my server console application in a service? » 2012-02-29 14:12:10

I just checked example. HERE IS THE SOLUTION!
There are two issues, one is minor related to the automatic assigning of handler (I didn't investigate further, because "basic pascal" works always as I told already in previous posts) and the other to "not assigned global constants in class creation" (I think compiler stuff, Arnaud will know about this better smile ).

So, Arnaud if you can include this corrections:
1. Problem: Constants should be moved to the class (it is better looking anyway smile, more object approach smile):

TSQLite3HttpService = class(TService)
  public
    const
    SERVICENAME = 'mORMotHttpServerService';
    SERVICEDISPLAYNAME = 'mORMot Http Server Service';
  var
(...)

if param='/install' then
          TServiceController.CreateNewService('','',TSQLite3HttpService.SERVICENAME,
              TSQLite3HttpService.SERVICEDISPLAYNAME, paramstr(0),'','','','',

2. Problem:
then next part of code, should be included\changed. Asm magic does not properly stop service, but startup and communication was ok with it:

procedure ServiceControlHandler(CtrlCode: DWord); stdcall;
begin
  Service.DoCtrlHandle(CtrlCode);
end;

{ TSQLite3HttpService }

constructor TSQLite3HttpService.Create;
begin
  inherited Create(SERVICENAME,SERVICEDISPLAYNAME);
  ControlHandler := ServiceControlHandler;
(...)

#43 Re: mORMot 1 » How can I convert my server console application in a service? » 2012-02-29 00:12:58

Your TService does work in all cases if control handler is explicitly assigned (not via "assembler" trick, this fails) as is already stated by my previous post:

winService.ControlHandler := ServiceControlHandler;

In my example has been used SQLite3Service.TService not SvcMgr.TService.

#44 Re: mORMot 1 » How can I convert my server console application in a service? » 2012-02-28 18:48:20

I didn't look at "10 - Background Http service" example, but maybe is there some issue which is explained here.

I'm having same source code at "3" different application implementations (different compiler defines) and works just fine (at least for named pipes at mORMot level):
1. For simple testing I implemented first as all in one GUI exe.
2. Then I separated on client\server part, client as GUI exe, server as console app.
3. At last I implemented server part as windows service too.


My favorite approach is not via sub-classing, but as composition (TService is just member).
So in short you need somewhere next basic things (approach is similar to the SvcMgr.TService):

winService: TService;
(...)
procedure ServiceControlHandler(CtrlCode: DWord); stdcall;
begin
  winService.DoCtrlHandle(CtrlCode);
end;
(...)
winService := TService.Create(SERVICE_NAME, SERVICE_DESC);
winService.ControlHandler := ServiceControlHandler;
winService.OnStart := StartHandler; //* In this handler you implement mORMot startup
winService.OnStop := StopHandler;  //* ...here the mORMot shutdown
winService.OnResume := StartHandler;
winService.OnPause := StopHandler;
ServicesRun; //* this is blocking function, here you put control to the windows service manager
(...)

#45 Re: mORMot 1 » Client-Server remote access to any method (DataSnap-like) » 2012-02-18 10:52:33

My second thought was that this number is the count of calls and even in that case 6 million is huge number comparing to "size" of core source code.
You have done really excellent work smile.

#46 Re: mORMot 1 » Client-Server remote access to any method (DataSnap-like) » 2012-02-17 12:30:33

ab wrote:

I think your code is leaking memory.

6,000,000 regression tests are running every time I commit the source code, and with no memory leak detected (with FastMM4).

Use FastMM4 memory leak features to guess where the leak comes from in your code.

Hm, 6 million tests, this must be wrongly counted, because line count of all your .pas sources is less then 400000 smile.

For memory leakage from Delphi 2006 up next simple setting could be used as first line in dpr file:

begin
ReportMemoryLeaksOnShutdown := True;
(...)
end.

This is usually enough, at least for me.

#47 Re: mORMot 1 » Demo code? » 2012-02-03 14:06:47

See this topic. Point 2 and 5. You have many samples (demos) at Samples folder, but the largest (most comprehensive) is MainDemo.

#48 Re: mORMot 1 » How to obtain the auto generated primary key value after an insert » 2012-01-29 13:02:30

ab wrote:

I do not get why TSQLRecordMany is not "optimized from the DB POV"?

Naturally when you design the database relations first (not ORM tool), then you connect e.g. two tables with foreign keys (if it is feasible on the chosen database, if not then the TSQLRecordMany should be used) and put some rules on it (cascade delete...). So what is here better, you have two tables and you have some automatic rules on the lowest level, this is really good if you are connecting to the database with other tools too.

ab wrote:

If you have some more precise design patterns, I'm interested.

Not yet, because current project (simple layout, single connecting tool to the db) which I'm working on, does need none of discussed.

ab wrote:

IMHO attributes are not the ultimate magic either. They are not good enough to describe most complex DB layouts in the wild.

I'm aware of that. But for plain description of table (1:1) is enough, e.g. from the serialization point of view (like xml serialization) when you design your model from scratch (CreateMissingTables), not for connecting to some existing database, which could be complex...
I'm aware too, that this is only syntactic sugar, not a real feature, because such behavior, could be described as is with TSQLRecordExternal and even be read from some external source (xml files, schemas). For the last one, you are pointing out generated Pascal source, what could be very cool smile (JSON is fine for data, but not for human editing if this is introduced too).

ab wrote:

I've a big Oracle project to reverse, with years of data and several DB layout patterns used - I think it will be a good candidate for this.

. That would be the ultimate test smile.

#49 Re: mORMot 1 » How to obtain the auto generated primary key value after an insert » 2012-01-27 16:15:54

Yes, this is the case (and not the rare one) what I'm pointing out. In real world database servers, you are not the only one who is accessing data. If you are having the benefit to have all control, that this is really rare case and you are really lucky smile.
So maybe is the time to push this forward (this is not only about the IDs) and do some lower layer which is tunned to the ground. So it is really opposite to the e.g. TSQLRecordMany approach (works everywhere but it is not optimized and not nature from the db point of view). It is really more work to be done, but will be better tuned if there is some abstraction introduced and lower level sql (or other dialect) is wrapped whit it. 

Another case whit this is, that we somehow introduce more descriptive way of all data properties. Not only, if this is the unique field (stored), but all the info, is this unique field, how long it is (chars, this is not only database info, it is useful for automatic gui design too) etc. Whit newer delphis this could be easily done with attributes, but with older ones some structure (record or class) should be introduced.

Arnaud what are you thinking about this?

#50 Re: mORMot 1 » How to obtain the auto generated primary key value after an insert » 2012-01-26 12:43:29

I'm not really in database programming, but I think that for each "real" database engine could be specified best solution (Firebird has generators, MS SQL has @@IDENTITY, SQLite3 has ROWID...) for auto generated IDs. This approach is made with many frameworks, which just abstracts low level database specifics with high level objects.

Some other way is to do with common sql, issuing select statement immediately after insert as a "batch":

INSERT INTO Table1 (Field1) VALUES (Value1);
SELECT max(ID) FROM Table1;

But for the second one, I think that all engines does not allow batch queries (exotic ones and if I remember correctly I couldn't do batch queries with IBX components for Firebird database) and atomicity is in question too (locking, transactions ?!).

Board footer

Powered by FluxBB