If your business logic is complex, you need to write nested statements in a DML statement. In this case, issues are difficult to locate. To simplify the development process, you can define a data view and write nested statements to the data view.
Note
A data view displays a logical table that describes the computing logic without storing physical data.
Syntax
CREATE TEMPORARY VIEW viewName AS [ (columnName[ , columnName]* ) ] queryStatement;
viewName: the name of the view.
columnName: the name of the field.
queryStatement: the alias of the nested statement.
Example
-- Create a source table.
CREATE TEMPORARY TABLE datagen_source (
name VARCHAR,
score BIGINT
) WITH (
'connector' = 'datagen',
'number-of-rows' = '10'
);
-- Create a result table.
CREATE TEMPORARY TABLE rds_output (
name VARCHAR,
score BIGINT
) WITH (
'connector' = 'blackhole'
);
-- Create a data view.
CREATE TEMPORARY VIEW tmp_view AS
SELECT
*
FROM
datagen_source;
-- Execute the DML statement.
INSERT INTO
rds_output
SELECT
name,
score
FROM
tmp_view;