Hi all.

I have a master detail form, I'm using SQLDB and running a current snapshot (Lazarus-0.9.29 rev 28828).

Retrieving data works Ok. Saving changes doesn't. Googling I found old comments in the mailing list saying primary keys must be integers. Is yet that the case? If it isn't, component declaration and relevant code follows.

Another issue, when the master have more than 1 record, if I edit the detail, then move around in the master, detail changes are lost. IIRC this works fine in dbExpress. It is a bug or a design limitation of sqldb?

  object PQConnection1: TPQConnection
    Connected = False
    LoginPrompt = False
    DatabaseName = 'contabilidad'
    KeepConnection = False
    Password = 'postgres'
    Transaction = SQLTransaction1
    UserName = 'postgres'
    HostName = '10.0.2.2'
    left = 444
    top = 12
  end
  object QueryMaster: TSQLQuery
    IndexName = 'DEFAULT_ORDER'
    Database = PQConnection1
    Transaction = SQLTransaction1
    ReadOnly = False
    SQL.Strings = (
      'SELECT *'
      'FROM asientos'
      'WHERE numejercicio = 1'
      ' AND numasiento = 13'
    )
    Params = <>
    left = 445
    top = 63
  end
  object QueryDetail: TSQLQuery
    IndexName = 'DEFAULT_ORDER'
    Database = PQConnection1
    Transaction = SQLTransaction1
    ReadOnly = False
    SQL.Strings = (
      'SELECT *'
      'FROM imputacionesasientos'
      'WHERE numejercicio = :numejercicio'
      ' AND numasiento = :numasiento'
      'ORDER BY numimputacion'
    )
    Params = <
      item
        DataType = ftUnknown
        Name = 'numejercicio'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'numasiento'
        ParamType = ptUnknown
      end>
    DataSource = SourceMaster
    left = 444
    top = 128
  end
  object SourceMaster: TDatasource
    DataSet = QueryMaster
    left = 376
    top = 63
  end
  object SourceDetail: TDatasource
    DataSet = QueryDetail
    left = 376
    top = 128
  end
  object SQLTransaction1: TSQLTransaction
    Active = False
    Action = caNone
    Database = PQConnection1
    left = 376
    top = 12
  end


procedure TForm1.FormCreate(Sender: TObject);
begin
  PQConnection1.Connected:=True;
  QueryMaster.Open;
// Parameter property settings seems also broken in the best dbExpress style!
  QueryDetail.Params.ParamByName('numejercicio').DataType:=ftSmallInt;
  QueryDetail.Params.ParamByName('numasiento').DataType:=ftLargeInt;
  QueryDetail.Open;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if QueryMaster.State<>dsBrowse then
     QueryMaster.Post;
  if QueryDetail.State<>dsBrowse then
     QueryDetail.Post;

  try
    QueryMaster.ApplyUpdates;
    QueryDetail.ApplyUpdates;
    SQLTransaction1.Commit;
  except
    SQLTransaction1.Rollback;
    raise;
  end;
end;

--
Ing. Julio César Gázquez
Mutual de Empleados del Banco
Mitre 923 1º Piso - (S2000COS) Rosario
Tel-Fax: 0341-4265010 411 0533



--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to