Page 1 of 1

Postgresql Provider SequenceMode=smPost bug ?

Posted: Fri 31 Oct 2014 09:07
by asamkaskus
Hi

I'm using UniDAC express with PostgresqlDAC trial.
With TUniQuery.SpecificOptions.SequenceMode = smPost, I'm expecting the primary key field ( Id, type autoincrement, primary key ), would only be given when I TUniQuery.post a record.
But what really happend is, it actually issuing a SELECT nextval ( monitored with SQLMonitor ) when I issue TUniQuery.Append and I got the current Id before posting.

I hope it is a bug.

Anybody experience this ?

Thanks
Andy

Re: Postgresql Provider SequenceMode=smPost bug ?

Posted: Fri 31 Oct 2014 11:19
by azyk
Unfortunately we couldn't reproduce the problem as you have described it. Please, try to compose a small sample to demonstrate the problem including a script to create test tables and send it to andreyz*devart*com .

Re: Postgresql Provider SequenceMode=smPost bug ?

Posted: Fri 31 Oct 2014 13:34
by asamkaskus
Let me discribe this simple program.

Tabl1 in Postgresql,
Primary key Id, autoincrement ( serial ).

In Delphi :
- Put TUniCOnnection, TPostgreqlUniProvider, TUniQuery and TUniDataSource
- Set TUniConnection.AutoCommit = FALSE
- Connect to the database
- Set TUniQuery.SpecificOptions.SequenceMode=smPost
- Set TUniQuery.Options.DefaultValues := TRUE
- TUniQuery SQL is set to 'SELECT * FROM Table1 WHERE Id=:iId', generate the other SQL, then set it to Active = TRUE
- Put a TDBEdit, pointing to Table1.Id
- Put a button, when pressed, just issue TUniQuery.Append;
- You can see when the button is pressed, TDBEdit displays a value ( while we haven't issue TUniQuery.Post ).

I hope you can reproduce the problem.

Re: Postgresql Provider SequenceMode=smPost bug ?

Posted: Mon 03 Nov 2014 09:25
by azyk
In your sample, you are setting the TUniQuery.Options.DefaultValues property to True. This means that the dataset requests values for the Id field from the server, since values for this field are set on the server side. Such behavior is correct. More details about the DefaultValues property can be found in our online documentation: http://www.devart.com/unidac/docs/index ... values.htm

Re: Postgresql Provider SequenceMode=smPost bug ?

Posted: Tue 04 Nov 2014 12:47
by asamkaskus
thank you for your answer azyk.

If so, then how can I set the Id to received value upon posting the record, while maintaining all other field's default values ? I got other fields such as ctr, status, etc each with its own default values.

Re: Postgresql Provider SequenceMode=smPost bug ?

Posted: Wed 05 Nov 2014 03:42
by asamkaskus
as comparison, IBDAC can you this feature as I needed.
I can see defaultvalues as true, and still can have the autoincrement Id as smPost mode with no error.

I haven't tried PgDAC.

Re: Postgresql Provider SequenceMode=smPost bug ?

Posted: Wed 05 Nov 2014 05:15
by AlexP
When creating a field with the Serial type, PostgreSQL creates a sequence and assigns it as the default field value, therefore we fill in this field value. To avoid this behavior, you can use the usual integer type instead of the serial type, fill in it using the trigger function with a sequence

Re: Postgresql Provider SequenceMode=smPost bug ?

Posted: Wed 05 Nov 2014 08:52
by asamkaskus
thank you AlexP

Re: Postgresql Provider SequenceMode=smPost bug ?

Posted: Wed 05 Nov 2014 09:03
by AlexP
You are welcome. Feel free to contact us if you have any further questions