Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Serge_G last won the day on November 13 2021

Serge_G had the most liked content!

Community Reputation

60 Excellent

1 Follower

About Serge_G

  • Birthday 06/29/1956

Technical Information

  • Delphi-Version
    Delphi 10.3 Rio

Recent Profile Visitors

1266 profile views
  1. Serge_G

    Split String

    @Fr0sT.Brutal, code was edited during your post. Just a thing, this MyCode = 600.005.0010 then requested result = 600.005.0011 should not work you have to manage a way to have the good formatstring something like procedure TForm23.Button1Click(Sender: TObject); var S : TArray<String>; fmt : string; begin S:=Edit3.Text.Split(['.']); fmt:='%.'+Length(S[Length(S)-1]).tostring+'d'; S[length(S)-1]:=Format(fmt,[(StrToInt(S[Length(S)-1])+1)]); Edit3.Text:=String.Join('.',S); end;
  2. Serge_G

    Split String

    Hi, yes you can Split procedure TForm23.Button1Click(Sender: TObject); var S : TArray<String>; begin S:=Edit3.Text.Split(['.']); S[length(S)-1]:=Format('%.3d',[(StrToInt(S[Length(S)-1])+1)]); Edit3.Text:=String.Join('.',S); end;
  3. Serge_G


    This is an error I had sometimes when using an FDQuery on a Form and the related FDConnection in a DataModule. I do not hide from you that this has the gift of annoying me, especially when I use the visual designer of LiveBindings and my DataModule is in the list of uses
  4. Serge_G


    not my mother tongue too Yes, here I miss some words I think I am not a fan of the WITH but, sometimes using it by lazyness
  5. Serge_G


    Something like : const SQL = // asSQltext with TFDQuery.Create(self) do begin connection:=fdconnection; SQL.Text:=SQL; //parambyName //macrobyname Open; // processing Close; end; or const SQL = 'your sql'; var Q : TFDQuery; Q:=TFDQuery.Create(self); try Q.Connection:=FDConnection; Q.SQL.Text:=SQL; //Q.ParamByName //Q.macrobyName Q.Open; // processing Q.Close; finally Q.Free; end;
  6. Serge_G


    Stano Ok, my response is in three parts. 1- The first is only a Firebird compliant SQL on how to use DATEADD function, and for the question asked, just sufficient. 2- Why I am not fan of the subquery ? Because it is evaluated at each row of MYTABLE . Perhaps a CTE should be better, but with the so poor data sample I am lazy to test over WITH X AS (SELECT MAX(DATEADD(-10 DAYS FROM TDATE)) MD FROM MYTABLE) SELECT M.ID,M.TNAME,M.TDATE,M.INVNO FROM MYTABLE M JOIN X ON 1=1 WHERE M.TNAME='AA' AND (TDATE>=X.MD OR M.INVNO IS NULL) Note that I prefer the list of each column to an * 3- Delphi side, yes there is code (much more lines and I don't create an runtime TFDQuery .... ) but queries with parameters is, I think is a very usefull technique (I use for years)
  7. Serge_G


    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]);
  8. Serge_G

    sql query

    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 for a long time now) Firedac is my prefered set of database components
  9. Serge_G

    sql query

    And question is ?
  10. Serge_G

    TBDEdit - save updates to 2 different tables.

    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" Yes, but I have a crystal ball 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)
  11. Serge_G

    FB-3 Get Connected Clients IP Numbers

    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 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 (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 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)
  12. Serge_G

    FB3 - FDBackUp

    Hi, You can backup your database even if there are users connected ("warm backup") Yes
  13. Serge_G


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

    Own TQuery without database

    Reflexion 1- as I remember , FreeReport is an ancestor or fork of FastReport Reflexion 2- BDE can still be installed (you have to download it from your registered product panel
  15. Serge_G

    ANN: Skia4Delphi v3.4.0

    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.