<?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"
	>
<channel>
	<title>Comments on: Here is How to Unpersist Your Persistent PL/SQL Package Data</title>
	<atom:link href="http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/feed/" rel="self" type="application/rss+xml" />
	<link>http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/</link>
	<description>News, views, tips and tricks on Oracle and other fun stuff</description>
	<pubDate>Fri, 21 Nov 2008 02:56:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: rohan</title>
		<link>http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/#comment-52017</link>
		<dc:creator>rohan</dc:creator>
		<pubDate>Fri, 07 Mar 2008 09:02:19 +0000</pubDate>
		<guid isPermaLink="false">http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/#comment-52017</guid>
		<description>my question to Barut - 
i need your help regarding package level variables. I have 1 package lets say package A that calls package B in a loop passing parameters to a stored proc in package B. Package B has package level variable as a table type (as in the example). The requirement is to persist the data being written into the table type between subsequent calls and hence I've used the package level variable.

However the package B keeps on getting uncompiled on its own throwing the error message - "ORA-04068: existing state of packages has been discarded". How do I resolve this issue with the statement - “DBMS_SESSION.MODIFY_PACKAGE_STATE(DBMS_SESSION.REINITIALIZE);” and at same time sticking to the requirement of persisting the data</description>
		<content:encoded><![CDATA[<p>my question to Barut -<br />
i need your help regarding package level variables. I have 1 package lets say package A that calls package B in a loop passing parameters to a stored proc in package B. Package B has package level variable as a table type (as in the example). The requirement is to persist the data being written into the table type between subsequent calls and hence I&#8217;ve used the package level variable.</p>
<p>However the package B keeps on getting uncompiled on its own throwing the error message - &#8220;ORA-04068: existing state of packages has been discarded&#8221;. How do I resolve this issue with the statement - “DBMS_SESSION.MODIFY_PACKAGE_STATE(DBMS_SESSION.REINITIALIZE);” and at same time sticking to the requirement of persisting the data</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GurpreetSingh Tuteja</title>
		<link>http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/#comment-51321</link>
		<dc:creator>GurpreetSingh Tuteja</dc:creator>
		<pubDate>Tue, 24 Jul 2007 23:35:05 +0000</pubDate>
		<guid isPermaLink="false">http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/#comment-51321</guid>
		<description>&lt;p&gt;Hi, 
In the above example of SERIALLY_REUSABLE pragma if i type command
'exec my_pkg.do_it; my_pkg.do_it' the answer is for i is 2. 
I am calling a package twice from another package. The first time all the global variables are reset. But the second the old values still persist. 
Can you help me??&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi,<br />
In the above example of SERIALLY_REUSABLE pragma if i type command<br />
&#8216;exec my_pkg.do_it; my_pkg.do_it&#8217; the answer is for i is 2.<br />
I am calling a package twice from another package. The first time all the global variables are reset. But the second the old values still persist.<br />
Can you help me??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andrew</title>
		<link>http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/#comment-50482</link>
		<dc:creator>andrew</dc:creator>
		<pubDate>Thu, 05 Apr 2007 17:19:01 +0000</pubDate>
		<guid isPermaLink="false">http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/#comment-50482</guid>
		<description>&lt;p&gt;Out of interest , Oracle 9iAS (unsure about V10), uses dbms_session.reset_package in mod_plsql by default. This is easily visible in the shared pool or a trace file (or by reading the docs...) http://www.sharemation.com/~dmcmahon/modowa.htm&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Out of interest , Oracle 9iAS (unsure about V10), uses dbms_session.reset_package in mod_plsql by default. This is easily visible in the shared pool or a trace file (or by reading the docs&#8230;) <a href="http://www.sharemation.com/~dmcmahon/modowa.htm" rel="nofollow">http://www.sharemation.com/~dmcmahon/modowa.htm</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PaweÅ‚ Barut</title>
		<link>http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/#comment-50480</link>
		<dc:creator>PaweÅ‚ Barut</dc:creator>
		<pubDate>Thu, 05 Apr 2007 07:29:45 +0000</pubDate>
		<guid isPermaLink="false">http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/#comment-50480</guid>
		<description>&lt;p&gt;Eddie,
To avoid "ORA-04068: existing state of packages has been discarded" 
I use "DBMS_SESSION.MODIFY_PACKAGE_STATE(DBMS_SESSION.REINITIALIZE);".
It is especially important when you use connection pooling.
Always when I get connection from pool, first operation I run is is 
DBMS_SESSION.MODIFY_PACKAGE_STATE(DBMS_SESSION.REINITIALIZE);.
It reinitializes package variables, so you have clear environment.
Overhead of calling DBMS_SESSION.MODIFY_PACKAGE_STATE is minimal, ant it simplifies your development. For example I do not have to restart web server every time I change something in packages. Change is visible at once and I do not get ORA-04068 error.
Regards, PaweÅ‚&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Eddie,<br />
To avoid &#8220;ORA-04068: existing state of packages has been discarded&#8221;<br />
I use &#8220;DBMS_SESSION.MODIFY_PACKAGE_STATE(DBMS_SESSION.REINITIALIZE);&#8221;.<br />
It is especially important when you use connection pooling.<br />
Always when I get connection from pool, first operation I run is is<br />
DBMS_SESSION.MODIFY_PACKAGE_STATE(DBMS_SESSION.REINITIALIZE);.<br />
It reinitializes package variables, so you have clear environment.<br />
Overhead of calling DBMS_SESSION.MODIFY_PACKAGE_STATE is minimal, ant it simplifies your development. For example I do not have to restart web server every time I change something in packages. Change is visible at once and I do not get ORA-04068 error.<br />
Regards, PaweÅ‚</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eddie Awad</title>
		<link>http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/#comment-50479</link>
		<dc:creator>Eddie Awad</dc:creator>
		<pubDate>Thu, 05 Apr 2007 04:45:31 +0000</pubDate>
		<guid isPermaLink="false">http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/#comment-50479</guid>
		<description>&lt;p&gt;Patrick, here is the scenario that we had and was actually the trigger for this post. There is one package that has many procedures/functions accessing the same associative arrays declared as private global package data. The data in the associative arrays is massaged and copied over to a procedure output parameters. Then, we have a ColdFusion web application that calls that procedure in the package more than one time. in subsequent calls, new records are added, &lt;em&gt;instead of recreated&lt;/em&gt;, to the the data (ref cursor) returned by the procedure. This is not what we want. So, we used SERIALLY_REUSABLE to solve this situation.&lt;/p&gt;

&lt;p&gt;Moreover, from the documentation: This SERIALLY_REUSABLE pragma is appropriate for packages that declare large temporary work areas that are used once and not needed during subsequent database calls in the same session.&lt;/p&gt;

&lt;p&gt;You're right about the "i" variable, it can be declared local to the procedure instead of global to the package. In fact, I could have declared g_tab local as well, however, this was a very simple example to specifically demonstrate package data persistency when variables are declared as package globals.&lt;/p&gt;

&lt;p&gt;Gary, thanks for the clarification. I noticed a strange behavior testing the "alter package ... compile" command on my XE database. I opened two SQLPlus sessions. I then called my_pkg.do_it in session1 and session2 multiple times. The data persisted across calls as expected in both sessions. I then issued "alter package my_pkg compile;" in session1. The package data in session1 was reinitialized, but not in sesion2. When I issued "alter package my_pkg compile;" for *the second time* in session1, I got "ORA-04068: existing state of packages has been discarded" when I called my_pkg.do_it in session2 and only then the package data was reinitialized in session2. Hum!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Patrick, here is the scenario that we had and was actually the trigger for this post. There is one package that has many procedures/functions accessing the same associative arrays declared as private global package data. The data in the associative arrays is massaged and copied over to a procedure output parameters. Then, we have a ColdFusion web application that calls that procedure in the package more than one time. in subsequent calls, new records are added, <em>instead of recreated</em>, to the the data (ref cursor) returned by the procedure. This is not what we want. So, we used SERIALLY_REUSABLE to solve this situation.</p>
<p>Moreover, from the documentation: This SERIALLY_REUSABLE pragma is appropriate for packages that declare large temporary work areas that are used once and not needed during subsequent database calls in the same session.</p>
<p>You&#8217;re right about the &#8220;i&#8221; variable, it can be declared local to the procedure instead of global to the package. In fact, I could have declared g_tab local as well, however, this was a very simple example to specifically demonstrate package data persistency when variables are declared as package globals.</p>
<p>Gary, thanks for the clarification. I noticed a strange behavior testing the &#8220;alter package &#8230; compile&#8221; command on my XE database. I opened two SQLPlus sessions. I then called my_pkg.do_it in session1 and session2 multiple times. The data persisted across calls as expected in both sessions. I then issued &#8220;alter package my_pkg compile;&#8221; in session1. The package data in session1 was reinitialized, but not in sesion2. When I issued &#8220;alter package my_pkg compile;&#8221; for *the second time* in session1, I got &#8220;ORA-04068: existing state of packages has been discarded&#8221; when I called my_pkg.do_it in session2 and only then the package data was reinitialized in session2. Hum!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gary</title>
		<link>http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/#comment-50478</link>
		<dc:creator>Gary</dc:creator>
		<pubDate>Wed, 04 Apr 2007 22:47:04 +0000</pubDate>
		<guid isPermaLink="false">http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/#comment-50478</guid>
		<description>&lt;p&gt;Worth mentioning that "ALTER PACKAGE package name COMPILE" will clear EVERY session's state for that package, not just the one doing the compile.
SERIALLY_REUSABLE is a 'quick fix' when you've got a package that uses lots of global variables written by someone who didn't realise about persistance.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Worth mentioning that &#8220;ALTER PACKAGE package name COMPILE&#8221; will clear EVERY session&#8217;s state for that package, not just the one doing the compile.<br />
SERIALLY_REUSABLE is a &#8216;quick fix&#8217; when you&#8217;ve got a package that uses lots of global variables written by someone who didn&#8217;t realise about persistance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick Wolf</title>
		<link>http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/#comment-50477</link>
		<dc:creator>Patrick Wolf</dc:creator>
		<pubDate>Wed, 04 Apr 2007 20:26:30 +0000</pubDate>
		<guid isPermaLink="false">http://awads.net/wp/2007/04/04/here-is-how-to-unpersist-your-persistent-plsql-package-data/#comment-50477</guid>
		<description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;I'm just curios, why should anybody use static package variables and on the other side decide to use SERIALLY_REUSABLE?&lt;/p&gt;

&lt;p&gt;If I really just want to use them for the call, why not just use local procedure/function variables?&lt;/p&gt;

&lt;p&gt;Something else I noticed in you example, why don't you declare "i" as local variable, does it really have to be static?&lt;/p&gt;

&lt;p&gt;Patrick&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I&#8217;m just curios, why should anybody use static package variables and on the other side decide to use SERIALLY_REUSABLE?</p>
<p>If I really just want to use them for the call, why not just use local procedure/function variables?</p>
<p>Something else I noticed in you example, why don&#8217;t you declare &#8220;i&#8221; as local variable, does it really have to be static?</p>
<p>Patrick</p>
]]></content:encoded>
	</item>
</channel>
</rss>
