[Zope-DB] Help needed with multi-table insert form
Norman Khine
norman@khine.net
Wed, 22 Jan 2003 16:34:01 -0000
This is a multi-part message in MIME format.
------=_NextPart_000_0007_01C2C234.11FE6D90
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hello,
I have a PostgreSQL database which has a number of tables, I have =
created a ZSQL Method called sql_INSERT_form which is as follows:
with Arguments:
business_name business_url business_type_id street_name town city =
postcode county_id title initials fname surname telephone fax email =
regdate status job_function_id
INSERT INTO business_name (business_name, business_url, =
business_type_id)
values (<dtml-sqlvar business_name type=3D"string" >, <dtml-sqlvar =
business_url type=3D"string">, <dtml-sqlvar business_type_id =
type=3D"int">);
<dtml-var sql_delimiter>
INSERT INTO business_address (street_name, town, city, postcode, =
county_id, business_name_id) values=20
(<dtml-sqlvar street_name type=3D"string">,
<dtml-sqlvar town type=3D"string">,
<dtml-sqlvar city type=3D"string">,=20
<dtml-sqlvar postcode type=3D"string">,
<dtml-sqlvar county_id type=3D"int">,
business_name_business_name_seq.last_value);
<dtml-var sql_delimiter>
INSERT INTO reseller (title, initials, fname, surname, telephone, fax, =
email, regdate, status, job_function_id, business_name_id)
values
(<dtml-sqlvar title type=3D"string">,
<dtml-sqlvar initials type=3D"string">,
<dtml-sqlvar fname type=3D"string">,
<dtml-sqlvar surname type=3D"string">,
<dtml-sqlvar telephone type=3D"string">,
<dtml-sqlvar fax type=3D"string">,
<dtml-sqlvar email type=3D"string">,
<dtml-sqlvar regdate type=3D"string">,
<dtml-sqlvar status type=3D"string">,
<dtml-sqlvar job_function_id type=3D"int">,
business_name_business_name_seq.last_value
);
When I test this, the database is populated as required.
BUT, when I try to add a form which is as follows:
<table border=3D0 cellpadding=3D3 cellspacing=3D4>
<form method=3D"post" name=3D"register" action=3D"resellerAdd.dtml">
<input type=3Dhidden name=3D"regdate" value=3D"<dtml-var DateTime>">
<input type=3Dhidden name=3D"status" type" value=3D"1">
<input type=3Dhidden name=3D"job_function_id" type" value=3D"1">
<tr>=20
<td colspan=3D4 bgcolor=3D"#99CCCC"> <font size=3D-1 face=3DArial> =
<b>Personal Profile</b> </font> </td>
</tr>
<tr>=20
<td> <font size=3D-1 face=3DArial> Title </font> </td>
<td> <select name=3D"title">
<option value=3D"">[Select One]</option>
<option>Mr.</option>
<option>Mrs.</option>
<option>Miss</option>
<option>Dr.</option>
</select> </td>
<td> <font size=3D-1 face=3DArial> First Name </font> </td>
<td> <input type=3D"text" name=3D"fname" size=3D10 maxlength=3D35> =
</td>
</tr>
<tr>=20
<td> <font size=3D-1 face=3DArial> Initials </font> </td>
<td> <input type=3D"text" name=3D"initials" size=3D1 =
maxlength=3D1> </td>
<td> <font size=3D-1 face=3DArial> Last Name </font> </td>
<td> <input type=3D"text" name=3D"surname" size=3D10 =
maxlength=3D35> </td>
</tr>
<tr>=20
<td colspan=3D4 bgcolor=3D"#99CCCC"> <font size=3D-1 face=3DArial> =
<b>Business Profile</b> </font> </td>
</tr>
<tr>=20
<td> <font size=3D-1 face=3DArial> Business Name </font> </td>
<td> <input type=3D"text" name=3D"business_name" size=3D15 =
maxlength=3D40>=20
</td>
<td> <font size=3D-1 face=3DArial> Job Title </font> </td>
<td> <input type=3D"text" name=3D"job_title" size=3D10 maxlength=3D40> =
</td>
</tr>
<tr>=20
<td> <font size=3D-1 face=3DArial> Street Address </font> </td>
<td> <input type=3D"text" name=3D"street_name" size=3D15 =
maxlength=3D25> </td>
<td> <font size=3D-1 face=3DArial> Town </font> </td>
<td> <input type=3D"text" name=3D"town" size=3D10 maxlength=3D25> </td>
</tr>
<tr>=20
<td> <font size=3D-1 face=3DArial> City </font> </td>
<td> <input type=3D"text" name=3D"city" size=3D10 maxlength=3D25> </td>
<td> <font size=3D-1 face=3DArial>Postal Code</font> </td>
<td> <input type=3D"text" name=3D"postcode" size=3D8 maxlength=3D"10">=20
</td>
</tr>
<tr>
<td> <font size=3D-1 face=3DArial> This is my </font> </td>
<td colspan=3D3> <select name=3D"homeorbusiness">
<option value=3D"1" selected>business address=20
<option value=3D"0">home address </select>
</td>
</tr>
<tr>=20
<td > <font size=3D-1 face=3DArial>Telephone</font> </td>
<td> <input type=3D"text" name=3D"telephone" size=3D10 =
maxlength=3D"20"> </td>
<td > <font size=3D-1 face=3DArial>Fax</font> </td>
<td> <input type=3D"text" name=3D"fax" size=3D10 maxlength=3D"20"> =
</td>
</tr>
<tr>=20
<td > <font size=3D-1 face=3DArial>Email Address</font> </td>
<td> <input type=3D"text" name=3D"email" size=3D10 maxlength=3D"45"> =
</td>
<td > <font size=3D-1 face=3DArial>Web site</font> </td>
<td><input type=3D"text" name=3D"business_url" value=3D"http://" =
size=3D15 maxlength=3D"35">=20
</td>
</tr>
<tr>=20
<td colspan=3D4 align=3Dcenter> <input type=3D"submit" name=3D"submit" =
value=3D"Submit Information">=20
<input type=3D"reset" name=3D"reset" value=3D"Reset =
Form">=20
</td>
</tr>
</table>
and resellerAdd.dtml DTML Method, which contains the following:
<dtml-call sql_INSERT_form>
<h2>Customer <dtml-var name=3D"business_name"> was added.</h2>
everytime i add submit, the server returns nothing .....
Any help will be much appreciated
Thanks
------=_NextPart_000_0007_01C2C234.11FE6D90
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have a PostgreSQL database which has =
a number of=20
tables, I have created a ZSQL Method called sql_INSERT_form which is as=20
follows:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>with Arguments:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>business_name business_url =
business_type_id=20
street_name town city postcode county_id title initials fname surname =
telephone=20
fax email regdate status job_function_id</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>INSERT INTO business_name =
(business_name,=20
business_url, business_type_id)<BR> values (<dtml-sqlvar =
business_name=20
type=3D"string" >, <dtml-sqlvar business_url type=3D"string">,=20
<dtml-sqlvar business_type_id type=3D"int">);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2><dtml-var =
sql_delimiter></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>INSERT INTO business_address =
(street_name, town,=20
city, postcode, county_id, business_name_id) values <BR>(<dtml-sqlvar =
street_name type=3D"string">,<BR><dtml-sqlvar town=20
type=3D"string">,<BR><dtml-sqlvar city type=3D"string">,=20
<BR><dtml-sqlvar postcode type=3D"string">,<BR><dtml-sqlvar =
county_id=20
type=3D"int">,<BR>business_name_business_name_seq.last_value);</FONT><=
/DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2><dtml-var =
sql_delimiter></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>INSERT INTO reseller (title, initials, =
fname,=20
surname, telephone, fax, email, regdate, status, job_function_id,=20
business_name_id)<BR>values<BR>(<dtml-sqlvar title=20
type=3D"string">,<BR><dtml-sqlvar initials=20
type=3D"string">,<BR><dtml-sqlvar fname=20
type=3D"string">,<BR><dtml-sqlvar surname=20
type=3D"string">,<BR><dtml-sqlvar telephone=20
type=3D"string">,<BR><dtml-sqlvar fax =
type=3D"string">,<BR><dtml-sqlvar=20
email type=3D"string">,<BR><dtml-sqlvar regdate=20
type=3D"string">,<BR><dtml-sqlvar status=20
type=3D"string">,<BR><dtml-sqlvar job_function_id=20
type=3D"int">,<BR>business_name_business_name_seq.last_value<BR>);</FO=
NT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>When I test this, the database is =
populated as=20
required.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>BUT, when I try to add a form which is =
as=20
follows:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><table border=3D0 cellpadding=3D3=20
cellspacing=3D4><BR><form method=3D"post" name=3D"register"=20
action=3D"resellerAdd.dtml"></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><input type=3Dhidden =
name=3D"regdate"=20
value=3D"<dtml-var DateTime>"></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><input type=3Dhidden name=3D"status" =
type"=20
value=3D"1"></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><input type=3Dhidden =
name=3D"job_function_id" type"=20
value=3D"1"></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><tr> <BR><td colspan=3D4=20
bgcolor=3D"#99CCCC"> <font size=3D-1 face=3DArial> =
<b>Personal=20
Profile</b> </font> </td><BR></tr><BR><tr> =
<BR> <td> <font size=3D-1 face=3DArial> Title =
</font>=20
</td><BR> <td> <select=20
name=3D"title"><BR> =
<option=20
value=3D"">[Select=20
One]</option><BR> =20
<option>Mr.</option><BR> &=
nbsp; =20
<option>Mrs.</option><BR> =
=20
<option>Miss</option><BR> =
=20
<option>Dr.</option><BR> &=
nbsp;=20
</select> </td><BR> <td> <font size=3D-1 =
face=3DArial>=20
First Name </font> </td><BR> =20
<td> <input type=3D"text" name=3D"fname" size=3D10 =
maxlength=3D35>=20
<BR> </td><BR></tr><BR><tr> <BR> <td> =
<font=20
size=3D-1 face=3DArial> Initials </font>=20
</td><BR> <td> <input =
type=3D"text"=20
name=3D"initials" size=3D1 maxlength=3D1>=20
</td><BR> <td> <font =
size=3D-1=20
face=3DArial> Last Name </font>=20
</td><BR> <td> <input =
type=3D"text"=20
name=3D"surname" size=3D10 maxlength=3D35> =
</td><BR></tr><BR><tr>=20
<BR> <td colspan=3D4 bgcolor=3D"#99CCCC"> <font size=3D-1 =
face=3DArial>=20
<b>Business Profile</b> </font>=20
</td><BR></tr><BR><tr> <BR> <td> <font =
size=3D-1=20
face=3DArial> Business Name </font> =
</td><BR> <td>=20
<input type=3D"text" name=3D"business_name" size=3D15 =
maxlength=3D40>=20
<BR></td><BR> <td> <font size=3D-1 face=3DArial> =
Job Title=20
</font> </td><BR> <td> <input type=3D"text"=20
name=3D"job_title" size=3D10 maxlength=3D40>=20
</td><BR></tr><BR><tr> <BR> <td> <font =
size=3D-1=20
face=3DArial> Street Address </font> =
</td><BR> <td>=20
<input type=3D"text" name=3D"street_name" size=3D15 =
maxlength=3D25>=20
</td><BR> <td> <font size=3D-1 face=3DArial> Town =
</font> </td><BR> <td> <input type=3D"text" =
name=3D"town"=20
size=3D10 maxlength=3D25> </td><BR></tr><BR><tr>=20
<BR> <td> <font size=3D-1 face=3DArial> City =
</font>=20
</td><BR> <td> <input type=3D"text" name=3D"city" =
size=3D10=20
maxlength=3D25> </td><BR> <td> <font size=3D-1=20
face=3DArial>Postal Code</font> </td><BR> <td> =
<input=20
type=3D"text" name=3D"postcode" size=3D8 maxlength=3D"10">=20
<BR></td><BR></tr><BR><tr><BR> <td> =
<font=20
size=3D-1 face=3DArial> This is my </font>=20
</td><BR> <td colspan=3D3> <select=20
name=3D"homeorbusiness"><BR> =
=20
<option value=3D"1" selected>business address=20
<BR> &nb=
sp; =20
<option value=3D"0">home address </select><BR> =20
</td><BR></tr><BR><tr> <BR> <td > <font =
size=3D-1=20
face=3DArial>Telephone</font> </td><BR> <td> =
<input=20
type=3D"text" name=3D"telephone" size=3D10 maxlength=3D"20">=20
</td><BR> <td > <font size=3D-1 =
face=3DArial>Fax</font>=20
</td><BR> <td> <input type=3D"text" name=3D"fax" =
size=3D10=20
maxlength=3D"20"> </td><BR></tr><BR><tr> =
<BR> <td=20
> <font size=3D-1 face=3DArial>Email Address</font>=20
</td><BR> <td> <input type=3D"text" name=3D"email" =
size=3D10=20
maxlength=3D"45"> </td><BR> <td > <font size=3D-1 =
face=3DArial>Web site</font> =
</td><BR> <td><input=20
type=3D"text" name=3D"business_url" value=3D"http://" size=3D15 =
maxlength=3D"35">=20
<BR></td><BR></tr><BR><tr> <BR> <td =
colspan=3D4=20
align=3Dcenter> <input type=3D"submit" name=3D"submit" =
value=3D"Submit=20
Information"> <BR>&nbsp;&nbsp;&nbsp; <input =
type=3D"reset"=20
name=3D"reset" value=3D"Reset Form">=20
<BR> </td><BR></tr><BR></table></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>and <FONT face=3D"Times New Roman"=20
size=3D3>resellerAdd.dtml DTML Method, which contains the=20
following:</FONT></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2><dtml-call=20
sql_INSERT_form><BR><h2>Customer <dtml-var =
name=3D"business_name">=20
was added.</h2></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>everytime i add submit, the server =
returns nothing=20
.....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Any help will be much =
appreciated</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV></BODY></HTML>
------=_NextPart_000_0007_01C2C234.11FE6D90--