Splitting an ODB File

From NeoWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 14:52, 8 November 2010 (edit)
Amayze ( | contribs)
(Copying across Queries, Forms and Reports)
← Previous diff
Current revision (15:02, 8 November 2010) (edit) (undo)
Amayze ( | contribs)
(Conclusion)
 
(4 intermediate revisions not shown.)
Line 59: Line 59:
== Copying across Macros == == Copying across Macros ==
-With old<dbname>.odb open select Tools->Macros-> Organise Macros->NeoOffice Basic+# With '''old<dbname>.odb''' open, from the {{menu|Tools}} select {{menu|Macros}} then {{menu|Organise Macros}} then {{menu|NeoOffice Basic}}
- +# Select one of your Macro Modules and click {{button|Edit}}
-Select one of your Macro Modules and click Edit.+# Save each module using the {{button|Save BASIC}} button.
- +# With '''<dbname>.odb''' open, from the {{menus|Tools}} select {{menu|Macros}} then {{menu|Organise Macros}} then {{menu|NeoOffice Basic}}
-Save each module using the Save BASIC button.+# Create a new Module in '''<dbname>'''
- +# Load in the macros you saved above using the {{button|Insert BASIC Source}} button.
-With <dbname>.odb open select Tools->Macros-> Organise Macros->NeoOffice Basic+# Save each module with the same name as it had before.
- +
-Create a new Module in <dbname>+
- +
-Load in the macros you saved above using the Insert BASIC Source button.+
- +
-Save each module with the same name as it had before.+
== Tidying up == == Tidying up ==
Line 77: Line 71:
The databse is now split in to separate databse and odb files and should work ok. I have however had a few problems with Autonumber fields and checkboxes The databse is now split in to separate databse and odb files and should work ok. I have however had a few problems with Autonumber fields and checkboxes
-Autonumber Fields: These seem to forget the next index, resulting in duplicate entries and failure to insert records due to duplicate Primary key fields.+; Autonumber Fields : These seem to forget the next index, resulting in duplicate entries and failure to insert records due to duplicate Primary key fields.
 +: Select {{menu|Tools}} then {{menu|SQL…}}
 +: Use the SQL Statement <tt>ALTER TABLE "TableName" ALTER COLUMN "PrimaryKeyField" RESTART WITH xxx</tt> where <tt>xxx</tt> is the next unused value in the table.
-Select Tools->SQL…+; Checkboxes : These seem to default to <tt>NULL</tt> which can cause problems
 +: Use the SQL Statement <tt>ALTER TABLE "TableName" ALTER COLUMN "TrueFalseField" SET DEFAULT FALSE</tt> (or <tt>TRUE</tt> as required)
-Use the SQL Statement ALTER TABLE "TableName" ALTER COLUMN "PrimaryKeyField" RESTART WITH xxx where xxx is the next unused value in the table.+== Conclusion ==
-Checkboxes: These seem to default to NULL which can cause problems+Everything should now work as before, but should NeoOffice crash it is much less likely that you will loose data. Also if you are developing a database for a client you can duplicate the above setup on their machine and yours. As you develop new versions of the Forms, Queries and Reports you can simply send then an updated odb file to copy over the old one. Their data will be unaffected. Obviously if you make changes to the tables you will have to visit the client or give them a list of steps or SQL commands to enter, but for the purposes of this guide I'll assume you know what you are doing if you are doing that!
-Use the SQL Statement ALTER TABLE "TableName" ALTER COLUMN "TrueFalseField" SET DEFAULT FALSE (or TRUE as required)+The next steps in this process are to upgrade to HSQLDB 2.0 to take advantage of the latest features (not least the use of ~ in paths which makes it possible to put the database in your home directory without having to know the user name) and to set the database in to server mode which allows multi user access and storage of the database on a server.
-== Conclusion ==+I hope to have articles on this soon…
- +
-Everything should now work as before, but should NeoOffice crash it is much less likely that you will loose data. Also if you are developing a database for a client you can duplicate the above setup on their machine and yours. As you develop new versions of the Forms, Queries and Reports you can simply send then an updated odb file to copy over the old one. Their data will be unaffected. Obviously if you make changes to the tables you will have to visit the client or give them a list of steps or SQL commands to enter, but for the purposes of this guide I'll assume you know what you are doing if you are doing that!+

Current revision

By default NeoOffice uses the embedded HSQL 1.8 database engine when creating a odb file. This is fine for quick development, but it can cause problems data loss problems if NeoOffice crashes and it makes it hard to deploy updated forms and reports to the user if you are developing a database for someone else. By splitting the database from the odb file the HSQL databse engine runs as a separate process and is unaffected inthe event of a NeoOffice crash.

This page is based on posting on the oooForum, specifically this page Base and HSQL together but not mixed? How to do it? - The Quick Fix.


Contents

Setting up NeoOffice

  1. Start NeoOffice
  2. Select NeoOffice then Preferences
  3. In the Preferences window select NeoOffice then Java
  4. Click on the button Class Path…
  5. Click on the button Add Archive…
  6. Type Shift-Cmd-G
  7. Enter the path /Applications/NeoOffice.app/Contents/basis-link/program/classes/ and click Go(N.B. you can type the first few letter of each folder name and press TAB to speed things up).
  8. Click the button Go
  9. Select the file hsqldb.jar and click and click Open.
  10. Click OK to get rid of all the dialogue boxes and restart NeoOffice.

Testing it works

  1. Download the file mydb.odb
  2. Create a folder in your Users folder called public/databases/mydb/
  3. Copy the mydb.odb file into this folder.
  4. Open the mydb.odb file
  5. It is an empty database. Add some tables to it. You should see several new files appear in the mydb folder that the mydb.odb file is in.

Splitting you databse

This section is based on Printing Multiple Values in One Field - Migrating an existing database from the all-inclusive database file (.odb) to a robust multi-mode database: on the oooForum.

  1. Make a copy of your odb file (from now on we will call the database <dbname> so the odb file is called <dbname>.odb, so if your database is called fred.db then all occurences of <dbname> should be replaced with fred.)
  2. Drag the copy of the database to the folder /Users/public/databases/<dbname>
  3. Make sure it is called <dbname>.odb
  4. Make another copy of this file and change the extension to .zip
  5. Extract the files (using BOM Archive Helper or Stuffit Expander). There should now be a folder call <dbname> or <dbname> Folder
  6. Double click this folder and then on the folder database
  7. Rename the files in this folder by pre-pending the name of your database and a period. ie backup becomes <dbname>.backup, data <dbname>.data, etc.
  8. Copy these renamed files back down the folder hierarchy to the <dbname> folder with the .odb file in it.
  9. Rename the .odb file old<dbname>.odb
  10. In NeoOffice from the File select New then Database
  11. Select Connect to an Existing Database and select JDBC. Click Next
  12. In the Data Source URL box enter: hsqldb:file:/users/public/databases/<dbname>/<dbname>;default_schema=true;shutdown=true;hsqldb.default_table_type=cached;get_column_name=false
  13. In the JDBC driver class box enter: org.hsqldb.jdbcDriver (NB there must not be a space at the end of this string)
  14. Click Next
  15. Enter SA as the Username
  16. Click Next
  17. Select to register the database and open it for editing.
  18. Save the file as <dbname>.odb in the /users/public/databases/<dbname> folder

You should now have a database with no Queries, Form or Reports. However all of your tables should be visible.

Copying across Queries, Forms and Reports

  1. Open both old<dbname>.odb and <dbname>.odb
  2. Drag each of the Queries, Forms and Reports from old<dbname>.odb to the corresponding section of <dbname>.odb

You will need to re-enter the name of all of the Queries. Make sure you don't make any typos!

Copying across Macros

  1. With old<dbname>.odb open, from the Tools select Macros then Organise Macros then NeoOffice Basic
  2. Select one of your Macro Modules and click Edit
  3. Save each module using the Save BASIC button.
  4. With <dbname>.odb open, from the select Macros then Organise Macros then NeoOffice Basic
  5. Create a new Module in <dbname>
  6. Load in the macros you saved above using the Insert BASIC Source button.
  7. Save each module with the same name as it had before.

Tidying up

The databse is now split in to separate databse and odb files and should work ok. I have however had a few problems with Autonumber fields and checkboxes

Autonumber Fields 
These seem to forget the next index, resulting in duplicate entries and failure to insert records due to duplicate Primary key fields.
Select Tools then SQL…
Use the SQL Statement ALTER TABLE "TableName" ALTER COLUMN "PrimaryKeyField" RESTART WITH xxx where xxx is the next unused value in the table.
Checkboxes 
These seem to default to NULL which can cause problems
Use the SQL Statement ALTER TABLE "TableName" ALTER COLUMN "TrueFalseField" SET DEFAULT FALSE (or TRUE as required)

Conclusion

Everything should now work as before, but should NeoOffice crash it is much less likely that you will loose data. Also if you are developing a database for a client you can duplicate the above setup on their machine and yours. As you develop new versions of the Forms, Queries and Reports you can simply send then an updated odb file to copy over the old one. Their data will be unaffected. Obviously if you make changes to the tables you will have to visit the client or give them a list of steps or SQL commands to enter, but for the purposes of this guide I'll assume you know what you are doing if you are doing that!

The next steps in this process are to upgrade to HSQLDB 2.0 to take advantage of the latest features (not least the use of ~ in paths which makes it possible to put the database in your home directory without having to know the user name) and to set the database in to server mode which allows multi user access and storage of the database on a server.

I hope to have articles on this soon…

Personal tools