You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jan Wielgus <li...@o2.pl> on 2003/10/31 17:23:17 UTC

Database actions - how to implement conditions?

Hello,

I'm using DatabaseDeleteAction to delete rows from a table. But
before the row is deleted I would like to check it for a condition
(in this special case if the primary key of that row is not anymore
referenced in other tables - if it would be, than it can't be
deleted). How can I put this "checking" before the actual
"delete"-action will be executed? 
I'm using a form for choosing the item to be deleted:

<xsl:template match="kpage">
  	<center>
  		<h3>Dokumenten-Kategorien</h3>
  	</center>
    <form action="main.xsp" method="post">
      <table class="list" align="center">
        <xsl:apply-templates select="kategorie" />
      <input type="hidden" name="id" value="{bid}" />
      <input type="hidden" name="cocoon-action" value="Delete" />
     <tr><td class="list" colspan="2"><input type="submit"
value="Loeschen" /></td></tr>
    </table>
    </form>
  </xsl:template>
  <xsl:template match="kategorie">
    <tr>
      <td class="list" width="300">
        <xsl:value-of select="name" />
      </td>
      <td class="list">
        <input type="radio" name="katid"
        value="{normalize-space(id)}" />
      </td>
    </tr>
  </xsl:template>

Regards

Jan


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


Re: Database actions - how to implement conditions?

Posted by Christian Haul <ha...@informatik.tu-darmstadt.de>.
Jan Wielgus wrote:
> Hello,
> 
> I'm using DatabaseDeleteAction to delete rows from a table. But
> before the row is deleted I would like to check it for a condition
> (in this special case if the primary key of that row is not anymore
> referenced in other tables - if it would be, than it can't be
> deleted). How can I put this "checking" before the actual
> "delete"-action will be executed? 
> I'm using a form for choosing the item to be deleted:

They are not meant to do this. One way could be to use the *QueryAction 
which allows arbitrary SQL. However, the best solution would be IMHO to 
make this a foreign key relationship guarded by the DBMS and chose a 
different pipeline if the action fails to delete the row.

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
     fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08


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