Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 78793476D9C for ; Thu, 7 Nov 2002 10:31:07 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 36A22477872 for ; Thu, 7 Nov 2002 10:16:22 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id gA7FGLhR019383; Thu, 7 Nov 2002 10:16:21 -0500 (EST) To: "Nekta Katz" Cc: pgsql-sql@postgresql.org Subject: Re: cast lo to oid In-reply-to: References: Comments: In-reply-to "Nekta Katz" message dated "Thu, 07 Nov 2002 23:22:26 +1100" Date: Thu, 07 Nov 2002 10:16:21 -0500 Message-ID: <19382.1036682181@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/105 X-Sequence-Number: 10247 "Nekta Katz" writes: > I have the following table > create table scan_docs ( > docid serial, > shipno numeric(10), > scan lo, > type text > ); > when I try to create the following rule > create rule "delete_scan_docs_lo" as > on delete to "scan_docs" > do select lo_unlink (old.scan); Why aren't you using the trigger that type LO provides for this purpose? Seems rather pointless to use a nonstandard type and then ignore the primary (sole) feature it provides... > create rule "delete_scan_docs_lo" as > on delete to "scan_docs" > do select lo_unlink (old.scan::oid); > "psql:scan_docs_rule.sql:3: ERROR: Cannot cast type 'lo' to 'oid' " Curious, as contrib/lo provides a function that's supposed to work for that: -- same function, named to allow it to be used as a type coercion, eg: -- CREATE TABLE a (image lo); -- SELECT image::oid FROM a; -- CREATE FUNCTION oid(lo) RETURNS oid AS 'MODULE_PATHNAME', 'lo_oid' LANGUAGE 'C'; What PG version are you using? regards, tom lane