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

SQL Anywhere 10.0.1 » MobiLink - Server Administration » Writing Synchronization Scripts » Script parameters

Script parameters Next Page

User-defined named parameters

You can also define your own parameters. These are especially useful for RDBMSs that don't allow user-defined variables.

User-defined parameters are defined (and set to NULL) when first referenced. They must start with the letter u and a period (u.). A user-defined parameter lasts for one synchronization—it is set to NULL at the start of every synchronization. User-defined parameters are in/out.

A typical use of user-defined parameters is to access state information without having to store it in a table (requiring potentially complex joins).


For example, assume you create a stored procedure called MyBSProc that sets a variable called var1 to bs_value:

  IN username (VARCHAR 128), INOUT var1 (VARCHAR 128)
 SET var1 = 'bs_value';

The following begin_connection script defines the user-defined parameter var1 and sets the value to bs_value:

CALL ml_add_connection_script ( 
  '{call MyBSProc( {ml s.username}, {ml u.var1} )}' );

The following begin_upload script references var1, whose value is bs_value:

CALL ml_add_connection_script ( 
  'update SomeTable set some_column = 123 where some_other_column = {ml u.var1}' );

Assume you have another stored procedure called MyPFDProc that defines its first parameter to in/out. The following prepare_for_download script changes the value of var1 to pfd_value:

CALL ml_add_connection_script ( 
  '{call MyPFDProc( {ml u.var1} )}' );

The following begin_download script references var1, whose value is now pfd_value:

CALL ml_add_connection_script ( 
  'insert into SomeTable values( {ml s.username}, {ml u.var1} )' );