[Zope] ZSQL: how to definde null
Dieter Maurer
dieter at handshake.de
Tue Oct 28 15:22:44 EST 2003
Christoph Landwehr wrote at 2003-10-27 14:13 +0100:
> Dieter Maurer schrieb:
>
> > Christoph Landwehr wrote at 2003-10-21 00:57 +0200:
> > > I have a ZSQL method, that looks like
> > >
> > > Attributes:
> > > some_name='empty'
> > >
> > > UPDATE
> > > foo
> > > SET
> > > bar = <dtml-sqlvar some_name type="string">
> > > WHERE
> > > some contitions ... ;
> >
> > You can try the "optional" attribute for "dtml-sqlvar".
> > You might need to use "type=nb" (non blank) rather than "type=string".
>
> In this case I dont't see how this could work, because I have to define
> 'some_name' in the SQL-Method's Attributes and supply a default value in
> case the user does not supply a value for 'some _name' in the form that
> feeds the SQL-Method. Therefor sone_name is never blank and the optional
> never is true.
>
> Am I missing something?
Yes, you should read the documentation for "dtml-sqlvar" and its
attribute "optional":
optional -- A flag indicating that a value is optional. If a
value is optional and is not provided (or is blank
when a non-blank value is expected), then the string
'null' is inserted.
Thus, you would use "type=nb" and ensure that the value is blank
(empty) iff you want to render "null".
--
Dieter
More information about the Zope
mailing list