[Zope] Trapping for empty fields
Chris Kratz
chris.kratz@vistashare.com
Tue, 13 Aug 2002 09:40:12 -0400
Hi Larry,
There is probably a cleaner way to do it, but we use dtml-if's to determine
whether to insert a string or a null. It's not terribly pretty, but it
works.
ie
INSERT INTO some_table(some_field)
VALUES(<dtml-if form_field><dtml-if "form_field
==''">NULL<dtml-else><dtml-sqlvar form_field
type=string></dtml-if><dtml-else>NULL</dtml-if>
The first test if to make sure the variable exists and is not None, so if you
know it always will exist, you only need to test whether or not the string is
empty. You may even have luck with sqltest in an update statement and the
optional keyword.
Hope that helps,
-Chris
On Tuesday 13 August 2002 09:23 am, McDonnell, Larry wrote:
> Hi,
>
> I am using MS Access dbs for storage (company policy). I am starting to
> create online forms so the company can collect data. There were some dbs
> already created that they want access via a web browser. Some of the fields
> are empty and when I try to update the record using my ZSQL Method I get
> the following error message:
>
> Error Type: sql.error
> Error Value: ('S1000', -3702, "[Microsoft][ODBC Microsoft Access Driver]
> Field 'units_in_service.Hydration' cannot be a zero-length string.")
> How do I trap for this error? Examples and pointers will be greatly
> appreciated. Thanks in Advance.
>
>
> Larry McDonnell
>
> Proton Energy Systems
> 50 Inwood Rd.
> Rocky Hill, CT 06067
> (860) 571-6533 ext. 531
> Email:lmcdonnell@protonenergy.com
> www.protonenergy.com
>
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
--
Chris Kratz
Systems Analyst/Programmer
VistaShare LLC
www.vistashare.com