🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.delphi.databases
Article #193

Re: How to secure database transactions?

#193
From: M.H. Avegaart
Date: Thu, 13 Apr 2000 00:00
85 lines
3971 bytes
I can see you copied this from the example...
The example shows transactions AND cached updates. You are not using cached
updates, so you would only use:

Database.StartTransaction;
try
  Query.ExecSQL;
   Database.Commit;
   Ok := True;
except
   Database1.Rollback;
   Ok := False;
end;


"Tim" <tim.hoebeek@NOSPAM.advalvas.be> schreef in bericht
news:pmf9fsghf7fo4tlk7jplcch8ieb74t13it@4ax.com...
> Hi,
>
> I'm trying to use a database without any visual (or other) interaction
> with the user. I often have bundles of SQL statements that should all
> be executed or, when this is not the case, none and start over again.
>
> Therefor I looked into StartTransaction, Rollback, Commit,
> ApplyUpdates and the like, but I don't fully understand what I've
> found in the help.
>
> The following is the code I currently have, but I have some questions
> about it:
>
> procedure StoreData (bits : boolean; tablename, fieldname : string;
>                      byteVal : byte; BitVal : boolean);
> begin
>  with Form1.PutQuery do
>   begin
>    Close; file://closing the query, in case it was still open
>    Database.StartTransaction; file://starting the transaction
> file://(this is the point used for
> file://a rollback)
>      with SQL do
>       begin
>        Clear; file://clearing the precious SQL statement
>        Add('INSERT INTO "'+tablename+'"("'+fieldname+'")');
>        if bit then Add('VALUES (:bitVal[i])') file://some bad coding
>               else Add('VALUES (:byteVal)'); file://the boolean
> file://indicates if it's a
> file://bit or a byte
>       end;
>    try
>      ApplyUpdates; file://Delphi tries to apply the updates
>      Database.Commit; file://a commit is done (when applyupdates
> file://succeeds)
>      OK := true; file://just a variable for checking
>    except
>      OK := false;
>      Database.Rollback; file://a rollback is performed when it
> file://didn't succeed
>      raise; file://the exceptions are raised
>    end;
>   CommitUpdates; file://the updates are commited again? why?
> file://is this true?
> {   ExecSQL;} file://is this still needed and why (not)?
>   end;
> end;
>
> I also don't know where the database part comes from
> (form1.putquery.DATABASE.x). In the help this is Database1.
>
> Of course I can add a TDatabase component, but given the syntax, this
> 'database1' is a child of a specific query and not Form1 in general.
>
> As you can see, I'm really lost here. If there's anyone who can help
> me, it would be greatly appreciated!
>
> This message has been cross-posted to several newsgroups, because
> there are problems with my ISP's newsserver and many posts don't make
> it over here. If you don't mind, I would appreciate a cc to
> tim.hoebeek@advalvas.be very much.
> Thank you for your understanding.
>
>
> Greetings,
>
>
> Tim.
Technical Details
Message-ID: <8d45g5$cq6$1@porthos.nl.uu.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <pmf9fsghf7fo4tlk7jplcch8ieb74t13it@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: ffff5,f1c16399821b6318,start
X-Google-Attributes: gidffff5,public
X-Google-Thread: fd817,f1c16399821b6318,start
X-Google-Attributes: gidfd817,public
X-Google-Thread: 10baee,f1c16399821b6318,start
X-Google-Attributes: gid10baee,public
X-Google-Thread: f8e31,f1c16399821b6318,start
X-Google-Attributes: gidf8e31,public
From: "M.H. Avegaart" <avegaart@NOSPAMmccomm.nl>
Subject: Re: How to secure database transactions?
Date: 2000/04/13
Message-ID: <8d45g5$cq6$1@porthos.nl.uu.net>
X-Deja-AN: 610597506
References: <pmf9fsghf7fo4tlk7jplcch8ieb74t13it@4ax.com>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
X-Complaints-To: abuse@nl.uu.net
X-Trace: porthos.nl.uu.net 955619653 13126 193.67.87.80 (13 Apr 2000 09:54:13 GMT)
Organization: UUNET-NL (http://www.nl.uu.net)
X-MSMail-Priority: Normal
NNTP-Posting-Date: 13 Apr 2000 09:54:13 GMT
Newsgroups: comp.lang.pascal.delphi.databases,comp.lang.pascal.delphi.misc,borland.public.delphi.students,alt.comp.lang.borland-delphi