You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Malte Vahlenkamp <Ma...@bdal.de> on 2002/05/06 08:44:27 UTC

Modular Database Actions - Multiple Inserts

Hello,

I have some problems with the modular database actions. I am trying to insert multiple rows from a form with several text boxes named ProjectParam1, ProjctParam2, ... The insert itself is runs, but all I get in this columns is a NULL value.  I already tried to solve this with a wildcard [*] but maybe I messed up something with the syntax. Any comments?

Thanks for your time

  Malte


Heres is the mapping I defined for the database action:

=========================== SNIP ==================================
	
	<table name="projectparams" alias="projectparams">
		<keys>
			<key name="ProjectParamsId" autoincrement="true" type="int">
				<mode name="auto" type="autoincr"/>
			</key>		
		</keys>
		
		<values>
		<value name="ProjectId"  type="int" set="master">									
			<mode name="attribute" parameter="org.apache.cocoon.components.modules.output.OutputModule:projects.projectid[0]" type="attrib"/>			
		</value>
		
		<value name="ParamName"  type="int">									
			<mode name="request" parameter="ParamName[*]" type="all"/>			
		</value>
		
		<value name="UnitName"  type="int">									
			<mode name="request" parameter="UnitName[*]" type="all"/>			
		</value>
		</values>
		
	</table>
		
	<table-set name="userAndProjects">
		<table name="projects"/>
		<table name="userprojects" others-mode="attrib"/>
		<table name="projectparams" others-mode="attrib"/>
	</table-set>

=========================== SNIP ==================================

And these are the request parameters

============================ SNIP =================================

<attributes>
<xsp-request:attribute-names>
<xsp-request:name>org.apache.cocoon.components.modules.output.OutputModule:userprojects.UserId[0]</xsp-request:name>
<xsp-request:name>org.apache.cocoon.components.modules.output.OutputModule:projectparams.ProjectParamsId[0]</xsp-request:name>
<xsp-request:name>org.apache.cocoon.components.modules.output.OutputModule:projectparams.ProjectId[0]</xsp-request:name>
<xsp-request:name>org.apache.cocoon.components.modules.output.OutputModule:projects.projectid[0]</xsp-request:name>
<xsp-request:name>org.apache.cocoon.components.modules.output.OutputModule:projects.userid[0]</xsp-request:name>
<xsp-request:name>org.apache.cocoon.components.modules.output.OutputModule:projects.ProjectName[0]</xsp-request:name>
<xsp-request:name>org.apache.cocoon.components.modules.output.OutputModule:userprojects.ProjectId[0]</xsp-request:name>
<xsp-request:name>org.apache.cocoon.action.modular.DatabaseAction.outputModeName</xsp-request:name>
</xsp-request:attribute-names>
	
</attributes>
	
<parameters>
<xsp-request:parameter-names>
<xsp-request:name>ProjectName</xsp-request:name>
<xsp-request:name>ProjectParamsId1</xsp-request:name>
<xsp-request:name>ProjectId</xsp-request:name>
<xsp-request:name>UserId</xsp-request:name>
<xsp-request:name>UnitName1</xsp-request:name>
<xsp-request:name>ParamName1</xsp-request:name>
</xsp-request:parameter-names>
	
</parameters>	

=================================== SNIP ====================================


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Modular Database Actions - Multiple Inserts

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 06.May.2002 -- 08:44 AM, Malte Vahlenkamp wrote:
> Hello,
> 
> I have some problems with the modular database actions. I am trying
> to insert multiple rows from a form with several text boxes named
> ProjectParam1, ProjctParam2, ... The insert itself is runs, but all I
> get in this columns is a NULL value.  I already tried to solve this
> with a wildcard [*] but maybe I messed up something with the
> syntax. Any comments? 

The crucial part when working on more than one row is to define which
columns vary and which are constant. This is done through the "set"
attribute to a column or a mode. All columns in a set vary and all
others are fixed.

Sets have one column that is special, the master column. The master
column is used to determine a) the number of rows to work on and b)
an enumeration of objects that is used to find the corresponding value
for the other columns.

As a consequence, only columns in a set may have a wildcard. In
addition, the behaviour depends on the input module used.

Thus you are missing to things here: ParamName and UnitName must have
a set attribute and your master column needs to have a wildcard.

> 	<table name="projectparams" alias="projectparams">
> 		<keys>
> 			<key name="ProjectParamsId" autoincrement="true" type="int">
> 				<mode name="auto" type="autoincr"/>
> 			</key>		
> 		</keys>
> 		
> 		<values>
> 		<value name="ProjectId"  type="int" set="master">									
 			<mode name="attribute" parameter="org.apache.cocoon.components.modules.output.OutputModule:projects.projectid[*]" type="attrib"/>
                                                                                                                         -^-
> 		</value>
> 		
  		<value name="ParamName"  type="int" set="slave">									
                                           -^^^^^^^^^^^-
