22.3 Database data type mapping

A well-structured overview of the mapping between Gambas data type → database data type for MySQL, PostgreSQL and SQLite can be found at http://gambaswiki.org/wiki/doc/db-type-mapping.

The database component of Gambas manages a mapping between each Gambas data type and each data type of the underlying database driver. This mapping is not bijective. Sometimes a Gambas data type does not exist in the database system. More often, however, the opposite is the case.

Because of this mapping Gambas data type → database data type, you need to be careful when designing your database. To avoid problems, you should always use the database manager supplied with Gambas.

Be careful with the SQL value NULL!
In Gambas, NULL and the invalid string are the same, but normally this is not the case with the database drivers. Gambas always stores NULL in the database if no value corresponding to the data type is specified. Consider NULL in SQL as a placeholder for missing data. You should bear this in mind when writing your SQL queries.

With the following SQL statement, you can successfully search for all data records in which no value corresponding to the data type is specified for the specified DB field field_name_xy:

SELECT * FROM TABLE_NAME WHERE field_name_xy IS NULL;