[Zope] How to insert NULL values
Jose Soares
jose@sferacarta.com
Thu, 15 Feb 2001 10:46:00 +0100
Not a very elegant solution, but it works.
In this way my ZSQL-Method is very large. I was thinking about a simplest
solution.
Thank you very much anyway Troy.
INSERT INTO INTRODUZIONI
(CODICE_FISCALE,DISTRETTO,CODICE_AZIENDALE,CODICE_CED,PARTITA_IVA,
MARCA, MARCA_MADRE, MARCA_PADRE, PASSAPORTO, SESSO, DATA_NASCITA,
COD_INTRODUZIONE,DATA_INTRODUZIONE,AZIENDA_PROVENIENZA,
MARCA_PRECEDENTE,PAESE_PROVENIENZA,AZIENDA_ORIGINE,RAZZA)
VALUES (
<dtml-sqlvar codice_fiscale type=string optional>,
<dtml-sqlvar distretto type=string>,
<dtml-sqlvar codice_aziendale type=string>,
<dtml-sqlvar codice_ced type=string>,
<dtml-sqlvar partita_iva type=string optional>,
<dtml-sqlvar marca type=string>,
<dtml-if "marca_madre == ''">
NULL,
<dtml-else>
<dtml-sqlvar marca_madre type=string optional>,
</dtml-if>
<dtml-if "marca_padre == ''">
NULL,
<dtml-else>
<dtml-sqlvar marca_padre type=string optional>,
</dtml-if>
<dtml-sqlvar passaporto type=string>,
<dtml-sqlvar sesso type=string>,
<dtml-sqlvar data_nascita type=string>,
<dtml-sqlvar cod_introduzione type=string>,
<dtml-sqlvar data_introduzione type=string>,
<dtml-if "azienda_provenienza == ''">
NULL,
<dtml-else>
<dtml-sqlvar azienda_provenienza type=string optional>,
</dtml-if>
<dtml-if "marca_precedente == ''">
NULL,
<dtml-else>
<dtml-sqlvar marca_precedente type=string optional>,
</dtml-if>
<dtml-if "paese_provenienza == ''">
NULL,
<dtml-else>
<dtml-sqlvar paese_provenienza type=string optional>,
</dtml-if>
<dtml-if "azienda_origine == ''">
NULL,
<dtml-else>
<dtml-sqlvar azienda_origine type=string optional>,
</dtml-if>
<dtml-sqlvar razza type=string>)
"Farrell, Troy" wrote:
> 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 )
>
> _______________________________________________
> 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 )