<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Eddie Awad’s Blog - Latest Comments in Two Oracle PL/SQL Features You Probably Don&amp;#8217;t Know About</title><link>http://awads.disqus.com/</link><description>News, views, tips and tricks on Oracle and other fun stuff</description><atom:link href="https://awads.disqus.com/two_oracle_plsql_features_you_probably_don8217t_know_about/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 25 Jun 2008 06:04:22 -0000</lastBuildDate><item><title>Re: Two Oracle PL/SQL Features You Probably Don&amp;#8217;t Know About</title><link>http://awads.net/wp/2007/04/30/two-oracle-plsql-features-you-probably-don%e2%80%99t-know-about/#comment-3659129</link><description>&lt;p&gt;Wiz,&lt;/p&gt;&lt;p&gt;You can add subprograms to a package without losing other subprograms, but when you change a package and recompile, you lose package "state" - which means that the values of package level variables will no longer be valid and available in your session. No way to avoid this, except to reorganize your package into two separate packages: one that contains your subprograms and another that contains the variables.&lt;/p&gt;&lt;p&gt;Steven Feuerstein&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Steven Feuerstein</dc:creator><pubDate>Wed, 25 Jun 2008 06:04:22 -0000</pubDate></item><item><title>Re: Two Oracle PL/SQL Features You Probably Don&amp;#8217;t Know About</title><link>http://awads.net/wp/2007/04/30/two-oracle-plsql-features-you-probably-don%e2%80%99t-know-about/#comment-3659128</link><description>&lt;p&gt;hello,&lt;/p&gt;&lt;p&gt;I'm wondering if there is any way that someone could update and add a function to a package without loosing the other functions and or variables declared previously in that package&lt;/p&gt;&lt;p&gt;best regards,&lt;br&gt;Wiz&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wiz</dc:creator><pubDate>Tue, 24 Jun 2008 06:31:44 -0000</pubDate></item><item><title>Re: Two Oracle PL/SQL Features You Probably Don&amp;#8217;t Know About</title><link>http://awads.net/wp/2007/04/30/two-oracle-plsql-features-you-probably-don%e2%80%99t-know-about/#comment-3659127</link><description>&lt;p&gt;The main reason you might not want to declare the mutually recursive procedures in the package specification, is that you might not want them visible from the outside, or you may only want one visible from the outside. Abstraction/information-hiding is a powerful concept.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jeremy Bradshaw</dc:creator><pubDate>Fri, 18 Jan 2008 07:10:06 -0000</pubDate></item><item><title>Re: Two Oracle PL/SQL Features You Probably Don&amp;#8217;t Know About</title><link>http://awads.net/wp/2007/04/30/two-oracle-plsql-features-you-probably-don%e2%80%99t-know-about/#comment-3659126</link><description>&lt;p&gt;Just curious to know, how often one (have to) use 'mutual recursive functions' in a common work place?&lt;/p&gt;&lt;p&gt;~ Siri&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Siri</dc:creator><pubDate>Sat, 24 Nov 2007 10:29:14 -0000</pubDate></item><item><title>Re: Two Oracle PL/SQL Features You Probably Don&amp;#8217;t Know About</title><link>http://awads.net/wp/2007/04/30/two-oracle-plsql-features-you-probably-don%e2%80%99t-know-about/#comment-3659125</link><description>&lt;p&gt;Ah! I see what you mean. Right, you have to "package" the two mutually recursive functions one way or another.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eddie Awad</dc:creator><pubDate>Tue, 15 May 2007 12:14:36 -0000</pubDate></item><item><title>Re: Two Oracle PL/SQL Features You Probably Don&amp;#8217;t Know About</title><link>http://awads.net/wp/2007/04/30/two-oracle-plsql-features-you-probably-don%e2%80%99t-know-about/#comment-3659124</link><description>&lt;p&gt;LOL ! There you have encapsulated two functions in one... it is almost a package!&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Seriously, you cannot have&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;create function f1 return number is begin return f2; end; &lt;br&gt;/&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;create function f2 return number is begin return f1; end; &lt;br&gt;/&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Laurent Schneider</dc:creator><pubDate>Tue, 15 May 2007 11:14:18 -0000</pubDate></item><item><title>Re: Two Oracle PL/SQL Features You Probably Don&amp;#8217;t Know About</title><link>http://awads.net/wp/2007/04/30/two-oracle-plsql-features-you-probably-don%e2%80%99t-know-about/#comment-3659123</link><description>&lt;p&gt;Laurent, mutual recursion does not have to be coded in a package. The following stored function for example works like a charm:&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;  CREATE OR REPLACE FUNCTION odd_or_even (n NATURAL) &lt;br&gt;     RETURN VARCHAR2&lt;br&gt;  IS&lt;br&gt;     l_return_var VARCHAR2 (4);&lt;br&gt;&lt;br&gt;     FUNCTION odd (n NATURAL )&lt;br&gt;        RETURN BOOLEAN;   -- forward declaration&lt;br&gt;&lt;br&gt;     FUNCTION even (n NATURAL)&lt;br&gt;        RETURN BOOLEAN&lt;br&gt;     IS&lt;br&gt;     BEGIN&lt;br&gt;        IF n = 0&lt;br&gt;        THEN&lt;br&gt;           RETURN TRUE;&lt;br&gt;        ELSE&lt;br&gt;           RETURN odd (n - 1);   -- mutually recursive call&lt;br&gt;        END IF;&lt;br&gt;     END even;&lt;br&gt;&lt;br&gt;     FUNCTION odd (n NATURAL)&lt;br&gt;        RETURN BOOLEAN&lt;br&gt;     IS&lt;br&gt;     BEGIN&lt;br&gt;        IF n = 0&lt;br&gt;        THEN&lt;br&gt;           RETURN FALSE;&lt;br&gt;        ELSE&lt;br&gt;           RETURN even (n - 1);   -- mutually recursive call&lt;br&gt;        END IF;&lt;br&gt;     END odd;&lt;br&gt;  BEGIN&lt;br&gt;     IF even (n)&lt;br&gt;     THEN&lt;br&gt;        l_return_var := 'even';&lt;br&gt;     ELSIF odd (n)&lt;br&gt;     THEN&lt;br&gt;        l_return_var := 'odd';&lt;br&gt;     ELSE&lt;br&gt;        l_return_var := 'oops';&lt;br&gt;     END IF;&lt;br&gt;&lt;br&gt;     RETURN l_return_var;&lt;br&gt;  END odd_or_even;&lt;br&gt;  /&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Of course, as a general rule, I keep away from using standalone functions and procedures and use packages instead.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eddie Awad</dc:creator><pubDate>Mon, 14 May 2007 16:04:42 -0000</pubDate></item><item><title>Re: Two Oracle PL/SQL Features You Probably Don&amp;#8217;t Know About</title><link>http://awads.net/wp/2007/04/30/two-oracle-plsql-features-you-probably-don%e2%80%99t-know-about/#comment-3659122</link><description>&lt;p&gt;Do not you need a package to use mutual recursion?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Laurent Schneider</dc:creator><pubDate>Sun, 13 May 2007 02:24:23 -0000</pubDate></item><item><title>Re: Two Oracle PL/SQL Features You Probably Don&amp;#8217;t Know About</title><link>http://awads.net/wp/2007/04/30/two-oracle-plsql-features-you-probably-don%e2%80%99t-know-about/#comment-3659121</link><description>&lt;p&gt;Don, yes you could, assuming that by package header you meant package specification, and assuming that your modules are created inside a package. In fact, that's one of the solutions I stated in my post: &lt;em&gt;The second option is to declare my_func2 in the package specification.&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;However, what if you do not have a package? Instead you have CREATE FUNCTION for example.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eddie Awad</dc:creator><pubDate>Thu, 03 May 2007 02:30:56 -0000</pubDate></item><item><title>Re: Two Oracle PL/SQL Features You Probably Don&amp;#8217;t Know About</title><link>http://awads.net/wp/2007/04/30/two-oracle-plsql-features-you-probably-don%e2%80%99t-know-about/#comment-3659120</link><description>&lt;p&gt;Could you not put the declarations in the package header?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Don Seiler</dc:creator><pubDate>Wed, 02 May 2007 17:43:07 -0000</pubDate></item><item><title>Re: Two Oracle PL/SQL Features You Probably Don&amp;#8217;t Know About</title><link>http://awads.net/wp/2007/04/30/two-oracle-plsql-features-you-probably-don%e2%80%99t-know-about/#comment-3659119</link><description>&lt;p&gt;Great analogy Laurent. Back in the old school days, I remember that the classic examples to demonstrate programming recursion were &lt;a href="http://en.wikipedia.org/wiki/Factorial" rel="nofollow noopener" target="_blank" title="http://en.wikipedia.org/wiki/Factorial"&gt;factorials&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Fibonacci_number" rel="nofollow noopener" target="_blank" title="http://en.wikipedia.org/wiki/Fibonacci_number"&gt;fibonacci numbers&lt;/a&gt;.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eddie Awad</dc:creator><pubDate>Mon, 30 Apr 2007 12:43:40 -0000</pubDate></item><item><title>Re: Two Oracle PL/SQL Features You Probably Don&amp;#8217;t Know About</title><link>http://awads.net/wp/2007/04/30/two-oracle-plsql-features-you-probably-don%e2%80%99t-know-about/#comment-3659118</link><description>&lt;p&gt;I had a good explanation of mutual recursion at school, a long time ago.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Simple recursion : you see yourself in a mirror, and in the mirror you see a small mirror where you see you again, and again.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Mutual recursion is : a boy is drawing a girl, the girl is drawing the boy (with a drawing of herself, drawing him, ...).&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;In Pascal, you had to add the keyword &lt;i&gt;forward&lt;/i&gt; to do this.&lt;/p&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Have a nice day,&lt;br&gt;Laurent&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Laurent Schneider</dc:creator><pubDate>Mon, 30 Apr 2007 06:01:11 -0000</pubDate></item></channel></rss>