[Zope] INSERT Syntax with Zope & ZPyGreSQLDA

Hannu Krosing hannu@trust.ee
Sat, 13 Mar 1999 21:08:52 +0200


lstep@mail.dotcom.fr wrote:
> 
> Hello,
> 
> I'm trying to use PostGreSQL with Zope, but I'm having
> problems using the SQL INSERT method in Z methods which
> require parameters.
> 
> For example, I make a Z SQL Method named 'foo'.
> In it:
> INSERT INTO messages
> VALUES
>   (<!--#sqlvar auteur type="string"-->,
>    'blahblahblah', 'now', 'f')
> 
> I write the name auteur in the 'arguments' form.
> 
> Next I create a DTML document with:
> <form action="foo" method="GET">
> Auteur: <input width="30" name="auteur" value=""><br>

why no type=text   ?

> <input type="submit" name="SUBMIT" value="Envoyer">
> <form>
> 
> When submitting the form, it displays me a new page
> (generated by Zope) asking me again the auteur parameter,
> as if the auteur variable wasn't passed to the Z SQL method :-(
> 
> Someone posted a mail recently with an example use
> of INSERT, where he put '(auteur)' after the 'INSERT INTO messages'
> text: INSERT INTO messages (auteur) ...
> 
> When I try this, I get:
> 
> Error, pg.error: server fatal error. Please report to your db administrator.

A good to test your SQL is using psql.

And upgrading to PyGreSQL 2.3 or later, which return proper sql messages
 
> SQL used:
> 
> INSERT INTO messages (auteur)
> VALUES
>   ('testing again',
>    'blahblahblah', 'now', 'f')

This is definitely wrong ;(

something like 
INSERT INTO messages (auteur,title,bookdate,any_good)
VALUES
  ('testing again',
   'blahblahblah', 'now', 'f')

might have worked. You may also mean current_date or current_time 
instead of now or now()