Contents Index modify_next_last_download_timestamp connection event new_row_cursor cursor event (deprecated)

MobiLink Synchronization Reference
  Synchronization Events

modify_user connection event


Function 

Provide the MobiLink user name.

Parameters 

In the following table, the description provides the SQL data type. If you are writing your script in Java or .NET, you should use the appropriate corresponding data type. See SQL-Java data types and SQL-.NET data types.

Item Parameter Description
1 ml_username VARCHAR(128). This is an INOUT parameter.
Default action 

None.

Description 

The MobiLink server provides the user name as a parameter when it calls scripts; the user name is sent by the MobiLink client. In some cases, you may want to have an alternate user name. This script allows you to modify the user name used in calling MobiLink scripts.

The ml_username parameter must be long enough to hold the user name.

SQL scripts for the modify_last_download_timestamp event must be implemented as stored procedures.

See also 

authenticate_user connection event

authenticate_user_hashed connection event

SQL example 

The following example works with an Adaptive Server Anywhere consolidated database. It maps a remote database user name to the id of the user using the device, by using a mapping table called user_device. This technique can be used when the same person has multiple remotes (such as a PDA and a laptop) requiring the same synchronization logic (based on the user's name or id).

call ml_add_connection_script(
 'ver1',
 'modify_user',
 'call ModifyUser( ? )'  )
CREATE PROCEDURE ModifyUser( INOUT u_name varchar(128) )
BEGIN
 select user_name
    into u_name
    from user_device
    where device_name = u_name
END
Java example 

The following stored procedure call registers a Java method called modifyUser as the script for the modify_user connection event when synchronizing the script version ver1. This syntax is for Adaptive Server Anywhere consolidated databases.

call ml_add_java_connection_script(
   'ver1',
   'modify_user',
   'ExamplePackage.ExampleClass.modifyUser' )

Following is the sample Java method modifyUser. It gets the user ID from the database and then uses it to set the user name.

public void ModifyUser( InOutString io_user_name )
  throws SQLException
{  Statement uid_select = curConn.createStatement();
   ResultSet uid_result = uid_select.executeQuery(
   "select rep_id from SalesRep where name = '" +
   io_user_name.getValue() + "' " );
   uid_result.next();
   io_user_name.setValue(
   java.lang.Integer.toString(uid_result.getInt( 1 ))
   uid_result.close();
   uid_select.close();
   return; }
.NET example 

The following stored procedure call registers a .NET method called ModUser as the script for the modify_user connection event when synchronizing the script version ver1. This syntax is for Adaptive Server Anywhere consolidated databases.

call ml_add_dnet_connection_script(
  'ver1',
  'modify_user',
  'TestScripts.Test.ModUser'
)

Following is the C# signature for the call ModUser.

public void ModUser( string user )

Contents Index modify_next_last_download_timestamp connection event new_row_cursor cursor event (deprecated)