[Zope] SQL Problem

2005-08-25 Thread Philip Beardmore
I'm having a really annoying SQL problem which I think (or hope) can
easily be sorted but I'm not sure how to do it.

I have a ZPT which is collecting data in a form - Both text boxes and
checkboxes.  The form then passes the variables on to a DTML Method
which does a few bits of error checking then calls an Z SQL Method to
insert the data.

If all of the data is completed (i.e. each textbox and checkbox is
ticked) then the form inserts the data exactly as it should.  If not all
checkboxes are ticked the page returns an error - This is due to the SQL
Method trying to insert data which hasnt been passed to it.

Below is my SQL Method:

INSERT choices
(userid, datetime, course, name, core1, core2, core3, core4, core5,
choice1, choice2, choice3, choice4)
VALUES
(
dtml-sqlvar userid type=string,
dtml-sqlvar datetime type=string,
dtml-sqlvar course type=string,
dtml-sqlvar name type=string,
dtml-sqlvar core1 type=string,
dtml-sqlvar core2 type=string,
dtml-sqlvar core3 type=string,
dtml-sqlvar core4 type=string,
dtml-sqlvar core5 type=string,
dtml-sqlvar choice1 type=string optional,
dtml-sqlvar choice2 type=string optional,
dtml-sqlvar choice3 type=string optional,
dtml-sqlvar choice4 type=string optional
)

Arguments are:
userid datetime course name core1 core2 core3 core4 core5 choice1
choice2 choice3 choice4

Note: Choice1-4 are checkboxes and every other item is a textbox.

Please help - Its doing my head in!

Cheers and all the best
Phil
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] SQL Problem

2005-08-25 Thread J Cameron Cooper

Philip Beardmore wrote:

I'm having a really annoying SQL problem which I think (or hope) can
easily be sorted but I'm not sure how to do it.

I have a ZPT which is collecting data in a form - Both text boxes and
checkboxes.  The form then passes the variables on to a DTML Method
which does a few bits of error checking then calls an Z SQL Method to
insert the data.

If all of the data is completed (i.e. each textbox and checkbox is
ticked) then the form inserts the data exactly as it should.  If not all
checkboxes are ticked the page returns an error - This is due to the SQL
Method trying to insert data which hasnt been passed to it.


You can provide default values to the parameters of your Z SQL Method. 
Alternately, I believe the DTML sqlvar tags can also be given a default 
behavior.


--jcc
--
Building Websites with Plone
http://plonebook.packtpub.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] SQL Problem

2005-08-25 Thread Philip Beardmore
Hi JCC,

That is exactly what I was looking for - Assigning a default value works
great!

I previously tried to do this using the syntax provided by zope help:
title:string=default value

but had no luck.

Thanks :-
Phil

- Original Message -
From: J Cameron Cooper [EMAIL PROTECTED]
Date: Thursday, August 25, 2005 10:35 pm
Subject: Re: [Zope] SQL Problem

 Philip Beardmore wrote:
  I'm having a really annoying SQL problem which I think (or hope) can
  easily be sorted but I'm not sure how to do it.
  
  I have a ZPT which is collecting data in a form - Both text boxes 
 and checkboxes.  The form then passes the variables on to a DTML 
 Method which does a few bits of error checking then calls an Z SQL 
 Method to
  insert the data.
  
  If all of the data is completed (i.e. each textbox and checkbox is
  ticked) then the form inserts the data exactly as it should.  If 
 not all
  checkboxes are ticked the page returns an error - This is due to 
 the SQL
  Method trying to insert data which hasnt been passed to it.
 
 You can provide default values to the parameters of your Z SQL 
 Method. 
 Alternately, I believe the DTML sqlvar tags can also be given a 
 default 
 behavior.
 
   --jcc
 -- 
 Building Websites with Plone
 http://plonebook.packtpub.com
 
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )