0

In zend, I've created mapper and model for a particular module. I'm trying to save a data into a table from a zend controller file

I am using postgresql as the database. I have set a table with primary key for auto incrementing

The table name and corresponding primary key is as follows:

tbl_user_group_business_prmission       --table

pk_bint_user_group_business_prmission_id   --primary key

Primary key generation is done as follows

 nextval('tbl_user_group_business_prmission_pk_bint_user_group_business_prmission_id_seq'::regclass)

You can see that the parameter inside nextval() is more than 60 in count(character).This is the issue which I am facing. I.e. I am not able to insert data into this table, as this parameter exceeds 60 in count(character)

I am getting error something like this "primary key does not generate".

This issue comes only if the characters inside the nextval() exceed 60

Lino Ck
  • 31
  • 7
  • 1
    Rename the table name or primary key to some short name if possible,since the parameter is the combination of table name and primary key which should not exceed the limit of 60 characters. – Reshil Mar 02 '13 at 08:08

1 Answers1

1

The postgres system uses no more than 63 bytes of an identifier; longer names can be written in commands, but they will be truncated. Check this manual SQL-SYNTAX-IDENTIFIERS.

But you can update the name of the sequence by creating a custom CREATE SEQUENCE or via the phppgadmin or pgAdmin interfaces.

In this case its better to change the table name or primary key column name shorter, because in zend it is hardcoded to create the sequence by concatinating the tableName+columnName+... You can see the code here /Zend/Db/Adapter/Pdo/Pgsql.php function lastInsertId

EDIT :
There is another suggestion in this SO post

Community
  • 1
  • 1
Nandakumar V
  • 4,317
  • 4
  • 27
  • 47
  • Thank you very much for this answer.Im sorry if its rubbish,is it there any way to change this hardcoded value in zend,so that I can take more of the identifier?Or how can I use Create Sequence ...?Thank you – Lino Ck Mar 03 '13 at 16:51
  • @LinoCk sorry, i don't think you can change that code. Its better to update the table name or field name and limit the sequence name to 60 chars – Nandakumar V Mar 07 '13 at 10:03