<?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/"
	>

<channel>
	<title>merill.net &#187; schema</title>
	<atom:link href="http://merill.net/tag/schema/feed/" rel="self" type="application/rss+xml" />
	<link>http://merill.net</link>
	<description>my utmost for His highest, my best for His glory</description>
	<lastBuildDate>Fri, 20 Apr 2012 21:31:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Changing the default schema in Oracle</title>
		<link>http://merill.net/2009/04/changing-the-default-schema-in-oracle/</link>
		<comments>http://merill.net/2009/04/changing-the-default-schema-in-oracle/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 03:14:01 +0000</pubDate>
		<dc:creator>Merill Fernando</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://merill.net/2009/04/changing-the-default-schema-in-oracle/</guid>
		<description><![CDATA[The application I was working on assumed that the user would always be in the default schema. I ran into a snag when I had to connect to the staging environment where the read only user that I was provided with didn’t have all the objects in his schema. The solution was to make a [...]]]></description>
			<content:encoded><![CDATA[<p>The application I was working on assumed that the user would always be in the default schema. I ran into a snag when I had to connect to the staging environment where the read only user that I was provided with didn’t have all the objects in his schema.</p>
<p>The solution was to make a call to change the default schema using the ALTER SESSION call with this code.</p>
<div class="csharpcode">
<pre class="alt">        <span class="rem">/// &lt;summary&gt;</span></pre>
<pre>        <span class="rem">/// Sets the schema to use if one is configured.</span></pre>
<pre class="alt">        <span class="rem">/// &lt;/summary&gt;</span></pre>
<pre>        <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> SetSchema()</pre>
<pre class="alt">        {</pre>
<pre>            var schema = ConfigurationManager.AppSettings[<span class="str">&quot;SchemaName&quot;</span>];</pre>
<pre class="alt">            <span class="kwrd">if</span> (<span class="kwrd">string</span>.IsNullOrEmpty(schema)) <span class="kwrd">return</span>;</pre>
<pre>&#160;</pre>
<pre class="alt">&#160;</pre>
<pre>            <span class="kwrd">using</span> (var connection = GetConnection())</pre>
<pre class="alt">            {</pre>
<pre>                <span class="kwrd">using</span> (var command = <span class="kwrd">new</span> OracleCommand(<span class="str">&quot;alter session set current_schema=&quot;</span> + schema))</pre>
<pre class="alt">                {</pre>
<pre>                    connection.Open();</pre>
<pre class="alt">                    command.Connection = connection;</pre>
<pre>                    command.ExecuteNonQuery();</pre>
<pre class="alt">                }</pre>
<pre>            }</pre>
<pre class="alt">        }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
]]></content:encoded>
			<wfw:commentRss>http://merill.net/2009/04/changing-the-default-schema-in-oracle/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

