Jump to content

Serge_G

Members
  • Content Count

    311
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Serge_G


  1. Hi,

     

    - what is this X.INVRNO  ? Your test table only contains INVNO column !

    - use DateAdd Firebird function to compute your old date parameter

     

    DATEADD(-10 DAYS FROM SELECT MAX(TDATE) FROM MYTABLE ))

     

    or

    SELECT MAX(DATEADD(-10 DAYS FROM TDATE)) FROM MYTABLE

     

    I am not  fan of sub-querys I should certainly prefer a Delphi Code based (we are in a Delphi forum 😉) and a  Firedac query with parameters and  macro (for the in clause) 


     

    var d : variant;
    begin
    YourFDquery.Close;
    d:=FDConnection.ExecSQLScalar('SELECT MAX(DATEADD(:g DAYS FROM TDATE)) FROM MYTABLE',[-10]) // in this way you can change day number
    if not VarisEmpty(d) then
    begin
    YourFDQuery.SQl.text('SELECT * FROM MYTABLE WHERE (TDATE >= :d or INVNO IS NULL) &inmacro');
    YourFDQuery.ParamByName('d').asDateTime:=d;
    yourFDquery.MacroByName('inmacro').asRaw:='AND TNAME IN (''AA'')'; // so you can easily change, i.e *using format or clear clause  
    yourFDQuery.Open;
    end;

    Ok, I change position of the IN clause to easily clear the clause but, you can modify SQL text to

    YourFDQuery.SQl.text('SELECT * FROM MYTABLE WHERE &inmacro (TDATE>=:D OR INVNO IS NULL)');
    YourFDQuery.ParamByName('d').asDateTime:=d;
    yourFDquery.MacroByName('inmacro').asRaw:='TNAME IN (''AA'') AND';  

    * "inmacro" can be computed by a format,

    var mymacro : String;
    begin
    mymacro:=Format('TNAME IN (%s) AND',[list_of_quoted_tname]);

     

     

     


  2. 2 hours ago, Stano said:

    no results can be displayed during editing.

     

    2 hours ago, Brian Evans said:

    FireDac where it accessed by double left clicking or right clicking the component.

    I didn't see it was ADOQuery until I zoom picture ! (I don't even understand how we can still use it, but I hate ADO :classic_angry: for a long time now) Firedac is my prefered set of database components 

    • Like 1

  3. 4 hours ago, PenelopeSkye said:

    as soon as you close the form the edit box is on after updating it, not the entire app just the form, the text is saved to the database.  I have been trying to simply understand how this is happening.

    Clearly, you have a Datasource component with property AutoEdit set to True. So, when you change cuurent record, close table, etc. value of TDBEdit is "saved"

    4 hours ago, PenelopeSkye said:

    I seriously doubt that this is enough info for anyone to go on, would you let me know what else you need?

    Yes, but I have a crystal ball :classic_biggrin:

    4 hours ago, PenelopeSkye said:

    I have been requested to find out the user who is updating certain of those fields on the form. 

     

    The BeforePost event if you want to  update the table i.e 
     

    procedure tb_dm_presentation_design_linksBeforePost(DataSet: TDataSet);
    begin 
    tb_dm_presentation_design_links.FieldByName('LAST_UPDATE').asDateTime:=now;
    tb_dm_presentation_design_links.FieldByName('LAST_USER').asString:=mygetuserfunction;
    end;

    The AfterPost event if you record changes in another table (using an insert Query)

    procedure tb_dm_presentation_design_linksAfterPost(DataSet: TDataSet);
    begin
    // anAdoQuery.SQL.Text:='INSERT INTO TRACKS (USER,DATE_UPDATE) VALUES (:U,:D)';
    // sorry not sure of syntax I am not fan of ADO
    anAdoQuery.Params.ParambyName('U').asString:=mygetuserfunction;
    anAdoQuery.Params.ParambyName('U').asDateTime:=now;
    anAdoQuery.ExecSQL;
    end;

    Now if you want to track only a set of columns, BeforePost is the event where you can check CurValue and NewValue (well with ADO I am not sure).
     

    if tb_dm_presentation_design_linkscust_upc.curvalue.asString<>tb_dm_presentation_design_linkscust_upc.Newvalue.asString then
     // insert query 

     

    N.B. Know that SGBDR (good ones) triggers can track this for you without Delphi code. But this SGBD you use, my crystal ball, don't show me🔮

     

    P.S. As I remember, but never in more than 20 years, there is also an OnChange event for fields (if fields are defined, and that seems to be the fact tb_dm_presentation_design_linkscust_upc)

     


  4. 19 hours ago, Henry Olive said:

    If i uncheck TCP/IPv6 ( Just TCP/IPv4 checked )  then i cannot connect My App 

    Not really related to the question! Check in the file firebird.conf if IPv6V6Only is not set to 1  (around line 712)

    Check also AuthServer and AuthClient values (chapter around line 397) 

     

    To have IP_V4 only I Found this explanation

    Quote

    The systemd configuration files for firebird, firebird-classic@.service & firebird-classic.socket are located in /usr/lib/systemd/system.

    #cat firebird-classic.socket

    [Unit]

    Description=Firebird Classic Activation Socket

    [Socket]

    ListenStream=3050

    I changed the ListenStream to

    ListenStream=0.0.0.0:3050

    and restarted the service and now firebird is listening on 0.0.0.0:3050 and not :::3050, which means it is listening on IPV4 protocol.


    But, systemd configuration files ⁉️ I don't think you will find them (this explanation was for CENTOS 7)
    I don't think changing the RemoteServicePort value to 0.0.0.0:3050 (around line 667) should be a good idea, (idea I can't check), but you can have a try


    Now, according to this https://www.firebirdsql.org/file/documentation/html/en/firebirddocs/isql/firebird-isql.html#isql-connect-connection-string-url
     

    Quote

    TCP/IP (first tries to connect using the IPv6 protocol, if it fails, then IPv4)

    So if you use INET4 to connect to your database instead of INET you will certainly have IP_V4 address in your MON$ATTACHMENTS table.
    How ? Certainly 2 ways
    - modifying firebird.conf   RemoteBindAddress (around line 725)  setting it to INET4 but this should be restricting I think

    - by delphi code at connexion (depending on components used)


  5. Hi,

    You can backup your database even if there are users connected ("warm backup")

    On 5/16/2022 at 2:27 PM, Henry Olive said:

    BackUp File's size same as actual database 

    Is that normal ( No compress )  ?

    Yes


  6. In FMX there are no DBGrid, DBEdit, DBxxxx controls. You have to bind your datas to controls (Grid, Edit ...) using Livebindings 

    • Like 1

  7. 16 hours ago, vfbb said:

    My Ubuntu is 20.04 too (although it should work on 18.04 too)

    Hi, I report my success on my full Ubuntu PC upgraded to Ubuntu 20.4

    I failed installation of 20.4 for WSL (not installation  but XFCE4 don't work fine, no terminal !)

    So I will still investigate about 18.04 version failure.

     

    • Like 1

  8. Hi Vincent, 

    Well I test with WSL and a full Ubuntu PC but always with 18.04,

    12 hours ago, Vincent Gsell said:

    I had trouble on linux side - lib load issue

    Have this one now !

     

    12 hours ago, Vincent Gsell said:

    I remove completely older version of skia

    I  just done the update via getit in 3.40

    I use the GitHub SKIA version installer (not the getit one).

     

    OK so, next step for me : installing Ubuntu 20.04 (it's time 😉)  first on my WSL.

    • Like 1

  9. Hi,

    Freanch Delphi Entreprise 11.1 (patch 1 now)  and Ubuntu 18.04 is my target.

    19 hours ago, vfbb said:

    if you can run a blank fmx app on your Ubuntu,

    Well, it's not a blank one (only a SkiaLabel added), I'll investigate further  for this  zlib1g-dev  and test a blank project in debug mode.

     

    Thanks

     

    • Like 1

  10. Hi,
    It worked as expected on Android, but I can't test on Ubuntu :classic_blush:
    I first have a problem of a lacking package I think it was zlib1g-dev, I install this one. 

    But, if now I can deploy my project or the demo the program don't run. What did I miss ? Is there any doc/help for a "good" deployment ? 


  11. 6 hours ago, sjordi said:

    Thanks Mr ListView specialist

    Not so, but I try to be 😉

    6 hours ago, sjordi said:

    Still in Arles here!

    And did you finally find the Arlésienne :classic_biggrin:

    6 hours ago, sjordi said:

    I checked your demos and found a lot of ListView customization,

    Yes, I don't remember where I was confronted to that checkbox. I think it was a question in www.developpez.net/forums and don't report it to my blog

     

    6 hours ago, sjordi said:

    but didn't find one that check/unchecks when only the checkmark is clicked

    Ah finally, I see where https://www.developpez.net/forums/blogs/138527-sergiomaster/b8177/fmx-selection-delements-tlistview/  I.3 part

    The mayor part is here, but I skipped the OnclickEx part (sorry)
     

     


  12. Ha, sorry to miss this one yesterday (still in Yeu).

    I wrote something like that in my blog, in a tutorial or in a response in a forum, I don't remember exactly where, only the image I used for demo. 

    But, as I remember, I don't use positions but the ItemObject name  

     


  13. Hi

    2 hours ago, Henry Olive said:

    CAST((10.00000 / 0.3048) * 14.7776 as NUMERIC (18,2))

    Some useless .00000 here !

    You have to learn about how Firebird do the job with scales don't remember where I read this in doc, but you can see here some instructions

    So if you use the SQL you have, before casting, a 13 scaled variable !

    SELECT  CAST(10 / 0.3048* 14.7776 AS NUMERIC(13,2)) FROM RDB$DATABASE

    This work also


  14. Well, your SQL is the first and easy way to get the line with Firebird < 3.0 

    With Firebird 3+ perhaps a windows analytical function can be used 


     

    WITH C AS (SELECT CUSTNO,LAST(TDATE) OVER (ORDER BY TDATE) D
    FROM MYTABLE WHERE CUSTNO=:CUSTNO )
    
    SELECT M.TDATE,M.AA,M.BB FROM MYTABLE M
                                      LEFT JOIN C ON C.CUSTNO=M.CUSTNO AND M.TDATE=C.D

     

    But IMO, advantage is null, and if you have more than one line with CUSTNO,TDATE identical you will get more than one line


     

     

     


  15. Not tested on 11.1 yet but I wrote this unit (for FMX)

    unit ImageUtils;
    
    interface
    
    uses
      System.SysUtils, System.UITypes, System.UIConsts , System.Math, System.Classes,
      FMX.Types, FMX.Graphics, FMX.Utils;
    
      type Talgorithm = (algnone,algluminosity,algaverage,alglightness, alpow);
    
      function ConvertToGrayscale(const aBitmap: TBitmap; const aMethod : TAlgorithm=algnone) : TBitmap; overload;
      function ConvertToGrayscale(const FileName : String; const aMethod : TAlgorithm=algnone) : TBitmap; overload;
      function ConvertToGrayscale(const aStream : TMemoryStream ; const aMethod : TAlgorithm=algnone) : TBitmap; overload;
    
    
    implementation
    
    
    function Colortogray(const aColor : Talphacolor; const aAlgo : TAlgorithm=algnone) : Talphacolor;
      var
        H,S,L : Single;
        C : TAlphacolorRec;
        gris : Integer;
        // https://www.johndcook.com/blog/2009/08/24/algorithms-convert-color-grayscale/
      begin
        c.Color:=acolor;
        case aAlgo of
          algluminosity: gris:=Round((0.2126*c.R) + (0.7152*c.G) + (0.0722*C.B));
          algaverage:    gris := (c.R + c.G + c.B) div 3;
          alglightness:  gris:=Round((maxvalue([TAlphacolorRec(aColor).R,TAlphacolorRec(aColor).G,TAlphacolorRec(aColor).B]) +
                            minvalue([TAlphacolorRec(aColor).R,TAlphacolorRec(aColor).G,TAlphacolorRec(aColor).B])) / 2);
          alpow        : gris:=round(power(( 0.2126*power(c.R,2.2)+0.7152*power(c.G,2.2)+0.0722*power(c.B,2.2)),1/2.2) );
          else begin
              RGBToHSL(aColor,H,S,L);
              Exit(HSLtoRGB(0,0, L));
          end;
        end;
        exit(Makecolor(gris,gris,gris));
      end;
    
    function ConvertToGrayscale(const aBitmap: TBitmap; const aMethod : TAlgorithm=algnone): TBitmap;
    var
      X, Y: Integer;
      bd1, bd2: TBitmapData;
      p1, p2: PAlphaColorArray;
    begin
      Result := TBitmap.Create(Round(aBitmap.Width), Round(aBitmap.Height));
      if (aBitmap.Map(TMapAccess.Read, bd1)
         and Result.Map(TMapAccess.Write, bd2)) then
      begin
        try
          for Y := 0 to (aBitmap.Height - 1) do
          begin
            p1 := PAlphaColorArray(bd1.GetScanline(Y));
            p2 := PAlphaColorArray(bd2.GetScanline(Y));
            for X := 0 to (aBitmap.Width - 1) do
            begin
               p2[X] := Colortogray(p1[X],aMethod);
            end;
          end;
        finally
          aBitmap.Unmap(bd1);
          Result.Unmap(bd2);
        end;
       end;
    end;
    
    function ConvertToGrayscale(const FileName : String; const aMethod : TAlgorithm=algnone): TBitmap;
    var
      X, Y: Integer;
      bd1 : TBitmapData;
      p1 : PAlphaColorArray;
    begin
      if not FileExists(FileName) then exit(nil);
      result:=TBitmap.CreateFromFile(FileName);
      if Result.Map(TMapAccess.ReadWrite, bd1) then
       begin
        try
          for Y := 0 to (Result.Height - 1) do
          begin
            p1 := PAlphaColorArray(bd1.GetScanline(Y));
            for X := 0 to (Result.Width - 1) do
            begin
               p1[X] := Colortogray(p1[X],aMethod);
            end;
          end;
        finally
          Result.Unmap(bd1);
         end;
       end;
    end;
    
    function ConvertToGrayscale(const aStream : TMemoryStream ; const aMethod : TAlgorithm=algnone) : TBitmap; overload;
    var
      X, Y: Integer;
      bd1 : TBitmapData;
      p1 : PAlphaColorArray;
    begin
     if aStream.Size=0 then Exit(nil);
     aStream.Position:=0;
     result:=TBitmap.CreateFromStream(AStream);
     if Result.Map(TMapAccess.ReadWrite, bd1) then
       begin
        try
          for Y := 0 to (Result.Height - 1) do
          begin
            p1 := PAlphaColorArray(bd1.GetScanline(Y));
            for X := 0 to (Result.Width - 1) do
            begin
               p1[X] := Colortogray(p1[X],aMethod);
            end;
          end;
        finally
          Result.Unmap(bd1);
         end;
       end;
    end;
    end.

    image.thumb.png.11fb96ba67d89c8c0203dadb3ea5a662.png

     

    as a quick test, left number is speed, effet is using Monochrome effect instead of  function

     try
         with TmonochromeEffect.Create(nil) do
         try
          ProcessEffect(nil,aBitmap, 0);
        finally
          Free;
        end;
        image6.Bitmap:=abitmap;
       finally
        aBitmap.Free;
        watch.Stop;
        lblEffet.Text:='Effet '+Watch.ElapsedMilliseconds.ToString;
       end;

     


  16. First what a strange query, a count without Grouping clause !

     

    Try this (before fb 3, solution). Really disliking this "subselect" !  

    SELECT (SELECT COUNT(1) FROM ATABLE) AS TOT,DOCNO,DOCTYPE FROM ATABLE

     

     

    Or use a window (analytical)  function  (here SUM(1) OVER () is the window function)


    (Wow now FB3+ have analytical functions 😲)

    SELECT SUM(1) OVER () FULLCOUNT, DOCNO,DOCTYPE from ATABLE

     

    • Like 1
×