This tutorial shows you how to set up a scripted upload that provides conflict detection. The tutorial creates the consolidated and remote databases, stored procedures, publications and subscriptions that are required by scripted upload.
Prérequis
This lesson assumes you have the roles and privileges listed in the Privileges section at the start of this tutorial: Tutorial: Using scripted upload.
Contexte et remarques
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.
This tutorial is presented in such a way that you can either just read through it, or you can cut and paste the text to run the sample.
Run the following command to create a directory to hold the tutorial files, and switch to that directory.
md c:\scriptedupload cd c:\scriptedupload |
Run the following command to create a consolidated database:
dbinit -dba DBA,sql consol.db |
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" |
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" "%SQLANY16%\MobiLink\setup\syncsa.sql" |
To open Interactive SQL and connect to consol.db using the dsn_consol DSN, run the following command:
dbisql -c "DSN=dsn_consol" |
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 ); COMMIT; CALL ml_add_table_script( 'default', 'employee', 'upload_insert', 'INSERT INTO employee ( id, name, salary ) VALUES ( {ml r.id}, {ml r.name}, {ml r.salary} )' ); CALL ml_add_table_script( 'default', 'employee', 'upload_update', 'UPDATE employee SET name = {ml r.name}, salary = {ml r.salary} WHERE id = {ml r.id}' ); CALL ml_add_table_script( 'default', 'employee', 'upload_delete', 'DELETE FROM employee WHERE id = {ml r.id}' ); 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.
![]() |
Discuter à propos de cette page dans DocCommentXchange.
|
Copyright © 2013, SAP AG ou société affiliée SAP - SAP Sybase SQL Anywhere 16.0 |