Genx Posted March 15, 2006 Posted March 15, 2006 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
Wim Decorte Posted March 15, 2006 Posted March 15, 2006 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.
Genx Posted March 15, 2006 Author Posted March 15, 2006 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
Genx Posted March 15, 2006 Author Posted March 15, 2006 Maybe a global field that stores the last serial? I import that into the other file and restore that value using a script. Would this work?
Fenton Posted March 15, 2006 Posted March 15, 2006 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.
Genx Posted March 15, 2006 Author Posted March 15, 2006 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
Recommended Posts
This topic is 6831 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 accountSign in
Already have an account? Sign in here.
Sign In Now