Halo,
I'm using TClientDataset, TDatasetProvider and TZQuery.
I have a postgreSQL database with a simple table with a field called id of type SERIAl and a field 'name' of type varchar(20).
I fould an article "How to use AutoInc fields with DataSnap" (http://dn.codegear.com/kr/article/20847) which describes how to handle the autoinc fields correctly. In brief, you should assign a negative value (eg. -1) to the "id" Field, call TClientDataset.ApplyChanges, and then TClientDataset.refresh to get the correct id value from the database.
I'm not sure if it is zeos or postgres as such, but the "id" fields are not excluded from the update statment, and they are stored in the table as negative values, so when I call TClientDataset.refresh, I get my id=-1 back from the database...
One thing which I noticed is, that the "id" field which is of type SERIAL seems not to be handled as an autoinc field. The property TClientDataset.FieldByName('id').Datetype indicates that it is an integer value not an autoinc.
Any Ideas how to manage this?
ps. its quite late now... so, if it is not clear what I mean, please excuse me, just tell me and I will try to describe it better
How to Handle AutoIncs (or SERIALS in Postgres)
Moderators: gto, EgonHugeist
-
- Junior Boarder
- Posts: 35
- Joined: 30.08.2005, 16:30
- Location: Olinda / PE
- Contact:
How to use this component? Seem self-explanatory but I do not want to manage sequences on the application. The sequences are automatically executed on the DATABASE.
So, the TZSequencev does what?
1. Exposes the PG Sequence to the Zeos componentes use it?
or
2. Executes the PG Sequence, get the result and assign to a field (the same field that would be automatically filled by the Database)
The second approach is not good. So, i need to know
Thanks in advance
So, the TZSequencev does what?
1. Exposes the PG Sequence to the Zeos componentes use it?
or
2. Executes the PG Sequence, get the result and assign to a field (the same field that would be automatically filled by the Database)
The second approach is not good. So, i need to know
Thanks in advance
-
- Junior Boarder
- Posts: 35
- Joined: 30.08.2005, 16:30
- Location: Olinda / PE
- Contact: