<?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/"
		>
<channel>
	<title>Comments on: Sqlplus is my second home, part 5: Reading the name of currently executing script</title>
	<atom:link href="http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script</link>
	<description>Oracle, Exadata, Performance, Troubleshooting - Mobile Life and Productivity.</description>
	<lastBuildDate>Wed, 08 Feb 2012 08:03:50 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Bill hancock</title>
		<link>http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/comment-page-1/#comment-4781</link>
		<dc:creator>Bill hancock</dc:creator>
		<pubDate>Tue, 22 Jun 2010 16:41:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/#comment-4781</guid>
		<description>What I think I need to solve my problem is that if I could have the Select_Table script the top level and each time it comes back to the Select_Table script it will be at the top and the recursion doesn&#039;t go higher then the 10 scripts I am calling.

The reason I say this is because in you example above you call blah.sql which the SELECT statement indicates it is the 1st level and blah calls blah2 which is the 2nd level, blah2 calls blah and you are back at the 1st level. I takes this to say that if I can have the Select_Table script as the 1st level each time I come back to this script I will be at the 1st level.</description>
		<content:encoded><![CDATA[<p>What I think I need to solve my problem is that if I could have the Select_Table script the top level and each time it comes back to the Select_Table script it will be at the top and the recursion doesn&#8217;t go higher then the 10 scripts I am calling.</p>
<p>The reason I say this is because in you example above you call blah.sql which the SELECT statement indicates it is the 1st level and blah calls blah2 which is the 2nd level, blah2 calls blah and you are back at the 1st level. I takes this to say that if I can have the Select_Table script as the 1st level each time I come back to this script I will be at the 1st level.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tanel Poder</title>
		<link>http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/comment-page-1/#comment-4779</link>
		<dc:creator>Tanel Poder</dc:creator>
		<pubDate>Tue, 22 Jun 2010 13:24:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/#comment-4779</guid>
		<description>long story short - sqlplus does not allow script calling depth of more than 20, so you need to find a way to not call scripts recursively so much. If you&#039;re building something complex, I&#039;d look into other tools (shell, perl or python) than just sqlplus scripts</description>
		<content:encoded><![CDATA[<p>long story short &#8211; sqlplus does not allow script calling depth of more than 20, so you need to find a way to not call scripts recursively so much. If you&#8217;re building something complex, I&#8217;d look into other tools (shell, perl or python) than just sqlplus scripts</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill hancock</title>
		<link>http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/comment-page-1/#comment-4778</link>
		<dc:creator>Bill hancock</dc:creator>
		<pubDate>Tue, 22 Jun 2010 13:21:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/#comment-4778</guid>
		<description>The answer to your first question is yes, kinda sorta. The menu script is named Select_Table, one of the selections in this menu is to exit and the Select_Table script is executed after each table load with some house cleaning scripts in the middle to prepare the selected table for the SQL*LOADER and error notification, but it comes back to the menu script for the user to either select another table to load or exit.

The first menu select is a script that prepares all the tables in the menu for loading this is done because the business unit wanted to be able to do just that load all the tables which means that they would be going down the menu selections loading all the tables. I have a start script that asks the user which server they want to work on and their answer sets some substitution and user variables and then calls the menu script, but when I used SET APPINFO ON and used the 

SELECT SYS_CONTEXT(&#039;USERENV&#039;, &#039;MODULE&#039;)  FROM DUAL;

This starter script and the set variables script were in the stack thereby causing the menu script to be third in line. This series of scripts is my 1st attempt at writing SQL scripts that act as a package, I have taken the number of scripts used from around 14 to 10 but my inexperience in the use of substitution variables and combining scripts is a problem I know.

In the second sentence you said you created a wrapper script that called your script. If I understand correctly, it called your script when the user wanted to use your script so if I had a script that called say the first script which would set a substitution variable to the name of the next script to execute and then called the wrapper script which would issue the @substitution variable and with each script the wrapper calls that script set the substitution variable to the name of the next script to execute could I get around the recursion restriction issue?

Here is an example of what I am talking about:

I have a script that is named “Start” which has only two lines a DEFINE next_script statement and a call to a script named “WrapperScript” that calls “My1stScript” in “My1stScript” I do some stuff a set next_script to “My2ndScript” and call the “WrapperScript” that has @next_script.

Is this what you were talking about? If not I guess I am a bit on the slow side so could you be a bit more detailed.</description>
		<content:encoded><![CDATA[<p>The answer to your first question is yes, kinda sorta. The menu script is named Select_Table, one of the selections in this menu is to exit and the Select_Table script is executed after each table load with some house cleaning scripts in the middle to prepare the selected table for the SQL*LOADER and error notification, but it comes back to the menu script for the user to either select another table to load or exit.</p>
<p>The first menu select is a script that prepares all the tables in the menu for loading this is done because the business unit wanted to be able to do just that load all the tables which means that they would be going down the menu selections loading all the tables. I have a start script that asks the user which server they want to work on and their answer sets some substitution and user variables and then calls the menu script, but when I used SET APPINFO ON and used the </p>
<p>SELECT SYS_CONTEXT(&#8216;USERENV&#8217;, &#8216;MODULE&#8217;)  FROM DUAL;</p>
<p>This starter script and the set variables script were in the stack thereby causing the menu script to be third in line. This series of scripts is my 1st attempt at writing SQL scripts that act as a package, I have taken the number of scripts used from around 14 to 10 but my inexperience in the use of substitution variables and combining scripts is a problem I know.</p>
<p>In the second sentence you said you created a wrapper script that called your script. If I understand correctly, it called your script when the user wanted to use your script so if I had a script that called say the first script which would set a substitution variable to the name of the next script to execute and then called the wrapper script which would issue the @substitution variable and with each script the wrapper calls that script set the substitution variable to the name of the next script to execute could I get around the recursion restriction issue?</p>
<p>Here is an example of what I am talking about:</p>
<p>I have a script that is named “Start” which has only two lines a DEFINE next_script statement and a call to a script named “WrapperScript” that calls “My1stScript” in “My1stScript” I do some stuff a set next_script to “My2ndScript” and call the “WrapperScript” that has @next_script.</p>
<p>Is this what you were talking about? If not I guess I am a bit on the slow side so could you be a bit more detailed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tanel Poder</title>
		<link>http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/comment-page-1/#comment-4777</link>
		<dc:creator>Tanel Poder</dc:creator>
		<pubDate>Mon, 21 Jun 2010 21:32:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/#comment-4777</guid>
		<description>Hi Bill,

Does this script call itself in the end, to get back to the menu again? sqlplus doesn&#039;t support more than 20 levels of such recursion, thus the error.

When I had a similar situation (I wanted to rerun a script again and again) I created another, wrapper script which just had thousands of lines  in it which called my script, simply something like this:

@myscript
@myscript
@myscript
@myscript
@myscript
....


That&#039;s not ideal solution, but I don&#039;t know any better sqlplpus-only solutions. Another option would be to use a shell script which constantly calls your script (which needs to log on again) or write something more sophisticated like a bash/ksh shell script which calls sqlplus in a separate child process and pipes any commands to that child for execution (if you are on unix)</description>
		<content:encoded><![CDATA[<p>Hi Bill,</p>
<p>Does this script call itself in the end, to get back to the menu again? sqlplus doesn&#8217;t support more than 20 levels of such recursion, thus the error.</p>
<p>When I had a similar situation (I wanted to rerun a script again and again) I created another, wrapper script which just had thousands of lines  in it which called my script, simply something like this:</p>
<p>@myscript<br />
@myscript<br />
@myscript<br />
@myscript<br />
@myscript<br />
&#8230;.</p>
<p>That&#8217;s not ideal solution, but I don&#8217;t know any better sqlplpus-only solutions. Another option would be to use a shell script which constantly calls your script (which needs to log on again) or write something more sophisticated like a bash/ksh shell script which calls sqlplus in a separate child process and pipes any commands to that child for execution (if you are on unix)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill hancock</title>
		<link>http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/comment-page-1/#comment-4774</link>
		<dc:creator>Bill hancock</dc:creator>
		<pubDate>Mon, 21 Jun 2010 19:32:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/#comment-4774</guid>
		<description>I am executing a series of sql scripts and keep running into the following

SP2-0309: SQL*Plus command procedures may only be nested to a depth of 20.

I have a menu script that I need to keep coming back to get input from the user how do I reset the stack mechanism so this !@#$%^ error goes away and the user can execute the series of scripts till their fingers fall off?

Any assistance you can provide will be of great help. I have tryed SET APPINFO MAIN as the first line in my menu script but this did not seem to help any. I use the SET APPINFO ON immediately after issueing the SET APPINFO MAIN and used the &quot;select SYS_CONTEXT(&#039;USERENV&#039;,&#039;MODULE&#039;) from dual;&quot; to see the leveling, so I am at my wits end.</description>
		<content:encoded><![CDATA[<p>I am executing a series of sql scripts and keep running into the following</p>
<p>SP2-0309: SQL*Plus command procedures may only be nested to a depth of 20.</p>
<p>I have a menu script that I need to keep coming back to get input from the user how do I reset the stack mechanism so this !@#$%^ error goes away and the user can execute the series of scripts till their fingers fall off?</p>
<p>Any assistance you can provide will be of great help. I have tryed SET APPINFO MAIN as the first line in my menu script but this did not seem to help any. I use the SET APPINFO ON immediately after issueing the SET APPINFO MAIN and used the &#8220;select SYS_CONTEXT(&#8216;USERENV&#8217;,'MODULE&#8217;) from dual;&#8221; to see the leveling, so I am at my wits end.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tanelp</title>
		<link>http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/comment-page-1/#comment-240</link>
		<dc:creator>tanelp</dc:creator>
		<pubDate>Wed, 30 Jul 2008 12:02:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/#comment-240</guid>
		<description>cool, thanks!</description>
		<content:encoded><![CDATA[<p>cool, thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taimo</title>
		<link>http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/comment-page-1/#comment-238</link>
		<dc:creator>Taimo</dc:creator>
		<pubDate>Tue, 29 Jul 2008 10:36:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/#comment-238</guid>
		<description>parameter APPINFO existed in at least since 7.2.3 but was OFF by default
In 8.0 and 8i APPINFO was ON by default
Since 9i APPINFO is OFF by default again

just my 2 cents worth</description>
		<content:encoded><![CDATA[<p>parameter APPINFO existed in at least since 7.2.3 but was OFF by default<br />
In 8.0 and 8i APPINFO was ON by default<br />
Since 9i APPINFO is OFF by default again</p>
<p>just my 2 cents worth</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sudhir</title>
		<link>http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/comment-page-1/#comment-239</link>
		<dc:creator>sudhir</dc:creator>
		<pubDate>Thu, 03 Jul 2008 15:36:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tanelpoder.com/2007/12/26/sqlplus-is-my-second-home-part-5-reading-the-name-of-currently-executing-script/#comment-239</guid>
		<description>some other choice in 10g

desc v$session

..
 CLIENT_IDENTIFIER                                  VARCHAR2(64)

SQL&gt; exec dbms_session.SET_IDENTIFIER(&#039;01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789&#039;);

SQL&gt; select CLIENT_IDENTIFIER,length(CLIENT_IDENTIFIER) from gv$session where sid = (select sid from v$mystat where rownum=1);

CLIENT_IDENTIFIER                                                LENGTH(CLIENT_IDENTIFIER)
---------------------------------------------------------------- -------------------------
0123456789012345678901234567890123456789012345678901234567890123                        64

I found in the past using bind variables in call to dbms_application_info helped reduce the burdon on parsing at least to some extent

btw, fantastic site</description>
		<content:encoded><![CDATA[<p>some other choice in 10g</p>
<p>desc v$session</p>
<p>..<br />
 CLIENT_IDENTIFIER                                  VARCHAR2(64)</p>
<p>SQL&gt; exec dbms_session.SET_IDENTIFIER(&#8217;01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789&#8242;);</p>
<p>SQL&gt; select CLIENT_IDENTIFIER,length(CLIENT_IDENTIFIER) from gv$session where sid = (select sid from v$mystat where rownum=1);</p>
<p>CLIENT_IDENTIFIER                                                LENGTH(CLIENT_IDENTIFIER)<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
0123456789012345678901234567890123456789012345678901234567890123                        64</p>
<p>I found in the past using bind variables in call to dbms_application_info helped reduce the burdon on parsing at least to some extent</p>
<p>btw, fantastic site</p>
]]></content:encoded>
	</item>
</channel>
</rss>

