Android Question read PRAGMA table_info

Alessandra Pellegri

Active Member
Licensed User
Longtime User
I should insert a column in a database if it doesn' exists.
I could do this:
B4X:
try
  ALTER TABLE myTable ADD COLUMN test BOOL;
catch
'Do nothing
end try

But I would like to use a more clean solution testing if the column already exists. But how could I read the PRAGMA table_info results ?

Thank you
 

eurojam

Well-Known Member
Licensed User
Longtime User
you can do something like this:
B4X:
   Dim cur As ResultSet
    cur = aSQL.ExecQuery("PRAGMA table_info(mytable);")
    Do While cur.NextRow
      Log(cur.GetString("name"))
    Loop

The field "name" contains the column names
 
Upvote 0
Top