It's weird to *require* a COMMIT on a simple SELECT, but the CommitRetaining trick seemed to work. The system table "pg_stat_activity" still shows the "<IDLE> in transaction" pending query but the lock is no more -- at least I could execute a CREATE TABLE normally.<br>
<br><div class="gmail_quote">2009/10/13 Michael Van Canneyt <span dir="ltr"><<a href="mailto:michael@freepascal.org">michael@freepascal.org</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
<br>
On Tue, 13 Oct 2009, Alexsander Rosa wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I'm using Lazarus from SVN with FPC 2.2.4 under Ubuntu 9.04 connecting to an 8.3 PosgreSQL server.<br>
<br>
I need to use it in a program that stays open all day -- it's a price check terminal. The user can read a barcode to show data about a single product or type<br>
part of a description and browse the resulting list. This list is a DBGrid whose TSQLQuery's DataSet stays open while the user browses (or simply abandon the<br>
terminal). It's a SELECT that does not change anything, it does not need a transaction. With the required transaction, there's always an "<IDLE> in<br>
transaction" query open when the Lazarus application is running:<br>
<br>
select datname, usename, query_start, procpid, client_addr from pg_stat_activity where current_query = '<IDLE> in transaction';<br>
<br>
This transaction locks the changes in the database structure so you can't, for example, create a new table with a foreign key. A mere CREATE TABLE with a<br>
FOREIGN KEY referring to an existing table would take forever waiting for that lock to be released.<br>
</blockquote>
<br></div>
Did you try calling "CommitRetaining" on the transaction ? It will commit the transaction (and so free the lock), but should keep the dataset open ?<br>
<br>
If you want the transaction closed (no transaction active), then you'll have to transfer the results of the query to a list (TCollection) and show the collection in the grid, because committing the transaction closes any dataset associated with it.<br>
<br>
Michael.<br><font color="#888888">
<br>
--<br>
_______________________________________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org" target="_blank">Lazarus@lists.lazarus.freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Atenciosamente,<br>Alexsander da Rosa<br>Linux User #113925<br><br>"Extremismo na defesa da liberdade não é defeito.<br>Moderação na busca por justiça não é virtude."<br>
-- Barry Goldwater<br>