This forum is for programmers who have questions about the source code.
-
wjstarck
- Posts: 936
- Joined: Tue Jul 31, 2007 7:18 am
- Location: Keller, TX
-
Contact:
Post
by wjstarck » Mon Oct 11, 2010 1:24 pm
Hello-
I need to add another field to one of my tables in 7.2
The following code adds the field just fine,
Code: Select all
command = "ALTER TABLE anestheticrecord ADD ChangeLog varchar(255)";
DataCore.NonQ(command);
but then attempts to do so everytime the plugin loads, so I get an error that the column already exists. Can you suggest a workaround?
Cheers,
Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
-
wjstarck
- Posts: 936
- Joined: Tue Jul 31, 2007 7:18 am
- Location: Keller, TX
-
Contact:
Post
by wjstarck » Mon Oct 11, 2010 1:43 pm
Well, I've found that I can encapsulate it in a try-catch like so:
Code: Select all
try {
command = "ALTER TABLE anestheticrecord ADD ChangeLog varchar(255)";
DataCore.NonQ(command);
}
catch { }
I'll go with that unless you have a cleaner way...
Cheers,
Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
-
alkhaef
- Posts: 105
- Joined: Fri Jul 02, 2010 10:37 am
- Location: Los Angeles, CA
Post
by alkhaef » Mon Oct 11, 2010 3:22 pm
Hmm... As far as I remember, the PluginExample had the outline for the "cleaner way" you're referring to...
Namely, by tracking the version of the current schema, you can alter the table only when you have to "upgrade" to a given version.
Best regards,
Al
Help! I've OD'ed on OD!
-
wjstarck
- Posts: 936
- Joined: Tue Jul 31, 2007 7:18 am
- Location: Keller, TX
-
Contact:
Post
by wjstarck » Mon Oct 11, 2010 3:49 pm
Thanks, Al.
I'll have a look....
Cheers,
Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA