Android Question sqlite query with function

Kiran Raotole

Active Member
Licensed User
I have a query "select *,closing as closing(parameter1,parameter2) from temp"
how to pass this query

i have to used function
how to do that?

Kiran Raotole

Active Member
Licensed User
ok I got it query will be :
cursor = year.ExecQuery2("select *, ? as closing from TEMP where FBOOK='ABCD'",Array As String(balance(year,"1234",paramas2)))

but my paramas1 contain some value of table like TEMP.ACCODE

how to pass this parameter?

Kiran Raotole

Active Member
Licensed User
No I have problem in B4A
sql.ExecQuery2("select *, ? as closing, ? as tot_dr , ? as tot_cr from GL where FBOOK='G001'", _
                Array As String( _
                    f1.balance_as_on(Starter.year,accode,"2018-03-31"), _
                    f1.tot_dr(Starter.year,accode,Starter.ch_date1,Starter.ch_date2), _
GL is my table in sql db
I want to pass GL field in balance_as_on like balance_as_on(GL.FNAME,"2018-03-31")


Well Known Member
Licensed User
any other option for this?
  1. Extract the fields say F1, F2 from the table with a select statement and a where clause for each record.
  2. Use the fields F1 and F2 in the Sub MyNewDate
  3. Iterate over each record and save to a list the result so it can be exported to Excel or inserted into a temporary table that you create.
  4. Here are some guidelines:
Dim MyList As List
Dim q As String = "SELECT F1, F2 from GL WHERE  FBOOK='G001'"
Dim cursor1 As ResultSet = SQL1.ExecQuery(q)
Do While cursor1.Nextrow
   MyList.Add(MyNewDate(cursor1.GetString("F1"), cursor1.getint("F2")))
   'Then you can save the list to a file and manipulate it in Excel or even save its data to a new temporary table

Sub MyNewDate(v1 As String, v2 As Int) As String
    Dim x As Long
    x = DateTime.Add(DateTime.DateParse(v1), 0, 0, v2)
    Return DateTime.Date(x)
End Sub
Example: F1 field has: "2018-03-31" And you want To add To it 4 days stored in F2 To come up with "2018-04-04"