helpinghand
search
needassistance
 
How To
Using Mimer SQL Mobile
Categories: Mobile, Programming Examples
Introduction

Mimer SQL Mobile is a full scale RDBMS with a very small footprint, which makes it suitable in resource-limited environments such as handheld devices and mobile phones. It is a multi user database server with complete support for standard SQL and transaction management.

The database in the mobile device can be accessed simultaneously from several local applications on the same time. Concurrently, it can be accessed from external clients in the network. The other way around, a local application on the device can access other Mimer SQL databases on other network nodes, for example databases on Linux, Unix, OpenVMS or Windows.

The client/server communication in Mimer SQL Mobile utilizes standardized network protocols such as LAN, wire-less LAN, Bluetooth, serial port, etc.

Data stored in Mimer SQL Mobile is compressed using a very effective algorithm to minimize the use of storage media


Development Environment

Mimer SQL Mobile for PocketPC includes a Windows based (NT, 2000 or XP) development environment where you, together with Microsoft’s embedded tools, can develop database applications for mobile devices. Before the application is transferred to the target hardware it can be verified in an emulation environment on the workstation.

For synchronization between the workstation and the device, Microsoft’s ActiveSync can be recommended.


The example environment

This article will present two applications - one using ODBC and one using SQL embedded in C++. These examples are Visual Studio projects that are ready to use, including a step-by-step instruction on how to build an application. The applications implement the same functionality and can access the same database. The only thing that differs is the database API.

The GUI for the application is very simple. It shows a selection list where a name can be chosen and the corresponding address is displayed. In the background a log record is stored for each operation performed. The log can be displayed and emptied.

The data model for the application is formed on three tables where one is the logbook, one is storing names and the third is storing addresses. The latter two are coupled together using the Foreign Key clause. All statements used to create the initial database are available in the mobile.sql file. The following SQL statements are creating the tables:

create table person(
pnr int,
name nchar varying(50),
surname nchar varying(50),
primary key(pnr));

create table person_address(
address_id int default next_value of address_id_seq,
pnr int,
phone nchar(10),
zipcode nchar(10),
address nchar varying(100),
city nchar varying(50),
primary key(address_id),
foreign key(pnr) references person(pnr));

create table audit(
logts timestamp,
action nchar varying(50));


In addition, some statements to be used in the device are created:

create statement select_persons
select pnr, name, surname from person;
create statement select_address
select address_id, phone, zipcode, address, city from person_address
where pnr=:pnr_value;
create statement insert_audit
insert into audit(logts, action)
values(current_timestamp, :action_value);
create statement select_audit
select logts, action from audit;
create statement clear_audit
delete from audit;
create statement insert_person
insert into person(pnr, name, surname)
values(:pnr, :name, :surname);
create statement insert_address
insert into person_address(pnr, phone, zipcode, address, city)
values(:pnr, :phone, :zipcode, :address, :city);


The sequence of work can shortly be described as follows; the database structure and executable statements accessing the database are created on the workstation. The statements, used by the application, can be static or dynamic. In the dynamic case, variables are used to couple the statement with the application (see the final example statement above). The database, including the statements, is then exported to the handheld device.


Getting Started

The first thing to do is to install Microsoft embedded Tools and then Mimer SQL Mobile.

When Mimer SQL Mobile is installed a program group called "Mimer SQL Mobile 9.1" is created which contains various programs and catalogues for Online Documentation, Utilities and Internet Resources.

In the "Online Documentation" catalogue, a Getting Started Guide is located – this is the starting point for the description on how to work with Mimer SQL Mobile. Further information is found in the documentation set that includes a Programmer’s Manual, a User’s Manual, a Reference Manual and a System Management Handbook.

Below is a short description to get going with the examples. The programs used in the description are the Mimer Administrator, found directly under the Program Group, and Batch SQL, found in the Utilities sub catalogue.

Create a local database on the workstation
When Mimer SQL Mobile is installed it is time to create a database on the workstation. This will be the database that you will use for development. You create the database by opening the Local tag in the Mimer Administrator and then click Add. Give this database the name "devmobile" so that it will fit with the example environment. The Description field for the database is not required but the Home Directory is. Use the Browse button to find or create a suitable directory for the database. Use the default options for the rest of the fields and press Ok.

You will now get a question whether you will create system databanks, or not. Answer Yes to this question and then a wizard will help you through this step. Use default values in the first part. In the second part you must decide a password for the database user SYSADM, a password that you must keep in mind. In the third part the databanks are created. Then, another question is raised asking what to do next. Unselect the choice "Start Wizard for Development User and Databank and Example" and perform only a startup of the database server. (The reason for not installing the "Development User and Databank and Example" is that it has nothing in common with the examples we are using in this description. Instead we recommend that these environments are installed in a separate database. It is of course possible to have all environments in the same database, but in mobile environments it is usually an issue to keep the environment as small as possible due to resource limitations).

Load the example environment into the database
When the database is successfully created the example database environment for the applications should be loaded. The SQL statements for doing this are available in the file mobile.sql.

Start the Batch SQL program found under the Utilities catalogue and select the database that you just created in the dialogue. Use the SYSADM user and the password that you selected above. When you get the SQL> prompter you should give the following statement to read the mobile.sql file:

read 'mobile.sql';


If the file is not located in the current directory you may have to use the complete path, e.g. 'c:\tmp\mobile.sql'.

Create a Remote Database for the device or for the emulation environment on the workstation
You should now create the database in the target environment, i.e. in the device or in the emulation environment. You do this by opening the Mimer Administrator on the workstation where you select the Remote tab and click the Add button. Give this database the name "mobiledb" so that it will fit with the example environment. Under Protocol you should chose "tcp – emulator" if you should use the emulator or else "rapi". You will now get into a dialogue where you can use default options all through. The dialogue is concluded by a question asking if you want to export the database (see below).

Exporting the example database to "mobiledb"
It is now possible to export the complete database environment to the device or to the emulation environment. You can explicitly perform an export by opening the Mimer Administrator on the workstation. By a right-click on a database in the list of local databases, a menu is displayed where an option "Export to handheld" or "Export to emulation" is available. You will also get an opportunity to export when you create your target database.

When exporting you will get into a dialogue with predefined names for source and target databases. If these names correspond with the names of the created databases no change is needed, just fill in the SYSADM password and press Ok.

Install and run the application
Unpack one of the zip-files (see below) that contain example applications and be sure that catalogues are expanded. You can read about the applications in the ReadMe.txt that is found in the corresponding Visual Studio project.

For details on how to manage Mimer SQL on the device, please refer to the Getting Started Guide.


Example files

The following files and packages are used in this article:

CppExampleEsql.zip - Visual C example using Embedded SQL and Mimer SQL Mobile.
CppExampleOdbc.zip - Visual C example using ODBC and Mimer SQL Mobile.
mobile.sql – SQL statements to create and load the example database.

The latest version of Mimer SQL Mobile is found at the download page.

The Microsoft studio to be used is the one included in the 'Microsoft® Windows® Platform SDK for Pocket PC' called Microsoft© eMbedded Visual Tools 3.0.

Please be in touch on developer@mimer.com if you want further information on Mimer SQL Mobile.


Last updated: 2003-11-25

 

Powered by Mimer SQL

Powered by Mimer SQL