[Lazarus] WebData

Michael Van Canneyt michael at freepascal.org
Sat Oct 16 12:24:59 CEST 2010



On Fri, 15 Oct 2010, ABorka wrote:

> On 10/15/2010 05:40, Leonardo M. Ramé wrote:
>> On 2010-10-15 14:24:48 +0200, Michael Van Canneyt wrote:
>>>> After removing the TSqlQuery and TSQLTransaction components from my app,
>>>> a new question came to my mind, in the case of complex inserts/updates
>>>> that involves more than one database table, is it possible to use
>>>> transactions?.
>>> 
>>> Hm. Not if you use the TSQLDBWebDataProvider. To do that, you would
>>> have to use TSQLSuery and a regular TWebDataProvider, and hook into
>>> the Before/after post events of the TSQLQuery.
>>> 
>>> But I'm certainly open for suggestions for improvements.
>>> 
>>> Michael.
>> 
>> Well, It's not an issue at all, I could create a stored procedure in
>> What do you think about this?
>
> But you can do these things already, I believe.
> I had multiple tables and some simple access rights to different people so my 
> SQL statements had to be different for everyone to get different records from 
> the tables.
>
> What I did is, I started from the first demo example found in 
> fcl-web/examples/webdata/demo/
>
> and created ONE action called "CRUD" that handles all the crud request from 
> the extjs clients. However, I am passing some additional parameters that 
> specifies which table is to be used and what needs to be done (Create, Read, 
> Update, Delete). From the session I got who is the user, so I was able to 
> prepare the proper SQL statements myself.
>

Is there any chance to put this in a kind of component that does most of the 
boilerplate work ? I would imagine 2 events:

OnGetConnection = Procedure (Sender : TObject; Var AConnection : TSQLConnection) of object;
OnGetQuery = Procedure (Sender : TObject; UpdateKind : TUpdateKind; SQL : TStrings); of object;

Michael.


More information about the Lazarus mailing list