Clear the database table before importing into Excel

  • Last update:July 08, 2022
  • I. Overview

    1. Problem description

    We hope to clear the data in the original database table before importing the Excel data and submitting it.


    2. Implementation ideas

    When setting the data entry attributes, the built-in SQL will be executed sequentially from top to bottom. Use this feature to set delete submission to clear the table in the first built-in sql, and then set smart submission or insert submission in the second built-in sql 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. Examples

    1.Prepare the data

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


    2. Design template

    Excel table used: Clear_the_database_table_before_importing_into _Excel.xlsx

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

    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. Set table emptying

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

    Note: Because the table is cleared, only one field is needed. Setting multiple fields may cause Cartesian product problems.


    4. Set insert data

    Add another built-in SQL below the previous built-in SQL, the Submit Type is "Smart Submit", select the "Product" table in FRDemo,Smart Add Fields, and add the corresponding cells, and check the "Product ID" as the primary key.


    5. Effect preview

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

    III. Template download

    Attachment List


    Theme: Data Entry
    Already the First
    Already the Last
    • 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