Firebird Question:
Download Questions PDF

How to load a file into database column?

Answer:

While some other database systems might have an SQL function for this, with Firebird you need an application. Datatype that holds binary files is called BLOB, and you should use sub_type zero, as sub_type one is for text-only data. Let's create a table to hold the file. We'll have a filename column and a blob column containing the file itself:

CREATE TABLE t1
(
file_name VARCHAR(200),
file_data BLOB SUB_TYPE 0
);

The blobs are loaded via parametrized query:

INSERT INTO t1 (file_name, file_data) VALUES (?, ?);

Download Firebird Interview Questions And Answers PDF

Previous QuestionNext Question
How to lock records in a table?How to get a list of tables, views and columns in Firebird database?