1CREATE EXTENSION lo;
2
3CREATE TABLE image (title text, raster lo);
4
5CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON image
6    FOR EACH ROW EXECUTE PROCEDURE lo_manage(raster);
7
8SELECT lo_create(43213);
9SELECT lo_create(43214);
10
11INSERT INTO image (title, raster) VALUES ('beautiful image', 43213);
12
13SELECT lo_get(43213);
14SELECT lo_get(43214);
15
16UPDATE image SET raster = 43214 WHERE title = 'beautiful image';
17
18SELECT lo_get(43213);
19SELECT lo_get(43214);
20
21DELETE FROM image;
22
23SELECT lo_get(43214);
24
25DROP TABLE image;
26