1

Hy I wrote an Application with Gambas uning SQLite

When I try to port to another Linux Ditro, I have different keys for the fields in the resultset for the SQLite Result

For example:

sqlect * from table

In on resultset I get

res["Tablename.Column1"] = Value
res["Tablename.Column2"] = Value
res["Tablename.Column3"] = Value

and In onther it is

res["Column1"] = Value
res["Column2"] = Value
res["Column3"] = Value

this is a big problem for me. Any Ideas ?

  • Maybe using alias names would result in both systems in the same names without table qualifier: `select column1 as column1, column2 as column2, column3 as column3 from table`. – Thorsten Kettner Jun 03 '16 at 21:22
  • I can not modify every query in this big finished application. I want to know why there is this difference in sqlite. I also could write select table.colum1, table.column2,table.colum3 from table BUT: I can not modify every query in this big finished application. – Thomas Krcal Jun 03 '16 at 21:25
  • It may be a different SQLite version. You see, the column names in the result shall be unique so you can access the columns by name. One SQLite version may make sure by combining table and column, whereas the other version notices that only one table is involved and omits the table qualifier in the results. – Thorsten Kettner Jun 03 '16 at 21:44
  • Of course I checked SQLite Versions very first. – Thomas Krcal Jun 03 '16 at 22:00

2 Answers2

2

After a very long journey I found it: I have to call

PRAGMA short_column_names = OFF

Very detailed Information can be found here:

https://www.sqlite.org/pragma.html#pragma_full_column_names

0

The documentation says:

The name of a result column is the value of the "AS" clause for that column, if there is an AS clause. If there is no AS clause then the name of the column is unspecified and may change from one release of SQLite to the next.

So the only reliable way of getting consistent result column names is to use AS.

CL.
  • 173,858
  • 17
  • 217
  • 259
  • That is clear. But the question was. Why is there a difference if there is not an AS from one distro to another by exactly the same release – Thomas Krcal Jun 05 '16 at 21:24