Jump to content

Serge_G

Members
  • Content Count

    311
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Serge_G

  1. Serge_G

    FB-3 SELECT WHERE

    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. 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
  3. Serge_G

    sql query

    And question is ?
  4. 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)
  5. 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 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 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)
  6. Serge_G

    FB3 - FDBackUp

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

    DB

    In FMX there are no DBGrid, DBEdit, DBxxxx controls. You have to bind your datas to controls (Grid, Edit ...) using Livebindings
  8. 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
  9. 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.
  10. Serge_G

    ANN: Skia4Delphi v3.4.0

    Hi Vincent, Well I test with WSL and a full Ubuntu PC but always with 18.04, Have this one now ! 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.
  11. Serge_G

    ANN: Skia4Delphi v3.4.0

    Hi, Freanch Delphi Entreprise 11.1 (patch 1 now) and Ubuntu 18.04 is my target. 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
  12. Hi, Change the "Windows 10 Desktop" style to "Default". The best way to do that is to remove "Default" style and then rename "Windows 10 Desktop" to blank
  13. Serge_G

    ANN: Skia4Delphi v3.4.0

    Hi, It worked as expected on Android, but I can't test on Ubuntu 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 ?
  14. Serge_G

    ListView: click on checkmark only?

    Not so, but I try to be 😉 And did you finally find the Arlésienne 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 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)
  15. Serge_G

    ListView: click on checkmark only?

    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
  16. Serge_G

    is FMX supported RTL (Right to Left) languages?

    Have a look at http://www.fmxrtl.com/info.php
  17. Serge_G

    FB-3,09 Case & Cast

    Hi 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
  18. Serge_G

    FB-3 SQL ROWS

    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
  19. Serge_G

    Delphi 10.3.3. - problem with adding customized view

    Or you can edit DevicePresets.xml file in C:\Users\<user_name>\AppData\Roaming\Embarcadero\BDS\22.0 But I think you have to restart your IDE to have changes applied
  20. Serge_G

    Any example bitmap to grayscale?

    You're welcome
  21. Serge_G

    Any example bitmap to grayscale?

    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. 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;
  22. Serge_G

    dbe install for delphi 11

    Hum, take care, install is a bit buggy if you don't use the "standard" install path for Delphi https://quality.embarcadero.com/browse/RSP-36785 installed you have to install the package dclbde280.bpl in the C:\Program Files (x86)\Embarcadero\Studio\22.0\bin
  23. Serge_G

    FB-3,09 Count(*)

    Forgot this one, better IMHO, for Firebird<3 using a CTE and JOIN WITH c as (Select count(1) nb from appose) select c.nb,t.* from c full join appose t on 1=1
  24. Serge_G

    FB-3,09 Count(*)

    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
  25. Serge_G

    quality.embarcadero.com not working?

    @Dalija Prasnikar solution is also my way to solve this recurrent problem.
×