Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Primary Key updateable

Status
Not open for further replies.

Alfonso3

Programmer
May 27, 2008
3
AT
Hi,

i am new to the forum and have one first question.

I am using Pervasive.SQL and I want to update a Primary Key field by following code: (pos is the primary)

update punkteschluessel
set pos = 10
where pos = 1
;

on executing i get following execution error: The key field is not modifiable (Btrieve Error 10).

Is there a possibility to update the primary key, otherwise i would have to use a synthetic primary key?!

thanks for answers!

regards,
Thorsten
 
How was your table created? If your table was created with a non-modifiable index,you will get the error 10 as you are seeing. A Primary Key is modifiable by default. I ran the following and was able to update the table:
Code:
create table test (f1 int primary key, f2 char(100))#
insert into test (f1, f2) values (1,'1')#
insert into test (f1, f2) values (2,'2')#
insert into test (f1, f2) values (3,'3')#
update test set f1 = 5 where f1 = 3#
select * from test

I was using PSQL v10 but I believe this would be the same for PSQL 2000, v8, and v9.


Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
Sage Accpac, for example, creates non-modifiable keys on their databases.

You'll have to copy the record, change the primary key and delete the original record.
 
sry for my responsing so late!

still don´t understand it, the table was created like this:

CREATE TABLE punkteschluessel USING 'punktes' + VersionExt
PAGESIZE 1024 PREALLOCATE 1 DCOMPRESS OWNER DataOwnerName OWNERACCESS NOENCRYPT WITH REPLACE

(PRIMARY KEY(pos),
pos INTEGER(2) (NOT NULL),
punkte INTEGER(2)
)
WITH INDEX (
punkte MOD
)
;
 
Wow, I haven't seen that syntax for Pervasive in a long time. That syntax is not supported with PSQL 2000 or later. It was only supported with the (very) old Scalable SQL.
In your case, I'm guessing that Primary Keys were created non-modifiable in that old version of PSQL. Can you post a BUTIL -STAT output of the data file?

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top