Clear table before import Excel

  • Last update:  2021-05-28
  • I. Overview

    1. Probelm description

    Hope to clear the data in the original table before importing the Excel data and submitting it.


    2. Solution

    When setting the data entry attributes, the built-in SQL will be executed sequentially from top to bottom. Using this feature, set delete submission to clear the table in the built-in SQL1, and then set smart submission in the built-in SQL2 to insert data.

    This method can ensure the consistency of the transaction. If the data insertion fails, the operation of emptying the table will also be rolled back.

    II. Example

    1. Prepare data

    Create a new general report, add a dataset ds1, SQL statement: SELECT * FROM Product

    1.png


    2. Design template

    Excel: Product.xlsx

    In the designer, design the table according to the Excel, and set "Cell Attributes > Expansion Direction" to "Vertical" in cell B3, as shown in the following figure:

    2.png

    Note: This example does not add widgets when designing the table, only supports importing data, and cannot be modified. If necessary, you can add it yourself.

    Select "Individually set for the template" in "Template > Web Attributes > Data Entry Settings", and double-click "Emptying Import" to add it to the toolbar.

    3.png


    3. Set to clear the table

    Click "Template>Data Entry Attributes" to add a built-in SQL submission, and the submission type is "Delete Submit". Select the table that needs to be cleared, add the field "ProductID" and check the primary key, use the formula SQL ("FRDemo", "SELECT ProductID FROM Product", 1) to query all ProductID as the primary key to clear the table .

    4.png


    4. Set to insert data

    Add a built-in SQL2, the submission type is "Smart Submit", select the "Product" table in FRDemo, add all the fields intelligently, and add the corresponding cells, and check the "ProductID" as the primary key.

    5.png


    5. Preview effect

    Click Emptying Import, and then click Submit after importing excel, the data table of the database will be cleared first and then the imported data will be inserted.

    6.gif

    III. Download template

    Click to download: 

    Clear_table_before_import.cpt



    Attachment List


    Theme: Data Entry
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy