Integer values are shown reversed (backwards) in dbgrid lazarus / 16-Databases ---------------------------------------------------------------------- pdvs · 2020-05-02 21:55 Dear all, in postgresql a query with the crosstab-function created a pivottable. This works correctly. When this dataset is shown in dbgrid the values in the last four columns are shown reversed. Has anyone an idea how I could solve this problem? Many thanks in advance, Paul Win10, Lazarus 2.0.4, postgresql 12.0 ---------------------------------------------------------------------- eljo · 2020-05-02 22:20 big vs small endian? ---------------------------------------------------------------------- madref · 2020-05-03 00:08 Make a query based on your pivotable Code: SQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SELECT datum, debiteurnummer, debiteurnaam, 2018, 2017, 2016 FROM pivotable ---------------------------------------------------------------------- eljo · 2020-05-03 00:55 Quote from: madref on May 03, 2020, 02:08:32 amMake a query based on your pivotable Code: SQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SELECT datum, debiteurnummer, debiteurnaam, 2018, 2017, 2016 FROM pivotableand that will correct the number that show as 2173 instead of 3712 some how? ---------------------------------------------------------------------- madref · 2020-05-03 10:15 Don't kwon...try it and see ---------------------------------------------------------------------- MarkMLl · 2020-05-03 11:56 Quote from: pdvs on May 02, 2020, 11:55:27 pmWhen this dataset is shown in dbgrid the values in the last four columns are shown reversed. What hardware and OS is the application running on? What hardware and OS is the server running on? Are there any intermediate pooling etc. systems and if so what hardware and OS are they running? What happens if you put *exactly* the same queries through psql? I find it a little implausible that an endianness error would cause a sequence of characters representing decimal digits to be reversed, and there is probably a simpler solution. MarkMLl ---------------------------------------------------------------------- pdvs · 2020-05-03 12:36 Quote from: MarkMLl on May 03, 2020, 01:56:13 pmQuote from: pdvs on May 02, 2020, 11:55:27 pmWhen this dataset is shown in dbgrid the values in the last four columns are shown reversed. What hardware and OS is the application running on? What hardware and OS is the server running on? Are there any intermediate pooling etc. systems and if so what hardware and OS are they running? application and server running on the same Laptop: 64-bits OS, Win10, x64-processor, Intel core i3-4005U CPU. [/quote] What happens if you put *exactly* the same queries through psql? [/quote] In the attachment you see the query test.sql executed in pgadmin4 with the result. Paul ---------------------------------------------------------------------- MarkMLl · 2020-05-03 13:08 Show us the output from psql, i.e. the program supplied and supported with PostgreSQL. Look, I'm trying to be helpful here but I'm also trying to do my own work. MarkMLl ---------------------------------------------------------------------- pdvs · 2020-05-03 16:22 Dear MarkMLI, I appreciate your patience and I hope that the attachment is what you mean or the following code, if not, I'm a beginner... thanks a lot for your support, This is the procedure which should show the dataset in dbgrid Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button_openqueryClick(Sender: TObject);begin  DataSource1.DataSet.Close;  TSQLQuery(DataSource1.DataSet).SQL.Text:=  'CREATE EXTENSION IF NOT EXISTS tablefunc;' +LineEnding+   ' SELECT * ' +LineEnding+  ' FROM crosstab' +LineEnding+  ' ( ' +LineEnding+   QuotedStr(   'select debiteurnummer, debiteurnaam, extract (year from datum) as jaar, '  +LineEnding+   ' sum (jaar_omzet) as totaal' +LineEnding+   ' from omzetdebprobeer' +LineEnding+   ' group by' +LineEnding+   ' debiteurnummer, debiteurnaam, extract (year from datum)' +LineEnding+   ' order by debiteurnummer') +LineEnding+    ',' +LineEnding+    QuotedStr(   'select distinct extract (year from datum) as jaar' +LineEnding+   ' from omzetdebprobeer' +LineEnding+   ' order by jaar desc') +LineEnding+     ' ) ' +LineEnding+    'AS ct (debiteurnummer character varying (10), debiteurnaam character varying (50),' +LineEnding+   '    "2018" integer, "2017" integer,' +LineEnding+   '    "2016" integer, "2015" integer)'  ;  DataSource1.DataSet.Open;  DBGrid1.AlternateColor := $00E8E8E8;  DBGrid1.setfocus;end;  and I tried this procedure for 2015,2016,2017,2018. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.SQLQuery12015GetText(Sender: TField; var aText: string;  DisplayText: Boolean);begin  aText:=TField(Sender).asstring;end;  Thanks again, Paul