Jump to content

baeckerg

Members
  • Content Count

    25
  • Joined

  • Last visited

Posts posted by baeckerg


  1. I just played around and if you really only need to load a certain status into the database which you need to reload you could do something like this:

    procedure TForm2.btn1Click(Sender: TObject);
    var
      I: Integer;
      node: TTreenode;
      ms: TMemoryStream;
    begin
      node := tv1.Items.Add(nil, 'ROOT Beer') ;
    for I := 0 to 10 do
      begin
        tv1.items.AddChild(node, 'Beer ' + i.toString);
      end;
    ms := TMemoryStream.Create;
    tv1.SaveToStream(ms);
    qry_1.SQL.Text := 'Insert into files (files) values (?)';
    qry_1.Params[0].LoadFromStream(ms, ftBlob);
    qry_1.ExecSQL();
    ms.Clear;
    qry_1.SQL.Text := 'Select f.files from files f limit 1';
    qry_1.Open();
    ms.Position := 0;
    TBlobField(qry_1.FieldByName('files')).SaveToStream(ms);
    ms.Position := 0;
    tv2.LoadFromStream(ms);
    ms.Free;
    end;

    just a quick and dirty hack with two treeviews (tv1, tv2) and Firedac on SQlite


  2. My solution was based on the fact that it is an integer field - therefore a simple "ADD" seamed to be the most straightforward way.

    I am not working on interbase. Therefore my SQL is based on SQlite. There you could use

    UPDATE mytable SET docno = CASE WHEN docno <2000 THEN docno + 210000 ELSE docno + 220000 END;

    which would give you more flexibility. In SQLite you could also do 

    UPDATE mytable SET docno = CASE WHEN docno <2000 then '21'|| DOCNO ELSE docno + 220000 END;

    since SQLite internally handles the fields as strings. But case can give you flexibility in case :classic_cheerleader: you need it


  3. Hi,

     

    in a program I have a central FireDAC connection to my database in a datamodule. I intend to have all record related activities (CRUD) in a class that holds the record. My questions are:

     

    1) is there any penalty if I pass the connection (as var parameter?) to the constructor of the class?

    2) is this the best way to separate the data from the UI?

     

    many thanks in advance

    Gernot

×