Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 2 of 2 total |
Prepared statements in Delphi |
Tue, Apr 21 2009 8:01 AM | Permanent Link |
Jon Lennart Aasenden | I have several quite simple sql statements that are executed hundreds or thousands of times in my application.
I figured I could speed things up a bit by preparing the insert/update queries, but im unsure what happens after they are executed. For excample: I have a query object (created from code) that is setup like this: if MakeQueryObj(FMarkQuery) then Begin FMarkQuery.sql.add('UPDATE JTFiles SET state=:P_state where id=:P_id'); FMarkQuery.Prepare; end else Raise Exception.Create('Failed to create query object error'); The makequeryobj() function just created an instance of TEDBQuery and sets the session and database name automatically. The above query is then used as such: With FMarkQuery do Begin ParamByName('P_state').AsInteger:=ord(newstate); ParamByName('P_id').AsInteger:=id; ExecSQL; end; My question is, if I add the line: FMarkQuery.active:=False; ..afterwards, does this unprepare the query? If I leave it as it - is the target record locked until the next call? |
Tue, Apr 21 2009 11:22 AM | Permanent Link |
Fernando Dias Team Elevate | Jon,
> .afterwards, does this unprepare the query? No. If you explicitly prepare a query you must also explicitly unprepare it. If I leave it as it - is the target record locked until the next call? No. Rows remain locked only during the update operation and are automatically unlocked after the update, unless the lock occurs inside a transaction - row locks acquired during a transaction remain until the transaction is committed. -- Fernando Dias [Team Elevate] |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |