[Lazarus] How to do insert/update and select on database

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] How to do insert/update and select on database

Free Pascal - Lazarus mailing list
Hi,

I'm new to database programming with Lazarus. So hence possible a couple of obvious questions!

I would like to do inserts, selects, and updates on a single SQLite database. I am now using multiple SQLQuery components with all their own queries. Is this the way it should work?

After a commit, the SQLQuery that populates the DBGrid is closed. Is this supposed to happen? The transaction component is set to caCommitRetaining. I believe I read somewhere that it should remain open in that case.

TIA!

Darius

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How to do insert/update and select on database

Free Pascal - Lazarus mailing list


On Sun, 2 Jun 2019, Darius Blaszyk via lazarus wrote:

> Hi,
>
> I'm new to database programming with Lazarus. So hence possible a couple of
> obvious questions!
>
> I would like to do inserts, selects, and updates on a single SQLite
> database. I am now using multiple SQLQuery components with all their own
> queries. Is this the way it should work?

It is one way to work. I usually do the same.

> After a commit, the SQLQuery that populates the DBGrid is closed. Is this
> supposed to happen? The transaction component is set to caCommitRetaining.
> I believe I read somewhere that it should remain open in that case.

No, this is not what it means. You should avoid caCommitRetaining.

There is an option on TSQLQuery, sqoKeepOpenOnCommit

Documented here:

https://docs.freepascal.org/docs-html/current/fcl/sqldb/tsqlquery.options.html

It does what you want.

Michael.
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How to do insert/update and select on database

Free Pascal - Lazarus mailing list


Op zo 2 jun. 2019 om 22:55 schreef Michael Van Canneyt via lazarus <[hidden email]>


On Sun, 2 Jun 2019, Darius Blaszyk via lazarus wrote:

> Hi,
>
> I'm new to database programming with Lazarus. So hence possible a couple of
> obvious questions!
>
> I would like to do inserts, selects, and updates on a single SQLite
> database. I am now using multiple SQLQuery components with all their own
> queries. Is this the way it should work?

It is one way to work. I usually do the same.

> After a commit, the SQLQuery that populates the DBGrid is closed. Is this
> supposed to happen? The transaction component is set to caCommitRetaining.
> I believe I read somewhere that it should remain open in that case.

No, this is not what it means. You should avoid caCommitRetaining.

There is an option on TSQLQuery, sqoKeepOpenOnCommit

Documented here:

https://docs.freepascal.org/docs-html/current/fcl/sqldb/tsqlquery.options.html

It does what you want.

Thanks. As always good and to the point advice!

Regards, Darius

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] How to do insert/update and select on database

Free Pascal - Lazarus mailing list
On 6/3/19 8:21 AM, Darius Blaszyk via lazarus wrote:
> Thanks. As always good and to the point advice!

AKA "Bikini format" - short and to the point -=B-)


--
  NOTE: No off-list assistance is given without prior approval.
        *Please keep mailing list traffic on the list unless*
        *a signed and pre-paid contract is in effect with us.*
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus