A 4D object field is a persistent database field type, stored as binary content. Previously, reading this type of field by an ODBC driver wasn’t possible. Until today.
Before, an error was returned when trying to read an object field. This prevented the completion of simple Select * from myTable requests, which could be frustrating for users who only wanted to browse the content of a table.
Good news! The SQL engine has been updated to allow 4D object fields to be read.
UPDATED SQL engine
With the updated SQL engine and ODBC driver, instead of returning an error when reading an object field, the field is now returned as binary content.
SQL CAST function on 4D object field
To browse the content of an object field, the SQL CAST function has been extended to return a JSON representation of it (provided the object can be shown in JSON format).
Now you can sit back and enjoy using Select * from myTable to check all of your database’s content … from 4D, Excel, or Crystal Reports!
The query below can now be run:
SELECT Persons.name, CAST (Persons.address as VARCHAR) FROM Persons
And here is the result with MS Query:
Reading an object field using SQL in 4D
You can also read an object field in a C_OBJECT variable.
SELECT address FROM Persons WHERE name = 'Smith' into :$obj;