Forum > Database

SQLITE3: TSQLQuery fails when using Params for float data (aarch64)

(1/3) > >>

apeoperaio:
I have an issue when using TSQLQuery to insert float data in a table using Params (on aarch64).

I attached a sample project, where TSQLQuery simply execute an insert statement (works) and perform insert using Params (does not work).
In order to test it just replace
  dbfile:= 'yourfilename';
with your filename.

Is it a known issue?

Lazarus 2.2.7 (rev lazarus_2_2_6-1-gada7a90f86) FPC 3.2.2 aarch64-darwin-cocoa

rvk:

--- Quote from: apeoperaio on March 16, 2023, 01:02:01 pm ---I attached a sample project, where TSQLQuery simply execute an insert statement (works) and perform insert using Params (does not work).

--- End quote ---
What does "does not work" mean?
Do you get an error?
Or does it do nothing (no error, no messages) and add nothing?

BTW shouldn't you use a sqlq.Prepare; after assigning sqlq.SQL.Text and before sqlq.ExecSQL, to let the program know what parameters there are?

apeoperaio:
It does not work in the sense that the float value is not inserted in the table.
When I use the SQL statement:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---sqlq.SQL.Text:= 'INSERT INTO DATA (int_value, float_value, str_value) values ("10", "1.3", "str1")';
I get 3 values in the table
101.3str1
while when I use:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    sqlq.SQL.Text:= 'INSERT INTO DATA (int_value, float_value, str_value) values (:int_value, :float_value, :str_value)';    sqlq.Params.Items[0].AsInteger:= 9;    sqlq.Params.Items[1].AsFloat:= 0.998;    sqlq.Params.Items[2].AsString:= 'str2';  
I get a table like:
90str2
The float value (0.998) is not inserted, the value in the table is 0.

apeoperaio:
I forgot to mention that, except from darwin aarch64, the code works for all other platforms (win x86_64, linux x86_64, darwin x86_64)

rvk:
What happens if you do:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---sqlq.SQL.Text:= 'INSERT INTO DATA (int_value, float_value, str_value) values (10, 1.3, "str1")';sqlq.Prepare;
Note that 10 and 1.3 aren't enclosed by quotes because they are not strings.

(I think sqlite does convert automatically but perhaps something goes wrong there)

Don't forget the prepare. It should be done automatically, but it can't hurt.

It the 10 and 1.3 are really added then too, then there must be something wrong with passing parameters.

Navigation

[0] Message Index

[#] Next page

Go to full version