title: Lazarus sqldb and Transactions
body: <p>I'm developing an application (for Win32 and WinCE) in Lazarus using sqldb components for data access.</p>
  
  <p>Remote database is PostgreSQL (but i have the same behaviour with local SQLite).
  Connection to PostgreSQL work perfectrly but when I open any Query (also a very simple select) database go in transaction: "idle in transaction".</p>
  
  <pre><code>var
    PGConnection:TPQConnection;
    PGTransaction:TSQLTransaction;
    myQuery:TSQLQuery;
  begin
    PGConnection := TPQConnection.Create(self);
    PGTransaction := TSQLTransaction.Create(self);
    myQuery := TSQLQuery.Create(self);
    try
      PGConnection.HostName := '192.168.1.2';
      PGConnection.DatabaseName:='testdb';
      PGConnection.UserName:='test';
      PGConnection.Password:='test';
      PGConnection.Transaction := PGTransaction;
      PGConnection.Open;
  
      myQuery.DataBase := PGConnection;
      myQuery.SQL.Add('SELECT 1 AS value');
      myQuery.Open; // &lt;- this start transaction
      ShowMessage(myQuery.FieldByName('value').AsString); // &lt;- db: "idle in transaction"
      myQuery.Close; // &lt;- db: "idle in transaction"
      PGConnction.Close; 
    finally
      myQuery.Free;
      PGConnection.Free;
      PGTransaction.Free;
    end;
  end;  
  </code></pre>
  
  <p>Ok, maybe sqldb work in this way: every query on database start a transaction, so, developer must Commit or Rollback after interrogation. But there is another question: when I commit the Transaction, sqldb close the query and i can't access value retrieved:</p>
  
  <pre><code>var
    PGConnection:TPQConnection;
    PGTransaction:TSQLTransaction;
    myQuery:TSQLQuery;
  begin
    PGConnection := TPQConnection.Create(self);
    PGTransaction := TSQLTransaction.Create(self);
    myQuery := TSQLQuery.Create(self);
    try
      PGConnection.HostName := '192.168.1.2';
      PGConnection.DatabaseName:='testdb';
      PGConnection.UserName:='test';
      PGConnection.Password:='test';
      PGConnection.Transaction := PGTransaction;
      PGConnection.Open;
  
      myQuery.DataBase := PGConnection;
      myQuery.SQL.Add('SELECT 1 AS value');
      myQuery.Open; // &lt;- this start transaction
      PGConnection.Transaction.Active := False; // &lt;- Close also myQuery
      ShowMessage(myQuery.FieldByName('value').AsString); // &lt;- Error: Field "value" not found
      myQuery.Close; 
      PGConnction.Close; 
    finally
      myQuery.Free;
      PGConnection.Free;
      PGTransaction.Free;
    end;
  end;  
  </code></pre>
  
  <p>This behavior is a bit boring: I can't use TSQLQuery dataset with dbgrid (since I do not want my database in transaction for too long) so I need to move selected data in Memory Tables.</p>
  
  <p>Is this a bug, I made some mistakes or is a normal operation? There is a way to open a SELECT Query and use it without start a transaction?</p>