doc-exports/docs/dws/tool/dws_mt_0115.html
Lu, Huayi 346ac31da9 DWS TG 8.1.3.200 VERSION
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Reviewed-by: Jiang, Beibei <beibei.jiang@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2023-08-28 09:20:17 +00:00

331 lines
35 KiB
HTML

<a name="EN-US_TOPIC_0000001188202576"></a><a name="EN-US_TOPIC_0000001188202576"></a>
<h1 class="topictitle1">DML</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_p19856515191519">This section describes the migration syntax of Oracle DML. The migration syntax decides how the keywords/features are migrated.</p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_p14743143861514">For details, see the following topics:</p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_p168491253101515"><a href="#EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_section18324123915168">SELECT</a></p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_p7216659171512"><a href="#EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_section1154515495164">INSERT</a></p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_p392824111610"><a href="#EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_section1751695411617">MERGE</a></p>
<div class="section" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_section18324123915168"><a name="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_section18324123915168"></a><a name="en-us_topic_0238518390_en-us_topic_0237362198_section18324123915168"></a><h4 class="sectiontitle">SELECT</h4><p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_p739491961712"><strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0237712280_b162518205212">Overview</strong></p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727451_p820316116">The Oracle <strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0237712280_b146231910632">SELECT </strong>statement starts a query, with an optional ORDER BY clause. The clause is used to retrieve records from one or more tables in a database.</p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727451_p41181752174719"><strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0237712280_b1312011529475">Input - SELECT</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727451_screen912095224710">SELECT col1, col2
FROM tab1;</pre>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727451_p1912385210476"><strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0237712280_b2123752114717">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727451_screen18159181964">SELECT col1, col2
FROM tab1;</pre>
</div>
<ol id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_ol55451752141715"><li id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_li1545105221714"><strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0237712280_b476314282112">Order of Clauses</strong><p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727286_p5081441222821">The <strong id="EN-US_TOPIC_0000001188202576__b148329712114">HAVING</strong> clause must follow the <strong id="EN-US_TOPIC_0000001188202576__b18832187201110">GROUP BY</strong> clause. However, Oracle allows <strong id="EN-US_TOPIC_0000001188202576__b118329712112">HAVING</strong> to be in front of or behind the <strong id="EN-US_TOPIC_0000001188202576__b178321781116">GROUP BY</strong> clause. In the target database, the <strong id="EN-US_TOPIC_0000001188202576__b5227102291114">HAVING</strong> clause is moved to behind the <strong id="EN-US_TOPIC_0000001188202576__b10227122151117">GROUP BY</strong> clause.</p>
<div class="fignone" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727286_fig19659369201331"><span class="figcap"><b>Figure 1 </b>Input - Order of Clauses</span><br><span><img id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727286_image48905050201331" src="figure/en-us_image_0000001234200745.png"></span></div>
<div class="fignone" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727286_fig1886079201331"><span class="figcap"><b>Figure 2 </b>Output - Order of Clauses</span><br><span><img id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727286_image18554688201331" src="figure/en-us_image_0000001188202702.png"></span></div>
</li><li id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_li19812142183"><strong id="EN-US_TOPIC_0000001188202576__b4131653111110">Extended Group By Clause</strong><p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727328_p57777245171928">The <strong id="EN-US_TOPIC_0000001188202576__b52391059121">GROUP BY</strong> clause can be specified if you want the database to group the selected rows based on the value of expr(s). If this clause contains <strong id="EN-US_TOPIC_0000001188202576__b1571241312126">CUBE</strong>, <strong id="EN-US_TOPIC_0000001188202576__b18712161318129">ROLLUP</strong>,<strong id="EN-US_TOPIC_0000001188202576__b1371212131128"> </strong>or <strong id="EN-US_TOPIC_0000001188202576__b9712111391212">GROUPING SETS</strong> extensions, then the database produces super-aggregate groupings in addition to the regular groupings. These features are not supported by <span id="EN-US_TOPIC_0000001188202576__text1958020141713">GaussDB(DWS)</span> but can be enabled using the <strong id="EN-US_TOPIC_0000001188202576__b1777182218124">UNION ALL</strong> operator.</p>
<div class="fignone" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727328_fig22731645201527"><span class="figcap"><b>Figure 3 </b>Input - Extended group by clause</span><br><span><img id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727328_image29323922201527" src="figure/en-us_image_0000001188681138.png"></span></div>
<div class="fignone" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727328_fig24851253201757"><span class="figcap"><b>Figure 4 </b>Output - Extended group by clause</span><br><span><img id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727328_image5485023710519" src="figure/en-us_image_0000001233800811.png"></span></div>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_p0855151914205"><strong id="EN-US_TOPIC_0000001188202576__b11755715214">GROUPING_ID and ROLLUP</strong></p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727328_p386784162012"><strong id="EN-US_TOPIC_0000001188202576__b9704553121215">GROUPING_ID</strong> returns a number that corresponds to the <strong id="EN-US_TOPIC_0000001188202576__b370485314121">GROUPING </strong>bit vector associated with a row. <strong id="EN-US_TOPIC_0000001188202576__b56311284136">GROUPING_ID </strong>is applicable only in a <strong id="EN-US_TOPIC_0000001188202576__b1163111816135">SELECT </strong>statement containing a <strong id="EN-US_TOPIC_0000001188202576__b663118813136">GROUP BY</strong> extension, such as the <strong id="EN-US_TOPIC_0000001188202576__b563119841319">ROLLUP</strong> operator and <strong id="EN-US_TOPIC_0000001188202576__b163110813131">GROUPING </strong>function. In queries with multiple <strong id="EN-US_TOPIC_0000001188202576__b115415210139">GROUP BY</strong> expressions, determining the <strong id="EN-US_TOPIC_0000001188202576__b11541321171320">GROUP BY</strong> level of a particular row requires multiple <strong id="EN-US_TOPIC_0000001188202576__b315416216137">GROUPING </strong>functions, which may complicate SQL statements. In such scenarios, <strong id="EN-US_TOPIC_0000001188202576__b1365273619135">GROUPING_ID </strong>is used to avoid statement complexity.</p>
</li><li id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_li830362671818"><strong id="EN-US_TOPIC_0000001188202576__b1035325021320">Table Name Inside Brackets</strong><p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727231_p14607382222751">Table names do not need to be specified within parentheses. However, allows using brackets.</p>
<div class="fignone" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727231_fig52682578201846"><span class="figcap"><b>Figure 5 </b>Input - Table name inside brackets</span><br><span><img id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727231_image39430386201846" src="figure/en-us_image_0000001233922301.png"></span></div>
<div class="fignone" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727231_fig39744670201846"><span class="figcap"><b>Figure 6 </b>Output - Table name inside brackets</span><br><span><img id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727231_image65201727201846" src="figure/en-us_image_0000001234042253.png"></span></div>
</li><li id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_li1530663710185"><strong id="EN-US_TOPIC_0000001188202576__b6355131691411">UNIQUE Keyword</strong><p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727179_p139135162315">Unique keyword is migrated as Distinct keyword.</p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727179_p5912532315"><strong id="EN-US_TOPIC_0000001188202576__b1230116279149">Input - SELECT UNIQUE</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727179_screen18911451234">SELECT UNIQUE a.item_id id,
a.menu_id parent_id,a.serialno menu_order
FROM ctp_menu_item_rel a WHERE
a.item_id IN(SELECT UNIQUE id FROM ctp_temp_item_table);</pre>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727179_p2916514234"><strong id="EN-US_TOPIC_0000001188202576__b733914336141">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727179_screen18911259231">SELECT DISTINCT a.item_id id,
a.menu_id parent_id,a.serialno menu_order
FROM ctp_menu_item_rel a WHERE
a.item_id IN(SELECT UNIQUE id FROM ctp_temp_item_table);</pre>
</li><li id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_li14329104716185"><strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_b1594717273191">USERENY</strong><p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_p12637141895116"><strong id="EN-US_TOPIC_0000001188202576__b2025118402146">I</strong><strong id="EN-US_TOPIC_0000001188202576__b202512406141">nput - CLIENT_INFO</strong></p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_p14783114855118">Returns user session information.</p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_screen329294345220">SELECT 1
FROM sp_ht ht
WHERE ht.hth = pi_contract_number
/* AND ht.contract_status = 2 --delete by leinian 2014-03-03(ECO) */
AND ht.contract_status IN ( 1, 2 ) /* add by leinian 2014-03-20(ECO) */
AND Nvl(ht.s3_pilot_flag, 'N') = 'N'
AND NOT EXISTS (SELECT 1
FROM asms.asms_lookup_values alv
WHERE alv.type_code = 'HTLX_LOAN'
AND ht.htlx = alv.code)
AND ht.duty_erp_ou_id = To_number(Nvl(Rtrim(Ltrim(Substr(Userenv(
'client_info'),
1,
8))), 218))
AND ht.source_code = 'ECONTRACT'
AND ht.needing_engineering_service IS NOT NULL
AND ht.khm != '28060'
AND ht.htlx != '111' ;</pre>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_p10566133845218"><strong id="EN-US_TOPIC_0000001188202576__b108261651191410">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_screen41131412105311">SELECT
1
FROM
sp_ht ht
WHERE
ht.hth = pi_contract_number /* AND ht.contract_status = 2 --delete by leinian 2014-03-03(ECO) */
AND ht.contract_status IN (
1
,2
) /* add by leinian 2014-03-20(ECO) */
AND Nvl( ht.s3_pilot_flag ,'N' ) = 'N'
AND NOT EXISTS (
SELECT
1
FROM
asms.asms_lookup_values alv
WHERE
alv.type_code = 'HTLX_LOAN'
AND ht.htlx = alv.code
)
AND ht.duty_erp_ou_id = To_number( Nvl( Rtrim( Ltrim( SUBSTR( MIG_ORA_EXT.USERENV ( 'client_info' ) ,1 ,8 ) ) ) ,218 ) )
AND ht.source_code = 'ECONTRACT'
AND ht.needing_engineering_service IS NOT NULL
AND ht.khm != '28060'
AND ht.htlx != '111' ;</pre>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_p63003496414"><strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_b726545816412">USERENV('CLIENT_INFO)</strong></p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_p119871736423">After the function in the package is converted, the function tag is not deleted. 4. The svproduct_is_for_pa function in <strong id="EN-US_TOPIC_0000001188202576__b1268175115114">sad_lookup_contract_pkg.bdy</strong> is used.</p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_p206171447163710"><strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_b48866511381">USERENV('CLIENT_INFO')</strong></p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_p1518017138414">USERENV used during the migration process. Migration fails due to the tool.</p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_screen130213222510">SELECT 1
FROM sp_ht ht
WHERE ht.hth = pi_contract_number
/* AND ht.contract_status = 2 --delete by leinian 2014-03-03(ECO) */
AND ht.contract_status IN ( 1, 2 ) /* add by leinian 2014-03-20(ECO) */
AND Nvl(ht.s3_pilot_flag, 'N') = 'N'
/* add by yangyirui 2012-09-10: S3 Data is not provided for the contract cutover. */
AND NOT EXISTS (SELECT 1
FROM asms.asms_lookup_values alv
WHERE alv.type_code = 'HTLX_LOAN'
AND ht.htlx = alv.code)
AND ht.duty_erp_ou_id = To_number(Nvl(Rtrim(Ltrim(Substr(Userenv(
'client_info'),
1,
8))), 218))
AND ht.source_code = 'ECONTRACT'
AND ht.needing_engineering_service IS NOT NULL
AND ht.khm != '28060'
AND ht.htlx != '111'</pre>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_p197839472377"><strong id="EN-US_TOPIC_0000001188202576__b54861156101620">Input</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_screen44617199420">Error message :client_info argument for USERENV function is not supported by the DSC.
4_sad_lookup_contract_pkg
================================
CREATE OR REPLACE PACKAGE BODY SAD.sad_lookup_contract_pkg IS
FUNCTION svproduct_is_for_pa(pi_contract_number IN VARCHAR2) RETURN VARCHAR2 IS
l_flag VARCHAR2(1) := 'N';
BEGIN
FOR rec_lookup IN (SELECT 1
FROM asms.asms_lookup_values alv
WHERE alv.type_code = 'HTLX_LOAN'
AND alv.duty_erp_ou_id = to_number(nvl(rtrim(ltrim(substr(userenv('client_info'), 1, 8))), 218))
)
LOOP
l_flag := 'Y';
END LOOP;
RETURN l_flag;
END svproduct_is_for_pa;
END sad_lookup_contract_pkg;
/
</pre>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_p1194774713371"><strong id="EN-US_TOPIC_0000001188202576__b6171133131712">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727248_screen1575494817422">CREATE OR replace FUNCTION sad_lookup_contract_pkg.Svproduct_is_for_pa (
pi_contract_number IN VARCHAR2)
RETURN VARCHAR2
IS
l_flag VARCHAR2 ( 1 ) := 'N';
BEGIN
FOR rec_lookup IN (SELECT 1
FROM asms.asms_lookup_values alv
WHERE alv.type_code = 'HTLX_LOAN'
AND alv.duty_erp_ou_id = To_number(Nvl(
Rtrim(Ltrim(Substr(
mig_ora_ext.Userenv (
'client_info'), 1, 8))
),
218)
))
LOOP
l_flag := 'Y';
END LOOP;
RETURN l_flag;
END;
/ </pre>
</li></ol>
<div class="section" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_section1154515495164"><a name="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_section1154515495164"></a><a name="en-us_topic_0238518390_en-us_topic_0237362198_section1154515495164"></a><h4 class="sectiontitle">INSERT</h4><p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_p1890113915210"><strong id="EN-US_TOPIC_0000001188202576__b165481417172">Overview</strong></p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727160_p8060118">The Oracle <strong id="EN-US_TOPIC_0000001188202576__b10777172014174">INSERT </strong>statement is used to insert a single record or multiple records into a table.</p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_p1270214332211"><strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_b6434204742212">NOLOGGING</strong></p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_p345514851917">NOLOGGING is commented from the inserted script.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_table584475133312" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_row1845125118331"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.8.6.1.3.1.1"><p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_p7845451203315"><strong id="EN-US_TOPIC_0000001188202576__b926113405177">Oracle Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.8.6.1.3.1.2"><p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_p3845751203317"><strong id="EN-US_TOPIC_0000001188202576__b95471644161715">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_row1184555163312"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.8.6.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_screen89737199286">INSERT INTO TBL_ORACLE NOLOGGING
SELECT emp_id, emp_name
FROM emp;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.8.6.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_screen17432519284">INSERT INTO TBL_ORACLE /*NOLOGGING*/
SELECT emp_id, emp_name
FROM emp;</pre>
</td>
</tr>
</tbody>
</table>
</div>
<ol id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_ol14790185972211"><li id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_li87901559122217"><strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_b656417314240">INSERT ALL</strong><p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727365_p22975233193937">The Oracle <strong id="EN-US_TOPIC_0000001188202576__b2078085513179">INSERT ALL</strong> statement is used to add multiple rows using a single <strong id="EN-US_TOPIC_0000001188202576__b4780115513173">INSERT</strong> statement. The rows can be inserted into either a single table or multiple tables. The target query is converted as a common table expression (CTE).</p>
<div class="fignone" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727365_fig35771242194012"><span class="figcap"><b>Figure 7 </b>Input - INSERT ALL</span><br><span><img id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727365_image11789526194012" src="figure/en-us_image_0000001188362670.png"></span></div>
<div class="fignone" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727365_fig13613849194047"><span class="figcap"><b>Figure 8 </b>Output - Insert All</span><br><span><img id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727365_image28979964194047" src="figure/en-us_image_0000001233922305.jpg"></span></div>
</li><li id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_li1768923020235"><strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_b8322197122411">INSERT FIRST</strong><p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727400_p4851957211719">The Oracle <strong id="EN-US_TOPIC_0000001188202576__b13277371182">INSERT FIRST</strong> is used to execute an INSERT statement when the first condition is true; other statements are ignored. The target query is converted as a CTE.</p>
<div class="fignone" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727400_fig32297713194244"><span class="figcap"><b>Figure 9 </b>Input - Insert first</span><br><span><img id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727400_image65977931194244" src="figure/en-us_image_0000001188202698.png"></span></div>
<div class="fignone" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727400_fig2327697319439"><span class="figcap"><b>Figure 10 </b>Output - Insert first</span><br><span><img id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727400_image638662219439" src="figure/en-us_image_0000001188362672.jpg"></span></div>
</li><li id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_li1327204117234"><strong id="EN-US_TOPIC_0000001188202576__b188471103197">INSERT with Table Alias</strong><div class="p" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_p1497414289252">The Oracle <strong id="EN-US_TOPIC_0000001188202576__b15550101514199">table aliases </strong>is used to clarify and improve readability when referring to a table in a query by assigning it a name or code. <strong id="EN-US_TOPIC_0000001188202576__b1522116387195">INSERT with table alias</strong> can be used with <strong id="EN-US_TOPIC_0000001188202576__b20221183831920">INSERT INTO </strong>statement. The tool supports the migration of <strong id="EN-US_TOPIC_0000001188202576__b19520124513197">INSERT INTO</strong> statements with <strong id="EN-US_TOPIC_0000001188202576__b4520134531915">table alias</strong>.<ol type="a" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_ol113131023162515"><li id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_li11313112310253"><strong id="EN-US_TOPIC_0000001188202576__b206421257101912">Blogic Operations</strong><p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_p41181752174719"><strong id="EN-US_TOPIC_0000001188202576__b16296113206">Input - INSERT with Table Alias</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_screen912095224710">CREATE
OR REPLACE FUNCTION myfct RETURN VARCHAR2 IS res VARCHAR2 ( 200 ) ;
BEGIN
res := 100 ;
INSERT INTO emp18 RW ( RW.empno ,RW.ename ) SELECT
res ,RWN.ename
FROM
emp16 RWN ;
COMMIT ;
RETURN res ;
END ;
/</pre>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_p1912385210476"><strong id="EN-US_TOPIC_0000001188202576__b18364157172013">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_screen812375214712">CREATE
OR REPLACE FUNCTION myfct RETURN VARCHAR2 IS res VARCHAR2 ( 200 ) ;
BEGIN
res := 100 ;
INSERT INTO emp18 ( empno ,ename ) SELECT
res ,RWN.ename
FROM
emp16 RWN ;
/* COMMIT ; */
null ;
RETURN res ;
END ;
/</pre>
</li><li id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_li1074573852518"><strong id="EN-US_TOPIC_0000001188202576__b1293071519206">Bulk Operations</strong><p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_p15851235171718"><strong id="EN-US_TOPIC_0000001188202576__b12216182082011">Input - INSERT with Table Alias</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_screen104633117486">INSERT
INTO
Public.emp14 ats (
ats.empno
,ats.ename
)
VALUES (
3
,'Categories'
)
;</pre>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_p1747115116488"><strong id="EN-US_TOPIC_0000001188202576__b16248625192016">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_screen1747251194812">INSERT
INTO
Public.emp14 (
empno
,ename
) SELECT
3
,'Categories'
;</pre>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_p85451413205116"><strong id="EN-US_TOPIC_0000001188202576__b11817143342015">Input - INSERT with Table Alias</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_screen854661315513">INSERT
INTO
"abc" . "emp18" wmc (
wmc.empno
,wmc.ename
) SELECT
wmc.empno
,wm_concat (wmc.ename) AS eName
FROM
emp16 wmc
GROUP BY
empno
;</pre>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_p1155318138511"><strong id="EN-US_TOPIC_0000001188202576__b9338104311208">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_screen55540134514">INSERT
INTO
"abc" . "emp18" (
empno
,ename
) SELECT
wmc.empno
,STRING_AGG (
wmc.ename
,','
) AS eName
FROM
emp16 wmc
GROUP BY
empno
;</pre>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_p5669156145011"><strong id="EN-US_TOPIC_0000001188202576__b4336948122020">Input - INSERT with Table Alias</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_screen9670268509">INSERT
INTO
emp14 "TABLE" (
"TABLE" .empno
,ename
) SELECT
empno
,ename
FROM
emp12
WHERE
emp12.salary &gt; (
SELECT
MAX( salary )
FROM
emp13 "TABLE"
WHERE
"TABLE" .empno &gt; 5
)
;</pre>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_p4678862506"><strong id="EN-US_TOPIC_0000001188202576__b113569592206">Output</strong></p>
<pre class="screen" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727096_screen15679156145019">INSERT
INTO
emp14 (
empno
,ename
) SELECT
empno
,ename
FROM
emp12
WHERE
emp12.salary &gt; (
SELECT
MAX( salary )
FROM
emp13 "TABLE"
WHERE
"TABLE" .empno &gt; 5
)
;</pre>
</li></ol>
</div>
</li></ol>
</div>
<div class="section" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_section1751695411617"><a name="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_section1751695411617"></a><a name="en-us_topic_0238518390_en-us_topic_0237362198_section1751695411617"></a><h4 class="sectiontitle">MERGE</h4><p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727259_p6025000322490"><strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0237712280_b14284522141837">MERGE</strong> is an ANSI-compliant SQL syntax operator used to select rows from one or more sources for updating or inserting a table or view. The criteria for updating or inserting the target table or view can be specified.</p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727259_p35756361594">Currently, this function is supported by <span id="EN-US_TOPIC_0000001188202576__text2780165017296">GaussDB(DWS)</span> 6.5.0 and later. DSC uses multiple methods to migrate <strong id="EN-US_TOPIC_0000001188202576__b1496683610596">MERGE</strong> to SQL statements compatible with <span id="EN-US_TOPIC_0000001188202576__text141001903309">GaussDB(DWS)</span>.</p>
<p id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727259_p4668152722498">Configure parameter <strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0237712280_b7399621164415">mergeImplementation </strong>as follows:</p>
<ul id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727259_ul49083613225023"><li id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727259_li52566247225023">Set to <strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0237712280_b1779014316446">With</strong> by default. In this option, the target query is converted as a CTE.</li></ul>
<div class="fignone" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727259_fig4738735219384"><span class="figcap"><b>Figure 11 </b>Input - MERGE</span><br><span><img id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727259_image1317031619384" src="figure/en-us_image_0000001188521216.png"></span></div>
<div class="fignone" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727259_fig6016263919384"><span class="figcap"><b>Figure 12 </b>Output - MERGE</span><br><span><img id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727259_image4133562819384" src="figure/en-us_image_0000001188521222.png"></span></div>
<ul id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727259_ul9315171415529"><li id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727259_li831511145520">Set to <strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0237712280_b32401302141031">SPLIT</strong>. In this option, the <strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0237712280_b1066411018581">MERGE</strong> statement is split into multiple <strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0237712280_b1419441365818">INSERT</strong> and <strong id="EN-US_TOPIC_0000001188202576__en-us_topic_0237712280_b19937131965811">UPDATE</strong> statements.</li></ul>
<div class="fignone" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727259_fig17316161475216"><span class="figcap"><b>Figure 13 </b>Input - MERGE</span><br><span><img id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727259_image83171614105211" src="figure/en-us_image_0000001188521218.png"></span></div>
<div class="fignone" id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727259_fig1731714145522"><span class="figcap"><b>Figure 14 </b>Output - MERGE</span><br><span><img id="EN-US_TOPIC_0000001188202576__en-us_topic_0238518390_en-us_topic_0237362198_en-us_topic_0202727259_image331761425220" src="figure/en-us_image_0000001188681136.png"></span></div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_mt_0104.html">Oracle Syntax Migration</a></div>
</div>
</div>