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

SQL Anywhere 11.0.1 (日本語) » Mobile Link - クイック・スタート » Mobile Link テクノロジの概要 » Mobile Link CustDB サンプルの解説 » 顧客と注文のプライマリ・キー・プールの管理

 

ULCustomerIDPool

以下のスクリプトは、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 スクリプトは、各アップロードの完了後に 20 個の顧客 ID が顧客 ID プールに残るように処理を行います。
    CALL ULOrderIDPool_maintain( {ml s.username} )

    CustDB の UL_CustomerIDPool_maintain プロシージャを次に示します。

    CREATE PROCEDURE ULCustomerIDPool_maintain ( IN syncuser_id INTEGER )
    BEGIN
      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;
    END