[Zope] How to insert NULL values

Farrell, Troy troy.farrell@wilcom.com
Wed, 14 Feb 2001 06:43:38 -0600


Ok.  Now for my next magic trick:
I would try modifying the ZSQL method.  Try something like:

INSERT INTO introduzioni (
  codice_fiscale,
  distretto,
  marca_precedente
) VALUES (
  <dtml-sqlvar CODICE_FISCALE type="int">,
  <dtml-sqlvar DISTRETTO type="string">,
  <dtml-if "_str(marca_precedente) == ''">
    NULL
  <dtml-else>
    <dtml-sqlvar marca_precedente type="string">
  </dtml-if>

<dtml-var sql_delimiter>

This will Submit NULL (not 'NULL') if the string is empty.  I didn't test
this, so it might have a bug or two :)
Note that your ZSQL method may be totally different, and I am just guessing
at it based upon your parameters.

Troy

-----Original Message-----
From: Jose Soares [mailto:jose@sferacarta.com]
Sent: Wednesday, February 14, 2001 3:45 AM
To: Farrell, Troy
Cc: zope@zope.org
Subject: Re: [Zope] How to insert NULL values


This one insert the string "NULL" into the field.


"Farrell, Troy" wrote:

> First of all, shouldn't the last line be
> )">
> instead?
> Also, try
> <dtml-call "qry.ins_introduzioni(
>             codice_fiscale=CODICE_FISCALE,
>             distretto=DISTRETTO,
>             marca_precedente='NULL'
> )">
>
> Good luck,
> Troy
>
> -----Original Message-----
> From: Jose Soares [mailto:jose@sferacarta.com]
> Sent: Monday, February 12, 2001 10:22 AM
> Cc: zope@zope.org
> Subject: [Zope] How to insert NULL values
>
> Hi all,
>
> I'm trying to insert NULL values into a column of a table
> using the ZSQL-Method without success.
>
> I tried the following:
>
>       <dtml-call "qry.ins_introduzioni(
>                   codice_fiscale=CODICE_FISCALE,
>                   distretto=DISTRETTO,
>                   marca_precedente=''
>        >")
>
> also:
>
>       <dtml-call "qry.ins_introduzioni(
>                   codice_fiscale=CODICE_FISCALE,
>                   distretto=DISTRETTO,
>                   marca_precedente=_.None
>        >")
>
> Please may somebody tell me the right syntax?
>
> Thank you.
>
> Jose'
>
> _______________________________________________
> 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 )
>
> _______________________________________________
> 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 )