 mysqlrows:=0;
   WITH mytable2 DO
     BEGIN
       mysqlrows:=recordcount;
     if mysqlrows <>0 THEN
      BEGIN
       Sawtooth.Clear;
       Smoothedfirstderiv.Clear;
       SmoothedSecondDeriv.Clear;
       sawtooth.NrOfElem           :=mysqlrows-1;
       smoothedfirstderiv.NrOfElem :=mysqlrows-1;
       smoothedsecondderiv.NrofElem:=mysqlrows-1;
       For ctr:=1 to mysqlrows-1  DO
        BEGIN
        {Load sawtooth vector with data}
         sawtooth.Elem[ctr]:=fields[1].Value;
         next;
        END;
       {vector now filled with data}

       firstderiv (sawtooth,0,mysqlrows-1,smoothedfirstderiv  ,round(filtersize.value));
       secondderiv(sawtooth,0,mysqlrows-1,smoothedsecondderiv ,round(filtersize.Value));
       {Data is now smoothed in vector, put it into t_pressuretime, the SQL table with the data}

       first;
       for CTR := 1 to mysqlrows-1 do
         BEGIN
          edit;
          fields[2].Value:=10*smoothedfirstderiv. Elem[ctr]; //Scaled up for the graph;
          fields[3].Value:=10*smoothedsecondderiv.Elem[ctr];
          next;
         END;
       showmessage('Done data transfer');
      END
       ELSE
        showmessage('Failed');
     myquery1.Execute;
     END;