PostgreSQLDatabase.OpenLargeObject

From Xojo Documentation

Method

PostgreSQLDatabase.OpenLargeObject(oid as Integer, [ReadOnly as Boolean=False]) As PostgreSQLLargeObject

Supported for all project types and targets.

Opens the large object specified by the passed oid. The ReadOnly parameter is optional and defaults to False. If you pass True, then the large object will be opened in read-only mode. If OpenLargeObject is successful, it returns an instance of PostgreSQLLargeObject.

Notes

PostgreSQL requires that all large object operations be performed inside of a transaction. Therefore, you must start a transaction before you perform your first large object operation:

db.ExecuteSQL("BEGIN TRANSACTION")

After you have performed your last large object operation, you should close the transaction, like this:

db.ExecuteSQL("END TRANSACTION")

Please see the PostgreSQLLargeObject class for information on how to work with large objects.

Example

Read the data in a large object:

// db is a previously connected PostgreSQLDatabase
// objectID is an integer referring to a previously created large object
Var largeObject As PostgreSQLLargeObject
largeObject = db.OpenLargeObject(objectID)

Var data As String = largeObject.Read(largeObject.Length)