Android Question Supabase - get value stored in a table column

PoppaBart

Member
HI,
I am trying to get the value of stored in a column of a supabase table. I want to get the value in the last row in the table so I can delete it.
I can retrieve the number of rows in the table, but I am having trouble in getting the value stored in my "id" field.
Does anyone know how to retrieve it.
 

Alexander Stolte

Expert
Licensed User
Longtime User
I want to get the value in the last row in the table
Supabase V1.13+
use order by + limit to get the last row in a table
B4X:
    Dim Query As Supabase_DatabaseSelect = xSupabase.Database.SelectData
    Query.Columns("*").From("dt_Tasks")
    Query.OrderBy("Tasks_Id.desc")
    Query.Limit(1)
    Wait For (Query.Execute) Complete (DatabaseResult As SupabaseDatabaseResult)
    xSupabase.Database.PrintTable(DatabaseResult)
 
Upvote 1

PoppaBart

Member
Supabase V1.13+
use order by + limit to get the last row in a table
B4X:
    Dim Query As Supabase_DatabaseSelect = xSupabase.Database.SelectData
    Query.Columns("*").From("dt_Tasks")
    Query.OrderBy("Tasks_Id.desc")
    Query.Limit(1)
    Wait For (Query.Execute) Complete (DatabaseResult As SupabaseDatabaseResult)
    xSupabase.Database.PrintTable(DatabaseResult)
Thank you. Is it possible to get the values stored in the row and put them into variables so they can be shown in a label.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Is it possible to get the values stored in the row and put them into variables so they can be shown in a label.
Yes, the same way as with jRDC2.

B4X:
    Dim Query As Supabase_DatabaseSelect = xSupabase.Database.SelectData
    Query.Columns("*").From("dt_Rooms")
    Wait For (Query.Execute) Complete (DatabaseResult As SupabaseDatabaseResult)
    
    For Each Row As Map In  DatabaseResult.Rows
        
        Dim xpnl As B4XView = xui.CreatePanel("")
        xpnl.SetLayoutAnimated(0,0,0,Root.Width,50dip)
        xpnl.LoadLayout("frm_RoomItem1")
        
        Dim xlbl_RoomName As B4XView = xpnl.GetView(0)
        xlbl_RoomName.Text = Row.Get("name") 'Fill the Room Name to the Label
        
        xclv_ChatRooms.Add(xpnl,Row.Get("id")) 'Gets the Room Id
        
    Next
 
Upvote 0

PoppaBart

Member
Yes, the same way as with jRDC2.

B4X:
    Dim Query As Supabase_DatabaseSelect = xSupabase.Database.SelectData
    Query.Columns("*").From("dt_Rooms")
    Wait For (Query.Execute) Complete (DatabaseResult As SupabaseDatabaseResult)
   
    For Each Row As Map In  DatabaseResult.Rows
       
        Dim xpnl As B4XView = xui.CreatePanel("")
        xpnl.SetLayoutAnimated(0,0,0,Root.Width,50dip)
        xpnl.LoadLayout("frm_RoomItem1")
       
        Dim xlbl_RoomName As B4XView = xpnl.GetView(0)
        xlbl_RoomName.Text = Row.Get("name") 'Fill the Room Name to the Label
       
        xclv_ChatRooms.Add(xpnl,Row.Get("id")) 'Gets the Room Id
       
    Next
Thanks again, you have been a great help.
 
Upvote 0
Top