How save any binary file to Postgresql

Hey
how i can save files like word doc or excel files to postgresql

look into the BLOB datatype… or just save the fileref/path in the database

ok
thanks

Alternatively: Catch the binary data in a encoded string and store it in a field of type TEXT.

that would be the perfect one for larger stuff, as you can read and write them as streams. But Large Objects are not a data type but an own kind of object in PostgreSQL. They have an OID identifier which you usually reference in a column. But keep in mind, you have to implement a strategy to to get rid of them once no longer needed/referenced otherwise they will pile up. And make sure they are included in your backup! Example: /Example Projects/Database/PostgreSQL/LargeObjects Docs: http://documentation.xojo.com/index.php/PostgreSQLLargeObject and PostgreSQL: Documentation: 14: Chapter 35. Large Objects

as this improses quite some overhead and compatibility issues if other clients / db functions want to access the data, I would only use such an approach for rather small binary strings.

The way I recommend for mid-size binary stuff is to store them in a bytea column in a PostgreSQL table and access them via MemoryBlocks from Xojo. (You should use at least 2017r2 - before you need to circumvent a bug). You can insert them using DatabaseRecord.BlobColumn or PostgreSQLPreparedStatement with the BindType POSTGRESQL_BYTEA and read or update them using DatabaseFiled.Value from a RecordSet.