> 			<mode name="request" parameter="ParamName[*]" type="all"/>			
> 		</value>
> 		
 		<value name="UnitName"  type="int" set="slave">									
                                          -^^^^^^^^^^^-
> 			<mode name="request" parameter="UnitName[*]" type="all"/>			
> 		</value>
> 		</values>
> 		
> 	</table>
> 		
> 	<table-set name="userAndProjects">
> 		<table name="projects"/>
> 		<table name="userprojects" others-mode="attrib"/>
> 		<table name="projectparams" others-mode="attrib"/>
> 	</table-set>

	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

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Modular Database Actions - Multiple Inserts

Posted by "Sreenivasan N." <sr...@ap.sony.com>.
Hello Malte

How are you and things. I saw your posting in Cocoon-user group and got an 
impression that you are developing a Intranet on Projects. I am also into 
same development and struckup in the initial stage. Can you help me in this 
regards.

My requirement is
1. Converting Request from a form to xml
2. Merging the same with another xml which was generated taking data from 
database.

Thanks in advance

Regards

Sreenivasan.

At 08:44 AM 5/6/02 +0200, you wrote:
>Hello,
>
>I have some problems with the modular database actions. I am trying to 
>insert multiple rows from a form with several text boxes named 
>ProjectParam1, ProjctParam2, ... The insert itself is runs, but all I get 
>in this columns is a NULL value.  I already tried to solve this with a 
>wildcard [*] but maybe I messed up something with the syntax. Any comments?
>
>Thanks for your time
>
>   Malte
>
>
>Heres is the mapping I defined for the database action:
>
>=========================== SNIP ==================================
>
>         <table name="projectparams" alias="projectparams">
>                 <keys>
>                         <key name="ProjectParamsId" autoincrement="true" 
> type="int">
>                                 <mode name="auto" type="autoincr"/>
>                         </key>
>                 </keys>
>
>                 <values>
>                 <value name="ProjectId"  type="int" 
> set="master"> 
>
>                         <mode name="attribute" 
> parameter="org.apache.cocoon.components.modules.output.OutputModule:projects.projectid[0]" 
> type="attrib"/>
>                 </value>
>
>                 <value 
> name="ParamName"  type="int"> 
 >
>                         <mode name="request" parameter="ParamName[*]" 
> type="all"/>
>                 </value>
>
>                 <value 
> name="UnitName"  type="int"> 
 >
>                         <mode name="request" parameter="UnitName[*]" 
> type="all"/>
>                 </value>
>                 </values>
>
>         </table>
>
>         <table-set name="userAndProjects">
>                 <table name="projects"/>
>                 <table name="userprojects" others-mode="attrib"/>
>                 <table name="projectparams" others-mode="attrib"/>
>         </table-set>
>
>=========================== SNIP ==================================
>
>And these are the request parameters
>
>============================ SNIP =================================
>
><attributes>
><xsp-request:attribute-names>
><xsp-request:name>org.apache.cocoon.components.modules.output.OutputModule:userprojects.UserId[0]</xsp-request:name>
><xsp-request:name>org.apache.cocoon.components.modules.output.OutputModule:projectparams.ProjectParamsId[0]</xsp-request:name>
><xsp-request:name>org.apache.cocoon.components.modules.output.OutputModule:projectparams.ProjectId[0]</xsp-request:name>
><xsp-request:name>org.apache.cocoon.components.modules.output.OutputModule:projects.projectid[0]</xsp-request:name>
><xsp-request:name>org.apache.cocoon.components.modules.output.OutputModule:projects.userid[0]</xsp-request:name>
><xsp-request:name>org.apache.cocoon.components.modules.output.OutputModule:projects.ProjectName[0]</xsp-request:name>
><xsp-request:name>org.apache.cocoon.components.modules.output.OutputModule:userprojects.ProjectId[0]</xsp-request:name>
><xsp-request:name>org.apache.cocoon.action.modular.DatabaseAction.outputModeName</xsp-request:name>
></xsp-request:attribute-names>
>
></attributes>
>
><parameters>
><xsp-request:parameter-names>
><xsp-request:name>ProjectName</xsp-request:name>
><xsp-request:name>ProjectParamsId1</xsp-request:name>
><xsp-request:name>ProjectId</xsp-request:name>
><xsp-request:name>UserId</xsp-request:name>
><xsp-request:name>UnitName1</xsp-request:name>
><xsp-request:name>ParamName1</xsp-request:name>
></xsp-request:parameter-names>
>
></parameters>
>
>=================================== SNIP ====================================
>
>
>---------------------------------------------------------------------
>Please check that your question has not already been answered in the
>FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
>To unsubscribe, e-mail: <co...@xml.apache.org>
>For additional commands, e-mail: <co...@xml.apache.org>








"Attitudes are much more important than aptitudes."
"Nothing is impossible for a willing heart"

Sreenivasan N.
Sony SARD
Ext 232

Email. sreenivasan.n@ap.sony.com
Per: nsreenivasan@yahoo.com


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>