Insert/update TBlobfield (aka image) using sql parameters
Should be something like:
qry.Parameters.Clear;
qry.Parameters.AddParameter.Name := 'blobVal';
qry.Parameters.ParamByName('blobVal').LoadFromFile('c:\sample.jpg', ftBlob);
// or load from stream:
// qry.Parameters.ParamByName('blobVal').LoadFromStream(MyStream, ftBlob);
qry.Parameters.AddParameter.Name := 'idVal';
qry.Parameters.ParamByName('idVal').Value := 1;
qry.SQL.Text := 'update tbl set pic = :blobVal where id = :idVal';
qry.ExecSQL;
To read the BLOB back from the DB:
qry.SQL.Text := 'select id, pic from tbl where id = 1';
qry.Open;
TBlobField(qry.FieldByName('pic')).SaveToFile('c:\sample_2.jpg');
What is the most efficient way to read tile data (MBTiles) from SQLite table by using AnyDAC (FireDAC)?
Definitely use TADQuery
. Unless you set the query to Unidirectional
, it will buffer all the records returned from the database in memory (default 50). Since you are dealing with blobs, your query should be written to retrieve the minimum number of records you need.
Use a parameterized query, like the following the query
SELECT * FROM ATable
WHERE X = :X AND Y = :Y AND Z = :Z
Once you have initially opened the query, you can change the parameters, then use the Refresh
method to retrieve the next record.
A memory table could not be used to retrieve data from the database, it would have to be populated via a query. It could be used to replace your TTileCache
records, but I would not recommend it because it would have more overhead than your memory cache implementation.
Related Topics
How to Understand How Value Converted to Date Format Implicitly
It's Possible to Create a Rule in Preceding Rows in Sum
Insert Xml File in SQL via Ssis
Determine Latest Row Added When No Index Is Present
SQL Query for Today's Date Minus Two Months
SQL Query Where Field Does Not Contain $X
SQL Statement Using Where Clause with Multiple Values
Sqlite - Replace Part of a String
SQL Database Design Best Practice (Addresses)
How to Confirm a Database Is Oracle & What Version It Is Using SQL
How to List Active Connections on Postgresql
Database Schema for Organizing Historical Stock Data
How to Delete Multiple Rows in SQL Where Id = (X to Y)
Select Multiple Columns from a Table, But Group by One
When Shouldn't You Use a Relational Database
How to Select a List of 10,000 Unique Ids from Dual in Oracle SQL