SetDatabaseBlob()

Syntax

SetDatabaseBlob(#Database, StatementIndex, *Buffer, BufferLength)
Description
Set the blob for future use with DatabaseUpdate().

Parameters

#Database The database to use.
StatementIndex Undefined query parameter index the blob should be inserted for. The first undefined parameter index starts from zero. The SQL syntax to specify undefined parameter is database manager dependent. See the following examples to see how to proceed.
*Buffer The address of the blob data.
BufferLength The size of the blob data in bytes.

Return value

None.

Example: SQLite and ODBC

  ; SQLite and ODBC shares the same syntax to insert blob. It is indicated by the '?' character
  ;
  ; The database should be opened and a table PHOTOS with 3 column (BLOB, VARCHAR(255), BLOB)
  ;
  SetDatabaseBlob(0, 0, ?Picture, PictureLength)
  SetDatabaseBlob(0, 1, ?SmallPicture, SmallPictureLength)
  DatabaseUpdate(0, "INSERT INTO PHOTOS (picture, name, small_picture) values (?, 'my description', ?);")

Example: PostgreSQL

  ; PostgreSQL uses another syntax: $1, $2.. into the statement to indicate the undefined parameter
  ;
  ; The database should be opened and a table PHOTOS with 3 column (BYTEA, VARCHAR(255), BYTEA)
  ;
  SetDatabaseBlob(0, 0, ?Picture, PictureLength)
  SetDatabaseBlob(0, 1, ?SmallPicture, SmallPictureLength)
  DatabaseUpdate(0, "INSERT INTO PHOTOS (picture, name, small_picture) values ($1, 'my description', $2);")
Note: PostgreSQL uses BYTEA to store large objects. The escaping needed to store binary data into such a column make it often bigger than expected. A good way to store binary data is to encode it with Base64Encoder() before submitting to the database manager.

See Also

DatabaseUpdate(), GetDatabaseBlob()

Supported OS

All

<- PreviousDatabaseRow() - Database Index - SetDatabaseDouble() ->