Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.1 » MobiLink - Client Administration » SQL Anywhere clients for MobiLink » Scripted upload » Tutorial: Using scripted upload


Lesson 1: Creating the consolidated database

This tutorial specifies file names and assumes they are in the current directory, which is scriptedupload. In a real application, you should specify the full path to the file.

 Create a consolidated database
  1. Run the following command to create a directory to hold the tutorial files, and switch to that directory.

    md c:\scriptedupload
    cd c:\scriptedupload
  2. Run the following command to create a consolidated database:

    dbinit consol.db
  3. Next, run the following command to define an ODBC data source for the consolidated database:

    dbdsn -w dsn_consol -y -c "UID=DBA;PWD=sql;DBF=consol.db;SERVER=consol"
  4. To use a database as a consolidated database, you must run a setup script that adds system tables, views, and stored procedures that are used by MobiLink. The following command sets up consol.db as a consolidated database:

    dbisql -c "DSN=dsn_consol" "%SQLANY12%\MobiLink\setup\syncsa.sql"
  5. To open Interactive SQL and connect to consol.db using the dsn_consol DSN, run the following command:

    dbisql -c "DSN=dsn_consol"
  6. Run the following SQL statements. They create the employee table on the consolidated database, insert values into the table, and create the required synchronization scripts.

    CREATE TABLE employee (
       id      unsigned integer primary key,
       name    varchar( 256),
       salary  numeric( 9, 2 )
    INSERT INTO employee VALUES( 100, 'smith', 225000 );
    CALL ml_add_table_script( 'default', 'employee', 'upload_insert',
           'INSERT INTO employee ( id, name, salary ) VALUES ( {ml}, {ml}, {ml r.salary} )' );
    CALL ml_add_table_script( 'default', 'employee', 'upload_update',
           'UPDATE employee SET name = {ml}, salary = {ml r.salary} WHERE id = {ml}' );
    CALL ml_add_table_script( 'default', 'employee', 'upload_delete',
           'DELETE FROM employee WHERE id = {ml}' );
    CALL ml_add_table_script( 'default', 'employee', 'download_cursor',
           'SELECT * from employee' );

    After you have executed the SQL, leave Interactive SQL running and connected to the consolidated database as you will be running more SQL against the database as you work through the tutorial.

  7. Proceed to Lesson 2: Creating the remote database.