pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
cast lo to oid
4+ messages / 2 participants
[nested] [flat]

* cast lo to oid
@ 2002-11-07 12:22  Nekta Katz <nekta_k@hotmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Nekta Katz @ 2002-11-07 12:22 UTC (permalink / raw)
  To: pgsql-sql

Hi,

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);

I get the error message

"psql:scan_docs_rule.sql:3: ERROR:  Function 'lo_unlink(lo)' does not exist
Unable to identify a function that satisfies the given argument types
You may need to add explicit typecasts"

So I add a type cast

create rule "delete_scan_docs_lo" as
on delete to "scan_docs"
do select lo_unlink (old.scan::oid);

but I get the following error message

"psql:scan_docs_rule.sql:3: ERROR:  Cannot cast type 'lo' to 'oid' "

Is there away around this?



_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. 
http://join.msn.com/?page=features/featuredemail




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: cast lo to oid
@ 2002-11-07 15:16  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Nekta Katz <nekta_k@hotmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2002-11-07 15:16 UTC (permalink / raw)
  To: Nekta Katz <nekta_k@hotmail.com>; +Cc: pgsql-sql

"Nekta Katz" <nekta_k@hotmail.com> 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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: cast lo to oid
@ 2002-11-08 00:11  Nekta Katz <nekta_k@hotmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Nekta Katz @ 2002-11-08 00:11 UTC (permalink / raw)
  To: tgl@sss.pgh.pa.us; +Cc: pgsql-sql

I didn't realize there was a contrib/lo, I only created the lo type as 
described in the psqlodbc faq.

I have now installed the contrib/lo and everything is working fine.

I am using PG version 7.2

thanks.



>From: Tom Lane <tgl@sss.pgh.pa.us>
>To: "Nekta Katz" <nekta_k@hotmail.com>
>CC: pgsql-sql@postgresql.org
>Subject: Re: [SQL] cast lo to oid Date: Thu, 07 Nov 2002 10:16:21 -0500
>
>"Nekta Katz" <nekta_k@hotmail.com> 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


_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: cast lo to oid
@ 2002-11-08 00:24  Nekta Katz <nekta_k@hotmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Nekta Katz @ 2002-11-08 00:24 UTC (permalink / raw)
  To: tgl@sss.pgh.pa.us; +Cc: pgsql-sql

I didn't realize there was a contrib/lo, I only created the lo type as 
described in the psqlodbc faq.

I have now installed the contrib/lo and everything is working fine.

I am using PG version 7.2

thanks.

>From: Tom Lane <tgl@sss.pgh.pa.us>
>To: "Nekta Katz" <nekta_k@hotmail.com>
>CC: pgsql-sql@postgresql.org
>Subject: Re: [SQL] cast lo to oid Date: Thu, 07 Nov 2002 10:16:21 -0500
>
>"Nekta Katz" <nekta_k@hotmail.com> 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
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org


_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2002-11-08 00:24 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-11-07 12:22 cast lo to oid Nekta Katz <nekta_k@hotmail.com>
2002-11-07 15:16 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-11-08 00:11 Re: cast lo to oid Nekta Katz <nekta_k@hotmail.com>
2002-11-08 00:24 Re: cast lo to oid Nekta Katz <nekta_k@hotmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox