<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Tuning Dynamic SQL with EXECUTE IMMEDIATE and Cursor Variables</title>
	<atom:link href="http://ediyanto83.wordpress.com/2007/04/14/tuning-dynamic-sql-with-execute-immediate-and-cursor-variables/feed/" rel="self" type="application/rss+xml" />
	<link>http://ediyanto83.wordpress.com/2007/04/14/tuning-dynamic-sql-with-execute-immediate-and-cursor-variables/</link>
	<description>Welcome to my weblog</description>
	<lastBuildDate>Tue, 17 Nov 2009 11:03:47 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Edi Yanto</title>
		<link>http://ediyanto83.wordpress.com/2007/04/14/tuning-dynamic-sql-with-execute-immediate-and-cursor-variables/#comment-351</link>
		<dc:creator>Edi Yanto</dc:creator>
		<pubDate>Mon, 28 Sep 2009 13:47:00 +0000</pubDate>
		<guid isPermaLink="false">http://ediyanto83.wordpress.com/2007/04/14/tuning-dynamic-sql-with-execute-immediate-and-cursor-variables/#comment-351</guid>
		<description>@boy, do you know if u change this code to v_name varchar2(255),  you&#039;ll recode it, if any change to the length of the last_name column in employees table, otherwise would cause the procedure/function invalid. Try to think if this variable is define in many places, will be a lot of changes you have to do.</description>
		<content:encoded><![CDATA[<p>@boy, do you know if u change this code to v_name varchar2(255),  you&#8217;ll recode it, if any change to the length of the last_name column in employees table, otherwise would cause the procedure/function invalid. Try to think if this variable is define in many places, will be a lot of changes you have to do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: boy</title>
		<link>http://ediyanto83.wordpress.com/2007/04/14/tuning-dynamic-sql-with-execute-immediate-and-cursor-variables/#comment-350</link>
		<dc:creator>boy</dc:creator>
		<pubDate>Mon, 28 Sep 2009 08:49:16 +0000</pubDate>
		<guid isPermaLink="false">http://ediyanto83.wordpress.com/2007/04/14/tuning-dynamic-sql-with-execute-immediate-and-cursor-variables/#comment-350</guid>
		<description>@edi...

i think what dan means is its not useful to use IMMEDIATE in your sample because its already know thaat table you going to select is &quot;employee&quot;.  know not because you put it into variable but because you using
v_name employees.last_name%TYPE;
v_sal employees.salary%TYPE;

i think it would be a lot more better if you change this into

v_name varchar2(255);
v_sal number;

that make your code is not dependent to any table until run time.</description>
		<content:encoded><![CDATA[<p>@edi&#8230;</p>
<p>i think what dan means is its not useful to use IMMEDIATE in your sample because its already know thaat table you going to select is &#8220;employee&#8221;.  know not because you put it into variable but because you using<br />
v_name employees.last_name%TYPE;<br />
v_sal employees.salary%TYPE;</p>
<p>i think it would be a lot more better if you change this into</p>
<p>v_name varchar2(255);<br />
v_sal number;</p>
<p>that make your code is not dependent to any table until run time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edi Yanto</title>
		<link>http://ediyanto83.wordpress.com/2007/04/14/tuning-dynamic-sql-with-execute-immediate-and-cursor-variables/#comment-155</link>
		<dc:creator>Edi Yanto</dc:creator>
		<pubDate>Wed, 03 Dec 2008 14:38:46 +0000</pubDate>
		<guid isPermaLink="false">http://ediyanto83.wordpress.com/2007/04/14/tuning-dynamic-sql-with-execute-immediate-and-cursor-variables/#comment-155</guid>
		<description>Hi Dan, thanks for your comments....

Maybe you can solve your above problems with this REF CURSOR syntax example, hopefully be useful for you..

DECLARE
   cur_ar              VARCHAR2 (32767)
         :=    &#039;SELECT *
                                            FROM vat.mpp_vat_ar_trx_int_v
                                            WHERE segment8 BETWEEN &#039;&#039;&#039;
            &#124;&#124; condition_start_date
            &#124;&#124; &#039;&#039;&#039; AND &#039;&#039;&#039;
            &#124;&#124; condition_end_date
            &#124;&#124; &#039;&#039;&#039;&#039;;

     TYPE cur_type IS REF CURSOR;

      CV                        cur_type;
      cur_temp1           vat.mpp_vat_ar_trx_int_v%ROWTYPE;
BEGIN
     IF condition_source IS NOT NULL
      THEN
         cur_ar := cur_ar &#124;&#124; &#039; AND org_id = &#039; &#124;&#124; condition_source;
     END IF;

      OPEN CV FOR cur_ar;

      LOOP
         FETCH CV
          INTO cur_temp1;

         EXIT WHEN CV%NOTFOUND;

         INSERT INTO vat.vat_ar_transaction_int
              VALUES (vdata_import_code, cur_temp1.transaction_number,
                      cur_temp1.npwp, cur_temp1.customer_number,
                      cur_temp1.org_id, &#039;A&#039;, &#039;2&#039;, &#039;1&#039;, &#039;1&#039;, &#039;000&#039;,
                      cur_temp1.segment6, cur_temp1.segment7,
                      cur_temp1.segment8, cur_temp1.segment9,
                      cur_temp1.segment10, cur_temp1.segment11,
                      cur_temp1.segment12, 0, 0, vcompany, user_id,
                      cur_temp1.segment17, cur_temp1.segment18, cur_temp1.segment19,
                      cur_temp1.segment20, cur_temp1.segment21,
                      cur_temp1.segment22, cur_temp1.segment23,
                      cur_temp1.segment24, cur_temp1.segment25,
                      cur_temp1.segment26, cur_temp1.segment27,
                      cur_temp1.segment28, cur_temp1.segment29,
                      cur_temp1.segment30, cur_temp1.segment31,
                      cur_temp1.segment32, cur_temp1.segment33,
                      cur_temp1.segment34, cur_temp1.segment35,
                      cur_temp1.segment36, cur_temp1.segment37,
                      cur_temp1.segment38, cur_temp1.segment39,
                      cur_temp1.segment40, cur_temp1.segment41,
                      cur_temp1.segment42, cur_temp1.segment43,
                      cur_temp1.segment44, cur_temp1.segment45,
                      cur_temp1.segment46, cur_temp1.segment47,
                      cur_temp1.segment48, cur_temp1.segment49,
                      cur_temp1.segment50, vdate, vuser, vdate, vuser, NULL,
                      &#039;N&#039;);

      END LOOP;

      CLOSE CV;

END;</description>
		<content:encoded><![CDATA[<p>Hi Dan, thanks for your comments&#8230;.</p>
<p>Maybe you can solve your above problems with this REF CURSOR syntax example, hopefully be useful for you..</p>
<p>DECLARE<br />
   cur_ar              VARCHAR2 (32767)<br />
         :=    &#8216;SELECT *<br />
                                            FROM vat.mpp_vat_ar_trx_int_v<br />
                                            WHERE segment8 BETWEEN &#8221;&#8217;<br />
            || condition_start_date<br />
            || &#8221;&#8217; AND &#8221;&#8217;<br />
            || condition_end_date<br />
            || &#8221;&#8221;;</p>
<p>     TYPE cur_type IS REF CURSOR;</p>
<p>      CV                        cur_type;<br />
      cur_temp1           vat.mpp_vat_ar_trx_int_v%ROWTYPE;<br />
BEGIN<br />
     IF condition_source IS NOT NULL<br />
      THEN<br />
         cur_ar := cur_ar || &#8216; AND org_id = &#8216; || condition_source;<br />
     END IF;</p>
<p>      OPEN CV FOR cur_ar;</p>
<p>      LOOP<br />
         FETCH CV<br />
          INTO cur_temp1;</p>
<p>         EXIT WHEN CV%NOTFOUND;</p>
<p>         INSERT INTO vat.vat_ar_transaction_int<br />
              VALUES (vdata_import_code, cur_temp1.transaction_number,<br />
                      cur_temp1.npwp, cur_temp1.customer_number,<br />
                      cur_temp1.org_id, &#8216;A&#8217;, &#8216;2&#8242;, &#8216;1&#8242;, &#8216;1&#8242;, &#8216;000&#8242;,<br />
                      cur_temp1.segment6, cur_temp1.segment7,<br />
                      cur_temp1.segment8, cur_temp1.segment9,<br />
                      cur_temp1.segment10, cur_temp1.segment11,<br />
                      cur_temp1.segment12, 0, 0, vcompany, user_id,<br />
                      cur_temp1.segment17, cur_temp1.segment18, cur_temp1.segment19,<br />
                      cur_temp1.segment20, cur_temp1.segment21,<br />
                      cur_temp1.segment22, cur_temp1.segment23,<br />
                      cur_temp1.segment24, cur_temp1.segment25,<br />
                      cur_temp1.segment26, cur_temp1.segment27,<br />
                      cur_temp1.segment28, cur_temp1.segment29,<br />
                      cur_temp1.segment30, cur_temp1.segment31,<br />
                      cur_temp1.segment32, cur_temp1.segment33,<br />
                      cur_temp1.segment34, cur_temp1.segment35,<br />
                      cur_temp1.segment36, cur_temp1.segment37,<br />
                      cur_temp1.segment38, cur_temp1.segment39,<br />
                      cur_temp1.segment40, cur_temp1.segment41,<br />
                      cur_temp1.segment42, cur_temp1.segment43,<br />
                      cur_temp1.segment44, cur_temp1.segment45,<br />
                      cur_temp1.segment46, cur_temp1.segment47,<br />
                      cur_temp1.segment48, cur_temp1.segment49,<br />
                      cur_temp1.segment50, vdate, vuser, vdate, vuser, NULL,<br />
                      &#8216;N&#8217;);</p>
<p>      END LOOP;</p>
<p>      CLOSE CV;</p>
<p>END;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://ediyanto83.wordpress.com/2007/04/14/tuning-dynamic-sql-with-execute-immediate-and-cursor-variables/#comment-154</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Wed, 03 Dec 2008 12:28:52 +0000</pubDate>
		<guid isPermaLink="false">http://ediyanto83.wordpress.com/2007/04/14/tuning-dynamic-sql-with-execute-immediate-and-cursor-variables/#comment-154</guid>
		<description>@Edi Yanto: Useful - but clearly avoiding the real issue:

This example, though using IMMEDIATE, doesn&#039;t solve anything, as the table name isn&#039;t really variable, but known indirectly at compile type via the variable &#039;table_name&#039;.

The %rowtype is bound to table_name, which is (or should be), by problem defintion, unknown. We cannot use the %rowtype on a REF CURSOR, leaving us with the problem unsolved, as 

&quot;select * from table_name&quot; 

will not be parsable for any &quot;table_name&quot;s as we cannot resolve &#039;*&#039; into any known %rowtype.

Feuerstein has a discussion of &quot;Dynamic PL/SQL&quot; in his &quot;Oracle PL/SQL Programming&quot;. As far as I can see, this (very tedious) method is the only way of solving the problem in a generic way. 

If somebody has a better idea, please mail me!

BR</description>
		<content:encoded><![CDATA[<p>@Edi Yanto: Useful &#8211; but clearly avoiding the real issue:</p>
<p>This example, though using IMMEDIATE, doesn&#8217;t solve anything, as the table name isn&#8217;t really variable, but known indirectly at compile type via the variable &#8216;table_name&#8217;.</p>
<p>The %rowtype is bound to table_name, which is (or should be), by problem defintion, unknown. We cannot use the %rowtype on a REF CURSOR, leaving us with the problem unsolved, as </p>
<p>&#8220;select * from table_name&#8221; </p>
<p>will not be parsable for any &#8220;table_name&#8221;s as we cannot resolve &#8216;*&#8217; into any known %rowtype.</p>
<p>Feuerstein has a discussion of &#8220;Dynamic PL/SQL&#8221; in his &#8220;Oracle PL/SQL Programming&#8221;. As far as I can see, this (very tedious) method is the only way of solving the problem in a generic way. </p>
<p>If somebody has a better idea, please mail me!</p>
<p>BR</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kris</title>
		<link>http://ediyanto83.wordpress.com/2007/04/14/tuning-dynamic-sql-with-execute-immediate-and-cursor-variables/#comment-139</link>
		<dc:creator>Kris</dc:creator>
		<pubDate>Fri, 14 Nov 2008 20:42:59 +0000</pubDate>
		<guid isPermaLink="false">http://ediyanto83.wordpress.com/2007/04/14/tuning-dynamic-sql-with-execute-immediate-and-cursor-variables/#comment-139</guid>
		<description>Very helpful.  Thanks!</description>
		<content:encoded><![CDATA[<p>Very helpful.  Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: luis</title>
		<link>http://ediyanto83.wordpress.com/2007/04/14/tuning-dynamic-sql-with-execute-immediate-and-cursor-variables/#comment-13</link>
		<dc:creator>luis</dc:creator>
		<pubDate>Thu, 17 May 2007 14:53:52 +0000</pubDate>
		<guid isPermaLink="false">http://ediyanto83.wordpress.com/2007/04/14/tuning-dynamic-sql-with-execute-immediate-and-cursor-variables/#comment-13</guid>
		<description>really nice programming
thanx a lot</description>
		<content:encoded><![CDATA[<p>really nice programming<br />
thanx a lot</p>
]]></content:encoded>
	</item>
</channel>
</rss>
