You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Joose Vettenranta <jo...@iki.fi> on 2004/07/09 19:02:26 UTC

modular database action and deleting from multiple tables

Hi,

updating & adding works OK. But when trying to do delete action, it  
seems to delete tables in wrong order happens: referential integrity  
violation in postgresql.

I have 3 tables in postgresql:

create table foo (
  id serial,
  name varchar(20),
primary key(id));

create table bar (
  id serial,
  foo_id integer,
  name varchar(20),
primary key (id),
foreign key (foo_id) references foo(id));

create table baz (
  id serial,
  foo_id integer,
  name varchar(20),
primary key (id),
foreign key (foo_id) references foo(id));


database.xml (for modulardatabase actions):

  <table name="foo" alias="foo">
   <keys>
    <key name="id" type="int" autoincrement="true" set="master">
     <mode name="auto"  type="autoincr"/>
    </key>
   </keys>
   <values>
    <value name="name" type="string"></value>
   </values>
  </table>

  <table name="bar" alias="bar">
   <keys>
    <key name="bar_id" type="int">
     <mode name="request-param" type="request-param"  
parameter="products.id">
      <parameter>products.id</parameter>
     </mode>
     <mode name="request-attr" type="attrib">
       
<parameter>org.apache.cocoon.components.modules.output.OutputModule: 
foo.id[0]</parameter>
     </mode>
    </key>
   </keys>
   <values>
    <value name="name"    type="string"></value>
   </values>
  </table>

for table baz the layout is same as in bar.

It tries first to remove foo and happens reference violation. So, how  
to make it remove the "childs" first and then the "master" table?

Thanks,

Joose

--
"Always remember that you are unique, just like everyone else!"
* http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: modular database action and deleting from multiple tables

Posted by Joose Vettenranta <jo...@iki.fi>.
Hi!

Seems like I solved the problem. The biggest problem was my typo.. I  
had wrong table-set in sitemap. And my table-set had also a bug, but  
this problem was solved by using correct table-set in sitemap =)

- Joose

9.7.2004 kello 20:02, Joose Vettenranta kirjoitti:

  Hi,
>
> updating & adding works OK. But when trying to do delete action, it  
> seems to delete tables in wrong order happens: referential integrity  
> violation in postgresql.
>
> I have 3 tables in postgresql:
>
> create table foo (
>  id serial,
>  name varchar(20),
> primary key(id));
>
> create table bar (
>  id serial,
>  foo_id integer,
>  name varchar(20),
> primary key (id),
> foreign key (foo_id) references foo(id));
>
> create table baz (
>  id serial,
>  foo_id integer,
>  name varchar(20),
> primary key (id),
> foreign key (foo_id) references foo(id));
>
>
> database.xml (for modulardatabase actions):
>
>  <table name="foo" alias="foo">
>   <keys>
>    <key name="id" type="int" autoincrement="true" set="master">
>     <mode name="auto"  type="autoincr"/>
>    </key>
>   </keys>
>   <values>
>    <value name="name" type="string"></value>
>   </values>
>  </table>
>
>  <table name="bar" alias="bar">
>   <keys>
>    <key name="bar_id" type="int">
>     <mode name="request-param" type="request-param"  
> parameter="products.id">
>      <parameter>products.id</parameter>
>     </mode>
>     <mode name="request-attr" type="attrib">
>       
> <parameter>org.apache.cocoon.components.modules.output.OutputModule: 
> foo.id[0]</parameter>
>     </mode>
>    </key>
>   </keys>
>   <values>
>    <value name="name"    type="string"></value>
>   </values>
>  </table>
>
> for table baz the layout is same as in bar.
>
> It tries first to remove foo and happens reference violation. So, how  
> to make it remove the "childs" first and then the "master" table?
>
> Thanks,
>
> Joose
>
> --
> "Always remember that you are unique, just like everyone else!"
> * http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
--
"Always remember that you are unique, just like everyone else!"
* http://iki.fi/joose/ * joose@iki.fi * +358 44 561 0270 *


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org