Delphi using Postgresql unique primary key
Posted on 2001-07-12
I'm trying to use a postgresql database from my Delphi application. This database has a sequence called 'uniquenumbergenerator' which should create a unique id for every database entry made.
I've tried 2 things to make this work:
1. I used a query with SQL: 'Select nextval('uniquenumbergenerator')';
2. I used the stored procedure nextval with arguments Input: String 'uniquenumbergenerator' and Result: integer
Problems with these things:
1. I tried to Close and Open the query directly behind each other:
And then I tried to read the value of the nextval. Executed 2 times within 20 statement behind eachother, this returned me the SAME values!!
2. Same story, I called these procedures within 20 statements from eachother and I got the same values for the unique numbers.
I think this problem has something to do with caching or something like this....
I have installed the postgresql ODBC driver on Windows 98 and everything works with the database, only these requests for unique values occuring behind eachother, do not work.
I am really stuck with this one, because my application cannot run without this problem solved, so that's why I offer 300 points to solve this one.