Hi
I am building a small database using PostgreSQL as the back end.
I am trying to programmatically insert data into a table. I have done this more times than I care to think about but this time I keep getting this error 2196 Object already exists"
The table is a 3 column table with PK, data to be inserted and an Postgres date/time key with its default set to now(). I know from previous experience that this works fine in Postgres. The table is nothing more than an audit trail of receipts. A user can have as many receipts for the same payment as they want. All this table does is capture the primary key of the payment and insert it into the second column and inserts by default the date/time of the new receipt being generated.
The columns are:
receiptdetailid - serial, primary key
paymentid - integer, default 0
receiptdate - date without time zone default now()
I can insert the data using PGAdmin 3 by a normal insert statement
"INSERT INTO receiptdetail (paymentid) values (25001)"
for example.
When I try to insert it twice using Access, I get this error. My suspicion is that it reads that a value of 25001 already exists and refuses to insert it into the table, even though the timestamp will be different. When I insert it using the backend software there is no problem.
What peeves me about this is that this action is intiated by a SQL string 'strINSERT' and the insertion is done by:
Set db = currentdb()
Set qdf = db.CreateQueryDef(strINSERT)
With qdf
.Connect = fnConnString 'being the ODBC connection to Postgres
.SQL = strINSERT
.ReturnsRecords = False
.Execute
.Close
Set qdf = Nothing
End With
And with Access, the variable is NOT an object unlike other languages even though the message states that it is.
Should I create another column, say integer and increment it by 1 every time a new record is added? Could this break that error even though it is a total waste of time?
Any ideas?
Thanks in advance
I am building a small database using PostgreSQL as the back end.
I am trying to programmatically insert data into a table. I have done this more times than I care to think about but this time I keep getting this error 2196 Object already exists"
The table is a 3 column table with PK, data to be inserted and an Postgres date/time key with its default set to now(). I know from previous experience that this works fine in Postgres. The table is nothing more than an audit trail of receipts. A user can have as many receipts for the same payment as they want. All this table does is capture the primary key of the payment and insert it into the second column and inserts by default the date/time of the new receipt being generated.
The columns are:
receiptdetailid - serial, primary key
paymentid - integer, default 0
receiptdate - date without time zone default now()
I can insert the data using PGAdmin 3 by a normal insert statement
"INSERT INTO receiptdetail (paymentid) values (25001)"
for example.
When I try to insert it twice using Access, I get this error. My suspicion is that it reads that a value of 25001 already exists and refuses to insert it into the table, even though the timestamp will be different. When I insert it using the backend software there is no problem.
What peeves me about this is that this action is intiated by a SQL string 'strINSERT' and the insertion is done by:
Set db = currentdb()
Set qdf = db.CreateQueryDef(strINSERT)
With qdf
.Connect = fnConnString 'being the ODBC connection to Postgres
.SQL = strINSERT
.ReturnsRecords = False
.Execute
.Close
Set qdf = Nothing
End With
And with Access, the variable is NOT an object unlike other languages even though the message states that it is.
Should I create another column, say integer and increment it by 1 every time a new record is added? Could this break that error even though it is a total waste of time?
Any ideas?
Thanks in advance
Last edited: