Android Question Help to perform the DBUtils.ExecuteMemoryTable

Bob Spielen

Active Member
Licensed User
I'm trying to get a list from a table using :

B4X:
Dim DBxdoKey As Double=bxdokey
    SqlStr="SELECT * FROM pedidos WHERE bxdo=" & DBxdoKey & " ORDER BY idnuvem"
   
    ' SqlStr = SELECT * FROM pedidos WHERE bxdo=45.1 ORDER BY idnuvem
   
    List=DBUtils.ExecuteMemoryTable(Starter.SQL3, SqlStr , Null, 0)


The bxdo field is a "DOUBLE" var type.

Even if SqltStr is "SELECT * FROM pedidos WHERE bxdo=45.1 ORDER BY idnuvem" the list returns allways as empty ....

What am I doing wrong?
Thanks for help.....
 

DonManfred

Expert
Licensed User
Longtime User
You should use parametrized Queries.

Something like

B4X:
Dim DBxdoKey As Double=bxdokey
    SqlStr="SELECT * FROM pedidos WHERE bxdo=? ORDER BY idnuvem"
    List=DBUtils.ExecuteMemoryTable(Starter.SQL3, SqlStr , Array As String(DBxdoKey),0)
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Even if SqltStr is "SELECT * FROM pedidos WHERE bxdo=45.1 ORDER BY idnuvem" the list returns allways as empty
1) There is no record with value 45.1 for bxdo, or
2) You are not using the right database, or
3) You are having a floating point issue (the DB stored 45.1 as 45.099999999 or 45.100000001 or something like that), or
4) Something else - have you checked the logs?
 
Upvote 0

Bob Spielen

Active Member
Licensed User
Thanks a lot for the reply,
OliverA is correct, I had a floating point problem.
I fixed the problem daclaring all related vars as float:


Example:

B4X:
    Dim DNr As Float
    
    DNr=60   :bxdotxt.put(DNr,"Pg CxLoja")
    DNr=60.1 :bxdotxt.put(DNr,"Pg MBoy_1")
    DNr=60.2 :bxdotxt.put(DNr,"Pg MBoy_2")
    DNr=60.3 :bxdotxt.put(DNr,"Pg MBoy_3")
    DNr=60.4 :bxdotxt.put(DNr,"Pg Cartão_1")
    DNr=60.5 :bxdotxt.put(DNr,"Pg Cartão_2")

And comparing the table in the subs.....

B4X:
Sub Start(DummyBxdoI As Float, DummyBxdoF As Float)
       SqlStr="SELECT idp3, idnuvem FROM pedidos WHERE bxdo>=" & DummyBxdoI & " AND bxdo<" & DummyBxdoF & " ORDER BY idp3"
       Lista=DBUtils.ExecuteMemoryTable(Starter.SQL3, SqlStr , Null, 0)
.
 .
  .
   . 
    .


So I can encrease the DNr "60"-payment option with more options and still beying in the "60"-class.
Maybe not so elegant solution but for now its working.

Thanks a lot also for DonManfred for the reply.
 
Upvote 0
Top