Jump to content

Preserving Serials on Import & Export


This topic is 5745 days old. Please don't post here. Open a new topic instead.

Recommended Posts

After 2 1/2 not totally pleasant months, one of the databases im working on is almost finished (yay). Now comes the fun part, exporting and importing, with 46 tables, the actual export script shouldnt be to difficult, however my query comes about the serial keys. Almost all of my tables have an incrementing primary key.

A) I forgot the functions to pull out (and set) the next serial key in the particular field of a table.

:) I have no idea where to store them so that i can restore them after an import.

Cheers for help, I really am not thinking to well lately so thanks for putting up with my fun questions.

~Genx

Link to comment
Share on other sites

The import "wizard" has a setting to disable auto-enter on the imported records, so your old primary keys are safe if you choose that option. All you'd need to do is reset the "next" value in the pk's field definition.

Link to comment
Share on other sites

Well, that solves one problem, but, lets say i export all my records, where would i store the "next" serial value for a particular table so that i could set / "restore" it in the other file?

Thanks,

~Genx

Link to comment
Share on other sites

There is a special Design function, GetNextSerialValue ( fileName ; fieldName )

Now, it has a weakness, in that both the file name and the field name may need to be entered as plain text. But when doing such an "update" routine you would know the file name and the field name (which would be an auto-entered serial ID field).

You'd use a special script step also. The whole thing looks like:

Set Next Serial Value [ GetNextSerialValue ( fileName; fieldName ) ]

And be grateful that you are "Young & Reckless", because what we had to do before FM added these was really awful, multiple Replaces to increment the number.

Link to comment
Share on other sites

Hehe, i love it, Thanks Fenton. I assume field name would be entered in the format "tablename::fieldname", and both files would have to be open. Based on this assumption, yay, i never really thought of having both files open at once. So thanks again guys.

~Genx

Link to comment
Share on other sites

This topic is 5745 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.