Jump to content

MathiasBurbach

Members
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

0 Neutral

Technical Information

  • Delphi-Version
    Delphi 12 Athens
  1. MathiasBurbach

    SQLite and calculated columns

    Hello Cristian, Thanks for your reply. Yes we now understand this is a FireDAC feature. We are using it already. Unfortunately the old MS Access application used to create tables from Select statements for reporting. We will change that. But in order to get there we did not want to touch it immediately. So when you ExecuteSQL Create Temporary Table Report As Select 1 "A::INT", NULL "B::INT" the column data types are unknown. So we need to create the table up-front: Create Temporary Table Report(A INT, B INT) and then do a Insert Into Report As Select 1 "A::INT", NULL "B::INT" Brian, we will look at converting our tables to STRICT tables to get a better type check. But the STRICT option doesn't work for tables created from a select statement. As you can clearly see I am fairly new to SQLite. Salut, Mathias
  2. MathiasBurbach

    SQLite and calculated columns

    Thanks, Uwe & Dmitry, for your replies. I didn't know that I could trick SQLite to return a column of a particular type like Dmitry suggested. I tested it already with one of our queries and the column comes back as an Integer instead of a Wide String. That makes it easy to stick to the current approach of calculating columns by SQLite expressions. We can mark this thread as "answered". 🙂
  3. MathiasBurbach

    SQLite and calculated columns

    Thanks for your reply, Uwe. The problem here is that FireDAC converts result columns to TWideString if they are NULL. So it really depends on your data what data type you end up with. We can not convert all TWideString data types to TFloatFields as there are strings stored in the database. So a general mapping rule would not help. We may need to calculate these values as calculated fields in TFDQuery. But in some instances the number of columns is dynamic and we do not have static fields for the query. In other cases where we have static fields we get an error message: We were hoping we could give SQLite some instruction to make the first row that returns a NULL value for a float calculation as a TFloatField instead of a TWideString. We could create a TFDConnection on the fly and create field mappings just for that query. But we were hoping for a better solution.
  4. MathiasBurbach

    SQLite and calculated columns

    We face a problem in a Delphi project, in which we replace MS Access as the database layer to SQLite using FireDAC. This is to facilitate replication from SQLite to PostgreSQL via PowerSync. Here is the situation we are facing: Imaging the following... CREATE TABLE t1(a int, b int); INSERT INTO t1 values(1,1); INSERT INTO t1 values(1,0); Running the query SELECT IIF(b > 0, a / b, NULL) AS c FROM t1 ORDER BY b DESC we get the column C as a Float. But if we change the order by clause to SELECT IIF(b > 0, a / b, NULL) AS c FROM t1 ORDER BY b ASC the column C is returned as a TWideString as the first row has a NULL value for C. Even as type cast SELECT IIF(b > 0, a / b, Cast(NULL As Float)) AS c FROM t1 ORDER BY b ASC isn't working. Is there any way how we can force SQLite to return column C of a certain type independent of the data that has been selected? Thanks for a short answer in advance. Salut, Mathias
  5. MathiasBurbach

    High DPI & anchoring in Delphi 11

    Hello Folks! After watching Ray Konopka’s brilliant presentation on Leveraging High DPI in VCL Applications at the ADUG symposium, we thought it is time to move our project to Delphi 11 and use TImageContainer and TVirtualImageList components. Our customer suggested to use the Google icons 1 that are available in different resolutions under the Apache License scheme. The icons are scaling well in toolbars, bit buttons and Delphi’s own DB navigator. What we did not expect but are witnessing is problems with right anchored labels. Right anchored controls move nicely to the new DPI setting of the second screen and back to the original 96 dpi of the first screen. But labels move out and not back. The second screen is set to of 150% scaling. The source code is available for download from here. For those not having Delphi 11 the executable is available for download from here. If I move the label into a panel, align the label left and the panel to the right it is working too. At this stage it seems I need to calculate the left position of the right aligned label each time TFrom.OnAfterMonitorDpiChanged is triggered. That can’t be true. Any ideas how to trick Delphi into doing the right thing? Salut, Mathias
  6. MathiasBurbach

    TFDMemTable & TSQLTimeStampOffsetField

    Hello Folks, we are trying to use the TSQLTimeStampOffsetField defined in Data.DB.pas for a TFDMemTable. We created a static field list and tried to open the TFDMemtable. We run into an error: The call stack ... Data.DB.DatabaseError('Type mismatch for field ''Start'', expecting: TimeStampOffset actual: Unknown',$1767270) Data.DB.DatabaseErrorFmt('Type mismatch for field ''%s'', expecting: %s actual: %s',(...),$1767270) Data.DB.TDataSet.CheckFieldCompatibility($1758D20,$17FFE10) Data.DB.DoBindFields($17FFF60) Data.DB.TDataSet.BindFields(True) FireDAC.Comp.DataSet.TFDDataSet.InternalOpen Data.DB.TDataSet.DoInternalOpen Data.DB.TDataSet.OpenCursor(???) FireDAC.Comp.DataSet.TFDDataSet.OpenCursor(False) Data.DB.TDataSet.SetActive(???) FireDAC.Comp.DataSet.TFDDataSet.SetActive(???) Data.DB.TDataSet.Open FMain.TfrmMain.FormCreate($1780E30) Vcl.Forms.TCustomForm.DoCreate Vcl.Forms.TCustomForm.AfterConstruction System._AfterConstruction($1780E30) Vcl.Forms.TCustomForm.Create(???) Vcl.Forms.TApplication.CreateForm(???,(no value)) ... indicates that the TDataSet.CheckFieldCompatibility method points to a FieldDef for the column Start, for which the data type is unknown. I have tried to setup the FieldDefs first before opening the TFDMemTable but that did not help either. Why can I define a field of type TSQLTimeStampOffsetField but when I open the dataset the data type is unknown? I am using Delphi 11 Alexandria Version 28.0.42600.6491. Thanks for a short answer in advance. Salut, Mathias
×