#1 2012-04-09 12:01:30

array81
Member
From: Italy
Registered: 2010-07-23
Posts: 411

Set ID value

Sometimes, I need copy same records of my old database to a new database (database without record).
To do it I have create an application, however I have problem with ID. In fact I cannot create a new record and set the ID value. I cannot use TSQLRecord.ADD because it don't support ID (ID is not save), and I cannot use TSQLRecord.UPDATE bucause it support ID but the record not exist (the new database is black database).

I think in SQLIte is possible specify the ID of a new record, in fact I use an SQLIte editor (http://sqliteadmin.orbmu2k.de/ based on ZeosLib), this free tool allow to import record from CSV file and I can import also the ID field. In alternative in fact the new table (new database) will be different from old table (old database).

Is there a solution? Something to add a new record with specific ID, if this ID not exist.

Last edited by array81 (2012-04-09 12:02:43)

Offline

#2 2012-04-09 12:53:05

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: Set ID value

It will need some code modifications ..

But it can be useful.
I'll look into it ..

Offline

#3 2012-04-09 19:18:40

array81
Member
From: Italy
Registered: 2010-07-23
Posts: 411

Re: Set ID value

Since the code must be changed, I would give you some advice:
1) The user can choose if he want only add the new record or in alternative update it (if ID already exists);
2) If the user choose add only, the user must be if there is an error (if ID already exists);
3) If the user choose add or update (if ID already exists) the user can know if the record was added or updated;

Thanks for your work

Offline

#4 2012-04-10 09:30:25

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: Set ID value

A new ForceID parameter has been set for TSQLRest.Add() to allow adding a given ID.
See http://synopse.info/fossil/info/3f9985da02

It won't fulfill your point 3) in the current state, I think.

Offline

#5 2012-04-10 09:37:56

array81
Member
From: Italy
Registered: 2010-07-23
Posts: 411

Re: Set ID value

Thanks I will try it.

Point 3 did not help me but I thought it might be useful to prevent problems.

Offline

#6 2012-04-10 20:37:26

array81
Member
From: Italy
Registered: 2010-07-23
Posts: 411

Re: Set ID value

Is it possible add this feature also for batch procedure?

Last edited by array81 (2012-04-10 20:37:37)

Offline

#7 2012-04-11 07:44:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: Set ID value

That's it: I've added a new ForceID parameter for TSQLRest.Add() and TSQLRestClientURI.BatchAdd() to allow adding a record with a given ID.

See http://synopse.info/fossil/info/bc45f7bbd3

Offline

Board footer

Powered by FluxBB