Android Question Problem making view

Majid_it

Member
hi
I wrote a code that works properly inside sqlite
But inside b4a gives an error

B4X:
        Dim str As String
        str = $"CREATE VIEW view_moshtari_sath as
            Select ROW_NUMBER() OVER ( ORDER BY year ASC , mon ASC , day ASC , ath1.ID ASC )
   RowNum , ath1.bedehkari , ath1.talabkari , ath1.tozih , ath1.ID , ath1.year , ath1.mon , ath1.day , ath1.ID_moshtari , ID_hesab
            from Tbl_moshtari_sath2 As ath1
            ORDER BY year DESC , mon DESC , day DESC , ath1.ID DESC"$
    
        sql.ExecNonQuery(str)

error
B4X:
(SQLiteException) android.database.sqlite.SQLiteException: near "(": syntax error (code 1): , while compiling: CREATE VIEW view_moshtari_sath as

why!!??
Help me please
 

Mahares

Expert
Licensed User
Longtime User
wrote a code that works properly inside sqlite
But inside b4a gives an error
Ya Magid:
1. by saying 'inside sqlite' do you mean a PC SQLite browser like DBBrowser or SQLite Studio, etc. If so, it is possible that SQLite version on your PC is more recent than the one on your device. Therefore your device may not support ROW_NUMBER() function. Usually the versions on the devices are way behind the versions on the PC.
2. All B4A does is pass the commands to the SQLite engine on your phone or tablet and it is up to the device SQLite version to process them. You can check the version on your device and compare it to the version that you use on your PC.
To check the version on your device:
B4X:
Dim sqliteversion As String =sql.ExecQuerysingleresult( "SELECT SQLite_version()")
Log(sqliteversion)
3. If you continue to have problems, you can always zip your project and post it to the forum. Someone will figure it out
 
Last edited:
Upvote 0

Majid_it

Member
Ya Magid:
1. by saying 'inside sqlite' do you mean a PC SQLite browser like DBBrowser or SQLite Studio, etc. If so, it is possible that SQLite version on your PC is more recent than the one on your device. Therefore your device may not support ROW_NUMBER() function. Usually the versions on the devices are way behind the versions on the PC.
2. All B4A does is pass the commands to the SQLite engine on your phone or tablet and it is up to the device SQLite version to process them. You can check the version on your device and compare it to the version that you use on your PC.
To check the version on your device:
B4X:
Dim sqliteversion As String =sql.ExecQuerysingleresult( "SELECT SQLite_version()")
Log(sqliteversion)
3. If you continue to have problems, you can always zip your project and post it to the forum. Someone will figure it out
SQLite is not supported for b4a ROW_NUMBER()
I went the other way
tnx man
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
SQLite is not supported for b4a ROW_NUMBER()
I went the other way
tnx man
No. That is not a correct answer. ROW_NUMBER() has nothing to do with B4A. It is the device SQLite version. I can run ROW_NUMBER() in B4A project in a phone with SQLite version: 3.28.0 without any problems. But, it does not run on a device with version 3.19.4
 
Upvote 0
Top