You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Eric Vernichon <ry...@hotmail.com> on 2001/08/08 13:37:41 UTC
[C2] esql & postgres' nextval
I'm trying to do the following :
<esql:query>
INSERT INTO foo(id,url,email,username,password)
VALUES (<esql:parameter>NEXTVAL('id_seq')
</esql:parameter>,'abcd','a@my.com','dfgdf','123');
</esql:query>
Error generated by C2 :
org.apache.cocoon.ProcessingException: Exception in
ServerPagesGenerator.generate():java.lang.RuntimeException: Error executed
prepared statement: INSERT INTO foo(id,url,email,username,password) VALUES
(?,'abcd','a@my.com','dfgdf','123'); : java.sql.SQLException: ERROR: pg_atoi:
error in "NEXTVAL('id_seq')": can't parse "NEXTVAL('id_seq')"
id is my primary key and i would like to auto-increment it.
Any suggestion ?
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: [C2] esql & postgres' nextval
Posted by Hubert NEOtyk Iwaniuk <hu...@office.ferienwelt.com.pl>.
HI
> I'm trying to do the following :
> <esql:query>
> INSERT INTO foo(id,url,email,username,password)
> VALUES (<esql:parameter>NEXTVAL('id_seq')
> </esql:parameter>,'abcd','a@my.com','dfgdf','123');
> </esql:query>
NEXTVAL is function stored in postgresql.
Consider doing it like this:
1. define table like:
a) sequence
CREATE SEQUENCE id_seq;
b) table
CREATE TABLE foo (
id INT PRIMARY KEY DEFAULT nextval('id_seq'),
[...]
other columns
[...]
);
2. Inserting data using DEFAULT
<esql:query>
INSERT INTO foo (url,email,username,password)
VALUES ('abcd','a@my.com','dfgdf','123');</esql:query>
You get what you wanted, and no error should be generated.
I haven't, because of configuration problems - my server is down, but it
should work.
Hope it helps.
hubert.
---
Ausgehende Mail ist zertifiziert virenfrei.
Uberpruft durch AVG Antivirus System (http://www.grisoft.com/de).
Version: 6.0.265 / Virendatenbank: 137 - Erstellungsdatum: 2001-07-18
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
AW: [C2] esql & postgres' nextval
Posted by Max Larsson <ma...@gmservice.de>.
Hallo,
i think you just have to skip the enclosing tag
esql:parameters to get it work, eg. like this:
<esql:query>INSERT INTO foo(id,url,email,username,password)
VALUES ( NEXTVAL('id_seq'),'abcd','a@my.com','dfgdf','123');</esql:query>
Max
> -----Ursprüngliche Nachricht-----
> Von: ryk@free.fr [mailto:ryk@free.fr]Im Auftrag von Eric Vernichon
> Gesendet: Mittwoch, 8. August 2001 13:38
> An: cocoon-users@xml.apache.org
> Betreff: [C2] esql & postgres' nextval
>
>
> I'm trying to do the following :
> <esql:query>
> INSERT INTO foo(id,url,email,username,password)
> VALUES (<esql:parameter>NEXTVAL('id_seq')
> </esql:parameter>,'abcd','a@my.com','dfgdf','123');
> </esql:query>
>
> Error generated by C2 :
> org.apache.cocoon.ProcessingException: Exception in
> ServerPagesGenerator.generate():java.lang.RuntimeException:
> Error executed
> prepared statement: INSERT INTO
> foo(id,url,email,username,password) VALUES
> (?,'abcd','a@my.com','dfgdf','123'); : java.sql.SQLException:
> ERROR: pg_atoi:
> error in "NEXTVAL('id_seq')": can't parse "NEXTVAL('id_seq')"
>
> id is my primary key and i would like to auto-increment it.
>
> Any suggestion ?
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>
>
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>