<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	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>PeopleSoft Tipster &#187; SQL</title>
	<atom:link href="http://peoplesofttipster.com/category/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://peoplesofttipster.com</link>
	<description>Tips and Tricks with a PeopleSoft slant</description>
	<lastBuildDate>Tue, 23 Feb 2010 09:30:41 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='peoplesofttipster.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/67bbe5b1d4e8b979a53c0881ce8a06e3?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>PeopleSoft Tipster &#187; SQL</title>
		<link>http://peoplesofttipster.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://peoplesofttipster.com/osd.xml" title="PeopleSoft Tipster" />
	<atom:link rel='hub' href='http://peoplesofttipster.com/?pushpress=hub'/>
		<item>
		<title>SQL Developer Hints and Tips</title>
		<link>http://peoplesofttipster.com/2009/02/17/sql-developer-hints-and-tips/</link>
		<comments>http://peoplesofttipster.com/2009/02/17/sql-developer-hints-and-tips/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 23:03:34 +0000</pubDate>
		<dc:creator>Tipster</dc:creator>
				<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://peoplesofttipster.com/?p=276</guid>
		<description><![CDATA[I&#8217;ve put together an overview of Oracle&#8217;s SQL Developer product &#8211; at least the main features from a PeopleSoft developer&#8217;s perspective &#8211; plus some productivity tips and configuration tweaks to make it a better user experience.
It&#8217;s probably a bit big to be a blog post so I&#8217;ve put it on a tab at the top, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=276&subd=duncandavies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve put together an overview of Oracle&#8217;s SQL Developer product &#8211; at least the main features from a PeopleSoft developer&#8217;s perspective &#8211; plus some productivity tips and configuration tweaks to make it a better user experience.</p>
<p>It&#8217;s probably a bit big to be a blog post so I&#8217;ve put it on a tab at the top, and at this link:</p>
<p><a href="http://peoplesofttipster.com/sql-developer/" target="_self">http://peoplesofttipster.com/sql-developer/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/duncandavies.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/duncandavies.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/duncandavies.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/duncandavies.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/duncandavies.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/duncandavies.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/duncandavies.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/duncandavies.wordpress.com/276/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/duncandavies.wordpress.com/276/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/duncandavies.wordpress.com/276/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=276&subd=duncandavies&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://peoplesofttipster.com/2009/02/17/sql-developer-hints-and-tips/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42d38fff00428e8b120714d45980af8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tipster</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating an entirely read-only user in PeopleSoft</title>
		<link>http://peoplesofttipster.com/2008/08/28/creating-an-entirely-read-only-user-in-peoplesoft/</link>
		<comments>http://peoplesofttipster.com/2008/08/28/creating-an-entirely-read-only-user-in-peoplesoft/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 22:15:00 +0000</pubDate>
		<dc:creator>Tipster</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PeopleSoft]]></category>
		<category><![CDATA[PeopleTools]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://duncandavies.wordpress.com/?p=139</guid>
		<description><![CDATA[On big projects it is quite likely that large numbers of developers have access to a many environments.  Occasionally they can have access to environment which is quite important, for instance one that the customer is using for training or testing.
To reduce the likelihood of developers accidentally deleting some data that they shouldn&#8217;t it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=139&subd=duncandavies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>On big projects it is quite likely that large numbers of developers have access to a many environments.  Occasionally they can have access to environment which is quite important, for instance one that the customer is using for training or testing.</p>
<p>To reduce the likelihood of developers accidentally deleting some data that they shouldn&#8217;t it would be quite normal to remove their access to the environment altogether.  However if they need access for troubleshooting purposes then (at least on projects I&#8217;ve seen) it&#8217;s quite normal for developers to be told &#8220;OK, you can have access, but be careful not to do anything destructive&#8221;.  Occasionally &#8211; as with everything &#8211; things can go wrong.  Either someone forgets which environment they&#8217;re in, or does something with unintended consequences.  An alternative to the &#8220;just be careful&#8221; approach would be to create an entirely read-only user profile (i.e. one that has display only privileges to every component system-wide).</p>
<p>A read-only user profile is shown in screenshot below, where no fields are editable and the save button is inactivated:</p>
<p><img class="size-full wp-image-143 alignnone" src="http://duncandavies.files.wordpress.com/2008/08/read-only_job.jpg?w=460&#038;h=374" alt="" width="460" height="374" /></p>
<p>Also, on Run Control pages the &#8216;Run&#8217; button is inactive.  It&#8217;s going to be pretty difficult to alter data in this environment.</p>
<p>Here&#8217;s how to do it quickly and easily &#8230;</p>
<p><span id="more-139"></span></p>
<h3>1. Create User Profile</h3>
<p>First, craft your perfect &#8216;read/write&#8217; user profile.  I&#8217;ll call this &#8216;DMD&#8217;.  Now clone it using the &#8216;Copy User Profile&#8217; functionality in the PIA.  This creates a new user profile (in my case &#8216;DMD_R&#8217;) with the same Roles, and this is the one we&#8217;re going to turn read-only.</p>
<h3>2. Create new Read-Only Permission Lists</h3>
<p>First create the Permission Lists by cloning those that are currently against the User Profile:</p>
<p><code><span style="font-size:9pt;line-height:80%;font-family:'Lucida Console';color:#7f7f7f;">INSERT INTO PSCLASSDEFN<br />
(CLASSID, VERSION, CLASSDEFNDESC, TIMEOUTMINUTES, DEFAULTBPM,<br />
 STARTAPPSERVER, ALLOWPSWDEMAIL, LASTUPDDTTM, LASTUPDOPRID)<br />
(SELECT CLASSID || '_R'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, VERSION<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, CLASSDEFNDESC<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, TIMEOUTMINUTES<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, DEFAULTBPM<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, STARTAPPSERVER<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, ALLOWPSWDEMAIL<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, SYSDATE<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, 'DMD'<br />
&nbsp;&nbsp;&nbsp;FROM PSCLASSDEFN<br />
&nbsp;&nbsp;WHERE CLASSID IN (<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SELECT DISTINCT CLASSID<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM PSROLECLASS<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE ROLENAME IN (<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SELECT ROLENAME<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM PSROLEUSER<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE ROLEUSER = 'DMD_R')))</span></code></p>
<p>Don&#8217;t forget to add the sign-on times:</p>
<p><code><span style="font-size:9pt;line-height:80%;font-family:'Lucida Console';color:#7f7f7f;">INSERT INTO PSAUTHSIGNON (CLASSID, DAYOFWEEK, STARTTIME, ENDTIME)<br />
SELECT CLASSID || '_R'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, DAYOFWEEK<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, STARTTIME<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, ENDTIME<br />
&nbsp;&nbsp;FROM PSAUTHSIGNON<br />
&nbsp;WHERE CLASSID IN (<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SELECT DISTINCT CLASSID<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM PSROLECLASS<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE ROLENAME IN (<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SELECT ROLENAME<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM PSROLEUSER<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE ROLEUSER = 'DMD_R'))</p>
<h3>3. Make the Permission Lists Display Only</h3>
<p></span></code><br />
We add the pages to the new permission lists, but set Display Only to 1:</p>
<p><code><span style="font-size:9pt;line-height:80%;font-family:'Lucida Console';color:#7f7f7f;">INSERT INTO PSAUTHITEM (CLASSID, MENUNAME, BARNAME, BARITEMNAME, PNLITEMNAME, DISPLAYONLY, AUTHORIZEDACTIONS)<br />
(SELECT CLASSID || '_R'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, MENUNAME<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, BARNAME<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, BARITEMNAME<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, PNLITEMNAME<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, 1 DISPLAYONLY<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, AUTHORIZEDACTIONS<br />
&nbsp;&nbsp;&nbsp;FROM PSAUTHITEM<br />
&nbsp;&nbsp;WHERE CLASSID IN (<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SELECT DISTINCT CLASSID<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM PSROLECLASS<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE ROLENAME IN (<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SELECT ROLENAME<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM PSROLEUSER<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE ROLEUSER = 'DMD_R')))</span></code></p>
<h3>4. Create the new Read-Only Roles</h3>
<p><code><span style="font-size:9pt;line-height:80%;font-family:'Lucida Console';color:#7f7f7f;">INSERT INTO PSROLEDEFN<br />
(ROLENAME, VERSION, ROLETYPE, DESCR, QRYNAME, ROLESTATUS, RECNAME, FIELDNAME, PC_EVENT_TYPE, QRYNAME_SEC, PC_FUNCTION_NAME, ROLE_PCODE_RULE_ON, ROLE_QUERY_RULE_ON, LDAP_RULE_ON, ALLOWNOTIFY, ALLOWLOOKUP, LASTUPDDTTM, LASTUPDOPRID, DESCRLONG)<br />
(SELECT SUBSTR(ROLENAME, 1,28) || '_R'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, VERSION<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, ROLETYPE<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, DESCR<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, QRYNAME<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, ROLESTATUS<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, RECNAME<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, FIELDNAME<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, PC_EVENT_TYPE<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, QRYNAME_SEC<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, PC_FUNCTION_NAME<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, ROLE_PCODE_RULE_ON<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, ROLE_QUERY_RULE_ON<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, LDAP_RULE_ON<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, ALLOWNOTIFY<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, ALLOWLOOKUP<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, SYSDATE<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, 'DMD'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, DESCRLONG<br />
&nbsp;&nbsp;&nbsp;FROM PSROLEDEFN<br />
&nbsp;&nbsp;WHERE ROLENAME IN (<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SELECT DISTINCT ROLENAME<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM PSROLEUSER<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE ROLEUSER = 'DMD_R'))</span></code></p>
<h3>5. Add the read only permission lists to the read only roles</h3>
<p><code><span style="font-size:9pt;line-height:80%;font-family:'Lucida Console';color:#7f7f7f;">INSERT INTO PSROLECLASS(ROLENAME, CLASSID)<br />
(SELECT SUBSTR(ROLENAME, 1,28) || '_R'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, CLASSID || '_R'<br />
&nbsp;&nbsp;&nbsp;FROM PSROLECLASS<br />
&nbsp;&nbsp;WHERE ROLENAME IN (<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SELECT DISTINCT ROLENAME<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM PSROLEUSER<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE ROLEUSER = 'DMD_R'))</span></code></p>
<h3>6. Update the user profile with the new read only rolenames</h3>
<p><code><span style="font-size:9pt;line-height:80%;font-family:'Lucida Console';color:#7f7f7f;">UPDATE PSROLEUSER<br />
&nbsp;&nbsp;&nbsp;SET ROLENAME = SUBSTR(ROLENAME, 1,28) || '_R'<br />
&nbsp;WHERE ROLEUSER = 'DMD_R'</span></code></p>
<p>And that&#8217;s it, although you may well also need to perform the following:</p>
<ul>
<li>Run Portal Security Sync (to sync security up).</li>
<li>Bounce the App Server and clear cache (my App Server didn&#8217;t pick up the signon times from the cloned permission lists until I did this).</li>
<li>Run SJT_OPR_CLS (Refresh the Security Join Table that contains the Operator and Classid data)</li>
<li>Close and reopen your Web Browser and clear it&#8217;s local cache.</li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/duncandavies.wordpress.com/139/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/duncandavies.wordpress.com/139/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/duncandavies.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/duncandavies.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/duncandavies.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/duncandavies.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/duncandavies.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/duncandavies.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/duncandavies.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/duncandavies.wordpress.com/139/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/duncandavies.wordpress.com/139/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/duncandavies.wordpress.com/139/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=139&subd=duncandavies&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://peoplesofttipster.com/2008/08/28/creating-an-entirely-read-only-user-in-peoplesoft/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42d38fff00428e8b120714d45980af8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tipster</media:title>
		</media:content>

		<media:content url="http://duncandavies.files.wordpress.com/2008/08/read-only_job.jpg" medium="image" />
	</item>
		<item>
		<title>Substringing and Oracle SQL &#8211; Basic Trick</title>
		<link>http://peoplesofttipster.com/2008/08/18/substringing-and-oracle-sql-basic-trick/</link>
		<comments>http://peoplesofttipster.com/2008/08/18/substringing-and-oracle-sql-basic-trick/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 22:19:36 +0000</pubDate>
		<dc:creator>Tipster</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://duncandavies.wordpress.com/?p=136</guid>
		<description><![CDATA[This may well be something that you already know, but it was totally new to me.  It was one of those magic moments where you stumble across something so elementary you wonder:
a) how you haven&#8217;t found out about it before
b) how much time it&#8217;ll save in the future
This is related to taking only a portion [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=136&subd=duncandavies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>This may well be something that you already know, but it was totally new to me.  It was one of those magic moments where you stumble across something so elementary you wonder:</p>
<p>a) how you haven&#8217;t found out about it before</p>
<p>b) how much time it&#8217;ll save in the future</p>
<p>This is related to taking only a portion of a string using Oracle SQL, and in particular the right hand side of a string.  In other programming languages I&#8217;ve been spoilt with the RIGHT(x,num_chars) command, which we don&#8217;t have in Oracle.</p>
<p>In the past I&#8217;ve made do using something like:</p>
<p><code><span style="font-size:9pt;line-height:80%;font-family:'Lucida Console';color:#7f7f7f;">SUBSTR(&lt;character_field&gt;,length(&lt;character_field&gt;)-4,4)</span></code></p>
<p>if I wanted to take the 4 right-most characters from a string.  This gets cumbersome pretty quickly when you have multiple substrings etc.</p>
<p>Today &#8211; to my delight &#8211; I discovered that you can include negative numbers and Oracle will count back from the right hand side.  So this will take the 4 right-most characters from a string:</p>
<p><code><span style="font-size:9pt;line-height:80%;font-family:'Lucida Console';color:#7f7f7f;">SUBSTR(&lt;character_field&gt;,-4)</span></code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/duncandavies.wordpress.com/136/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/duncandavies.wordpress.com/136/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/duncandavies.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/duncandavies.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/duncandavies.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/duncandavies.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/duncandavies.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/duncandavies.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/duncandavies.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/duncandavies.wordpress.com/136/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/duncandavies.wordpress.com/136/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/duncandavies.wordpress.com/136/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=136&subd=duncandavies&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://peoplesofttipster.com/2008/08/18/substringing-and-oracle-sql-basic-trick/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42d38fff00428e8b120714d45980af8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tipster</media:title>
		</media:content>
	</item>
		<item>
		<title>PeopleCode records: PSPCMNAME and PSPCMPROG</title>
		<link>http://peoplesofttipster.com/2008/08/11/peoplecode-records-pspcmname-and-pspcmprog/</link>
		<comments>http://peoplesofttipster.com/2008/08/11/peoplecode-records-pspcmname-and-pspcmprog/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 23:57:44 +0000</pubDate>
		<dc:creator>Tipster</dc:creator>
				<category><![CDATA[PeopleSoft]]></category>
		<category><![CDATA[PeopleTools]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://duncandavies.wordpress.com/?p=129</guid>
		<description><![CDATA[A widely known tip and a new (at least for me) discovery:
Widely known tip
Most techies who&#8217;ve looked under the covers will be aware of PSPCMPROG.  It&#8217;s the underlying table where PeopleCode is storeed.  This isn&#8217;t immediately useful however as the actual code itself is stored in the PROGTXT field in binary so it&#8217;s [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=129&subd=duncandavies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>A widely known tip and a new (at least for me) discovery:</p>
<h3>Widely known tip</h3>
<p>Most techies who&#8217;ve looked under the covers will be aware of PSPCMPROG.  It&#8217;s the underlying table where PeopleCode is storeed.  This isn&#8217;t immediately useful however as the actual code itself is stored in the PROGTXT field in binary so it&#8217;s not easily accessible.  This isn&#8217;t an insurmountable issue however as there are a couple of routines to decode the field (an <a href="http://www.geocities.com/dlprice1/software/decodepc.sqr" target="_blank">SQR</a> and a <a href="http://www.passportgeek.com/node/33" target="_blank">Java</a> version, both by <a href="http://ideatec.blogspot.com/" target="_blank">David L Price</a>).  I&#8217;ve not used either method personally, but a colleague has used the SQR version with great success.</p>
<p>For me, this field isn&#8217;t quite the most useful on PSPCMPROG.  You may have noticed that if you update the PeopleCode on a record, the record properties aren&#8217;t updated to reflect the change &#8211; I guess because the record definition itself hasn&#8217;t changed (although strangely Component and Page PeopleCode do update the timestamp on the corresponding Component/Page definition &#8211; so there&#8217;s a bit of an inconsistency there).  So how do you check when and by whom a piece of Record PeopleCode was last updated?  If you check the LASTUPDDTTM and LASTUPDOPRID fields on the PSPCMPROG record via SQL then it&#8217;s all recorded there.  This snippet of knowledge has saved me (or at least expedited troubleshooting by showing me the correct person to ask about the change) innumerable times.</p>
<h3>Lesser known tip</h3>
<p>I&#8217;ve not really had much reason to look at the PSPCMNAME record in the past, however a colleague and I checked it recently and discovered the RECNAME and REFNAME fields.  Every time you create some PeopleCode your code is parsed and a line inserted into PSPCMNAME for every reference to a Tools object.  I assume that this is the record searched when using &#8216;Find Definition References&#8217; within App Designer.  However, now we know the SQL table behind this we can therefore query this table to quickly find out objects affected by code in a specified project, for example.</p>
<p>Both the company I currently work for and my previous employer had utilities to export project details to file, printing out settings and details from Tools objects to speed-up the documentation process (and we know how much techies love documenting!).  Now we can add to that utility any objects that are affected but which aren&#8217;t included in the project.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/duncandavies.wordpress.com/129/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/duncandavies.wordpress.com/129/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/duncandavies.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/duncandavies.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/duncandavies.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/duncandavies.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/duncandavies.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/duncandavies.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/duncandavies.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/duncandavies.wordpress.com/129/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/duncandavies.wordpress.com/129/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/duncandavies.wordpress.com/129/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=129&subd=duncandavies&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://peoplesofttipster.com/2008/08/11/peoplecode-records-pspcmname-and-pspcmprog/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42d38fff00428e8b120714d45980af8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tipster</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Best Practises in less than 20 minutes</title>
		<link>http://peoplesofttipster.com/2008/01/29/sql-best-practises-in-less-than-20-minutes/</link>
		<comments>http://peoplesofttipster.com/2008/01/29/sql-best-practises-in-less-than-20-minutes/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 21:17:02 +0000</pubDate>
		<dc:creator>Tipster</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PeopleSoft]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://duncandavies.wordpress.com/?p=77</guid>
		<description><![CDATA[A post on the blog of H.Tonguç Yılmaz drew my attention to a great video tutorial by Stephane Faroult on &#8220;SQL Best Practises in less than 20 minutes&#8221;.
http://www.roughsea.com/vids/SQL_Best_Practices.html
Stephane clearly knows his topic, but also possesses a wonderful dry wit.   His comical example of the developer&#8217;s shopping algorithm and the &#8220;DBA doing the parameter [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=77&subd=duncandavies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>A post on the blog of <a href="http://tonguc.wordpress.com/">H.Tonguç Yılmaz</a> drew my attention to a great video tutorial by Stephane Faroult on &#8220;SQL Best Practises in less than 20 minutes&#8221;.</p>
<p><a href="http://www.roughsea.com/vids/SQL_Best_Practices.html">http://www.roughsea.com/vids/SQL_Best_Practices.html</a></p>
<p><a href="http://www.roughsea.com/vids/SQL_Best_Practices.html"></a>Stephane clearly knows his topic, but also possesses a wonderful dry wit.   His comical example of the developer&#8217;s shopping algorithm and the &#8220;DBA doing the parameter dance&#8221; to tune it had me chuckling away and has made sure that the point won&#8217;t be forgotten.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/duncandavies.wordpress.com/77/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/duncandavies.wordpress.com/77/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/duncandavies.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/duncandavies.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/duncandavies.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/duncandavies.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/duncandavies.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/duncandavies.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/duncandavies.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/duncandavies.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/duncandavies.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/duncandavies.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=77&subd=duncandavies&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://peoplesofttipster.com/2008/01/29/sql-best-practises-in-less-than-20-minutes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42d38fff00428e8b120714d45980af8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tipster</media:title>
		</media:content>
	</item>
		<item>
		<title>Materialized Views</title>
		<link>http://peoplesofttipster.com/2008/01/10/materialized-views/</link>
		<comments>http://peoplesofttipster.com/2008/01/10/materialized-views/#comments</comments>
		<pubDate>Thu, 10 Jan 2008 17:20:52 +0000</pubDate>
		<dc:creator>Tipster</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PeopleSoft]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://peoplesofttipster.com/2008/01/10/materialized-views/</guid>
		<description><![CDATA[A materialized view (aka Snapshot) is a sort of &#8217;summary table&#8217;, the use of which allows you to reduce the processing time and complexity of some queries.
It&#8217;s a view where the data is defined via a SQL statement, but the resulting dataset is actually stored in the database (which can then be indexed, analysed etc). [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=70&subd=duncandavies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>A materialized view (aka Snapshot) is a sort of &#8217;summary table&#8217;, the use of which allows you to reduce the processing time and complexity of some queries.</p>
<p>It&#8217;s a view where the data is defined via a SQL statement, but the resulting dataset is actually stored in the database (which can then be indexed, analysed etc).  Depending upon the parameters chosen Oracle can keep the data in your view in sync with that in the tables upon which it is based.   They were originally designed for replication (i.e. holding local copies of remote tables) but they&#8217;ve been adapted for performance tuning and reporting use.</p>
<p><span id="more-70"></span><br />
When you have a large SQL query, a portion of which could be &#8216;pre-calculated&#8217;, it may well be possible to extract this and use it in a materialized view.  This hugely benefits query performance, particularly if you can get some or all of the more complex work done in advance (and run only once too, rather than repeatedly in a nested subquery).  It&#8217;s preferable to creating a table to do the same as Materialized Views can be updated when the data they are built from alters.</p>
<p>The syntax is as follows:</p>
<p><code><span style="font-size:9pt;line-height:80%;font-family:'Lucida Console';color:#7f7f7f;">CREATE MATERIALIZED VIEW &lt;view_name&gt;<br />
BUILD IMMEDIATE<br />
REFRESH COMPLETE ON DEMAND<br />
AS (&lt;Sql Query Goes Here&gt;)</span></code></p>
<p>Now you&#8217;ve seen the considerable upside, it&#8217;s only fair I point out that there are two (fairly minor) potential downsides to Materialized views:</p>
<p>1) As it writes the dataset to the database it does use extra disk space, the increase in query performance should more than offset this negative.</p>
<p>2) If the master table performance receives a lot of inserts, performance may suffer due to the overhead of also inserting into the Materialized View.</p>
<p>This is &#8211; as far as I know &#8211; an Oracle-only function, however I believe Indexed views in SQL Server are similar to so non-Oracle sites aren&#8217;t excluded from this performance improving goodness.</p>
<p>There&#8217;s a whole lot more to Materialized Views than the high-level view given here, but a quick Google shows plenty of resources to sate those hungry for more detail.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/duncandavies.wordpress.com/70/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/duncandavies.wordpress.com/70/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/duncandavies.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/duncandavies.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/duncandavies.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/duncandavies.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/duncandavies.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/duncandavies.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/duncandavies.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/duncandavies.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/duncandavies.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/duncandavies.wordpress.com/70/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=70&subd=duncandavies&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://peoplesofttipster.com/2008/01/10/materialized-views/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42d38fff00428e8b120714d45980af8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tipster</media:title>
		</media:content>
	</item>
		<item>
		<title>Shared Pool</title>
		<link>http://peoplesofttipster.com/2007/12/13/shared-pool/</link>
		<comments>http://peoplesofttipster.com/2007/12/13/shared-pool/#comments</comments>
		<pubDate>Thu, 13 Dec 2007 21:06:03 +0000</pubDate>
		<dc:creator>Tipster</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PeopleSoft]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://peoplesofttipster.com/2007/12/13/shared-pool/</guid>
		<description><![CDATA[Oracle Databases contain a &#8217;shared pool&#8217;, which is a repository for recently run SQL.  If you attempt to execute the same piece of SQL repeatedly you&#8217;ll probably notice that the execution time decreases, this is because of how Oracle parses the SQL (i.e. it&#8217;s a soft parse, not a hard parse) and the execution [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=62&subd=duncandavies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>Oracle Databases contain a &#8217;shared pool&#8217;, which is a repository for recently run SQL.  If you attempt to execute the same piece of SQL repeatedly you&#8217;ll probably notice that the execution time decreases, this is because of how Oracle parses the SQL (i.e. it&#8217;s a soft parse, not a hard parse) and the execution plan is already calculated for the SQL.  I&#8217;ve spoken about this before in an App Engine context <a href="http://peoplesofttipster.com/2007/07/31/reuse-in-app-engines/" target="_blank">here</a>.</p>
<p>This cache (or to use the correct term the &#8216;Shared Pool&#8217;) is all very useful, but what if you&#8217;re trying to tune a piece of SQL?  You want to get a &#8216;natural&#8217; idea of how long it&#8217;ll take to run, not the artificially quick result you&#8217;ll get if it&#8217;s in the shared pool.  (Execution Time is of course not the only measure to consider when tuning, examining the execution plan is critically important.)</p>
<p>We need to flush any mentions of our SQL from the shared pool.  DBAs can clear it by issuing the &#8216;ALTER SYSTEM FLUSH SHARED_POOL&#8217; command, but us un-privileged developers don&#8217;t have that luxury (and neither would we want to clear the entire cache).</p>
<p>Instead, re-calculating the statistics on a table means that &#8220;all shared SQL areas that contain statements referencing the analyzed schema object are flushed from the shared pool&#8221;.</p>
<p>A fuller (and slightly more expertly worded) explanation is available here:</p>
<p><a href="http://download-west.oracle.com/docs/cd/B12037_01/server.101/b10743/memory.htm" target="_blank">http://download-west.oracle.com/docs/cd/B12037_01/server.101/b10743/memory.htm</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/duncandavies.wordpress.com/62/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/duncandavies.wordpress.com/62/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/duncandavies.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/duncandavies.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/duncandavies.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/duncandavies.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/duncandavies.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/duncandavies.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/duncandavies.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/duncandavies.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/duncandavies.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/duncandavies.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=62&subd=duncandavies&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://peoplesofttipster.com/2007/12/13/shared-pool/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42d38fff00428e8b120714d45980af8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tipster</media:title>
		</media:content>
	</item>
		<item>
		<title>Portal Navigation</title>
		<link>http://peoplesofttipster.com/2007/12/09/portal-navigation/</link>
		<comments>http://peoplesofttipster.com/2007/12/09/portal-navigation/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 20:29:28 +0000</pubDate>
		<dc:creator>Tipster</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PeopleSoft]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://peoplesofttipster.com/2007/12/09/portal-navigation/</guid>
		<description><![CDATA[I would imagine many of you are familiar with the PSPRSMDEFN table as it is tremendously useful.  I would gamble most have a SQL snippet tucked away somewhere that will query it to find the PIA navigation to any given component.  However Jim Marion has posted some SQL on his blog that is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=60&subd=duncandavies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I would imagine many of you are familiar with the PSPRSMDEFN table as it is tremendously useful.  I would gamble most have a SQL snippet tucked away somewhere that will query it to find the PIA navigation to any given component.  However Jim Marion has posted some SQL on <a href="http://jjmpsj.blogspot.com/">his blog</a> that is the tidiest I&#8217;ve seen to date (it&#8217;s Oracle specific BTW).</p>
<p>Most SQL snippets use multiple joins to the table, I&#8217;ve seen one before that used connect_by_prior, but this one is the smallest script yet.</p>
<p>Thanks Jim!</p>
<p>Edit:</p>
<p>this slightly more succinct version may be even better.<br />
<code><span style="font-size:9pt;line-height:80%;font-family:'Lucida Console';color:#7f7f7f;">select distinct rtrim(reverse<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(sys_connect_by_path(reverse<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(portal_label), ' &gt; ')), ' &gt; ') path<br />
&nbsp;&nbsp;from psprsmdefn<br />
&nbsp;where portal_name = 'EMPLOYEE'<br />
&nbsp;&nbsp;&nbsp;and portal_prntobjname = 'PORTAL_ROOT_OBJECT'<br />
&nbsp;start with portal_uri_seg2 = :1<br />
connect by prior<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;portal_prntobjname = portal_objname</span></code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/duncandavies.wordpress.com/60/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/duncandavies.wordpress.com/60/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/duncandavies.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/duncandavies.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/duncandavies.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/duncandavies.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/duncandavies.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/duncandavies.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/duncandavies.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/duncandavies.wordpress.com/60/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/duncandavies.wordpress.com/60/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/duncandavies.wordpress.com/60/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=60&subd=duncandavies&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://peoplesofttipster.com/2007/12/09/portal-navigation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42d38fff00428e8b120714d45980af8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tipster</media:title>
		</media:content>
	</item>
		<item>
		<title>An Alternative way of writing Effdt clauses</title>
		<link>http://peoplesofttipster.com/2007/10/07/an-alternative-way-of-writing-effdt-clauses/</link>
		<comments>http://peoplesofttipster.com/2007/10/07/an-alternative-way-of-writing-effdt-clauses/#comments</comments>
		<pubDate>Sun, 07 Oct 2007 21:59:20 +0000</pubDate>
		<dc:creator>Tipster</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PeopleSoft]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://peoplesofttipster.com/2007/10/07/an-alternative-way-of-writing-effdt-clauses/</guid>
		<description><![CDATA[I’ve covered the RANK analytic function before but neglected to mention a useful application for it, and that is for rewriting Effdt and Effseq clauses more efficiently.
The usual way to return the job row (this could be any table, I’m just picking job as a common example) that’s effective for each Employee at a specific [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=41&subd=duncandavies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I’ve covered the RANK analytic function before but neglected to mention a useful application for it, and that is for rewriting Effdt and Effseq clauses more efficiently.</p>
<p>The usual way to return the job row (this could be any table, I’m just picking job as a common example) that’s effective for each Employee at a specific date is probably something similar to this:</p>
<p><code>SELECT emplid, empl_rcd, effdt, effseq<br />
&nbsp;&nbsp;FROM ps_job j<br />
&nbsp;WHERE j.effdt =<br />
&nbsp;&nbsp;&nbsp;&nbsp;(SELECT MAX (j1.effdt)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM ps_job j1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE j1.emplid = j.emplid<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AND j1.empl_rcd = j.empl_rcd<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AND j1.effdt &lt;= '10/AUG/2007')<br />
&nbsp;&nbsp;&nbsp;AND j.effseq =<br />
&nbsp;&nbsp;&nbsp;&nbsp;(SELECT MAX (j2.effseq)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM ps_job j2<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE j2.emplid = j.emplid<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AND j2.empl_rcd = j.empl_rcd<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AND j2.effdt = j.effdt)</code></p>
<p><strong>Execution Cost = 3010, time = 1 sec.</strong></p>
<p><code>SELECT emplid, empl_rcd, effdt, effseq<br />
&nbsp;&nbsp;FROM (<br />
SELECT emplid, empl_rcd, effdt, effseq,<br />
&nbsp;&nbsp;RANK () OVER<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(PARTITION BY emplid, empl_rcd<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ORDER BY effdt DESC<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, effseq DESC) rnk<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM ps_job<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE effdt &lt;= '10/AUG/2007') j<br />
&nbsp;WHERE rnk = 1</code></p>
<p><strong>Execution Cost = 665, time = 78 msecs.</strong></p>
<p>Not only is the code shorter and easier, the database execution cost is less than a quarter of the ‘standard’ method and the execution time is less than a tenth.</p>
<p>Explain plans and costs are obviously variable depending upon your environment, the tables and indexes and the volume of data; however it should be clear from the example above that there are sometimes quicker ways than the ‘standard’ method.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/duncandavies.wordpress.com/41/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/duncandavies.wordpress.com/41/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/duncandavies.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/duncandavies.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/duncandavies.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/duncandavies.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/duncandavies.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/duncandavies.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/duncandavies.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/duncandavies.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/duncandavies.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/duncandavies.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=41&subd=duncandavies&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://peoplesofttipster.com/2007/10/07/an-alternative-way-of-writing-effdt-clauses/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42d38fff00428e8b120714d45980af8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tipster</media:title>
		</media:content>
	</item>
		<item>
		<title>Lag and Lead</title>
		<link>http://peoplesofttipster.com/2007/09/21/lag-and-lead/</link>
		<comments>http://peoplesofttipster.com/2007/09/21/lag-and-lead/#comments</comments>
		<pubDate>Fri, 21 Sep 2007 21:16:19 +0000</pubDate>
		<dc:creator>Tipster</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PeopleSoft]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://peoplesofttipster.com/2007/09/21/lag-and-lead/</guid>
		<description><![CDATA[I&#8217;ve previously looked at the RANK and DENSE_RANK analytic functions, so thought I&#8217;d expand a little by mentioning LAG (and LEAD).
Analytic Functions are extensions to Oracle SQL that enable common tasks to be accomplished faster than using large blocks of SQL or PL/SQL. They are apparently &#8216;under review by the ANSI SQL committee for inclusion [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=40&subd=duncandavies&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve previously looked at the RANK and DENSE_RANK analytic functions, so thought I&#8217;d expand a little by mentioning LAG (and LEAD).</p>
<p>Analytic Functions are extensions to Oracle SQL that enable common tasks to be accomplished faster than using large blocks of SQL or PL/SQL. They are apparently &#8216;under review by the ANSI SQL committee for inclusion in the SQL specification&#8217;, although whether this will ever happen or not is anyones guess.</p>
<p>The LAG function solves (at least for those of us on Oracle) the oft-encountered issue of retrieving data from a prior row.</p>
<p><span id="more-40"></span>The standard way for dealing with this is either to have multiple &#8217;self-joins&#8217; to the same table, or to just use a blank space and populate those fields needing prior row data in a subsequent piece of SQL.</p>
<p>The example below shows how to code SQL to resolve an issue most of us have faced at least once in our careers &#8230; you&#8217;re pulling back all the employees in JOB who&#8217;ve changed departments, but we also want to know which department they&#8217;ve come from.<br />
i.e. | EMPLID | EFFDT | NEW_DEPT | OLD_DEPT |<br />
<code><br />
SELECT *<br />
FROM (SELECT j.emplid, j.effdt, j.deptid, LAG (j.deptid, 1, NULL) OVER (PARTITION BY j.emplid, j.empl_rcd ORDER BY j.effdt, j.effseq) old_deptid<br />
FROM ps_job j) j1<br />
WHERE j1.deptid &lt;&gt; j1.old_deptid</code></p>
<p>The above SQL has an inline view with some columns from the job record, plus the LAG function which provides us with the Deptid from the prior row.  The main select just chooses those rows where the current Deptid is different from the previous Deptid.</p>
<p>The LAG function works as follows:</p>
<p><code>LAG (j.deptid, 1, NULL) OVER (PARTITION BY j.emplid, j.empl_rcd ORDER BY j.effdt, j.effseq)</code></p>
<p>The first field (j.deptid) is the field that you want the previous value of.  The 1 is how many rows to step back, and the NULL is what value is to be used when there is no prior row.  The &#8216;Partition By&#8217; fields are what divides the data into &#8216;result sets&#8217;, in this case we only want it to look back through the job rows for one person at a time, if there are no more rows for that emplid and we encounter data for the next emplid then stop and treat them as a new result set, don&#8217;t treat it as a Deptid change.  The &#8216;order by&#8217; fields just tell the function how to sort the rows before searching through them.</p>
<p>The LEAD function only differs from LAG in that it searches for the next row, rather than the previous one.</p>
<p>Quick to write and quick to run &#8230;</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/duncandavies.wordpress.com/40/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/duncandavies.wordpress.com/40/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/duncandavies.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/duncandavies.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/duncandavies.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/duncandavies.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/duncandavies.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/duncandavies.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/duncandavies.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/duncandavies.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/duncandavies.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/duncandavies.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peoplesofttipster.com&blog=893910&post=40&subd=duncandavies&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://peoplesofttipster.com/2007/09/21/lag-and-lead/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42d38fff00428e8b120714d45980af8d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tipster</media:title>
		</media:content>
	</item>
	</channel>
</rss>