SQL Script

  • Last update: January 04, 2026
  • Overview

    Version

    FineDataLink VersionFunctional Change
    1.0/
    4.1.3Allowed calling stored procedures on the Script Configuration tab page when the data source was a MySQL, Oracle, or SQL Server database.
    4.1.11.2

    Allowed setting SQL Execution Method to enable execution of the stored procedure creation statement as a single statement. Allowed adding remarks to the SQL statements without affecting execution.

    Allowed calling stored procedures when the data source was a HP Vertica and GaussDB 200 database.

    4.1.12.2Db2 and SAP HANA support calling stored procedures with no return values.

    Application Scenario

    To process data in a database, such as creating, updating, deleting, reading, and summarizing data, you can use the SQL Script node.

    Function Description

    Data Processing and Data Insertion, Update, and Deletion

    You can use SQL statements to process data.

    After selecting the data source type and a data connection, you can write SQL statements to process data. Note that:

    • The SQL statements must be written in accordance with the syntax of the connected database.

    • You can reference custom parameters or assignment parameters from upstream nodes in SQL statements to perform data insertion, update, and deletion in the database. The following image is an example. For details about the parameter-referencing method in SQL Script, see Parameter Overview.

    iconNote:
    If the parameter to be referenced is generated by an upstream node with Closure Character enabled, you do not need to add quotation marks when referencing the parameter.

    Calling Stored Procedures

    You can call stored procedures when reading data from MySQL, Oracle, SQL Server, HP Vertica, GaussDB 200, IBM Db2, and SAP HANA databases. For details, see Calling Database Stored Procedures in Scheduled Tasks.

    Setting SQL Execution Method

    Starting from FineDataLink V4.1.11.2, SQL Script supports the execution of single and multiple SQL statements. You can input a stored procedure creation statement, and set SQL Execution Method to Execute A Single Statement, as shown in the following figure.

    iconNote:
     SQL statements can be executed as a single statement. You can also add remarks to SQL statements, which do not affect execution.
    SQL Execution Method DescriptionDescription
    Execute A Single Statement

    The SQL script is sent to the database for execution without being split.

    iconNote:

    1. Only statements for creating stored procedures are supported here; statements with command separators, such as delimiter, are not supported.

    2. Stored procedures of Oracle databases are not supported.


    Execute Multiple Statements (Separated by Semicolon (;))

    iconNote:
    SQL script remarks cannot contain semicolons(;), as semicolons will invalidate the remark logic, causing SQL invalidity errors.


    The system automatically splits the SQL script statements and submits them to the database in batches for processing.
    CREATE PROCEDURE fdldemotest.Deletemoney1(IN nu INT)
    BEGIN
        DELETE FROM  fdldemotest.Order_Customer_Information WHERE `Freight` = nu;
        select * from fdldemotest.Order_Customer_Information;
    END

     

    Click Run to execute the task. You can see the created stored procedure, as shown in the following figure.

    Example

    This example demonstrates how to create two tables, insert data into one table, and store the summary data from that table in the other table using the SQL Script node in Data Development.

    Creating a Database Table

    1. Create a scheduled task, set the location and name, and enter Development Mode, as shown in the following figure.

    2. Drag in an SQL Script node and configure it as shown in the following figure. The SQL statement creates two tables, order1 and order2, with the same fields ID and inventory, as shown in the following figure.

     

    The SQL statement is as follows. 

    USE `fdldemotest`;
    CREATE TABLE IF NOT EXISTS `Order1` (
      `ID` INT,
      `inventory` INT
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    CREATE TABLE IF NOT EXISTS `Order2` (
      `ID` INT,
      `inventory` INT
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    3. Click Node Information to enter the tab page and rename the node Database Table Creation, as shown in the following figure.

     

    Inserting Data into the Table

    1. Drag in another SQL Script node and configure it as shown in the following figure. The SQL statement inserts 9 records into the order1 table, as shown in the following figure.

    The SQL statement is as follows.

    insert into
      `fdldemotest`.`Order1` (ID, inventory)
    values
      (1, 20);
    insert into
      `fdldemotest`.`Order1`(ID, inventory)
    values
      (1, 21);
    insert into
      `fdldemotest`.`Order1` (ID, inventory)
    values
      (1, 22);
    insert into
      `fdldemotest`.`Order1` (ID, inventory)
    values
      (2, 23);
    insert into
      `fdldemotest`.`Order1` (ID, inventory)
    values
      (2, 24);
    insert into
      `fdldemotest`.`Order1` (ID, inventory)
    values
      (2, 25);
    insert into
      `fdldemotest`.`Order1` (ID, inventory)
    values
      (3, 26);
    insert into
      `fdldemotest`.`Order1` (ID, inventory)
    values
      (3, 27);
    insert into
      `fdldemotest`.`Order1` (ID, inventory)
    values
      (3, 28);

    2. Click Node Information to enter the tab page and rename the node Inserting Data into Order1, as shown in the following figure.

    Summarizing Data

    1. Drag in another SQL Script node and configure it as shown in the following figure. The SQL statement groups and summarizes data from Order1 and inserts the result data into Order2, as shown in the following figure.

    The SQL statement is as follows.

    insert into `fdldemotest`.`Order2`
    select ID, sum(inventory) from `fdldemotest`.`Order1` group by ID

    2. Click Node Information to enter the tab page and rename the node Inserting Grouped Data into Order2, as shown in the following figure.

    Running the Task

    Click Run to execute the task. After a successful execution, the log is displayed as shown in the following figure.

     After successful execution, you can see two new tables in the database:

    Order1:

    Order2:

    Publishing the Task

    After successful execution, click Publish to publish the task to Production Mode, as shown in the following figure.

    SQL Syntax Supported by SQL Script

    iconNote:
    Starting from FineDataLink V4.1.11.2, the SQL Script node supports the MERGE statement.
    TypeSyntaxFunction
    Data processing
    INSERTInsert data.
    DELETEDelete data.
    UPDATEUpdate data.
    SELECTQuery data.
    Database table operations
    CREATE TABLECreate a database table.
    DROP TABLEDelete a database table.
    Stored procedure statements/ (When SQL Execution Method is set to Execut A Single Statement, statements with command separators, such as delimiter, are not supported.)



    附件列表


    主题: Data Development - Scheduled Task
    Previous
    Next
    • 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