dbTalk Databases Forums  

Blob with OIDs and trigger

comp.databases.postgresql comp.databases.postgresql


Discuss Blob with OIDs and trigger in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Philipp Kraus
 
Posts: n/a

Default Blob with OIDs and trigger - 11-18-2009 , 08:01 AM






Hi,

I have create a table with this structur

CREATE TABLE import
(
id1 integer NOT NULL,
id2 integer NOT NULL,
dataset oid NOT NULL,
CONSTRAINT import_pk PRIMARY KEY (id1, id2),
CONSTRAINT import_fk FOREIGN KEY (id1, id1)
REFERENCES ... MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE
)
WITH (OIDS=FALSE);

I insert my blobs with JDBC and I can read / write them without problems.

Must I delete explicite the blob, if I delete a row on my table "import" ?
If yes, how? I would like to do this with a trigger on my table.

Thanks a lot
Phil

Reply With Quote
  #2  
Old   
Thomas Kellerer
 
Posts: n/a

Default Re: Blob with OIDs and trigger - 11-18-2009 , 08:16 AM






Philipp Kraus, 18.11.2009 15:01:
Quote:
Hi,

I have create a table with this structur

CREATE TABLE import
(
id1 integer NOT NULL,
id2 integer NOT NULL,
dataset oid NOT NULL,
CONSTRAINT import_pk PRIMARY KEY (id1, id2),
CONSTRAINT import_fk FOREIGN KEY (id1, id1)
REFERENCES ... MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE
)
WITH (OIDS=FALSE);

I insert my blobs with JDBC and I can read / write them without problems.

Must I delete explicite the blob, if I delete a row on my table "import" ?
If yes, how? I would like to do this with a trigger on my table.
My understanding is that you need to take care of deleting the large objects yourself.

Unless you have BLOBs > 1GB and/or you need to access only parts of the BLOBs (e.g. bytes 42 to 56) you can use bytea columns instead. They are easy to read and write in JDBC (set/getBinaryStream) and you don't need to worry about housekeeping.

Thomas

Reply With Quote
  #3  
Old   
Philipp Kraus
 
Posts: n/a

Default Re: Blob with OIDs and trigger - 11-18-2009 , 08:42 AM



On 2009-11-18 15:16:04 +0100, Thomas Kellerer
<OTPXDAJCSJVU (AT) spammotel (DOT) com> said:

Quote:
Philipp Kraus, 18.11.2009 15:01:
Hi,

I have create a table with this structur

CREATE TABLE import
(
id1 integer NOT NULL,
id2 integer NOT NULL,
dataset oid NOT NULL,
CONSTRAINT import_pk PRIMARY KEY (id1, id2),
CONSTRAINT import_fk FOREIGN KEY (id1, id1)
REFERENCES ... MATCH SIMPLE
ON UPDATE CASCADE ON DELETE CASCADE
)
WITH (OIDS=FALSE);

I insert my blobs with JDBC and I can read / write them without problems.

Must I delete explicite the blob, if I delete a row on my table "import" ?
If yes, how? I would like to do this with a trigger on my table.

My understanding is that you need to take care of deleting the large
objects yourself.
I understand that also, but how can I delete the binary data in a
trigger function in the table?
I would like to run a trigger on update / delete that delete the binary
data (if it is required)

Reply With Quote
  #4  
Old   
Thomas Kellerer
 
Posts: n/a

Default Re: Blob with OIDs and trigger - 11-18-2009 , 09:06 AM



Philipp Kraus, 18.11.2009 15:42:
Quote:
I understand that also, but how can I delete the binary data in a
trigger function in the table?
I would like to run a trigger on update / delete that delete the binary
data (if it is required)
Maybe this helps:
http://www.postgresql.org/docs/8.4/static/lo.html

Why don't you use bytea? Makes live a lot easier

Thomas

Reply With Quote
  #5  
Old   
Thomas Kellerer
 
Posts: n/a

Default Re: Blob with OIDs and trigger - 11-18-2009 , 09:07 AM



Thomas Kellerer, 18.11.2009 16:06:
Quote:
Philipp Kraus, 18.11.2009 15:42:
I understand that also, but how can I delete the binary data in a
trigger function in the table?
I would like to run a trigger on update / delete that delete the
binary data (if it is required)

Maybe this helps:
http://www.postgresql.org/docs/8.4/static/lo.html
Oh and: http://www.postgresql.org/docs/8.4/static/vacuumlo.html

Reply With Quote
  #6  
Old   
Philipp Kraus
 
Posts: n/a

Default Re: Blob with OIDs and trigger - 11-18-2009 , 09:26 AM



On 2009-11-18 16:06:48 +0100, Thomas Kellerer
<OTPXDAJCSJVU (AT) spammotel (DOT) com> said:

Quote:
Philipp Kraus, 18.11.2009 15:42:
I understand that also, but how can I delete the binary data in a
trigger function in the table?
I would like to run a trigger on update / delete that delete the binary
data (if it is required)

Maybe this helps:
http://www.postgresql.org/docs/8.4/static/lo.html

Why don't you use bytea? Makes live a lot easier
I have take the example under 8.3 but it dosn't work

CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON image
FOR EACH ROW EXECUTE PROCEDURE lo_manage(raster);

The command "lo_manage" isn't known by the database

Reply With Quote
  #7  
Old   
Thomas Kellerer
 
Posts: n/a

Default Re: Blob with OIDs and trigger - 11-18-2009 , 09:48 AM



Philipp Kraus, 18.11.2009 16:26:
Quote:
I have take the example under 8.3 but it dosn't work

CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON image
FOR EACH ROW EXECUTE PROCEDURE lo_manage(raster);

The command "lo_manage" isn't known by the database

Did you install the module?

Reply With Quote
  #8  
Old   
Philipp Kraus
 
Posts: n/a

Default Re: Blob with OIDs and trigger - 11-18-2009 , 09:55 AM



On 2009-11-18 16:48:55 +0100, Thomas Kellerer
<OTPXDAJCSJVU (AT) spammotel (DOT) com> said:

Quote:
Philipp Kraus, 18.11.2009 16:26:
I have take the example under 8.3 but it dosn't work

CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON image
FOR EACH ROW EXECUTE PROCEDURE lo_manage(raster);

The command "lo_manage" isn't known by the database

Did you install the module?
I had installed the binary package for OSX and created the
plpsql language into my database. Do I have forgot something?

Reply With Quote
  #9  
Old   
Thomas Kellerer
 
Posts: n/a

Default Re: Blob with OIDs and trigger - 11-18-2009 , 10:15 AM



Philipp Kraus, 18.11.2009 16:55:
Quote:
On 2009-11-18 16:48:55 +0100, Thomas Kellerer
OTPXDAJCSJVU (AT) spammotel (DOT) com> said:

Philipp Kraus, 18.11.2009 16:26:
I have take the example under 8.3 but it dosn't work

CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON image
FOR EACH ROW EXECUTE PROCEDURE lo_manage(raster);

The command "lo_manage" isn't known by the database

Did you install the module?

I had installed the binary package for OSX and created the
plpsql language into my database. Do I have forgot something?

Yes, you need to install the contrib module "lo".
The script should be located in share/contrib

Thomas

Reply With Quote
  #10  
Old   
Philipp Kraus
 
Posts: n/a

Default Re: Blob with OIDs and trigger - 11-18-2009 , 12:31 PM



On 2009-11-18 17:15:58 +0100, Thomas Kellerer
<OTPXDAJCSJVU (AT) spammotel (DOT) com> said:

Quote:
Philipp Kraus, 18.11.2009 16:55:
On 2009-11-18 16:48:55 +0100, Thomas Kellerer
OTPXDAJCSJVU (AT) spammotel (DOT) com> said:

Philipp Kraus, 18.11.2009 16:26:
I have take the example under 8.3 but it dosn't work

CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON image
FOR EACH ROW EXECUTE PROCEDURE lo_manage(raster);

The command "lo_manage" isn't known by the database

Did you install the module?

I had installed the binary package for OSX and created the
plpsql language into my database. Do I have forgot something?

Yes, you need to install the contrib module "lo". The script should be
located in share/contrib
Thanks. It works now

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.