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

SQL Anywhere 11.0.1 (中文) » MobiLink - 入门 » MobiLink 技术简介 » 研究 MobiLink 的 CustDB 示例 » 维护客户和订单的主键池



以下脚本在 ULCustomerIDPool 表中定义:

  • download_cursor  
    SELECT pool_cust_id FROM ULCustomerIDPool 
       WHERE last_modified >= {ml s.last_table_download}
         AND pool_emp_id = {ml s.username}

  • upload_insert   CustDB 的 upload_insert 脚本如下所示:
    INSERT INTO ULCustomerIDPool ( pool_cust_id )
       VALUES( {ml r.pool_cust_id} )

  • upload_delete   CustDB 的 upload_delete 脚本如下所示:
    DELETE FROM ULCustomerIDPool
       WHERE pool_cust_id = {ml r.pool_cust_id}

  • end_upload   以下 end_upload 脚本用于确保每次上载后客户 ID 池中保留 20 个客户 ID:
    CALL ULOrderIDPool_maintain( {ml s.username} )

    CustDB 的 UL_CustomerIDPool_maintain 过程如下所示:

    CREATE PROCEDURE ULCustomerIDPool_maintain ( IN syncuser_id INTEGER )
      DECLARE pool_count INTEGER;
      -- Determine how many ids to add to the pool
      SELECT COUNT(*) INTO pool_count
        FROM ULCustomerIDPool
        WHERE pool_emp_id = syncuser_id;
      -- Top up the pool with new ids
      WHILE pool_count < 20 LOOP
        INSERT INTO ULCustomerIDPool ( pool_emp_id )
          VALUES ( syncuser_id );
        SET pool_count = pool_count + 1;
      END LOOP;