Обсуждение: cast lo to oid
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
"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
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
Hi, I wonder if it is possible to remove a field of a table ? I haven't found anything about this into the reference manual. Can I do something like that ?: ALTER TABLE table DROP COLUMN column; Thanks Rachel ************************************** Rachel.Vaudron@lazaret.unice.fr Laboratoire de prehistoire du Lazaret33 bis bd Franck Pilatte 06300 Nice http://rachel.familinux.org ******** Windows a bug's life ********
Uz.ytkownik Rachel.Vaudron napisa?: > Hi, > > I wonder if it is possible to remove a field of a table ? > I haven't found anything about this into the reference manual. > Can I do something like that ?: > > ALTER TABLE table > DROP COLUMN column; alter table xxx rename to temp; create table xxx as select field1, field2, ...without some field... from temp; drop table temp; Tomasz Myrta
Thanks a lot, but it's already what i am doing! It's very a pity that there is no way do to this more quickly!!! > alter table xxx rename to temp; > create table xxx as > select field1, field2, ...without some field... from temp; > drop table temp; > > Tomasz Myrta > > Rachel
I think 7.3 has this feature. Daniel ""Rachel.Vaudron"" <rachel@lazaret.unice.fr> schrieb im Newsbeitrag news:Pine.LNX.4.33.0211080811160.12232-100000@lazaret.unice.fr... > Hi, > > I wonder if it is possible to remove a field of a table ? > I haven't found anything about this into the reference manual. > Can I do something like that ?: > > ALTER TABLE table > DROP COLUMN column; > > Thanks > Rachel > ************************************** > Rachel.Vaudron@lazaret.unice.fr > Laboratoire de prehistoire du Lazaret > 33 bis bd Franck Pilatte 06300 Nice > http://rachel.familinux.org > ******** Windows a bug's life ******** > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org
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