All Products
Search
Document Center

DataWorks:Configure a do-while node

Last Updated:Mar 26, 2026

A do-while node works like the do-while statement in programming languages: it runs an inner workflow in a loop and evaluates an exit condition at the end of each iteration. The loop runs at least once before the condition is checked. Use a do-while node alone, or combine it with an assignment node to iterate over a result set.

Prerequisites

Before you begin, ensure that you have:

Limitations

ConstraintDetail
EditionDataWorks Standard Edition and higher only
Maximum loops1,024 iterations per node instance
Parallel executionNot supported — each loop starts only after the previous one ends

How it works

A do-while node has three built-in components:

ComponentRoleCan be deleted?
Start nodeMarks the beginning of each iteration; does not run business logicNo
Shell nodeSample business processing node provided by DataWorks; can be replaced with another node typeNo (replace with another node type as needed)
End nodeEvaluates the exit condition; returns True to continue or False to stopNo

Execution follows this sequence in each iteration:

  1. The start node signals the beginning of the loop.

  2. Inner nodes run in dependency order.

  3. The end node evaluates the exit condition.

  4. If the end node returns True, the next iteration starts. If it returns False, the loop ends.

Built-in variables available to all inner nodes:

VariableDescriptionStarting value
${dag.loopTimes}The current iteration count1
${dag.offset}The offset of the current iteration count from 10

Inner nodes reference input and output parameters configured on the do-while node using ${dag.<parameter name>}.

Create a do-while node

  1. Go to the DataStudio page. Log on to the DataWorks console. In the top navigation bar, select the desired region. In the left-side navigation pane, choose Data Development and Governance > Data Development. On the page that appears, select the desired workspace from the drop-down list and click Go to Data Development.

  2. Create the node. Hover over the 新建 icon and choose Create Node > General > do-while. Alternatively, find the target workflow in the left pane, click the workflow name, right-click General, and choose Create Node > do-while.

  3. In the Create Node dialog box, set the Name and Path parameters, then click Confirm.

Example: loop five times and print the iteration count

This example runs a do-while node for exactly five iterations. In each iteration, the shell node prints the current loop number.

What's next

  • To pass data between the outer workflow and inner nodes, configure input and output parameters on the do-while node. Inner nodes reference them using ${dag.<parameter name>}.

  • To iterate over a result set, combine the do-while node with an assignment node. Use ${dag.offset} (starts from 0) to index into each row.

  • The do-while node always runs at least one iteration before evaluating the exit condition, matching the behavior of a do-while statement. It does not support a pre-check like a while loop. To achieve for-each behavior, use ${dag.offset} and configure input/output parameters accordingly.