[Helma-user] Support for PostgreSQL sequences

Julian Tree julian.tree at gmail.com
Tue Aug 8 09:36:02 CEST 2006


Hmmm... I am having problem add a new record for postgresql

Root/type.properties:
---------------------------------------------------
_children 				= collection(Company)
_children.accessname 	= company_id

Company/type.properties:
---------------------------------------------------
_db          			= filepressdb
_table       			= company
_id          			= company_id
_idgen 					= company_company_id_seq
_name      	 			= company_name
creator 	 			= creator
modifier 	 			= modifier
contact_name 			= contact_name
company_name 			= company_name
email        			= email   			
company_type 			= company_type
             			

Root/new.hac
-------------------------------
var c = new Company();
c.company_name = "Blah Blah";
c.company_type = "agency";
root.add(c);


I get following error
java.lang.RuntimeException: org.postgresql.util.PSQLException: ERROR:
relation "dual" does not exist
(/helma-1.5.0/apps/filepress/Root/temp.hac#10)
the sql Log gives me this :  SELECT 'company_company_id_seq'.nextval FROM dual


if I comment out the _idgen line I get this error
ERROR: column "company_id" is of type integer but expression is of
type character varying
sql Log: INSERT INTO company ( company_id, company_type, creator,
modifier, contact_name, company_name, email, phone_main, phone_fax,
phone_mobile, phone_other, web_site, comments ) VALUES ( ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ? )




Just to add a note, I created Company table using following SQL ,
notice company_id is created using serial, but it is jsut a int4
field. Any ideas


CREATE TABLE company
(
  company_id serial NOT NULL,
  company_type varchar(10) NOT NULL DEFAULT 'SHOP'::character varying,
  creator varchar(20) NOT NULL DEFAULT ''::character varying,
  creationtime timestamp NOT NULL DEFAULT '0001-01-01
00:00:00'::timestamp without time zone,
  modifier varchar(20) NOT NULL DEFAULT ''::character varying,
  modificationtime timestamp NOT NULL DEFAULT '0001-01-01
00:00:00'::timestamp without time zone,
  contact_name varchar(100) NOT NULL DEFAULT ''::character varying,
  company_name varchar(100) NOT NULL DEFAULT ''::character varying,
  email varchar(60) NOT NULL DEFAULT ''::character varying,
  phone_main varchar(11) NOT NULL DEFAULT ''::character varying,
  phone_fax varchar(11) NOT NULL DEFAULT ''::character varying,
  phone_mobile varchar(11) NOT NULL DEFAULT ''::character varying,
  phone_other varchar(11) NOT NULL DEFAULT ''::character varying,
  web_site varchar(255) NOT NULL DEFAULT ''::character varying,
  comments text NOT NULL DEFAULT ''::text,
  creation_stamp text NOT NULL DEFAULT ''::text,
  CONSTRAINT company_id PRIMARY KEY (company_id)
)





On 6/17/06, Hannes Wallnoefer <hannesw at gmail.com> wrote:
> Anybody using PostgreSQL out there? I just checked in support for
> PostgreSQL sequence syntax for ID generation in Helma:
>
> select nextval('sequence_name')
>
> All you have to do is add something the following to the
> type.properties of your Prototype:
>
> _idgen = sequence_name
>
> Please let me know if it works. I'm too lazy to install and configure
> PostgreSQL just for the testing :-)
>
> hannes
> _______________________________________________
> Helma-user mailing list
> Helma-user at helma.org
> http://helma.org/mailman/listinfo/helma-user
>


More information about the Helma-user mailing list