doc-exports/docs/dws/tool/dws_07_6823.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

802 lines
47 KiB
HTML

<a name="EN-US_TOPIC_0000001188202580"></a><a name="EN-US_TOPIC_0000001188202580"></a>
<h1 class="topictitle1">Procedure</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_section1651350172318"><h4 class="sectiontitle">Variable Data Type</h4><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p11688125012234">NVARCHAR changed to NCHAR VARING.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_table18543507234" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row96884505237"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.1.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p106889507237"><strong id="EN-US_TOPIC_0000001188202580__en-us_topic_0237712545_b825811552594">Netezza Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.1.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p8688175010231"><strong id="EN-US_TOPIC_0000001188202580__en-us_topic_0237712545_b81851635102616">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row56881950112310"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen186881450102311">CREATE OR REPLACE PROCEDURE "NTZDB"."EDW"."SP_NTZ_NVARCHAR"
(CHARACTER VARYING(8))
RETURNS INTEGER
LANGUAGE NZPLSQL AS
BEGIN_PROC
DECLARE
V_PAR_DAY ALIAS for $1;
V_PRCNAME NVARCHAR(50):= 'SP_O_HXYW_LNSACCTINFO_H';
V_CNT INTEGER;
V_STEP_INFO NVARCHAR(500);
D_TIME_START TIMESTAMP:= CURRENT_TIMESTAMP;
O_RETURN INTEGER;
BEGIN
O_RETURN := 0;
--Writes logs and starts the recording process.
CALL SP_LOG_EXEC(V_PRCNAME,V_PAR_DAY,D_TIME_START,0,0,'The process running ',' ');
V_STEP_INFO := '1.Initialization';
RETURN O_RETURN;
END;
END_PROC;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.1.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen1368945014239">CREATE OR REPLACE FUNCTION "EDW"."SP_NTZ_NVARCHAR"
(CHARACTER VARYING(8))
RETURN INTEGER
AS
V_PAR_DAY ALIAS for $1;
V_PRCNAME NCHAR VARYING(50):= 'SP_O_HXYW_LNSACCTINFO_H';
V_CNT INTEGER;
V_STEP_INFO NCHAR VARYING(500);
D_TIME_START TIMESTAMP:= CURRENT_TIMESTAMP;
O_RETURN INTEGER;
BEGIN
O_RETURN := 0;
/* Writes logs and starts the recording process. */
SP_LOG_EXEC(V_PRCNAME,V_PAR_DAY,D_TIME_START,0,0,'The process running',' ');
V_STEP_INFO := '1.Initialization';
RETURN O_RETURN;
END;
/</pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_section16821850142316"><h4 class="sectiontitle">row counts</h4><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p86892050192316">The <strong id="EN-US_TOPIC_0000001188202580__en-us_topic_0237712545_b1871928719">row_count</strong> function is supported for affected row counting.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_table6841550162319" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row136891650142311"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.2.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p1568955032314"><strong id="EN-US_TOPIC_0000001188202580__en-us_topic_0237712545_b97841124173215">Netezza Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.2.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p2689155011238"><strong id="EN-US_TOPIC_0000001188202580__en-us_topic_0237712545_b1577572312918">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row19689155022318"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen11689155019230">CREATE OR REPLACE PROCEDURE "NTZDB"."EDW"."SP_NTZ_ROWCOUNT"
(CHARACTER VARYING(8))
RETURNS INTEGER
LANGUAGE NZPLSQL AS
BEGIN_PROC
DECLARE
V_PAR_DAY ALIAS for $1;
O_RETURN INTEGER;
BEGIN
O_RETURN := 0;
EXECUTE IMMEDIATE 'INSERT INTO TMPO_HXYW_LNSACCTINFO_H1
( ACCTNO, ACCTYPE, SUBCTRLCODE, CCY, NAME )
SELECT ACCTNO, ACCTYPE, SUBCTRLCODE, CCY, NAME
FROM O_HXYW_LNSACCTINFO T
WHERE NOT EXISTS (SELECT 1 FROM O_HXYW_LNSACCT T1
WHERE T1.DATA_START_DT&lt;='''||V_PAR_DAY||'''
AND T.MD5_VAL=T1.MD5_VAL)';
O_RETURN := ROW_COUNT;
RETURN O_RETURN;
END;
END_PROC;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.2.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen468910503237">CREATE OR REPLACE FUNCTION "EDW"."SP_NTZ_ROWCOUNT"
(CHARACTER VARYING(8))
RETURN INTEGER
AS
V_PAR_DAY ALIAS for $1;
O_RETURN INTEGER;
BEGIN
O_RETURN := 0;
EXECUTE IMMEDIATE 'INSERT INTO TMPO_HXYW_LNSACCTINFO_H1
( ACCTNO, ACCTYPE, SUBCTRLCODE, CCY, NAME )
SELECT ACCTNO, ACCTYPE, SUBCTRLCODE, CCY, NAME
FROM O_HXYW_LNSACCTINFO T
WHERE NOT EXISTS (SELECT 1 FROM O_HXYW_LNSACCT T1
WHERE T1.DATA_START_DT&lt;='''||V_PAR_DAY||'''
AND T.MD5_VAL=T1.MD5_VAL)';
O_RETURN := SQL%ROWCOUNT;
RETURN O_RETURN;
END;
/</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_note16822137112410"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p1582311722411"><strong id="EN-US_TOPIC_0000001188202580__b1514791418195">ROW_COUNT</strong> identifies the number of rows associated with the previous SQL statement. If the previous SQL statement is a DELETE, INSERT, or UPDATE statement, ROW_COUNT identifies the number of rows that qualified for the operation.</p>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_section1610585052314"><h4 class="sectiontitle">System Tables</h4><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p469015015233">System<strong id="EN-US_TOPIC_0000001188202580__en-us_topic_0237712545_b155197441315"> tables _V_SYS_COLUMNS</strong> is replaced with <strong id="EN-US_TOPIC_0000001188202580__en-us_topic_0237712545_b34813501518">information_schema.columns</strong>.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_table21118501235" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row769085014237"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.3.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p1569095062310"><strong id="EN-US_TOPIC_0000001188202580__en-us_topic_0237712545_b12535202715336">Netezza Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.3.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p369017501234"><strong id="EN-US_TOPIC_0000001188202580__en-us_topic_0237712545_b1031552542916">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row1969019509233"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.3.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen469011504238"> BEGIN
SELECT COUNT(*) INTO V_CNT FROM _V_SYS_COLUMNS
WHERE table_schem = 'SCOTT'
AND TABLE_NAME='TMPO_HXYW_LNSACCTINFO_H1';
if V_CNT&gt;0 then
EXECUTE IMMEDIATE 'DROP TABLE TMPO_HXYW_LNSACCTINFO_H1';
end if;
END;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.3.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen156901450112315">BEGIN
SELECT COUNT(*) INTO V_CNT FROM information_schema.columns
WHERE table_schema = lower('SCOTT')
AND table_name = lower('TMPO_HXYW_LNSACCTINFO_H1');
if V_CNT&gt;0 then
EXECUTE IMMEDIATE 'DROP TABLE TMPO_HXYW_LNSACCTINFO_H1';
end if;
END;</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_note11587182122413"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p182462892416">Column mapping:</p>
<ul id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_ul724628132411"><li id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_li182412832413">table_schem =&gt; table_schema</li><li id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_li62442852416">table_name =&gt; table_name</li><li id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_li1624428132417">column_name =&gt; column_name</li><li id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_li4246280247">ordinal_position =&gt; ordinal_position</li><li id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_li1724228152420">type_name =&gt; data_type</li><li id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_li102472892414">is_nullable =&gt; is_nullable</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_section2121125019238"><h4 class="sectiontitle">For date subtraction, the corresponding Integer should be returned</h4><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p4691205072313">Return value should be integer for date subtraction.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_table13121350142313" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row10691185014234"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.4.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p13691195018230"><strong id="EN-US_TOPIC_0000001188202580__en-us_topic_0237712545_b17646626113615">Netezza Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.4.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p1669113505232"><strong id="EN-US_TOPIC_0000001188202580__b617346897">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row13692350142311"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.4.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen18692250172314">SELECT CAST( T1.Buyback_Mature_Dt - CAST( '${gsTXDate}' AS DATE) AS CHAR( 5 ) )
FROM tab1 T1
WHERE T1.col1 &gt; 10;
-----
SELECT CURRENT_DATE - DATE '2019-03-30';</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.4.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen156921050202320">SELECT CAST( EXTRACT( 'DAY' FROM ( T1.Buyback_Mature_Dt - CAST( '${gsTXDate}' AS DATE ) ) ) AS CHAR( 5 ) )
FROM tab1 T1
WHERE T1.col1 &gt; 10;
-------
SELECT EXTRACT( 'DAY' FROM (CURRENT_DATE - CAST( '2019-03-30' AS DATE ) ) );
</pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_section81281500235"><h4 class="sectiontitle">Support of TRANSLATE Function</h4><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p19692150122310">The SQL TRANSLATE() function replaces a sequence of characters in a string with another sequence of characters. The function replaces a single character at a time.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_table1213165062319" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row166921250192311"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.5.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p5692950192319"><strong id="EN-US_TOPIC_0000001188202580__b151831816132116">Netezza Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.5.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p66921350142317"><strong id="EN-US_TOPIC_0000001188202580__b5321520132113">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row66921350192313"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen26929503236">TRANSLATE(param1)
TRANSLATE(1st param, 2nd param, 3rd param)
TRANSLATE(1st param, 2nd param, 3rd param, 4th param)</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.5.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen36922507237">UPPER(param1)
TRANSLATE(1st param, 3rd param, RPAD(2nd param, LENGTH(3rd param), ' '))
TRANSLATE(1st param, 3rd param, RPAD(2nd param, LENGTH(3rd param), 4th param))</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_note186431942152416"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p1750824816241">If it contains a single parameter, just excute the UPPER.</p>
<p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p15508204892420">UPPER(param1)</p>
<p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p850894822411">If it contains two parameters, throw error.</p>
<p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p18508134816247">If it contains three parameters, TRANSLATE(1st param, 3rd param, RPAD(2nd param, LENGTH(3rd param), ' ')).</p>
<p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p0508048112410">If it contains four parameters, TRANSLATE(1st param, 3rd param, RPAD(2nd param, LENGTH(3rd param), 4th param)).</p>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_section31371850132312"><h4 class="sectiontitle">Data Type</h4><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p206933503231">NATIONAL CHARACTER VARYING ( ANY )</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_table141373505238" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row5693145032313"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.6.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p6693185072317"><strong id="EN-US_TOPIC_0000001188202580__en-us_topic_0237712545_b9378133614305">Netezza Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.6.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p569318502239"><strong id="EN-US_TOPIC_0000001188202580__b730705127">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row19693175012237"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen8693650182317">CREATE OR REPLACE PROCEDURE sp_ntz_nchar_with_any
( NATIONAL CHARACTER VARYING(10)
, NATIONAL CHARACTER VARYING(ANY) )
RETURN NATIONAL CHARACTER VARYING(ANY)
LANGUAGE NZPLSQL AS
BEGIN_PROC
DECLARE
I_LOAD_DT ALIAS FOR $1 ;
-- ETL Date
V_TASK_ID ALIAS FOR $2 ;
BEGIN
RETURN I_LOAD_DT || ',' || V_TASK_ID;
END;
END_PROC;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen469395013232">CREATE OR REPLACE FUNCTION sp_ntz_nchar_with_any
( NATIONAL CHARACTER VARYING(10)
, NATIONAL CHARACTER VARYING )
RETURN NATIONAL CHARACTER VARYING
AS
I_LOAD_DT ALIAS FOR $1 ;
/* ETL Date */
V_TASK_ID ALIAS FOR $2 ;
BEGIN
RETURN I_LOAD_DT || ',' || V_TASK_ID;
END;
/</pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p1969455022315">CHARACTER VARYING ( ANY )</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_table11149145015232" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row96942500233"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.8.1.3.1.1"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p2694175062310"><strong id="EN-US_TOPIC_0000001188202580__b1961233717">Netezza Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.8.1.3.1.2"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p17695950132313"><strong id="EN-US_TOPIC_0000001188202580__b487755601">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row8695165082311"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.8.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen146951550182319">CREATE OR REPLACE PROCEDURE sp_ntz_char_with_any
( NATIONAL CHARACTER VARYING(10)
, CHARACTER VARYING(ANY) )
RETURN CHARACTER VARYING(ANY)
LANGUAGE NZPLSQL AS
BEGIN_PROC
DECLARE
I_LOAD_DT ALIAS FOR $1 ;
-- ETL Date
V_TASK_ID ALIAS FOR $2 ;
BEGIN
RETURN I_LOAD_DT || ',' || V_TASK_ID;
END;
END_PROC;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.8.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen136951350182314">CREATE OR REPLACE FUNCTION sp_ntz_char_with_any
( NATIONAL CHARACTER VARYING(10)
, CHARACTER VARYING )
RETURN CHARACTER VARYING
AS
I_LOAD_DT ALIAS FOR $1 ;
/* ETL Date */
V_TASK_ID ALIAS FOR $2 ;
BEGIN
RETURN I_LOAD_DT || ',' || V_TASK_ID;
END;
/</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p1669511508235">Numeric (ANY)</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_table716316506232" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row14695105017231"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.10.1.3.1.1"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p1169516500237"><strong id="EN-US_TOPIC_0000001188202580__b2116787535">Netezza Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.10.1.3.1.2"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p66952507237"><strong id="EN-US_TOPIC_0000001188202580__b118823297">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row9695135012315"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.10.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen169585014231">CREATE or replace PROCEDURE sp_ntz_numeric_with_any
( NUMERIC(ANY)
, NUMERIC(ANY) )
RETURNS NATIONAL CHARACTER VARYING(ANY)
LANGUAGE NZPLSQL
AS BEGIN_PROC
DECLARE
ERROR_INFO NVARCHAR(2000) := '';
V_VC_YCBZ NVARCHAR(1) := 'N';
V_VC_SUCCESS NVARCHAR(10) := 'SUCCESS';
p_l_begindate ALIAS FOR $1;
p_l_enddate ALIAS FOR $2;
BEGIN
ERROR_INFO := CRHSP_CRH_ETL_EXCHDATE(p_l_begindate,p_l_enddate);
if ERROR_INFO != V_VC_SUCCESS then
V_VC_YCBZ := 'C';
end if;
RETURN V_VC_SUCCESS;
END;
END_PROC;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.10.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen06961650132317">CREATE or replace FUNCTION sp_ntz_numeric_with_any
( NUMERIC
, NUMERIC )
RETURN NATIONAL CHARACTER VARYING
AS
ERROR_INFO NCHAR VARYING(2000) := '';
V_VC_YCBZ NCHAR VARYING(1) := 'N';
V_VC_SUCCESS NCHAR VARYING(10) := 'SUCCESS';
p_l_begindate ALIAS FOR $1;
p_l_enddate ALIAS FOR $2;
BEGIN
ERROR_INFO := CRHSP_CRH_ETL_EXCHDATE(p_l_begindate,p_l_enddate);
if ERROR_INFO != V_VC_SUCCESS then
V_VC_YCBZ := 'C';
end if;
RETURN V_VC_SUCCESS;
END;
/</pre>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_section131818500236"><h4 class="sectiontitle">Exception</h4><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p069615012311">TRANSACTION_ABORTED</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_table31821950132312" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row569675013235"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.11.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p669625092319"><strong id="EN-US_TOPIC_0000001188202580__b590192932">Netezza Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.11.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p6696145019233"><strong id="EN-US_TOPIC_0000001188202580__b1552641158">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row46967509233"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen116965504231">CREATE OR REPLACE PROCEDURE sp_ntz_transaction_aborted
( NUMERIC(ANY)
, NUMERIC(ANY) )
RETURNS NATIONAL CHARACTER VARYING(ANY)
LANGUAGE NZPLSQL
AS BEGIN_PROC
DECLARE
ERROR_INFO NVARCHAR(2000) := '';
p_l_begindate ALIAS FOR $1;
p_l_enddate ALIAS FOR $2;
BEGIN
ERROR_INFO := CRHSP_CRH_ETL_EXCHDATE(p_l_begindate,p_l_enddate);
RETURN ERROR_INFO;
EXCEPTION
WHEN TRANSACTION_ABORTED THEN
ROLLBACK;
BEGIN
ERROR_INFO := SQLERRM||' sp_o_transaction_aborted:';
RETURN ERROR_INFO;
END;
WHEN OTHERS THEN
BEGIN
ERROR_INFO := SQLERRM||' sp_o_transaction_aborted:';
RETURN ERROR_INFO;
END;
END;
END_PROC;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.11.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen0697145012315">CREATE or replace FUNCTION sp_ntz_transaction_aborted
( NUMERIC
, NUMERIC )
RETURN NATIONAL CHARACTER VARYING
AS
ERROR_INFO NCHAR VARYING(2000) := '';
p_l_begindate ALIAS FOR $1;
p_l_enddate ALIAS FOR $2;
BEGIN
ERROR_INFO := CRHSP_CRH_ETL_EXCHDATE(p_l_begindate,p_l_enddate);
RETURN ERROR_INFO;
EXCEPTION
WHEN INVALID_TRANSACTION_TERMINATION THEN
ROLLBACK;
BEGIN
ERROR_INFO := SQLERRM||' sp_o_transaction_aborted:';
RETURN ERROR_INFO;
END;
WHEN OTHERS THEN
BEGIN
ERROR_INFO := SQLERRM||' sp_o_transaction_aborted:';
RETURN ERROR_INFO;
END;
END;
/</pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_section1520845082317"><h4 class="sectiontitle">END statement is specified without semicolon (;)</h4><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p369855092320">END statement specified without semicolon (;) is migrated as follows:</p>
<p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p5698145020239">END /</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_table820975010235" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row19698105017237"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.12.4.1.3.1.1"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p9698550152317"><strong id="EN-US_TOPIC_0000001188202580__b484636772">Netezza Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.12.4.1.3.1.2"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p106981503237"><strong id="EN-US_TOPIC_0000001188202580__b1559446484">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row1869810506232"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.12.4.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen3698195002312">CREATE or replace PROCEDURE sp_ntz_end_wo_semicolon
( NATIONAL CHARACTER VARYING(10) )
RETURNS CHARACTER VARYING(ANY)
LANGUAGE NZPLSQL
AS
BEGIN_PROC
DECLARE
v_B64 Varchar(64) := 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
v_I int := 0;
v_J int := 0;
v_K int := 0;
v_N int := 0;
v_out Numeric(38,0) := 0;
I_LOAD_DT ALIAS FOR $1;
BEGIN
v_N:=Length(v_B64);
FOR v_I In Reverse 1..Length(IN_base64)
LOOP
v_J:=Instr(v_B64,Substr(IN_base64,v_I,1))-1;
If v_J &lt;0 Then
RETURN -1;
End If;
V_Out:=V_Out+v_J*(v_N**v_K);
v_K:=v_K+1;
END LOOP;
RETURN V_Out;
END
END_PROC;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.12.4.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen18699145016236">CREATE or replace FUNCTION sp_ntz_end_wo_semicolon
( NATIONAL CHARACTER VARYING(10) )
RETURN CHARACTER VARYING
AS
v_B64 Varchar(64) := 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
v_I int := 0;
v_J int := 0;
v_K int := 0;
v_N int := 0;
v_out Numeric(38,0) := 0;
I_LOAD_DT ALIAS FOR $1;
BEGIN
v_N:=Length(v_B64);
FOR v_I In Reverse 1..Length(IN_base64)
LOOP
v_J:=Instr(v_B64,Substr(IN_base64,v_I,1))-1;
If v_J &lt;0 Then
RETURN -1;
End If;
V_Out:=V_Out+v_J*(v_N**v_K);
v_K:=v_K+1;
END LOOP;
RETURN V_Out;
END;
/</pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_section223395018232"><h4 class="sectiontitle">LOOP</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_table6233165032316" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row36991550162320"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.13.2.1.3.1.1"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p969915018236"><strong id="EN-US_TOPIC_0000001188202580__b2002761122">Netezza Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.13.2.1.3.1.2"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p6699750102314"><strong id="EN-US_TOPIC_0000001188202580__b1329359166">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row146991150142311"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.13.2.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen17699150112318">CREATE OR REPLACE PROCEDURE sp_ntz_for_loop_with_more_dots
( INTEGER )
RETURNS CHARACTER VARYING(ANY)
LANGUAGE NZPLSQL
AS BEGIN_PROC
DECLARE p_abc INTEGER;
p_bcd INTEGER;
p_var1 ALIAS FOR $1;
BEGIN
p_bcd := ISNULL(p_var1, 10);
RAISE NOTICE 'p_bcd=%', p_bcd;
FOR p_abc IN 0...(p_bcd)
LOOP
RAISE NOTICE 'hello world %', p_abc;
END LOOP;
END;
END_PROC;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.13.2.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen2700125052314">CREATE OR replace FUNCTION sp_ntz_for_loop_with_more_dots
( INTEGER )
RETURN CHARACTER VARYING
AS
p_abc INTEGER ;
p_bcd INTEGER;
p_var1 ALIAS FOR $1;
BEGIN
p_bcd := NVL(p_var1, 10);
RAISE NOTICE 'p_bcd=%', p_bcd;
FOR p_abc IN 0..(p_bcd)
LOOP
RAISE NOTICE 'hello world %', p_abc;
END LOOP;
END;
/</pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_section18251195042311"><h4 class="sectiontitle">Gauss keyword</h4><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p0700165011238">CURSOR</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_table1825219505233" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row870085012313"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.14.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p8700125011233"><strong id="EN-US_TOPIC_0000001188202580__b235168163">Netezza Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.14.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p570045016233"><strong id="EN-US_TOPIC_0000001188202580__b1777288780">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row57001350172312"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.14.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen19700175092311">CREATE OR REPLACE PROCEDURE sp_ntz_keyword_cursor()
RETURNS INTEGER
LANGUAGE NZPLSQL
AS BEGIN_PROC
DECLARE
tablename NVARCHAR(100);
cursor RECORD;
BEGIN
FOR cursor IN SELECT t.TABLENAME FROM _V_TABLE t
WHERE TABLENAME LIKE 'T_ODS_CRM%'
LOOP
tablename := cursor.TABLENAME;
END LOOP;
END;
END_PROC;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.14.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen16701155072316">CREATE OR REPLACE FUNCTION sp_ntz_keyword_cursor()
RETURN INTEGER
AS
tablename NCHAR VARYING(100);
mig_cursor RECORD;
BEGIN
FOR mig_cursor IN (SELECT t.TABLENAME FROM _V_TABLE t
WHERE TABLENAME LIKE 'T_ODS_CRM%')
LOOP
tablename := mig_cursor.TABLENAME;
END LOOP;
END;
/</pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_section92659507238"><h4 class="sectiontitle">DECLARE</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_table1126514509239" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row4701350142316"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.15.2.1.3.1.1"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p177014502232"><strong id="EN-US_TOPIC_0000001188202580__b1429140567">Netezza Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.15.2.1.3.1.2"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p12701145014231"><strong id="EN-US_TOPIC_0000001188202580__b860293083">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row1070125022314"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.15.2.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen1470145042315">CREATE OR REPLACE PROCEDURE sp_ntz_declare_inside_begin
( NATIONAL CHARACTER VARYING(10) )
RETURNS INTEGER
LANGUAGE NZPLSQL
AS BEGIN_PROC
DECLARE
I_LOAD_DT ALIAS FOR $1;
BEGIN
DECLARE
MYCUR RECORD;
VIEWSQL1 NVARCHAR(4000);
BEGIN
FOR MYCUR IN ( SELECT VIEWNAME,VIEWSQL
FROM T_DDW_AUTO_F5_VIEW_DEFINE
WHERE OWNER = 'ODS_PROD' )
LOOP
VIEWSQL1 := MYCUR.VIEWSQL;
WHILE INSTR(VIEWSQL1,'v_p_etldate') &gt; 0
LOOP
VIEWSQL1 := SUBSTR(VIEWSQL1,1,INSTR(VIEWSQL1,'v_p_etldate') - 1)||''''||I_LOAD_DT||''''||SUBSTR(VIEWSQL1,INSTR(VIEWSQL1,'v_p_etldate') + 11);
END LOOP;
EXECUTE IMMEDIATE VIEWSQL1;
END LOOP;
END;
RETURN 0;
END;
END_PROC;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.15.2.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen7702135016231">CREATE OR REPLACE FUNCTION sp_ntz_declare_inside_begin
( NATIONAL CHARACTER VARYING(10) )
RETURN INTEGER
AS
I_LOAD_DT ALIAS FOR $1;
BEGIN
DECLARE
MYCUR RECORD;
VIEWSQL1 NCHAR VARYING(4000);
BEGIN
FOR MYCUR IN ( SELECT VIEWNAME,VIEWSQL
FROM T_DDW_AUTO_F5_VIEW_DEFINE
WHERE OWNER = 'ODS_PROD' )
LOOP
VIEWSQL1 := MYCUR.VIEWSQL;
WHILE INSTR(VIEWSQL1,'v_p_etldate') &gt; 0
LOOP
VIEWSQL1 := SUBSTR(VIEWSQL1,1,INSTR(VIEWSQL1,'v_p_etldate') - 1)||''''||I_LOAD_DT||''''||SUBSTR(VIEWSQL1,INSTR(VIEWSQL1,'v_p_etldate') + 11);
END LOOP;
EXECUTE IMMEDIATE VIEWSQL1;
END LOOP;
END;
RETURN 0;
END;
/</pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_section9288950122317"><h4 class="sectiontitle">EXECUTE AS CALLER</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_table11288155022319" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row0702125052317"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.16.2.1.3.1.1"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p8702750182314"><strong id="EN-US_TOPIC_0000001188202580__b593377085">Netezza Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.16.2.1.3.1.2"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p1570215509233"><strong id="EN-US_TOPIC_0000001188202580__b280112387">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row270235011238"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.16.2.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen14702195019231">CREATE or replace PROCEDURE sp_ntz_exec_as_caller
( CHARACTER VARYING(512) )
RETURNS INTEGER
LANGUAGE NZPLSQL
EXECUTE AS CALLER
AS BEGIN_PROC
DECLARE
SQL ALIAS FOR $1;
BEGIN
EXECUTE IMMEDIATE SQL;
RETURN 0;
END;
END_PROC;
------------------------
CREATE or replace PROCEDURE sp_ntz_exec_as_owner
( CHARACTER VARYING(512) )
RETURNS INTEGER
LANGUAGE NZPLSQL
EXECUTE AS OWNER
AS BEGIN_PROC
DECLARE
SQL ALIAS FOR $1;
BEGIN
EXECUTE IMMEDIATE SQL;
RETURN 0;
END;
END_PROC;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.16.2.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen5703950162316">CREATE OR REPLACE FUNCTION sp_ntz_exec_as_caller
( CHARACTER VARYING(512) )
RETURN INTEGER
SECURITY INVOKER
AS
SQL ALIAS FOR $1;
BEGIN
EXECUTE IMMEDIATE SQL;
RETURN 0;
END;
/
------------------------
CREATE OR REPLACE FUNCTION sp_ntz_exec_as_owner
( CHARACTER VARYING(512) )
RETURN INTEGER
SECURITY DEFINER
AS
SQL ALIAS FOR $1;
BEGIN
EXECUTE IMMEDIATE SQL;
RETURN 0;
END;
/</pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_section2315450112314"><h4 class="sectiontitle">Expression</h4><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p18703205014238">SELECT result assign into variable.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_table1317145052317" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row67032500231"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.17.3.1.3.1.1"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p670385017235"><strong id="EN-US_TOPIC_0000001188202580__b657321958">Netezza Syntax</strong></p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.17.3.1.3.1.2"><p id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_p8703135012315"><strong id="EN-US_TOPIC_0000001188202580__b1365638033">Syntax After Migration</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_row9703155010233"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.17.3.1.3.1.1 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen1470345062318">CREATE OR REPLACE PROCEDURE sp_sel_res_to_var
( NATIONAL CHARACTER VARYING(10) )
RETURNS CHARACTER VARYING(ANY)
LANGUAGE NZPLSQL
AS BEGIN_PROC
DECLARE
counts INTEGER := 0 ;
I_LOAD_DT ALIAS FOR $1 ;
BEGIN
COUNTS := SELECT COUNT( * )
FROM tb_sel_res_to_var
WHERE ETLDATE = I_LOAD_DT;
EXECUTE IMMEDIATE 'insert into TABLES_COUNTS values( ''tb_sel_res_to_var'', ''' || I_LOAD_DT || ''', ' || COUNTS || ')' ;
RETURN '0' ;
END;
END_PROC;</pre>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.17.3.1.3.1.2 "><pre class="screen" id="EN-US_TOPIC_0000001188202580__en-us_topic_0238518433_en-us_topic_0237362226_en-us_topic_0213479753_screen20704125014232">CREATE OR REPLACE FUNCTION sp_sel_res_to_var
( NATIONAL CHARACTER VARYING(10) )
RETURN CHARACTER VARYING
AS
counts INTEGER := 0 ;
I_LOAD_DT ALIAS FOR $1 ;
BEGIN
SELECT COUNT(*)
INTO COUNTS
FROM tb_sel_res_to_var
WHERE ETLDATE = I_LOAD_DT;
EXECUTE IMMEDIATE 'insert into TABLES_COUNTS values( ''tb_sel_res_to_var'', ''' || I_LOAD_DT || ''', ' || COUNTS || ')' ;
RETURN '0' ;
END;
/</pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_07_0682.html">Netezza Syntax Migration</a></div>
</div>
</div>