Skip to content
Browse files

initial import of rayapps blog with old posts

  • Loading branch information...
0 parents commit 2e33560c9bc1bb903451f3710bf0797b77eac47d @rsim committed
Showing with 3,849 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +10 −0 README.textile
  3. +58 −0 Rakefile
  4. +4 −0 _config.yml
  5. +14 −0 _includes/show_post.html
  6. +27 −0 _includes/sidebar.html
  7. +1 −0 _includes/tag_cloud.html
  8. +40 −0 _layouts/default.html
  9. +30 −0 _layouts/post.html
  10. +45 −0 _posts/2007-08-27-how-to-explicitly-set-oracle-date-column-as-ruby-date-attribute.textile
  11. +118 −0 _posts/2007-08-27-how-to-setup-ruby-and-oracle-client-on-intel-mac.textile
  12. +68 −0 _posts/2007-08-30-rails-patch-for-oracle-clob-defaults.textile
  13. +29 −0 _posts/2007-10-30-oracle-e-business-suite-authentication-in-ruby.textile
  14. +77 −0 _posts/2007-11-16-some-issues-with-oracle-views-as-activerecord-source.textile
  15. +42 −0 _posts/2008-01-08-fix-for-rails-20-on-oracle-with-database-session-store.textile
  16. +49 −0 _posts/2008-01-26-make-rails-database-migrations-faster-on-oracle.textile
  17. +59 −0 _posts/2008-02-23-how-to-log-db-statistics-at-info-log-level-in-rails-20.textile
  18. +80 −0 _posts/2008-03-15-ruby-plsql-gem-simple-ruby-api-for-plsql-procedures.textile
  19. +11 −0 _posts/2008-04-03-my-presentation-on-using-ruby-with-oracle-at-euruko-conference.textile
  20. +11 −0 _posts/2008-04-05-video-from-euruko-2008.textile
  21. +70 −0 _posts/2008-04-24-how-to-setup-ruby-and-new-oracle-instant-client-on-leopard.textile
  22. +9 −0 _posts/2008-05-04-session-proposal-for-oow-using-ruby-on-rails-with-oracle-e-business-suite.textile
  23. +41 −0 _posts/2008-05-13-activerecord-oracle-enhanced-adapter.textile
  24. +53 −0 _posts/2008-05-21-using-mod_rails-with-rails-applications-on-oracle.textile
  25. +25 −0 _posts/2008-06-26-ruby-plsql-gem-now-supports-jruby-and-oracle-jdbc-driver.textile
  26. +38 −0 _posts/2008-06-28-activerecord-oracle-enhanced-adapter-version-111-released.textile
  27. +9 −0 _posts/2008-07-08-vote-for-my-session-proposal-at-oracle-openworld.textile
  28. +106 −0 _posts/2008-07-10-custom-activerecord-create-add-and-delete-methods-for-legacy-databases.textile
  29. +13 −0 _posts/2008-07-25-screencast-of-oracle-e-business-suite-setup-management-tool.textile
  30. +19 −0 _posts/2008-07-27-latest-additions-to-oracle-enhanced-adapter.textile
  31. +15 −0 _posts/2008-09-06-oracle-enhanced-adapter-presentation-at-rejectconf-in-berlin.textile
  32. +21 −0 _posts/2008-09-22-coding-or-drag-and-droping.textile
  33. +17 −0 _posts/2008-09-24-some-positive-drag-and-drop-experience.textile
  34. +18 −0 _posts/2008-09-26-openworld-unconference-presentation-about-rails-on-oracle.textile
  35. +158 −0 _posts/2008-12-02-ntlm-windows-domain-authentication-for-rails-application.textile
  36. +17 −0 _posts/2009-01-03-more-information-sources-on-activerecord-oracle-enhanced-adapter.textile
  37. +23 −0 _posts/2009-03-23-activerecord-oracle-enhanced-adapter-also-on-jruby-and-ruby-19.textile
  38. +282 −0 _posts/2009-04-12-how-to-install-oracle-database-10g-on-mac-os-x-intel.textile
  39. +78 −0 _posts/2009-04-21-ruby-plsql-new-version-ruby-191-support-and-more.textile
  40. +201 −0 _posts/2009-07-21-initial-version-of-datamapper-oracle-adapter.textile
  41. +56 −0 _posts/2009-09-06-how-to-setup-ruby-and-oracle-instant-client-on-snow-leopard.textile
  42. +351 −0 _posts/2009-09-14-how-to-install-oracle-database-10g-on-mac-os-x-snow-leopard.textile
  43. +52 −0 _posts/2009-09-28-new-features-in-activerecord-oracle-enhanced-adapter-version-1-2-2.textile
  44. +36 −0 _posts/2009-10-20-notes-from-oracle-openworld-2009.textile
  45. +325 −0 _posts/2009-11-25-more-oracle-data-types-supported-by-ruby-plsql-gem.textile
  46. +186 −0 _posts/2009-11-27-oracle-plsql-unit-testing-with-ruby.textile
  47. +98 −0 _posts/2010-01-04-ruby-plsql-0-4-1-support-for-package-variables-views-dbms_output-and-more.textile
  48. +37 −0 _posts/2010-01-06-screencasts-of-oracle-plsql-unit-testing-with-ruby.textile
  49. +55 −0 _posts/2010-02-24-activerecord-oracle-enhanced-adapter-version-1-2-4.textile
  50. +163 −0 _posts/2010-02-26-ruby-plsql-0-4-2-better-support-for-object-types-and-types-in-packages.textile
  51. +16 −0 _posts/2010-06-17-please-vote-for-my-ruby-session-proposals-at-oracle-openworld.textile
  52. +132 −0 _posts/2010-06-21-oracle-enhanced-adapter-1-3-0-is-rails-3-compatible.textile
  53. +27 −0 atom.xml
  54. +250 −0 css/screen.css
  55. +60 −0 css/syntax.css
  56. BIN files/rejectconf-oracle-enhaced-adapter.pdf
  57. BIN images/betwnstr.png
  58. BIN images/datamapper.jpg
  59. BIN images/doty.png
  60. BIN images/doty_450.png
  61. BIN images/drag-and-drop.gif
  62. BIN images/fr_attending.png
  63. BIN images/gradient.gif
  64. BIN images/hr-schema-demo.png
  65. BIN images/oow-submit-session.png
  66. BIN images/oow.png
  67. BIN images/oow2010.png
  68. BIN images/oracle-bi.png
  69. BIN images/rails3.gif
  70. BIN images/railspluswindows.png
  71. BIN images/rejectconf08.jpg
  72. BIN images/rooms.png
  73. BIN images/rss.png
  74. BIN images/sl_oracle.jpg
  75. BIN images/urra.png
  76. +16 −0 index.html
3 .gitignore
@@ -0,0 +1,3 @@
+_drafts/
+_site/
+tags
10 README.textile
@@ -0,0 +1,10 @@
+h1. This is the data for blog.rayapps.com
+
+It is automatically transformed by "Jekyll":http://github.com/mojombo/jekyll into a static site.
+
+h1. License
+
+The following directories and their contents are Copyright Raimonds Simanovskis. You may not reuse anything therein without my permission:
+
+* _posts/
+* images/
58 Rakefile
@@ -0,0 +1,58 @@
+desc 'Generate tags pages'
+task :tags => :tag_cloud do
+ puts "Generating tags..."
+ require 'rubygems'
+ require 'jekyll'
+ include Jekyll::Filters
+
+ options = Jekyll.configuration({})
+ site = Jekyll::Site.new(options)
+ site.read_posts('')
+
+ # Remove tags directory before regenerating
+ FileUtils.rm_rf("tags")
+
+ site.tags.sort.each do |tag, posts|
+ html = <<-HTML
+---
+layout: default
+title: "Tag archive: #{tag}"
+---
+<h1>Posts tagged with "#{tag}"</h1>
+
+{% for post in site.tags.#{tag} %}
+ {% include show_post.html %}
+{% endfor %}
+HTML
+
+ FileUtils.mkdir_p("tags/#{tag}")
+ File.open("tags/#{tag}/index.html", 'w+') do |file|
+ file.puts html
+ end
+ end
+ puts 'Done.'
+end
+
+desc 'Generate tags pages'
+task :tag_cloud do
+ puts 'Generating tag cloud...'
+ require 'rubygems'
+ require 'jekyll'
+ include Jekyll::Filters
+
+ options = Jekyll.configuration({})
+ site = Jekyll::Site.new(options)
+ site.read_posts('')
+
+ html = ''
+ max_count = site.tags.map{|t,p| p.count}.max
+ site.tags.sort.each do |tag, posts|
+ s = posts.count
+ font_size = ((20 - 10.0*(max_count-s)/max_count)*2).to_i/2.0
+ html << "<a href=\"/tags/#{tag}\" title=\"Postings tagged #{tag}\" style=\"font-size: #{font_size}px; line-height:#{font_size}px\">#{tag}</a> "
+ end
+ File.open('_includes/tag_cloud.html', 'w+') do |file|
+ file.puts html
+ end
+ puts 'Done.'
+end
4 _config.yml
@@ -0,0 +1,4 @@
+markdown: rdiscount
+pygments: true
+permalink: /:year/:month/:day/:title
+exclude: Rakefile README.textile
14 _includes/show_post.html
@@ -0,0 +1,14 @@
+<div class="post">
+ <h3 class="date">{{ post.date | date: "%B %d, %Y" }}</h3>
+ <h2 class="title"><a href="{{ post.url }}">{{ post.title }}</a></h2>
+ <div class="meta">
+ Posted by Raimonds Simanovskis,
+ tags:
+ {% for tag in post.tags %}
+ <a href="/tags/{{ tag }}" title="View posts tagged with &quot;{{ tag }}&quot;">{{ tag }}</a>{% if forloop.last != true %}, {% endif %}
+ {% endfor %}
+ </div>
+ <div class="body">
+ {{ post.content }}
+ </div>
+</div>
27 _includes/sidebar.html
@@ -0,0 +1,27 @@
+<p>
+ <a href="http://apex.oracle.com/pls/otn/f?p=19297:4:1971505610653388::NO:4:P4_ID:263">
+ <img src="http://www.oracle.com/technology/community/oracle_ace/oracle_ace_blk.gif" title="Oracle ACE"/>
+ </a>
+</p>
+<p>
+ <a href="http://www.workingwithrails.com/recommendation/new/person/16493-raimonds-simanovskis">
+ <img src="http://workingwithrails.com/images/tools/compact-small.jpg" title="Recommend Me"/>
+ </a>
+</p>
+
+<h2>Tags</h2>
+<p>
+ {% include tag_cloud.html %}
+</p>
+
+<h2>Recent posts</h2>
+<ul class="posts">
+ {% for post in site.posts limit:5 %}
+ <li><a href="{{ post.url }}">{{ post.title }}</a>
+ <br/><span class="date">{{ post.date | date: "%b %d, %Y" }}</span>
+ </li>
+ {% endfor %}
+</ul>
+
+
+<h2>Recent comments</h2>
1 _includes/tag_cloud.html
@@ -0,0 +1 @@
+<a href="/tags/apache" title="Postings tagged apache" style="font-size: 10.0px; line-height:10.0px">apache</a> <a href="/tags/authentication" title="Postings tagged authentication" style="font-size: 10.0px; line-height:10.0px">authentication</a> <a href="/tags/conference" title="Postings tagged conference" style="font-size: 12.0px; line-height:12.0px">conference</a> <a href="/tags/conferences" title="Postings tagged conferences" style="font-size: 10.0px; line-height:10.0px">conferences</a> <a href="/tags/database" title="Postings tagged database" style="font-size: 10.0px; line-height:10.0px">database</a> <a href="/tags/datamapper" title="Postings tagged datamapper" style="font-size: 10.0px; line-height:10.0px">datamapper</a> <a href="/tags/mac" title="Postings tagged mac" style="font-size: 11.0px; line-height:11.0px">mac</a> <a href="/tags/ntlm" title="Postings tagged ntlm" style="font-size: 10.0px; line-height:10.0px">ntlm</a> <a href="/tags/oracle" title="Postings tagged oracle" style="font-size: 20.0px; line-height:20.0px">oracle</a> <a href="/tags/oracle_enhanced" title="Postings tagged oracle_enhanced" style="font-size: 12.0px; line-height:12.0px">oracle_enhanced</a> <a href="/tags/plsql" title="Postings tagged plsql" style="font-size: 12.0px; line-height:12.0px">plsql</a> <a href="/tags/rails" title="Postings tagged rails" style="font-size: 15.0px; line-height:15.0px">rails</a> <a href="/tags/ruby" title="Postings tagged ruby" style="font-size: 18.5px; line-height:18.5px">ruby</a> <a href="/tags/ruby-plsql" title="Postings tagged ruby-plsql" style="font-size: 12.0px; line-height:12.0px">ruby-plsql</a> <a href="/tags/screencast" title="Postings tagged screencast" style="font-size: 10.0px; line-height:10.0px">screencast</a> <a href="/tags/testing" title="Postings tagged testing" style="font-size: 10.0px; line-height:10.0px">testing</a> <a href="/tags/windows" title="Postings tagged windows" style="font-size: 10.0px; line-height:10.0px">windows</a>
40 _layouts/default.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <title>{{ page.title }}</title>
+ <meta name="author" content="Raimonds Simanovskis" />
+ <link href="http://feeds.feedburner.com/rayapps_blog" rel="alternate" title="rayapps_blog" type="application/atom+xml" />
+
+ <!-- syntax highlighting CSS -->
+ <link rel="stylesheet" href="/css/syntax.css" type="text/css" />
+
+ <!-- Homepage CSS -->
+ <link rel="stylesheet" href="/css/screen.css" type="text/css" media="screen, projection" />
+
+</head>
+<body>
+
+<div id="rap">
+ <h1 id="header">
+ <a href="/">Ray::Apps.blog</a>
+ </h1>
+
+ <div id="content">
+ {{ content }}
+ </div>
+
+ <!-- begin sidebar -->
+ <div id="sidebar">
+ {% include sidebar.html %}
+ </div>
+
+</div>
+
+<a href="http://github.com/rsim"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub" /></a>
+
+<!-- Google Analytics -->
+<!-- Google Analytics end -->
+
+</body>
+</html>
30 _layouts/post.html
@@ -0,0 +1,30 @@
+---
+layout: default
+---
+<div class="post">
+ <h3 class="date">{{ page.date | date: "%B %d, %Y" }}</h3>
+ <h2 class="title"><a href="{{ page.url }}">{{ page.title }}</a></h2>
+ <div class="meta">
+ Posted by <span class="author">Raimonds Simanovskis</span>, tags:
+ {% for tag in page.tags %}
+ <a href="/tags/{{ tag }}" title="View posts tagged with &quot;{{ tag }}&quot;">{{ tag }}</a>{% if forloop.last != true %}, {% endif %}
+ {% endfor %}
+ </div>
+ <div class="body">
+ {{ content }}
+ </div>
+
+ <div class="related_posts">
+ <h4>Possibly related posts (automatically generated)</h4>
+ <ul class="posts">
+ {% for post in site.related_posts limit:3 %}
+ <li><span class="date">{{ post.date | date: "%b %d, %Y" }}</span> &raquo; <a href="{{ post.url }}">{{ post.title }}</a></li>
+ {% endfor %}
+ </ul>
+ </div>
+
+ <div class="comments">
+ <h4>Comments</h4>
+ </div>
+
+</div>
45 _posts/2007-08-27-how-to-explicitly-set-oracle-date-column-as-ruby-date-attribute.textile
@@ -0,0 +1,45 @@
+---
+layout: post
+title: How to explicitly set Oracle DATE column as Ruby Date attribute
+tags: ruby rails oracle
+---
+
+As you probably have noticed Oracle has just one DATE type for table columns which is supposed both for storing just dates and dates with time. From the other side Ruby has different classes Date and Time. If you are using Rails then Rails tries to guess from the database column types what are the classes for corresponding object attributes in Ruby. And as both dates and dates with time appear as DATE columns Rails has difficulties to guess whether it should be Ruby Date or Ruby Time.
+
+Current Rails Oracle adapter has the following workaround implemented:
+
+{% highlight ruby %}
+# * Oracle uses DATE or TIMESTAMP datatypes for both dates and times.
+# Consequently some hacks are employed to map data back to Date or Time
+# in Ruby. If the column_name ends in _time it's created as a Ruby Time.
+# Else if the hours/minutes/seconds are 0, I make it a Ruby Date. Else
+# it's a Ruby Time. This is a bit nasty - but if you use Duck Typing
+# you'll probably not care very much. In 9i and up it's tempting to
+# map DATE to Date and TIMESTAMP to Time, but too many databases use
+# DATE for both. Timezones and sub-second precision on timestamps are
+# not supported.
+{% endhighlight %}
+
+This workaround is problematic if you have date columns which can be NULL. In this case Rails cannot determine if this is date or datetime column. And if you use standard scaffolds or, for example, <a href="http://activescaffold.com/">ActiveScaffold</a>, it will use _datetime_select_ helper and not _date_select_ helper for this column - which means that you will be asked to specify also time for new dates.
+
+Therefore, as I typically name all date columns with _DATE at the end, I created a patch which makes all such columns to be handled as Ruby Date attributes:
+
+{% highlight ruby %}
+# RSI: OracleAdapter patch - treat columns which end with 'date' as ruby date type
+module ActiveRecord::ConnectionAdapters
+ class OracleColumn
+ def simplified_type(field_type)
+ return :boolean if OracleAdapter.emulate_booleans && field_type == 'NUMBER(1)'
+ case self.name
+ # RSI: treat columns which end with 'date' as ruby date columns
+ when /date$/i then :date
+ # RSI: removed 'date' from regex
+ when /time/i then :datetime
+ else super
+ end
+ end
+ end
+end
+{% endhighlight %}
+
+Include this in environment.rb file or put it into separate file in e.g. lib directory and require it in environment.rb file.
118 _posts/2007-08-27-how-to-setup-ruby-and-oracle-client-on-intel-mac.textile
@@ -0,0 +1,118 @@
+---
+layout: post
+title: How to setup Ruby and Oracle client on Intel Mac
+tags: ruby oracle mac
+---
+
+bq(warning). UPDATE: <a href="http://blog.rayapps.com/2008/04/24/how-to-setup-ruby-and-new-oracle-instant-client-on-leopard/">New version of this instruction for Intel Macs with Leopard is available here.</a>
+<a href="http://blog.rayapps.com/2009/09/06/how-to-setup-ruby-and-oracle-instant-client-on-snow-leopard/">New version of instructions for Snow Leopard is available here.</a>
+
+h3. Introduction
+
+I have been using Oracle technologies for many years but just some time ago discovered Ruby and Rails. As I had ideas how to make Ruby on Rails frontends for existing Oracle based systems I started to explore how to use Ruby on Rails together with Oracle databases.
+
+Just recently I switched from PC notebook to MacBook Pro and unfortunately found out that <a href="http://forums.oracle.com/forums/thread.jspa?threadID=481059">Oracle Instant Client is not yet released for Intel Macs</a>. As there is no promise when it will be released and as I could not wait for that I decided to make old <a href="http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/macsoft.html">PowerPC version of Oracle Instant Client</a> to run on Intel Mac. As I didn't find any good description how to do that I decided to write description of it by myself - hopefully it will help others.
+h3. Universal or "fat" binary Ruby
+
+The first thing is that you need to get "universal" or "fat" binary installation of Ruby - it means that it contains both Intel and PowerPC (PPC) binary code. You will need PPC version of Ruby when you will work with Oracle and you will need Intel version of Ruby when you will do other things. PPC code is running in emulation mode on Intel processors and therfore is slower as well as there are some compatibility issues with some other libraries (I will mention later what issues I found out).
+
+It is possible to get and install precompiled Ruby either from <a href="http://www.macports.org/">MacPorts</a> or using <a href="http://rubyosx.rubyforge.org/">Ruby One-Click Installer</a>. But I prefer to compile Ruby from source code as it gives me more control what is installed and where. I used <a href="http://hivelogic.com/narrative/articles/ruby-rails-mongrel-mysql-osx">Hivelogic guide</a> to compile Ruby from source code.
+
+Here are my additional notes what I changed to Hivelogic guide to make "fat" binaries.
+
+h3. Installing "readline"
+
+At first you need to install "readline" shared libraries. At first I tried to make them from "readline" library source code but I always got just Intel binaries. Therefore I found and downloaded "readline" library <a href="http://downloads.sourceforge.net/rudix/readline-5.2-8universal.dmg?modtime=1185921225&big_mirror=0">installer package</a> with universal binaries and installed it. If you previously installed Intel binary of "readline" library then it is better to restart Mac to ensure that new dynamic library will be loaded.
+
+h3. Compiling Ruby
+
+Next you need to download and extract Ruby 1.8.6 source code.
+
+Before running "configure" command I made the following change in "configure" file:
+
+{% highlight ruby %}
+# Choose a default set of architectures based upon platform.
+case "$target_os" in
+darwin*)
+ TARGET_ARCHS="*ppc i386*"
+ ;;
+{% endhighlight %}
+
+You can specify this also on command line but this change ensures that you will not forget it :) Then you need to run "configure" script with additional parameter at the end:
+
+pre(terminal). ./configure --prefix=/usr/local --enable-pthread --with-readline-dir=/usr/local \
+--enable-shared --enable-fat-binary
+
+After running "make" hopefully you will get everything compiled and you should get "fat" ruby binary. You can verify it with the following command and should see the following result:
+
+pre(terminal). $ file ruby
+ruby: Mach-O universal binary with 2 architectures
+ruby (for architecture ppc): Mach-O executable ppc
+ruby (for architecture i386): Mach-O executable i386
+
+If you do not see that ruby binary contains both ppc and i386 executables then something went wrong. If it is OK then you can do "sudo make install" to install binaries in target directories.
+
+h3. Make PPC and "fat" versions of Ruby
+
+As you will need to be able to force to run PPC version of Ruby later then we need to extract PPC executable in a separate file and store original "fat" binary in another file:
+
+pre(terminal). ditto -arch ppc /usr/local/bin/ruby /usr/local/bin/ruby_ppc
+mv /usr/local/bin/ruby /usr/local/bin/ruby_fat
+
+Then I recommend to create simple scripts that will help you to switch between "fat" and PPC versions of Ruby:
+
+ppc_ruby.sh:
+
+{% highlight sh %}
+#!/bin/bash
+sudo ln -fs /usr/local/bin/ruby_ppc /usr/local/bin/ruby
+{% endhighlight %}
+
+fat_ruby.sh:
+
+{% highlight ruby %}
+#!/bin/bash
+sudo ln -fs /usr/local/bin/ruby_fat /usr/local/bin/ruby
+{% endhighlight %}
+
+So when you need to have PPC version of Ruby then run "ppc_ruby.sh" script and when you need "fat" version (which will actually run Intel binary) then run "fat_ruby.sh" script.
+
+h3. Install Oracle Instant Client for PPC
+
+Install Oracle Instant Client according to the <a href="http://creativi.st/blog/articles/2005/06/25/rails-oracle-client-on-mac-os-x">following description</a>.
+
+h3. Compile and install ruby-oci8
+
+I used the <a href="http://blog.sven-tissot.de/files/ror_and_oracle.html">following description</a> as a basis but some additional changes were needed for ruby-oci8-1.0.0-rc3 compilation.
+
+Open ruby-oci8 README file and find section "=== Intel Mac" where are described what to do to compile ruby-oci8 on Intel Mac.
+
+Before running any ruby scripts you need to run ppc_ruby.sh script to switch to PPC binary.
+
+If you compiled "fat" Ruby from source code then you need to modify file /usr/local/lib/ruby/1.8/fat-darwin8.10.1/rbconfig.rb according to README file (make backup of file before modifications). If you installed Ruby from binary distribution then find where is located your rbconfig.rb file.
+
+* find lines with CONFIG["CFLAGS"] and CONFIG["LDFLAGS"] and CONFIG["ARCH_FLAG"]
+* remove "-arch i386" if present (was not present in my case)
+* and add "-arch ppc" to all of these lines.
+
+Make and install ruby-oci8 and if it finishes successfully then restore rbconfig.rb file from backup.
+
+Try
+
+pre(terminal). ruby -r oci8 -e "OCI8.new('scott', 'tiger','orcl').exec('select * from emp') do |r| puts r.join(','); end"
+
+or similar to verify that you can access Oracle database from ruby.
+
+Congratulations! You have managed to connect to Oracle DB from Ruby on Intel Mac! If you got some issues at some point then please write it in comments and I will try to help with that.
+
+h3. Post installation notes
+
+If you previously installed (or if you will install in future) any Ruby gems with native extensions (e.g. Mongrel or MySQL C API) then you need to reinstall these gems with "fat" Ruby (i.e. running "fat_ruby.sh" script and then "sudo gem install"). It will ensure that all gems will also have "fat" native extensions so that you can run them both in PPC Ruby and Intel Ruby.
+
+h3. Known issues with PPC Ruby
+
+So far I have got the following issues with running PPC version of Ruby:
+
+* Capistrano is failing to make SSH connection when running in PPC Ruby (I was testing with new Capistrano 2.0). Therefore you need always to switch to "fat" Ruby before running "cap deploy".
+* As I also wanted that MySQL is running under PPC I got some issues with MySQL native extensions compilation - I solved them using the <a href="http://www.fatmixx.com/2007/05/30/ruby-mysql-gem-error/">following description</a>.
+* ruby-ldap connections were failing when running in PPC Ruby within Ruby on Rails. I managed to fix it by putting "require ldap" as a first line in config/environment.rb file.
68 _posts/2007-08-30-rails-patch-for-oracle-clob-defaults.textile
@@ -0,0 +1,68 @@
+---
+layout: post
+title: Rails patch for Oracle CLOB defaults
+tags: ruby rails oracle
+---
+
+If you are using Rails 1.2.3 with Oracle database then you might find that text attributes (which map to Oracle CLOB data type) get invalid default values - e.g. you might find that when you create new record it will get "empty_clob()" as default text attribute value.
+
+I found out that this issue is corrected in current edge Rails. As I still primarily use Rails 1.2.3 I created the following patch according to the changes that are done in edge Rails. You can put it in environment.rb file or better put into a separate file and require it in environment.rb file.
+
+{% highlight ruby %}
+# RSI: text defaults handling from http://dev.rubyonrails.org/ticket/7344 & http://dev.rubyonrails.org/changeset/6090
+module ActiveRecord::ConnectionAdapters
+ class OracleAdapter
+ def quote(value, column = nil) #:nodoc:
+ # RSI: patched
+ if value && column && [:text, :binary].include?(column.type)
+ %Q{empty_#{ column.sql_type.downcase rescue 'blob' }()}
+ else
+ super
+ end
+ end
+
+ def columns(table_name, name = nil) #:nodoc:
+ (owner, table_name) = @connection.describe(table_name)
+ table_cols = <<-SQL
+ select column_name as name, data_type as sql_type, data_default, nullable,
+ decode(data_type, 'NUMBER', data_precision,
+ 'FLOAT', data_precision,
+ 'VARCHAR2', data_length,
+ null) as limit,
+ decode(data_type, 'NUMBER', data_scale, null) as scale
+ from all_tab_columns
+ where owner = '#{owner}'
+ and table_name = '#{table_name}'
+ order by column_id
+ SQL
+ select_all(table_cols, name).map do |row|
+ limit, scale = row['limit'], row['scale']
+ if limit || scale
+ row['sql_type'] << "(#{(limit || 38).to_i}" + ((scale = scale.to_i) > 0 ? ",#{scale})" : ")")
+ end
+ # clean up odd default spacing from Oracle
+ if row['data_default']
+ row['data_default'].sub!(/^(.*?)\s*$/, '\1')
+ row['data_default'].sub!(/^'(.*)'$/, '\1')
+ # RSI: patched
+ row['data_default'] = nil if row['data_default'] =~ /^(null|empty_[bc]lob\(\))$/i
+ end
+ OracleColumn.new(oracle_downcase(row['name']),
+ row['data_default'],
+ row['sql_type'],
+ row['nullable'] == 'Y')
+ end
+ end
+
+ # RSI: added
+ def add_column_options!(sql, options) #:nodoc:
+ # handle case of defaults for CLOB columns, which would otherwise get "quoted" incorrectly
+ if options_include_default?(options) && (column = options[:column]) && column.type == :text
+ sql << " DEFAULT #{quote(options.delete(:default))}"
+ end
+ super
+ end
+
+ end
+end
+{% endhighlight %}
29 _posts/2007-10-30-oracle-e-business-suite-authentication-in-ruby.textile
@@ -0,0 +1,29 @@
+---
+layout: post
+title: Oracle E-Business Suite Authentication in Ruby
+tags: oracle ruby authentication
+---
+
+I was developing Ruby on Rails application that access data from existing Oracle E-Business Suite application and I wanted to add to this application possibility for users to authenticate themselves by their existing Oracle E-Business Suite user names and passwords.
+
+Oracle is not publicly providing algorythms which are used for user passwords encryption (which are stored in FND_USER table) and therefore some googling was necessary. I was lucky to find <a href="http://www.milci.com/eappsjira">Jira eBusiness Suite Authenticator</a> with full source code in Java which also included all Oracle E-Business Suite password encryption / decryption functions. Actually it seems that the >1000 lines source code is decompiled from Oracle Java classes as there are no comments and variable names don't tell anything.
+
+But as I did not have any better source material I started Ruby rewrite of this code and happily managed to finish it in couple of days. As a result I created <a href="http://svn.rayapps.com/plugins/oracle_ebs_authentication/">Oracle EBS Authentication</a> plugin and you can find out in <a href="http://svn.rayapps.com/plugins/oracle_ebs_authentication/README">README</a> file how to install it.
+
+Usage of this plugin is quite simple - here is an example:
+
+{% highlight ruby %}
+database_name = ActiveRecord::Base.connection.current_database
+authenticator = OracleEbsAuthentication::Authenticator.new(database_name)
+if authenticator.validate_user_password(login, password)
+ # user authenticated
+ if authenticator.user_reponsibilities.include? "System Administrator"
+ # user has System Administrator role
+ end
+ # ...
+else
+ # authentication failed
+end
+{% endhighlight %}
+
+BTW Oracle EBS password encryption approach <a href="http://www.integrigy.com/security-resources/advisories/Integrigy_Encrypted_Password_Disclosure.pdf">has quite a lot of weaknesses</a>. So if you provide SQL*Net access to your Oracle EBS database then anyone with valid Oracle EBS user name and password can decrypt APPS database user password and also can decrypt passwords of all other users. You can have a deeper look in plugin source code to understand how it can be done :)
77 _posts/2007-11-16-some-issues-with-oracle-views-as-activerecord-source.textile
@@ -0,0 +1,77 @@
+---
+layout: post
+title: Some issues with Oracle views as ActiveRecord source
+tags: ruby rails oracle
+---
+
+I am using Ruby on Rails to publish data from existing "legacy" application on Oracle database which already have existing complex data model. I am defining additional database views on existing legacy data to which I grant select rights to Rails schema. And I am using Rails conventions when defining these views - view names as pluralized / underscored version of Rails model name, ID column as primary key and %_ID columns as foreign keys.
+
+Typically this works quite well and I can use Rails find methods to automatically generate SQL SELECTs from these views. But for some legacy data I got the problem with Oracle number type mapping to Ruby integer type.
+
+Rails standard convention for database NUMBER type mapping is the following:
+
+* NUMBER with specified scale and without precision (e.g. NUMBER(15)) is mapped to :integer
+* NUMBER with specified scale and with precision (e.g. NUMBER(15,2)) is mapped to :decimal
+* NUMBER without scale and precision (just NUMBER) is mapped to :decimal
+
+If primary keys and foreign keys in legacy tables are defined as e.g. NUMBER(15) then everything is OK and they will be mapped to :integer in Rails. But if primary keys or foreign keys in legacy tables are defined as NUMBER then they will be mappec to :decimal in Rails.
+
+And what happens if e.g. primary key is mapped to :decimal in Rails? Then, for example, you get that customer.id is equal to "123.0" and you get ugly URLs like "/customers/123.0".
+
+One workaround is to use customer.id.to_i everywhere but it is quite annoying. Therefore I created patch for Oracle adapter (this is tested with Rails 1.2.3) which always sets data type as :integer for all primary keys (column name ID) and foreign keys (column name like %_ID). This includes also date columns patch that <a href="http://blog.rayapps.com/2007/08/27/how-to-explicitly-set-oracle-date-column-as-ruby-date-attribute/">I wrote about previously</a>.
+
+{% highlight ruby %}
+module ActiveRecord::ConnectionAdapters
+ class OracleColumn
+ def simplified_type(field_type)
+ return :boolean if OracleAdapter.emulate_booleans && field_type == 'NUMBER(1)'
+ case self.name
+ # RSI: treat columns which end with 'date' as ruby date columns
+ when /date$/i then :date
+ # RSI: removed 'date' from regex
+ when /time/i then :datetime
+ # RSI: treat id columns (primary key) as integer
+ when /^id$/i then :integer
+ # RSI: treat _id columns (foreign key) as integer
+ when /_id$/i then :integer
+ else super
+ end
+ end
+ end
+
+ # RSI: patch to change selected results NUMBER to integer for primary and foreign keys
+ class OracleAdapter
+ def select(sql, name = nil)
+ cursor = execute(sql, name)
+ cols = cursor.get_col_names.map { |x| oracle_downcase(x) }
+ rows = []
+
+ while row = cursor.fetch
+ hash = Hash.new
+
+ cols.each_with_index do |col, i|
+ hash[col] =
+ case row[i]
+ when OCI8::LOB
+ name == 'Writable Large Object' ? row[i]: row[i].read
+ when OraDate
+ (row[i].hour == 0 and row[i].minute == 0 and row[i].second == 0) ?
+ row[i].to_date : row[i].to_time
+ else row[i]
+ end unless col == 'raw_rnum_'
+ # RSI: patch - convert to integer if column is ID or ends with _ID
+ hash[col] = hash[col].to_i if (col =~ /^id$/i || col =~ /_id$/i) && hash[col]
+ end
+
+ rows << hash
+ end
+
+ rows
+ ensure
+ cursor.close if cursor
+ end
+ end
+end
+{% endhighlight %}
+
+I have not yet verified this with Rails 2.0. And probably I will collect all my Oracle adapter patches and will release it as plugin. Is anybody interested in this?
42 _posts/2008-01-08-fix-for-rails-20-on-oracle-with-database-session-store.textile
@@ -0,0 +1,42 @@
+---
+layout: post
+title: Fix for Rails 2.0 on Oracle with database session store
+tags: ruby rails oracle
+---
+
+As I started to explore Rails 2.0 I tried to migrate one application to Rails 2.0 which is using Oracle as a database. Here are some initial tips for Rails 2.0 on Oracle that I found out.
+
+Oracle adapter is no more included in Rails 2.0 so you need to install it separately. It is also not yet placed on gems.rubyforge.org therefore you need to install it with:
+
+pre(terminal). sudo gem install activerecord-oracle-adapter --source http://gems.rubyonrails.org
+
+The next issue that you will get is error message "select_rows is an abstract method". You can find more information about it in <a href="http://dev.rubyonrails.org/ticket/10415">this ticket</a>. As suggested I fixed this issue with the following Oracle adapter patch that I call from anvironment.rb file:
+
+{% highlight ruby %}
+module ActiveRecord
+ module ConnectionAdapters
+ class OracleAdapter
+ def select_rows(sql, name = nil)
+ result = select(sql, name)
+ result.map{ |v| v.values}
+ end
+ end
+ end
+end
+{% endhighlight %}
+
+And then I faced very strange behaviour that my Rails application was not working with database session store - no session data was saved. When I changed session store to cookies then everything worked fine.
+
+When I continued investigation I found out that the issue was that for each new session new row was created in "sessions" table but no session data was saved in "data" column. As "data" column is text field which translates to CLOB data type in Oracle then it is not changed in Oracle adapter by INSERT or UPDATE statements but with special "write_lobs" after_save callback (this is done so because in Oracle there is limitation that literal constants in SQL statements cannot exceed 4000 characters and therefore such hack with after_save callback is necessary). And then I found that class CGI::Session::ActiveRecordStore::Session (which is responsible for database session store) does not have this write_lobs after_save filter. Why so?
+
+As I understand now in Rails 2.0 ActiveRecord class definition sequence has changed - now at first CGI::Session::ActiveRecordStore::Session class is defined which inherits from ActiveRecord::Base and only afterwards OracleAdapter is loaded which adds write_lobs callback to ActiveRecord::Base but at this point it is not adding this callback to already defined Session class. As in Rails 1.2 OracleAdapter was loaded together with ActiveRecord and before Session class definition then there was no such issue.
+
+So currently I solved this issue with simple patch in environment.rb file:
+
+{% highlight ruby %}
+class CGI::Session::ActiveRecordStore::Session
+ after_save :write_lobs
+end
+{% endhighlight %}
+
+Of course it would be nicer to force that OracleAdapter is loaded before CGI::Session::ActiveRecordStore::Session definition (when ActionPack is loaded). If somebody knows how to do that please write a comment :)
49 _posts/2008-01-26-make-rails-database-migrations-faster-on-oracle.textile
@@ -0,0 +1,49 @@
+---
+layout: post
+title: Make Rails database migrations faster on Oracle
+tags: ruby rails oracle
+---
+
+When using Ruby on Rails on Oracle I noticed that my database migration tasks are much slower than on MySQL.
+
+I just found the cause for that - rake db:schema:dump task was taking very long time on my Oracle databases (and this task is executed at the end of rake db:migrate). As a result of this task Oracle Rails adapter is executing
+
+{% highlight sql %}
+SELECT LOWER(table_name) FROM user_tables
+{% endhighlight %}
+
+statement. If your database contains a lot of other schemas with a lot of tables (as in my case I deploy Rails user schema in Oracle E-Business Suite database) then this statement is quite slow (it took more than 10 seconds in my case).
+
+As all Rails tables are located in Rails user schema then you can get the same result with
+
+{% highlight sql %}
+SELECT LOWER(table_name) FROM all_tables WHERE owner = SYS_CONTEXT('userenv','session_user')
+{% endhighlight %}
+
+which now executes much faster than original statement.
+
+So you can make the following patch for Oracle Rails adapter to make this change
+
+{% highlight ruby %}
+module ActiveRecord
+ module ConnectionAdapters
+ class OracleAdapter
+ def tables(name = nil)
+ select_all("select lower(table_name) from all_tables where owner = sys_context('userenv','session_user')").inject([]) do | tabs, t |
+ tabs << t.to_a.first.last
+ end
+ end
+ end
+ end
+end
+{% endhighlight %}
+
+and include it in environment.rb file or in some separate patch file which you load at Rails startup.
+
+P.S. I have published <a href="http://svn.rayapps.com/lib/oracle_adapter_20_patch.rb">all my patches for Oracle Rails 2.0 adapter</a>. You can download this file, place it in Rails application lib directory and then just include
+
+{% highlight ruby %}
+require "oracle_adapter_20_patch"
+{% endhighlight %}
+
+in your environment.rb file. Look at comments in this file to find out what each patch is doing.
59 _posts/2008-02-23-how-to-log-db-statistics-at-info-log-level-in-rails-20.textile
@@ -0,0 +1,59 @@
+---
+layout: post
+title: How to log DB statistics at info log level in Rails 2.0
+tags: ruby rails
+---
+
+When I switched some my applications to Rails 2.0 I noticed that I do not see anymore DB execution time statistics in my production log file (which I set at info level). Now I saw zero database processing time for all my requests, e.g.:
+
+{% highlight text %}
+Completed in 0.22203 (4 reqs/sec) | Rendering: 0.13277 (59%) | DB: 0.00000 (0%)
+{% endhighlight %}
+
+When investigating why is it so I found the following small changeset that is done in Rails 2.0 - <a href="http://dev.rubyonrails.org/changeset/8162">http://dev.rubyonrails.org/changeset/8162</a>.
+
+In Rails 1.2 at debug level you got both SQL and database processing time in log file and at info level you got just database processing time. In Rails 2.0 at debug level you get the same in log file but at info level you do not get database processing time.
+
+So if you are like me and want to analyze your production log file with tools like <a href="http://nubyonrails.com/articles/a-hodel-3000-compliant-logger-for-the-rest-of-us">pl_analyze</a> then you can monkey patch ActiveRecord to get back the previous behaviour as in Rails 1.2:
+
+{% highlight ruby %}
+module ActiveRecord
+ module ConnectionAdapters
+ class AbstractAdapter
+ protected
+ def log(sql, name)
+ if block_given?
+ # RSI: changed to get DB statistics in log file at info level
+ # if @logger and @logger.debug?
+ if @logger and @logger.level <= Logger::INFO
+ result = nil
+ seconds = Benchmark.realtime { result = yield }
+ @runtime += seconds
+ log_info(sql, name, seconds)
+ result
+ else
+ yield
+ end
+ else
+ log_info(sql, name, 0)
+ nil
+ end
+ rescue Exception => e
+ # Log message and raise exception.
+ # Set last_verification to 0, so that connection gets verified
+ # upon reentering the request loop
+ @last_verification = 0
+ message = "#{e.class.name}: #{e.message}: #{sql}"
+ log_info(message, name, 0)
+ raise ActiveRecord::StatementInvalid, message
+ end
+ end
+ end
+end
+{% endhighlight %}
+
+And now you will get database processing statistics back in log file at info level:
+
+{% highlight text %}
+Completed in 0.21853 (4 reqs/sec) | Rendering: 0.10835 (49%) | DB: 0.09657 (44%)
+{% endhighlight %}
80 _posts/2008-03-15-ruby-plsql-gem-simple-ruby-api-for-plsql-procedures.textile
@@ -0,0 +1,80 @@
+---
+layout: post
+title: "ruby-plsql gem: simple Ruby API for PL/SQL procedures"
+tags: ruby-plsql ruby oracle plsql
+---
+
+In several projects I have used Ruby and Rails to access legacy Oracle databases which have both tables with data as well as PL/SQL packages with lot of existing business logic. Sometimes it is easier just to redo business logic in Ruby but sometimes you need to reuse existing PL/SQL packages and procedures.
+
+Let's use this simple PL/SQL function as an example:
+
+{% highlight sql %}
+CREATE OR REPLACE FUNCTION test_uppercase
+ ( p_string VARCHAR2 )
+ RETURN VARCHAR2
+IS
+BEGIN
+ RETURN UPPER(p_string);
+END test_uppercase;
+{% endhighlight %}
+
+If you are using ruby-oci8 library to connect to Oracle then you can call this PL/SQL procedure from Ruby in the following way (more details can be found in <a href="http://ruby-oci8.rubyforge.org/en/api.html">ruby-oci8 documentation</a>):
+
+{% highlight ruby %}
+conn = OCI8.new("hr","hr","xe")
+cursor = conn.parse <<-EOS
+BEGIN
+ :return := test_uppercase(:p_string);
+END;
+EOS
+cursor.bind_param(':p_string',"xxx",String)
+cursor.bind_param(':return',nil,String,4000)
+cursor.exec
+puts cursor[':return']
+cursor.close
+{% endhighlight %}
+
+This does not look like Ruby-style as it is too long and complex code which just calls one simple PL/SQL function :(
+
+Wouldn't it be much nicer if you could get the same result with the following code?
+
+{% highlight ruby %}
+plsql.connection = OCI8.new("hr","hr","xe")
+puts plsql.test_uppercase('xxx')
+{% endhighlight %}
+
+This idea served as inspiration to create ruby-plsql gem which would provide such nice Ruby API to access existing PL/SQL procedures and functions. Here are other examples how you can use it.
+
+Call procedure with named parameters:
+
+{% highlight ruby %}
+plsql.test_uppercase(:p_string => 'xxx')
+{% endhighlight %}
+
+Call procedure with specified schema:
+
+{% highlight ruby %}
+plsql.hr.test_uppercase('xxx')
+{% endhighlight %}
+
+Call procedure from specified package in specified schema:
+
+{% highlight ruby %}
+plsql.hr.test_package.test_uppercase('xxx')
+{% endhighlight %}
+
+Call procedure with output arguments:
+
+{% highlight ruby %}
+plsql.test_copy("abc", nil, nil) # returns output arguments { :p_to => "abc", :p_to_double => "abcabc" }
+{% endhighlight %}
+
+To install this gem execute
+
+pre(terminal). sudo gem install ruby-plsql
+
+As I mentioned before it also requires ruby-oci8 library to access Oracle. I have plans to create JRuby / JDBC support in the future versions of this gem.
+
+Current limitation is that this API support just NUMBER, VARCHAR2, DATE and TIMESTAMP types for PL/SQL procedures which are dynamically mapped to Ruby Fixnum/Bignum/Float, String, DateTime and Time types.
+
+If you find this gem interesting then please let me know in comments what additional features you would like to have for it.
11 _posts/2008-04-03-my-presentation-on-using-ruby-with-oracle-at-euruko-conference.textile
@@ -0,0 +1,11 @@
+---
+layout: post
+title: My presentation on using Ruby with Oracle at Euruko conference
+tags: ruby conference oracle
+---
+
+I gave short presentation about "Using Ruby with Oracle" at European Ruby conference <a href="http://www.euruko2008.org/">Euruko 2008</a>. You can <a href="http://www.euruko2008.org/system/assets/documents/0000/0009/simanovskis-using-ruby-with-oracle-euruko2008.pdf">download presentation slides at their site</a>. My collegue took a video of my presentation so probably after some time I will post it as well :)
+
+Either because of this presentation or maybe just because more people are interested in Ruby on Oracle the number of visits to this blog is fast growing during the last days. Which makes me more motivated to do more investigations in Ruby and Oracle area.
+
+One area of further research could be standardization of different ActiveRecord Oracle adapter patches - otherwise now I have different patches in each project and this becomes quite hard to manage.
11 _posts/2008-04-05-video-from-euruko-2008.textile
@@ -0,0 +1,11 @@
+---
+layout: post
+title: Video from Euruko 2008
+tags: conferences ruby
+---
+
+I made <a href="http://ruby.lv/files/Euruko_2008.m4v">short video from Euruko 2008 conference</a> where you can see Matz, Koichi, JRuby guys, DrNic ar me as well :)
+
+<object width="400" height="330" type="application/x-shockwave-flash" data="http://video.google.com/googleplayer.swf?docId=-1237678620877495277"><param name="allowScriptAccess" value="never"><param name="movie" value="http://video.google.com/googleplayer.swf?docId=-1237678620877495277"><param name="quality" value="best"><param name="bgcolor" value="#ffffff"><param name="scale" value="noScale"><param name="wmode" value="opaque"></object>
+
+I posted my presentation slides in my <a href="/2008/04/03/my-presentation-on-using-ruby-with-oracle-at-euruko-conference/">previous post</a>.
70 _posts/2008-04-24-how-to-setup-ruby-and-new-oracle-instant-client-on-leopard.textile
@@ -0,0 +1,70 @@
+---
+layout: post
+title: How to setup Ruby and new Oracle Instant Client on Leopard
+tags: ruby oracle mac
+---
+
+bq(warning). UPDATE: <a href="http://blog.rayapps.com/2009/09/06/how-to-setup-ruby-and-oracle-instant-client-on-snow-leopard/">New version of instructions for Snow Leopard is available here.</a>
+
+h3. Introduction
+
+We waited for it long, long time and finally it has arrived - <a href="http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/intel_macsoft.html">Oracle Instant Client for Intel Mac</a>. I was lucky to test beta version of the client already for the last couple of weeks and so far everything was working OK. Therefore as the final version is now available to everybody I am here rewriting <a href="http://blog.rayapps.com/2007/08/27/how-to-setup-ruby-and-oracle-client-on-intel-mac/">my previous instructions</a> on how to get Ruby working with Oracle on Mac.
+
+h3. Installing Oracle Instant Client for Intel Mac
+
+At first you need to <a href="http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/intel_macsoft.html">download Oracle Instant Client for Intel Mac</a>. Download "Instant Client Package - Basic" and "Instant Client Package - SDK" and also I suggest "Instant Client Package - SQL*Plus" if you would like to have command line sqlplus utility.
+
+Unzip downloaded archives and move it where you would like to have it - I am keeping it in /usr/local/oracle/instantclient_10_2. Then go to this directory and make symbolic links for dynamic libraries
+
+pre(terminal). sudo ln -s libclntsh.dylib.10.1 libclntsh.dylib
+sudo ln -s libocci.dylib.10.1 libocci.dylib
+
+Then I recommend to create and place somewhere your tnsnames.ora file where you will keep your database connections definitions - I place this file in directory /usr/local/oracle/network/admin.
+
+Then finally you need to set up necessary environment variables - I place the following definitions in my .bash_profile script:
+
+{% highlight sh %}
+export DYLD_LIBRARY_PATH="/usr/local/oracle/instantclient_10_2"
+export SQLPATH="/usr/local/oracle/instantclient_10_2"
+export TNS_ADMIN="/usr/local/oracle/network/admin"
+export NLS_LANG="AMERICAN_AMERICA.UTF8"
+export PATH=$PATH:$DYLD_LIBRARY_PATH
+{% endhighlight %}
+
+Use your path to Oracle Instant Client if it differc from /usr/local/oracle/instantclient_10_2. And as you see I also define NLS_LANG environment variable - this is necessary if your database is not in UTF8 encoding but in Ruby you want to get UTF-8 encoded strings from the database. Specifying this NLS_LANG environment variable you will force that Oracle Instant Client will do character set translation.
+
+After these steps relaunch Terminal application (so that new environment variables are set), specify database connection in tnsnames.ora file and try if you can access your database with sqlplus from command line.
+
+h3. Ruby installation
+
+If you are using Leopard then I assume that you are using preinstalled Ruby which is the simplest option. I tried to compile Ruby from sources on Mac OS X Leopard but when I compared performance then original Ruby was a little bit faster on some benchmarks and therefore I sticked with original one.
+
+h3. Compile and install ruby-oci8
+
+Download the latest version of <a href="http://rubyforge.org/projects/ruby-oci8/">ruby-oci8</a> (version 1.0.0 at time of writing this post).
+
+As Oracle Instant Client is available just for Intel i386 architecture you need to change in file /usr/lib/ruby/1.8/universal-darwin9.0/rbconfig.rb line 17 to:
+
+{% highlight ruby %}
+'-arch i386'
+{% endhighlight %}
+
+Then go to directory where you extracted ruby-oci8 source and execute ruby-oci8 standard installation sequence:
+
+pre(terminal). ruby setup.rb config
+make
+sudo make install
+
+After that you can change back file /usr/lib/ruby/1.8/universal-darwin9.0/rbconfig.rb line 17 to:
+
+{% highlight ruby %}
+'-arch ppc -arch i386'
+{% endhighlight %}
+
+Now try
+
+pre(terminal). ruby -r oci8 -e "OCI8.new('scott', 'tiger','orcl').exec('select * from emp') do |r| puts r.join(','); end"
+
+or similar to verify that you can access Oracle database from ruby.
+
+That's it! Please write in comments if something is not working according to these instructions.
9 ...8-05-04-session-proposal-for-oow-using-ruby-on-rails-with-oracle-e-business-suite.textile
@@ -0,0 +1,9 @@
+---
+layout: post
+title: Session proposal for OOW - Using Ruby on Rails with Oracle E-Business Suite
+tags: conference oracle ruby rails
+---
+
+<a href="https://mix.oracle.com/ideas/27038-using-ruby-on-rails-with-oracle-e-business-suite"><img src="/images/oow-submit-session.png" alt="OOW_submit_session.png" border="0" width="317" height="179" align="right" /></a><a href="https://mix.oracle.com/">mix.oracle.com</a> team created opportunity to <a href="http://oracleappslab.com/2008/05/02/suggest-a-session-topic-for-openworld/">suggest and vote for sessions</a> at Oracle OpenWorld conference. Therefore I will also try this opportunity and will suggest topic which is covered by many posts in this blog - I proposed session <a href="https://mix.oracle.com/ideas/27038-using-ruby-on-rails-with-oracle-e-business-suite">Using Ruby on Rails with Oracle E-Business Suite</a>.
+
+So if you would like me to present this topic in <a href="http://www.oracle.com/openworld/2008/index.html">Oracle OpenWorld conference</a> then please <a href="https://mix.oracle.com/ideas/27038-using-ruby-on-rails-with-oracle-e-business-suite">go to mix.oracle.com and vote for it</a>!
41 _posts/2008-05-13-activerecord-oracle-enhanced-adapter.textile
@@ -0,0 +1,41 @@
+---
+layout: post
+title: ActiveRecord Oracle enhanced adapter
+tags: oracle_enhanced ruby rails oracle
+---
+
+In all Ruby on Rails on Oracle projects where I am using original ActiveRecord Oracle adapter I always create some "monkey patches" of Oracle adapter to support my needs. I have written about several of these patches in this blog (see <a href="/2008/01/26/make-rails-database-migrations-faster-on-oracle/">1</a>, <a href="/2008/01/08/fix-for-rails-20-on-oracle-with-database-session-store/">2</a>, <a href="/2007/11/16/some-issues-with-oracle-views-as-activerecord-source/">3</a>).
+
+As such monkey patches are not easily maintainable and reusable between projects I decided to fork existing Oracle adapter and create my own ActiveRecord Oracle "enhanced" adapter where I will add all my enhancements.
+
+Today I released first version (1.1.0) of Oracle enhanced adapter on <a href="http://rubyforge.org/projects/oracle-enhanced/">RubyForge</a> as well as source code is available at <a href="http://github.com/rsim/oracle-enhanced">GitHub</a>.
+
+To install Oracle enhanced adapter execute (should be available soon):
+
+pre(terminal). sudo gem install activerecord-oracle_enhanced-adapter
+
+To use it you need to use "oracle_enhanced" as the adapter name in database.yml configuration file instead of "oracle". In addition I recommend to create config/initializers/oracle_enhanced.rb file where to put any adapter configuration options that you can see below.
+
+Initial version contains the following enhancements:
+
+* Improved perfomance of schema dump methods when used on large data dictionaries
+* Added LOB writing callback for sessions stored in database (see <a href="http://blog.rayapps.com/2008/01/08/fix-for-rails-20-on-oracle-with-database-session-store/">previous post</a>)
+* Added emulate_dates_by_column_name option
+Set the option below and as a result columns with DATE in their name will be emulated as Date (and not as Time which is default for DATE columns in database)
+{% highlight ruby %}
+ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
+{% endhighlight %}
+* Added emulate_integers_by_column_name option
+Set the option below and as a result number columns with ID at the end of column always will be emulated as Fixnum (useful if in legacy database column type is specified just as NUMBER without precision information which by default is mapped to BigDecimal Ruby type)
+{% highlight ruby %}
+ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
+{% endhighlight %}
+* Added emulate_booleans_from_strings option
+Set the option below and as a result CHAR(1), VARCHAR2(1) columns or VARCHAR2 columns with FLAG or YN at the end of their name will be emulated as booleans (and "Y" and "N" will be used to store true and false values). This is useful for legacy databases where Rails default convention of NUMBER(1) for boolean values cannot be used (e.g. if you are using Oracle E-Business Suite where booleans are stored as "Y" and "N").
+{% highlight ruby %}
+ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
+{% endhighlight %}
+
+If you need to override how date, integer or boolean columns are identified then you can redefine class methods is_date_column?, is_integer_column? and is_boolean_column? definitions in OracleEnhancedAdapter class.
+
+Please comment if you find these enhancements useful in your projects and also what other Oracle adapter enhancements you need in your Ruby on Rails on Oracle projects.
53 _posts/2008-05-21-using-mod_rails-with-rails-applications-on-oracle.textile
@@ -0,0 +1,53 @@
+---
+layout: post
+title: Using mod_rails with Rails applications on Oracle
+tags: ruby rails oracle apache
+---
+
+As many others I also got interested in new <a href="http://modrails.com/">mod_rails</a> deployment solution for Rails applications. And when I read <a href="http://nubyonrails.com/articles/ask-your-doctor-about-mod_rails">how to use it for development environment needs</a> I decided to try it out.
+
+As you probably know I am using Mac for development and using Oracle database for many Rails applications. So if you do it as well then at first you need to <a href="http://blog.rayapps.com/2008/04/24/how-to-setup-ruby-and-new-oracle-instant-client-on-leopard/">setup Ruby and Oracle on your Mac</a>.
+
+After that I installed and did setup of mod_rails according to <a href="http://www.fngtps.com/2008/04/using-passenger-on-osx-for-rails-development">these instructions</a> and <a href="http://nubyonrails.com/articles/ask-your-doctor-about-mod_rails">these additional notes</a>.
+
+One additional thing that I had to do was to change the user which will be used to run Apache httpd server as otherwise default www user did not see my Rails applications directories. You should do it in /etc/apache2/httpd.conf:
+
+{% highlight apache %}
+User yourusername
+Group yourusername
+{% endhighlight %}
+
+And then I started to fight with the issue that ruby which was started from mod_rails could not load ruby-oci8 library as it could not find Oracle Instant Client shared library. And the reason for that was that mod_rails launched ruby with very minimal list of environment variables. E.g. as DYLD_LIBRARY_PATH environment variable was not specified then ruby-oci8 could not find Oracle Instant Client libraries.
+
+The issue is that there is no documented way how to pass necessary environment variables to mod_rails. Unfortunately mod_rails is ignoring SetEnv settings from Apache httpd.conf file. Therefore I needed to find some workaround for the issue and finally I did the following solution.
+
+I created executable script file /usr/local/bin/ruby_with_env:
+
+{% highlight sh %}
+#!/bin/bash
+export DYLD_LIBRARY_PATH="/usr/local/oracle/instantclient_10_2:$DYLD_LIBRARY_PATH"
+export SQLPATH=$DYLD_LIBRARY_PATH
+export TNS_ADMIN="/usr/local/oracle/network/admin"
+export NLS_LANG="AMERICAN_AMERICA.UTF8"
+/usr/bin/ruby $*
+{% endhighlight %}
+
+and then in Apache httpd.conf file I changed RailsRuby line to
+
+{% highlight apache %}
+RailsRuby /usr/local/bin/ruby_with_env
+{% endhighlight %}
+
+As a result in this way I was able to specify necessary environment variables before Ruby and Rails was started and after this change ruby-oci8 libraries were successfully loaded.
+
+You can use this solution also on Linux hosts where you will deploy Rails applications in production.
+
+Currently I still have issue with mod_rails that it fails to execute RMagick library methods (which is compiled with ImageMagick). I get strange errors in Apache error_log:
+
+{% highlight text %}
+The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
+Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
+[error] [client ::1] Premature end of script headers:
+{% endhighlight %}
+
+When I was running the same application with Mongrel then everything was running correctly. If anyone has any ideas what could be the reason please write some comment.
25 _posts/2008-06-26-ruby-plsql-gem-now-supports-jruby-and-oracle-jdbc-driver.textile
@@ -0,0 +1,25 @@
+---
+layout: post
+title: ruby-plsql gem now supports JRuby and Oracle JDBC driver
+tags: ruby-plsql ruby oracle plsql
+---
+
+Some time ago I created <a href="/2008/03/15/ruby-plsql-gem-simple-ruby-api-for-plsql-procedures/">ruby-plsql gem</a> which provides simple Ruby API for Oracle PL/SQL stored procedures.
+
+Initially this gem supported just MRI with ruby-oci8 library which provides connectivity to Oracle database as this was my main development and production environment for Ruby & Oracle applications. But as <a href="http://jruby.codehaus.org/">JRuby</a> is fast growing alternative Ruby deployment platform and as it can be integrated into Oracle Fusion middleware platform (e.g. <a href="https://mix.oracle.com/">Oracle Mix</a> is running on JRuby on Oracle Fusion middleware) then I planned to support JRuby as well.
+
+I started to work on JRuby support during <a href="http://headius.blogspot.com/2008/05/jruby-pre-railsconf-hackfest-on.html">RailsConf JRuby hackfest</a> and initially this did not seem very hard task for me. But as I did not know JDBC very well it took me much more time than initially planned. And unfortunately JDBC is also much less powerful compared to ruby-oci8 library for construction of dynamic PL/SQL calls. In addition I needed to strugle with Ruby and JDBC data type mappings which differs from Ruby and ruby-oci8 data type mappings.
+
+But finally I have completed JRuby support and released <a href="http://rubyforge.org/frs/?group_id=5816&release_id=23386">ruby-plsql gem version 0.2.0</a>. And good news are that from usage perspective ruby-plsql behaves identically on MRI and JRuby - at least my RSpec tests are telling so.
+
+To install this gem on JRuby execute
+
+pre(terminal). sudo jruby -S gem install ruby-plsql
+
+or
+
+pre(terminal). sudo jgem install ruby-plsql
+
+depending on how you have installed JRuby on your computer.
+
+Source code of ruby-plsql is located on <a href="http://github.com/rsim/ruby-plsql">GitHub</a> where you can find usage examples in RSpec tests.
38 _posts/2008-06-28-activerecord-oracle-enhanced-adapter-version-111-released.textile
@@ -0,0 +1,38 @@
+---
+layout: post
+title: ActiveRecord Oracle enhanced adapter version 1.1.1 released
+tags: oracle_enhanced ruby rails oracle
+---
+
+I just released <a href="http://rubyforge.org/frs/?group_id=6212&release_id=23422">new version</a> of <a href="http://blog.rayapps.com/2008/05/13/activerecord-oracle-enhanced-adapter/">ActiveRecord Oracle enhanced adapter</a> which includes several new enhancements which could be useful if you use ActiveRecord with legacy Oracle databases:
+
+* Added ignore_table_columns option for class definitions
+You can specify which table (or view) columns should be ignored by ActiveRecord - these could be either columns which you do not need in Rails application or which have currently unsupported data types. For example:
+{% highlight ruby %}
+class Employee < ActiveRecord::Base
+ ignore_table_columns :phone_number, :hire_date
+end
+{% endhighlight %}
+* Added support for TIMESTAMP columns
+You can create tables with :timestamp data type which will create TIMESTAMP columns and you can access values from TIMESTAMP columns. Unfortunately due to current ruby-oci8 limitations when you will retrieve TIMESTAMP values it will be without fractional seconds (but if you pass Time value with fractional seconds then it will be stored in database).
+* NLS_DATE_FORMAT and NLS_TIMESTAMP_FORMAT independent DATE and TIMESTAMP columns support
+By default Oracle adapter (and enhanced adapter as well) changes NLS_DATE_FORMAT and NLS_TIMESTAMP_FORMAT to 'DD-MON-YYYY HH24:MI:SS'. But if you are working with some legacy database which requires different NLS date settings then now you can change these settings to different ones. You can put in some initialization file some other NLS settings, e.g.:
+{% highlight ruby %}
+ActiveRecord::Base.connection.execute %q{alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS'}
+ActiveRecord::Base.connection.execute %q{alter session set nls_timestamp_format = 'DD-MON-YYYY HH24:MI:SS'}
+{% endhighlight %}
+and ActiveRecord will continue to work correctly with date values.
+
+Also one Rails 2.1 related issue was solved. Previously Oracle enhanced adapter always added after_save callback to ActiveRecord session store which stores BLOB data in the database (as in Rails 2.0 there was issue that this callback was not added). Now in Rails 2.1 this callback is added by ActiveRecord therefore Oracle enhanced adapter checks if this callback is already added or not. So now this should work correctly both in Rails 2.0 and Rails 2.1.
+
+Also I have noticed that in some Rails 2.1 applications Oracle adapter is failing on ActiveRecord session store updates when partial updates are enabled. If you also have such issue then put this into your initialization file which will work as workaround until I will find what is causing this problem:
+
+{% highlight ruby %}
+CGI::Session::ActiveRecordStore::Session.partial_updates = false
+{% endhighlight %}
+
+To get the new release just do:
+
+pre(terminal). sudo gem install activerecord-oracle_enhanced-adapter
+
+Source code of Oracle enhanced adapter is located at <a href="http://github.com/rsim/oracle-enhanced">GitHub</a>. And you can submit bug reports and enhancement requests in <a href="http://rsim.lighthouseapp.com/projects/11468-oracle-enhanced/tickets">Lighthouse</a>. There you can see also some identified enhancements - please add comments to them if you also would like to have them. Then it will be easier for me to select what to include in next version of adapter.
9 _posts/2008-07-08-vote-for-my-session-proposal-at-oracle-openworld.textile
@@ -0,0 +1,9 @@
+---
+layout: post
+title: Vote for my session proposal at Oracle OpenWorld
+tags: oracle conference ruby rails
+---
+
+<a href="https://mix.oracle.com/ideas/27038-using-ruby-on-rails-with-oracle-e-business-suite"><img src="/images/oow.png" alt="oow.png" border="0" width="107" height="114" align="right" /></a>If you still have not voted for my session proposal <a href="https://mix.oracle.com/ideas/27038-using-ruby-on-rails-with-oracle-e-business-suite">"Using Ruby on Rails with Oracle E-Business Suite"</a> then please do so :) Voting deadline is near - July 13th.
+
+In any case I am going to be at <a href="http://www.oracle.com/openworld/2008/index.html">Oracle OpenWorld conference</a> in San Francisco in September. So if some of my blog readers will also be there and would like to have some chat with me about Oracle and Ruby then please let me know.
106 ...2008-07-10-custom-activerecord-create-add-and-delete-methods-for-legacy-databases.textile
@@ -0,0 +1,106 @@
+---
+layout: post
+title: Custom ActiveRecord create, add and delete methods for legacy databases
+tags: oracle_enhanced ruby rails oracle ruby-plsql
+---
+
+In some Ruby on Rails projects I am putting ActiveRecord interface on top of existing legacy databases. It is quite easy to specify legacy table names and primary keys in ActiveRecord models so that ActiveRecord would generate correct SQL SELECT statements to read data from legacy databases.
+
+But it is more difficult to insert, update and delete in legacy databases using ActiveRecord. When using Oracle legacy databases then quite often they have exposed PL/SQL APIs for writing to tables and you are typically not allowed to directly modify tables with INSERT, UPDATE and DELETE statements.
+
+Therefore I created support for custom create, update and delete methods in the <a href="http://rubyforge.org/frs/?group_id=6212&release_id=23785">version 1.1.3 of ActiveRecord Oracle enhanced adapter</a> which uses also my <a href="http://github.com/rsim/ruby-plsql">ruby-plsql gem</a>.
+
+Let's look at the following example. Assume that we have the following table:
+
+{% highlight sql %}
+CREATE TABLE test_employees (
+ employee_id NUMBER(6,0),
+ first_name VARCHAR2(20),
+ last_name VARCHAR2(25),
+ hire_date DATE,
+ salary NUMBER(8,2),
+ version NUMBER(15,0),
+ create_time DATE,
+ update_time DATE
+)
+{% endhighlight %}
+
+And we have the following PL/SQL API package that should be used to write to this table:
+
+{% highlight sql %}
+CREATE OR REPLACE PACKAGE test_employees_pkg IS
+ PROCEDURE create_employee(
+ p_first_name VARCHAR2,
+ p_last_name VARCHAR2,
+ p_hire_date DATE,
+ p_salary NUMBER,
+ p_employee_id OUT NUMBER);
+ PROCEDURE update_employee(
+ p_employee_id NUMBER,
+ p_first_name VARCHAR2,
+ p_last_name VARCHAR2,
+ p_hire_date DATE,
+ p_salary NUMBER);
+ PROCEDURE delete_employee(
+ p_employee_id NUMBER);
+END;
+{% endhighlight %}
+
+Then we define ActiveRecord model in the following way:
+
+{% highlight ruby %}
+class TestEmployee < ActiveRecord::Base
+ set_primary_key :employee_id
+ # should return ID of new record
+ set_create_method do
+ plsql.test_employees_pkg.create_employee(
+ :p_first_name => first_name,
+ :p_last_name => last_name,
+ :p_hire_date => hire_date,
+ :p_salary => salary,
+ :p_employee_id => nil
+ )[:p_employee_id]
+ end
+ # return value is ignored
+ set_update_method do
+ plsql.test_employees_pkg.update_employee(
+ :p_employee_id => id,
+ :p_first_name => first_name,
+ :p_last_name => last_name,
+ :p_hire_date => hire_date,
+ :p_salary => salary
+ )
+ end
+ # return value is ignored
+ set_delete_method do
+ plsql.test_employees_pkg.delete_employee(
+ :p_employee_id => id
+ )
+ end
+end
+{% endhighlight %}
+
+And as a result we can use this model in the same way as other ActiveRecord models:
+
+{% highlight ruby %}
+@employee = TestEmployee.create(
+ :first_name => "First",
+ :last_name => "Last",
+ :hire_date => Date.today
+)
+@employee.reload
+@employee.first_name = "Second"
+@employee.save!
+@employee.destroy
+{% endhighlight %}
+
+And all writing to the database will be done using defined API procedures.
+
+Currently this functionality is embedded into Oracle enhanced adapter but if somebody needs it also for other databases this functionality could easily be extraced from the adapter.
+
+To get the new release of Oracle enhanced adapter just do:
+
+pre(terminal). sudo gem install activerecord-oracle_enhanced-adapter
+
+Source code of Oracle enhanced adapter is located at <a href="http://github.com/rsim/oracle-enhanced">GitHub</a> and you can submit bug reports and enhancement requests in <a href="http://rsim.lighthouseapp.com/projects/11468-oracle-enhanced/tickets">Lighthouse</a>.
+
13 _posts/2008-07-25-screencast-of-oracle-e-business-suite-setup-management-tool.textile
@@ -0,0 +1,13 @@
+---
+layout: post
+title: Screencast of Oracle E-Business Suite setup management tool
+tags: oracle screencast
+---
+
+<img src="/images/urra.png" alt="URRA.png" border="0" width="260" height="156" align="right" />**Warning:** this post will be unrelatead to Ruby :)
+
+For many years our company is using <a href="http://www.it-alise.com/en/solutions/urra">tool for Oracle E-Business Suite setup management</a> that we initially built for our own purposes but now also we are offering to other Oracle partners and customers.
+
+As I was bored to do demonstrations of it over and over again I finally decided to create a <a href="http://www.it-alise.com/files/URRA_demo.mov">screencast of this tool</a> (it's 22 MB large). And I think that my first experiment in screencasting is not too bad :)
+
+Previously screencasting was quite hard stuff as there was not so many good tools for that. In this case I used <a href="http://www.varasoftware.com/products/screenflow/">ScreenFlow</a> tool which was released this year (and is available just on Mac OS X Leopard) and I have to say that it is much more better and easier compared to any other tools that I have seen earlier. So I am strongly recommending it to others who are interested in screencasting.
19 _posts/2008-07-27-latest-additions-to-oracle-enhanced-adapter.textile
@@ -0,0 +1,19 @@
+---
+layout: post
+title: Latest additions to Oracle enhanced adapter
+tags: oracle_enhanced ruby rails oracle
+---
+
+Short information about latest enhancements in ActiveRecord Oracle enhanced adapter:
+
+* Oracle enhanced adapter is now compatible with <a href="http://compositekeys.rubyforge.org/">composite_primary_keys gem</a> which is quite useful if you are working with legacy databases.
+* Adapter now is also working correctly with Rails 2.1 partial_updates enabled. Previously I mentioned that you needed to disable partial_updates when using CLOB/BLOB columns. Now the issue is found and fixed and partial_updates are working with CLOB/BLOB columns.
+* Support for other date and time formats when assigning string to :date or :datetime column. For example, if you would like to assign strings with format dd.mm.yyyy to date and datetime columns then add the following configuration options:
+{% highlight ruby %}
+ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.string_to_date_format = "%d.%m.%Y"
+ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.string_to_time_format = "%d.%m.%Y %H:%M:%S"
+{% endhighlight %}
+
+To get the new release of Oracle enhanced adapter do as always:
+
+pre(terminal). sudo gem install activerecord-oracle_enhanced-adapter
15 _posts/2008-09-06-oracle-enhanced-adapter-presentation-at-rejectconf-in-berlin.textile
@@ -0,0 +1,15 @@
+---
+layout: post
+title: Oracle enhanced adapter presentation at RejectConf in Berlin
+tags: oracle_enhanced ruby rails conference oracle
+---
+
+<div style="text-align:center;"><img src="/images/rejectconf08.jpg" alt="rejectconf08.jpg" border="0" width="400" height="315" /></div>
+
+I just returned from <a href="http://en.oreilly.com/railseurope2008/public/content/home">RailsConf Europe</a> in Berlin and attended a lot of good Ruby and Rails related sessions.
+
+I also tried to submit there my session proposal about using Rails with Oracle but as there were too many good proposals and as my topic was with too narrow topic then it was not accepted. Therefore I used opportunity to give 5 minutes presentation about Oracle enhanced adapter in <a href="http://www.rug-b.com/trac/wiki/RejectConf">RejectConf</a> where anybody could present anything.
+
+<a href="/files/rejectconf-oracle-enhaced-adapter.pdf" title="rejectconf_oracle_enhaced_adapter.pdf">Here are my slides</a> that I used in this presentation. And at least one participant was interested in this topics as he uses Rails and Oracle and did not know about my adapter.
+
+My next public appearance is planned at <a href="http://wiki.oracle.com/page/Oracle+OpenWorld+Unconference">Oracle OpenWorld unconference</a> where I have recerved time slot on Thursday, September 25th at 10am. Please come there if you are attending Oracle OpenWorld and are interested in how to use Ruby on Rails with your legacy Oracle databases.
21 _posts/2008-09-22-coding-or-drag-and-droping.textile
@@ -0,0 +1,21 @@
+---
+layout: post
+title: Coding or drag-and-dropping?
+tags: oracle conference
+---
+
+Today was my first day at Oracle OpenWorld and here are my first impressions from the sessions I attended.
+
+The first one was _Building Web 2.0 Social Applications in Ruby on Rails with BEA AquaLogic Interaction_ by <a href="http://blog.thebdgway.com/">Chris Bucchere</a> where he explained how they built social application for BEA conference participants. And it was interesting to see also some code examples from this application that he presented.
+
+<div style="text-align:center;"><img src="/images/drag-and-drop.gif" alt="drag_and_drop.gif" border="0" width="320" height="186" /></div>
+
+And then after that I participated in three Oracle Develop hands-on sessions about <a href="http://www.oracle.com/technologies/soa/soa-suite.html">Oracle SOA suite</a> and <a href="http://www.oracle.com/technology/products/webcenter/index.html">WebCenter</a>. I signed up for these sessions because I thought that they will be more technical and code-intensive compared to other sessions.
+
+As a result I spent three hours in Oracle JDeveloper but all I was doing was dragging-and-dropping and filling some pop-up dialog boxes. I did not write single line of Java code during these workshops. And as a result I had just vague idea why all the dragged components worked together.
+
+Having experience of coding in Ruby and trying to create small and beautiful code this drag-and-drop development did not feel quite natural for me. And I am afraid that this drag-and-drop development approach will create bunch of developers who will not be able to create real code anymore.
+
+The other consequences of this drag-and-drop style coding is that it is hard to version control the resulting generated code and it is also much harder to unit test such generated code. Probably this is the reason why I could not find any OpenWorld session about unit testing and test-driven development.
+
+Am I missing some hidden beauty of drag-and-drop development? Or am I spoiled with beauty of Ruby?
17 _posts/2008-09-24-some-positive-drag-and-drop-experience.textile
@@ -0,0 +1,17 @@
+---
+layout: post
+title: Some positive drag-and-drop experience
+tags: oracle conference
+---
+
+In the <a href="/2008/09/22/coding-or-drag-and-droping/">previous post</a> I wrote that I didn't quite like drag-and-drop development style in JDeveloper that I experienced during Oracle OpenWorld hands-on session.
+
+<div style="text-align:center;"><img src="/images/oracle-bi.png" alt="oracle_bi.png" border="0" width="640" height="279" /></div>
+
+Today I was in <a href="http://www.oracle.com/technology/products/bi/enterprise-edition.html">Oracle BI Answers & Dashboard</a> hands-on session and during this session I was also drag-and-dropping to create reports, charts and business intelligence dashboards. But in this case I liked it as it seemed natural way how to create such reports.
+
+The main difference why I liked it was that I got immediate feedback how the end report will look like - after each change I could immediately see and test real report with real data. And such immediate feedback is key prerequisite for interactive analytical reporting development.
+
+In JDeveloper case I needed to compile and build everything and restart local application server after each change to see real results from any change - and it took at least 10 seconds for just sample "hello world" application. I assume that this lag will be even longer in larger real projects. Probably it is not so long time but when you compare it to 1 second feedback time then anything larger seems long.
+
+I also visited Oracle demo grounds where I discussed my concerns regarding JDeveloper drag-and-drop development style. At the end we reached common understanding that JDeveloper and ADF framework is really good for former Oracle Forms developers who do not want to learn HTML, CSS and Javascript and auto-generated applications could be quite OK for internal enterprise applications. But if you want to build advanced web applications you still need to learn and be expert in these web technologies (HTML, CSS and Javascript).
18 _posts/2008-09-26-openworld-unconference-presentation-about-rails-on-oracle.textile
@@ -0,0 +1,18 @@
+---
+layout: post
+title: OpenWorld unconference presentation about Rails on Oracle
+tags: oracle conference ruby rails oracle
+---
+
+On last day of Oracle OpenWorld I did my <a href="http://wiki.oracle.com/page/Oracle+OpenWorld+Unconference">unconference</a> presentation - Using Ruby on Rails with legacy Oracle databases.
+
+As I did not know if anyone will come to listen to it I was glad that six people attended (including <a href="http://db360.blogspot.com/">Kuassi Mensah</a> from Oracle who is helping to promote Ruby support inside Oracle). And on the previous day I also managed to show parts of my presentation to Rich and Anthony from <a href="http://theappslab.com/">Oracle AppsLab</a> team.
+
+I published my slides on Slideshare:
+<div style="text-align:center;"><object id="__sse619018" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=using-rails-with-legacy-oracle-db-1222386749548113-9&stripped_title=using-ruby-on-rails-with-legacy-oracle-databases-presentation" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse619018" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=using-rails-with-legacy-oracle-db-1222386749548113-9&stripped_title=using-ruby-on-rails-with-legacy-oracle-databases-presentation" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></div>
+
+And I published <a href="http://github.com/rsim/legacy_oracle_sample">my demo project</a> on GitHub:
+
+<div style="text-align:center;"><img src="/images/hr-schema-demo.png" border="0" alt="hr_schema_demo.png" width="640" height="231" /></div>
+
+Thanks to all Oracle people who recognize my work on Ruby and Oracle integration and I hope that our common activities will increase number of Ruby and Rails projects on Oracle :)
158 _posts/2008-12-02-ntlm-windows-domain-authentication-for-rails-application.textile
@@ -0,0 +1,158 @@
+---
+layout: post
+title: NTLM Windows domain authentication for Rails application
+tags: ntlm windows rails apache authentication
+---
+
+h3. Introduction
+
+<img src="/images/railspluswindows.png" border="0" alt="RailsPlusWindows.png" width="239" height="96" align="right" />In one "enterprise" Ruby on Rails project we had an idea to integrate Windows domain user authentication with Rails application — as majority of users were using Windows and Internet Explorer and always were logged in Windows domain then it would be very good if they could log in automatically to the new Rails application without entering their username and password.
+
+Windows is using <a href="http://en.wikipedia.org/wiki/NTLM">NTLM protocol</a> to provide such functionality — basically it uses additional HTTP headers to negotiate authentication information between web server and browser. It is tightly integrated into Microsoft Internet Information Server and if you live in pure Windows world then implementation of NTLM authentication is just a checkbox in IIS.
+
+But if you are using Ruby on Rails with Apache web server in front of it and running everything on Linux or other Unix then this is not so simple. Therefore I wanted to share my solution how I solved this problem.
+
+h3. mod_ntlm Apache module installation
+
+The first step is that we need NTLM protocol support for Apache web server so that it could handle Windows domain user authentication with web browser.
+
+The first thing I found was <a href="http://modntlm.sourceforge.net/">mod_ntlm</a>, but unfortunately this project is inactive for many years and do not have support for Apache 2.2 that I am using.
+
+The other option I found was <a href="http://adldap.sourceforge.net/wiki/doku.php?id=mod_auth_ntlm_winbind">mod_auth_ntlm_winbind</a> from Samba project but this solution requires Samba's winbind daemon on the same server which makes the whole configuration more complex and therefore I was not eager to do that.
+
+Then finally I found that someone has <a href="http://mywheel.net/blog/index.php/mod_ntlm2-on-apache-22x/">patched mod_ntlm to work with Apache 2.2</a> and this looked promising. I took this version of mod_ntlm but in addition I needed to make some additional patches to it and as a result I published <a href="http://github.com/rsim/mod_ntlm">my final mod_ntlm version in my GitHub repository</a>.
+
+If you would like to *install mod_ntlm module on Linux* then at first ensure that you have Apache 2.2 installed together with Apache development utilities (check that you have either apxs or apxs2 utility in your path). Then from the source directory of @mod_ntlm@ (that you downloaded from my GitHub repository) do:
+
+pre(terminal). apxs -i -a -c mod_ntlm.c
+
+If everything goes well then it should install @mod_ntlm.so@ module in the directory where all other Apache modules is installed. It also tries to add module load directive in Apache configuration file @httpd.conf@ but please check by yourself that you have
+
+{% highlight apache %}
+LoadModule ntlm_module ...directory.path.../mod_ntlm.so
+{% endhighlight %}
+
+line in your configuration file and directory path is the same as for other Apache modules. Try to restart Apache server to see if the module will be successfully loaded.
+
+I also managed to *install mod_ntlm on my Mac OS X Leopard* so that I could later test NTLM authentication locally. Installation on Mac OS X was a little bit more tricky as I needed to compile 64-bit architecture module to be able to load it with preinstalled Apache:
+
+pre(terminal). sudo ln -s /usr/include/malloc/malloc.h /usr/include/malloc.h
+sudo ln -s /usr/include/sys/statvfs.h /usr/include/sys/vfs.h
+apxs -c -o mod_ntlm.so -Wc,"-shared -arch i386 -arch x86_64" -Wl,"-arch i386 -arch x86_64" mod_ntlm.c
+sudo apxs -i -a -n 'ntlm' mod_ntlm.so
+
+After this check @/etc/apache2/httpd.conf@ file that it includes:
+
+{% highlight apache %}
+LoadModule ntlm_module libexec/apache2/mod_ntlm.so
+{% endhighlight %}
+
+and try to restart Apache with
+
+pre(terminal). sudo apachectl -k restart
+
+h3. mod_ntlm Apache module configuration
+
+The next thing is that you need to configure @mod_ntlm@. Put these configuration directories in the same place where you have your virtual host configuration directives related to your Rails application. Let's assume that we have domain "domain.com" with domain controllers "dc01.domain.com" and "dc02.domain.com". And let's use /winlogin as a URL which will be used for Windows domain authentication.
+
+{% highlight apache %}
+RewriteEngine On
+<Location /winlogin>
+ AuthName "My Application"
+ AuthType NTLM
+ NTLMAuth on
+ NTLMAuthoritative on
+ NTLMDomain domain.com
+ NTLMServer dc01.domain.com
+ NTLMBackup dc02.domain.com
+ require valid-user
+</Location>
+{% endhighlight %}
+
+@mod_ntlm@ will set @REMOTE_USER@ environment variable with authenticated Windows username. If we are using Mongrel servers cluster behind Apache web server then we need to add the following configuration lines to put @REMOTE_USER@ in HTTP header X-Forwarded-User of forwarded request to Mongrel cluster.
+
+{% highlight apache %}
+RewriteCond %{LA-U:REMOTE_USER} (.+)
+RewriteRule . - [E=RU:%1]
+RequestHeader add X-Forwarded-User %{RU}e
+{% endhighlight %}
+
+Please remember to put all previous configuration lines before any other URL rewriting directives. In my case I have the following configuration lines which will forward all non-static requests to my Mongrel servers cluster (which in my case have HAproxy on port 3000 before them):
+
+{% highlight apache %}
+# Redirect all non-static requests to haproxy
+RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
+RewriteRule ^/(.*)$ http://127.0.0.1:3000%{REQUEST_URI} [L,P,QSA]
+{% endhighlight %}
+
+h3. Rails sessions controller
+
+Now the final part is to handle authenticated Windows users in Rails sessions controller. Here are examples how I am doing this.
+
+routes.rb:
+
+{% highlight ruby %}
+map.winlogin 'winlogin', :controller => 'sessions', :action => 'create_from_windows_login'
+{% endhighlight %}
+
+sessions_controller.rb:
+
+{% highlight ruby %}
+def create_from_windows_login
+ if !(login = forwarded_user)
+ flash[:error] = "Browser did not provide Windows domain user name"
+ user = nil
+ elsif user = User.authenticated_by_windows_domain(login)
+ # user has access rights to system
+ else
+ flash[:error] = "User has no access rights to application"
+ end
+ self.current_user = user
+ if logged_in?
+ # store that next time automatic login should be made
+ cookies[:windows_domain] = {:value => 'true', :expires => Time.now + 1.month}
+ # Because of IE NTLM strange behavior need to give 401 response with Javascript redirect
+ @redirect_to = redirect_back_or_default_url(root_path)
+ render :status => 401, :layout => 'redirect'
+ else
+ render :action => 'new'
+ end
+end
+private
+ def forwarded_user
+ return nil unless x_forwarded_user = request.headers['X-Forwarded-User']
+ users = x_forwarded_user.split(',')
+ users.delete('(null)')
+ users.first
+ end
+{% endhighlight %}
+
+@User.authenticated_by_windows_domain@ is model method that either find existing or creates new user based on authenticated Windows username in parameter and checks that user has access rights. Private method forwarded_user extracts Windows username from HTTP header — in my case it always was formatted as "(null),username" therefore I needed to remove unnecessary "(null)" from it.
+
+In addition I am storing browser cookie that user used Windows domain authentication — it means that next time we can forward this user directly to @/winlogin@ instead of showing login page if user has this cookie. We cannot forward all users to @/winlogin@ as then for all users browser will prompt for Windows username and password (and probably we are also using other authentication methods).
+
+The last thing is that we need to do a little hack as a workaround for strange Internet Explorer behavior. If Internet Explorer has authenticated with some web server using NTLM protocol then IE will think that this web server will require NTLM authentication for all POST requests. And therefore it does "performance optimization" when doing POST requests to this web server — the first POST request from browser will have no POST data in it, just header with NTLM authentication message. In Rails application case we do not need these NTLM authentications for all POST requests as we are maintaining Rails session to identify logged in users. Therefore we are making this trick that after successful authentication we return HTTP 401 code which makes IE think that it is not authenticated anymore with this web server. But together with HTTP 401 code we return HTML page which forces client side redirect to home page either using JavaScript or
+
+create_from_windows_login.html.erb:
+
+{% highlight erb %}
+<% content_for :head do %>
+ <script language="javascript">
+ <!--
+ location.replace("<%= @redirect_to %>");
+ //-->
+ </script>
+ <noscript>
+ <meta http-equiv="Refresh" content="0; URL=<%= @redirect_to %>" />
+ </noscript>
+<% end %>
+<%= link_to 'Redirecting...', @redirect_to %>
+{% endhighlight %}
+
+@content_for :head@ is used to specify which additional content should be put in @<header>@ part of layout.
+
+As a result you now have basic Windows domain NTLM authentication working. Please let me know in comments if you have any issues with this solution or if you have other suggestions how to use Windows domain NTLM authentication in Rails applications.
+
+h3. Additional hints
+
+NTLM authentication can be used also in Firefox. Enter @about:config@ in location field and then search for @network.automatic-ntlm-auth.trusted-uris@. There you can enter servers for which you would like to use automatic NTLM authentication.
17 _posts/2009-01-03-more-information-sources-on-activerecord-oracle-enhanced-adapter.textile
@@ -0,0 +1,17 @@
+---
+layout: post
+title: More information sources on ActiveRecord Oracle enhanced adapter
+tags: oracle_enhanced ruby rails oracle
+---
+
+I'm glad to see that there are many users of <a href="http://github.com/rsim/oracle-enhanced">ActiveRecord Oracle enhanced adapter</a> and therefore comments in this blog is not anymore the best way how to communicate with Oracle enhanced adapter users. Therefore I created several other information exchange places which I hope will be more effective.
+
+The latest addition is <a href="http://github.com/rsim/oracle-enhanced/wikis">wiki pages on GitHub</a> where I put usage description and examples as well as some troubleshooting hints that previously were scattered in README file and different blog posts. This is the first place where to look for information about Oracle enhanced adapter. And if you are GitHub user then you can correct mistakes or add additional content also by yourself.
+
+If you have some question or you would like to discuss some feature then you can use <a href="http://groups.google.com/group/oracle-enhanced">Google discussion group</a>. I will use this discussion group also for new release announcements as well so subscribe to it if you would like to get Oracle enhanced adapter news.
+
+If you would like to report some bug or new feature (and patch would be greatly appreciated) then please use <a href="http://rsim.lighthouseapp.com/projects/11468-oracle-enhanced">Lighthouse issue tracker</a>.
+
+And source code of Oracle enhanced adapter is still located in <a href="http://github.com/rsim/oracle-enhanced">Github repository</a>. If you are GitHub user then you can watch it or even fork it and experiment with some new features.
+
+And BTW I just released <a href="http://groups.google.com/group/oracle-enhanced/browse_thread/thread/874e196fb3d76e89">Oracle enhanced adapter version 1.1.9</a> with some new features and it has been also tested with latest Rails 2.2 release.
23 _posts/2009-03-23-activerecord-oracle-enhanced-adapter-also-on-jruby-and-ruby-19.textile
@@ -0,0 +1,23 @@
+---
+layout: post
+title: ActiveRecord Oracle enhanced adapter also on JRuby and Ruby 1.9
+tags: oracle_enhanced ruby rails oracle
+---
+
+So far if you wanted to use Ruby on Rails on Oracle database you needed to use different adapters depending on the Ruby platform that you wanted to use. If you used original MRI (Matz Ruby interpreter) 1.8.6 then hopefully you were using Oracle enhanced adapter. But if you wanted to use JRuby then you needed to use JDBC adapter that is maintained by JRuby team (and which sometimes might work differently than Oracle enhanced adapter). And if you wanted to use new Ruby 1.9.1 then you were out of luck as no adapter supported it.
+
+Therefore I wanted to announce great news that *ActiveRecord Oracle enhanced adapter 1.2.0 is released* and it supports *all three major Ruby platforms!*
+
+* Use Oracle enhanced adapter on MRI 1.8.6 with ruby-oci8 1.0.x library or gem
+* Use Oracle enhanced adapter on JRuby (so far tested with 1.1.6) with JDBC Oracle driver
+* Use Oracle enhanced adapter on Ruby/YARV 1.9.1 with ruby-oci8 2.0 library or gem
+
+This provides you with much more flexibility to develop on one Ruby platform but deploy on another and on all three platforms you can use <a href="http://wiki.github.com/rsim/oracle-enhanced/usage">the same additional functionality</a> that Oracle enhanced adapter provides on top of standard ActiveRecord functionality.
+
+And during testing of Oracle enhanced adapter on all platforms additional milestone was achieved - *Oracle enhanced adapter passes 100% ActiveRecord unit tests!* But to be honest I need to tell that I needed to patch quite many unit tests for Oracle specifics as not all SQL that runs on MySQL is also valid on Oracle. I published my patched branch of ActiveRecord unit tests at my <a href="http://github.com/rsim/rails/tree/oracle_enhanced">GitHub fork of Rails</a> - you can clone the repository and verify by yourself.
+
+So please try out new version of Oracle enhanced adapter on any Ruby platform:
+
+pre(terminal). gem install activerecord-oracle_enahnced-adapter
+
+If you have any questions please use <a href="http://groups.google.com/group/oracle-enhanced">discussion group</a> or post comments here. In nearest future I will also add more instructions how to install Oracle enhanced adapter on JRuby and Ruby 1.9.1 at <a href="http://wiki.github.com/rsim/oracle-enhanced">GitHub wiki page</a>.
282 _posts/2009-04-12-how-to-install-oracle-database-10g-on-mac-os-x-intel.textile
@@ -0,0 +1,282 @@
+---
+layout: post
+title: How to install Oracle Database 10g on Mac OS X Intel
+tags: oracle database mac
+---
+
+bq(warning). UPDATE: <a href="http://blog.rayapps.com/2009/09/14/how-to-install-oracle-database-10g-on-mac-os-x-snow-leopard/">Created instructions how to install Oracle 10g on Mac OS X Snow Leopard</a>
+
+Couple days ago Oracle developers on Mac OS X received Easter present - finally <a href="http://www.oracle.com/technology/software/products/database/oracle10g/htdocs/10204macsoft_x86-64.html">Oracle Database 10g was released for Mac OS X 10.5 Intel platform</a>. This download includes installation guide for Mac OS X but as any Oracle installation guide it is quite long and contains a lot of unnecessary information for first time install as well as does not contain some necessary information.
+
+Therefore I am posting here my shorter tutorial how to install it. And this tutorial is targeted to developers who want to install local Oracle database for development needs on their MacBook, iMac or Mac Pro.
+
+h3. Initial preparation
+
+If you are a developer then I suppose you already have Xcode tools installed which are required also for Oracle installation. And I tried these steps on Mac OS X latest version 10.5.6.
+
+Then you need to create oracle user as well as increase default kernel parameters. Open Terminal and switch to root user:
+
+pre(terminal). sudo -i
+
+Create oinstall group and oracle user (I used group and user number 600 to ensure that they do not collide with existing groups and users):
+
+pre(terminal). dscl . -create /groups/oinstall
+dscl . -append /groups/oinstall gid 600
+dscl . -append /groups/oinstall passwd "*"
+dscl . -create /users/oracle
+dscl . -append /users/oracle uid 600
+dscl . -append /users/oracle gid 600
+dscl . -append /users/oracle shell /bin/bash
+dscl . -append /users/oracle home /Users/oracle
+dscl . -append /users/oracle realname "Oracle software owner"
+mkdir /Users/oracle
+chown oracle:oinstall /Users/oracle
+
+Change password for oracle user:
+
+pre(terminal). passwd oracle
+
+Change default kernel parameters:
+
+pre(terminal). vi /etc/sysctl.conf
+
+and enter values recommended by Oracle:
+
+pre(terminal). kern.sysv.semmsl=87381
+kern.sysv.semmns=87381
+kern.sysv.semmni=87381
+kern.sysv.semmnu=87381
+kern.sysv.semume=10
+kern.sysv.shmall=2097152
+kern.sysv.shmmax=2197815296
+kern.sysv.shmmni=4096
+kern.maxfiles=65536
+kern.maxfilesperproc=65536
+net.inet.ip.portrange.first=1024
+net.inet.ip.portrange.last=65000
+kern.corefile=core
+kern.maxproc=2068
+kern.maxprocperuid=2068
+
+After this reboot your computer so that these new kernel parameters would be taken into effect. After reboot open again Terminal and now login as oracle user:
+
+pre(terminal). su - oracle
+
+Set shell settings in .bash_profile
+
+pre(terminal). vi .bash_profile
+
+and enter
+
+pre(terminal). export DISPLAY=:0.0
+export ORACLE_BASE=$HOME
+umask 022
+ulimit -Hn 65536
+ulimit -Sn 65536
+
+As you see I prefer to install all Oracle related files under home directory of oracle user therefore I am setting ORACLE_BASE to home directory. And also include ulimit settings - I forgot to do this initially and got strange TNS service errors because of that.
+
+Now execute this script so that these settings are applied to current shell:
+
+pre(terminal). . ./.bash_profile
+
+Now download <a href="http://www.oracle.com/technology/software/products/database/oracle10g/htdocs/10204macsoft_x86-64.html">db.zip installation archive</a> and place it somewhere and unzip it:
+
+pre(terminal). mkdir Install
+cd Install
+# download db.zip to this directory
+unzip db.zip
+cd db/Disk1
+
+Now you are ready to start installation:
+
+pre(terminal). ./runInstaller
+
+h3. Installation
+
+In installation wizard I selected the following options:
+
+* Advanced Installation - so that I can change some default options
+* Standard Edition - as I don't need additional features of Enterprise Edition
+* Create Database / General Purpose
+* Global database name: orcl, SID: orcl
+* Character set: UTF-8 AL32UTF8
+* Create database with sample schemas
+* Selected "Use the same password for all the accounts" - do not specify default "manager" password as it will not be allowed :)
+* Password Management - selected this to unlock necessary sample accounts (e.g. HR schema account that I use as default test schema)
+
+At the end of installation you will be instructed to run one shell script from root.
+Hopefully installation will complete successfully.
+
+h3. Additional oracle user settings
+
+If you will use oracle user later then add the following lines to .bash_profile of oracle user:
+
+pre(terminal). export ORACLE_HOME=/Users/oracle/oracle/product/10.2.0/db_1
+export DYLD_LIBRARY_PATH=$ORACLE_HOME/lib
+export ORACLE_SID=ORCL
+PATH=$PATH:$ORACLE_HOME/bin
+
+After this relogin as oracle user and verify listener status:
+
+pre(terminal). lsnrctl status
+
+and if it is down then start it with
+
+pre(terminal). lsnrctl start
+
+and verify if you can connect to Oracle database with sample user (that I unlocked during installation)
+
+pre(terminal). sqlplus hr/hr@orcl
+
+If it fails then do some investigation :)
+
+h3. Change listener to listen on localhost
+
+As I need this Oracle database just as local development database on my computer then I want to change the listener so that it would listen just on localhost port 1521:
+
+pre(terminal). vi $ORACLE_HOME/network/admin/listener.ora
+
+and change the contents of the file to:
+
+pre(terminal). SID_LIST_LISTENER =
+ (SID_LIST =
+ (SID_DESC =
+ (SID_NAME = PLSExtProc)
+ (ORACLE_HOME = /Users/oracle/oracle/product/10.2.0/db_1)
+ (PROGRAM = extproc)
+ )
+ (SID_DESC =
+ (SID_NAME = orcl)
+ (ORACLE_HOME = /Users/oracle/oracle/product/10.2.0/db_1)
+ )
+ )
+LISTENER =
+ (DESCRIPTION_LIST =
+ (DESCRIPTION =
+ (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
+ (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
+ )
+ )
+
+Then also change ORCL alias definition in $ORACLE_HOME/network/admin/tnsnames.ora to:
+
+pre(terminal). ORCL =
+ (DESCRIPTION =
+ (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
+ (CONNECT_DATA =
+ (SERVER = DEDICATED)
+ (SERVICE_NAME = orcl)
+ )
+ )
+
+After this change restart listener and try to connect with sqlplus to verify that these changes are successful.
+
+h3. Automatic startup of Oracle database
+
+If you want that Oracle database is started automatically when your computer is booted then you need to create the following startup script. Start terminal and switch to root.
+
+At first edit /etc/oratab and change N to Y at the end of line for ORCL database - this will be used by dbstart utility to find which databases should be started automatically.
+
+Then create startup script for Oracle database:
+
+pre(terminal). mkdir /Library/StartupItems/Oracle
+cd /Library/StartupItems/Oracle
+vi Oracle
+
+and enter the following:
+
+{% highlight sh %}
+#!/bin/sh
+
+# Suppress the annoying "$1: unbound variable" error when no option
+# was given
+if [ -z $1 ] ; then
+ echo "Usage: $0 [start|stop|restart] "
+ exit 1
+fi
+
+# source the common startup script
+. /etc/rc.common
+
+# Change the value of ORACLE_HOME to specify the correct Oracle home
+# directory for the installation
+ORACLE_HOME=/Users/oracle/oracle/product/10.2.0/db_1
+DYLD_LIBRARY_PATH=$ORACLE_HOME/lib
+export ORACLE_HOME DYLD_LIBRARY_PATH
+
+# change the value of ORACLE to the login name of the
+# oracle owner at your site
+ORACLE=oracle
+
+PATH=$PATH:$ORACLE_HOME/bin
+
+# Set shell limits for the Oracle Database
+ulimit -Hu 2068
+ulimit -Su 2068
+ulimit -Hn 65536
+ulimit -Sn 65536
+
+StartService()
+{
+ ConsoleMessage "Starting Oracle Databases"
+ su $ORACLE -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
+}
+
+StopService()
+{
+ ConsoleMessage "Stopping Oracle Databases"
+ su $ORACLE -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
+}
+
+RestartService()
+{
+ StopService
+ StartService
+}
+
+RunService "$1"
+{% endhighlight %}
+
+and then make this script executable
+
+pre(terminal). chmod a+x Oracle
+
+and in addition create properties file:
+
+pre(terminal). vi StartupParameters.plist
+
+with the following contents:
+
+pre(terminal). {
+ Description = "Oracle Database Startup";
+ Provides = ("Oracle Database");
+ Requires = ("Disks");
+ OrderPreference = "None";
+}
+
+Now you can verify that these scripts are working. Open new terminal and try
+
+pre(terminal). sudo /Library/StartupItems/Oracle/Oracle stop
+
+to stop the database and
+
+pre(terminal). sudo /Library/StartupItems/Oracle/Oracle start
+
+to start again the database. And later you can reboot your computer also to verify that Oracle database will be started automatically.
+
+h3. Hide oracle user from login window
+
+After computer reboot you probably noticed that now you got oracle user in initial login window. To get rid of it execute this from terminal:
+
+pre(terminal). sudo defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array-add oracle
+
+h3. What next?
+
+Now when you have Oracle database installed you would need some development tools that you could use to access the database. Here are some links:
+
+* <a href="http://www.oracle.com/technology/products/database/sql_developer/index.html">Oracle SQL Developer</a> - free Oracle GUI tool that supports Mac OS X as well
+* If you would like to use Ruby and Ruby on Rails then check out my tutorial <a href="http://blog.rayapps.com/2008/04/24/how-to-setup-ruby-and-new-oracle-instant-client-on-leopard/">how to setup Ruby and Oracle client</a>
+* If you would like to use PHP then <a href="http://www.oracle.com/technology/pub/articles/bibbs-php-leopard.html">you can check out this tutorial</a>
+
+Please comment if you find any issues with Oracle Database 10g installation using this tutorial.
78 _posts/2009-04-21-ruby-plsql-new-version-ruby-191-support-and-more.textile
@@ -0,0 +1,78 @@
+---
+layout: post
+title: ruby-plsql new version - Ruby 1.9.1 support and more
+tags: ruby-plsql ruby oracle plsql
+---
+
+I have released <a href="http://github.com/rsim/ruby-plsql">ruby-plsql gem</a> (Ruby API for Oracle PL/SQL procedure calls) new version 0.3.0 which includes several new features.
+
+h3. Ruby 1.9.1
+
+Probably the most important is support for Ruby 1.9.1 - now you can use both <a href="http://blog.rayapps.com/2009/03/23/activerecord-oracle-enhanced-adapter-also-on-jruby-and-ruby-19/">Oracle enhanced adapter</a> and ruby-plsql gem on all three major Ruby plaforms:
+
+* MRI 1.8.6 with ruby-oci8 1.0.x library or gem
+* Ruby/YARV 1.9.1 with ruby-oci8 2.0 library or gem (currently just trunk version of ruby-oci8 2.0 contains the last bug fixes for Ruby 1.9.1)
+* JRuby (so far tested with 1.1.6) with JDBC Oracle driver
+
+h3. ActiveRecord connection
+
+In addition usage of ruby-plsql gem in Ruby on Rails project is simplified. Now you can include in environment.rb or some initializer file just:
+
+{% highlight ruby %}
+plsql.activerecord_class = ActiveRecord::Base
+
+{% endhighlight %}
+
+and you don't need to specify plsql.connection anymore - it will always use current ActiveRecord connection. This is also useful when ActiveRecord reestablishes connection to database as you don't need to reestablish plsql connection in this case.
+
+In addition if you use several different connections to Oracle database then you can assign to @plsql.activerecord_class@ also different class that inherits from @ActiveRecord::Base@ and has connection to different database.
+
+h3. Database time zone
+
+Also you can also specify in which timezone @DATE@ values are stored in database:
+
+{% highlight ruby %}
+plsql.default_timezone = :local
+
+{% endhighlight %}
+
+or
+
+{% highlight ruby %}
+plsql.default_timezone = :utc
+
+{% endhighlight %}
+
+This will affect how @DATE@ values (without timezone) will be converted to @Time@ or @DateTime@ values (with timezone), default selection is @:local@ timezone. If you have set @plsql.activerecord_class@ then the value will be taken from @ActiveRecord::Base.default_timezone@.
+
+h3. BLOB support
+
+You can now use @BLOB@ data type for input and output parameters and function return values.
+I remind you that also @NUMBER@, @VARCHAR2@, @DATE@, @TIMESTAMP@ and @CLOB@ data types are supported,
+
+h3. Synonym support
+
+Now you can also use private and public database synonyms to functions or procedures or packages.
+E.g. if @ORA_LOGIN_USER@ is public database synonym to @SYS.LOGIN_USER@ function then instead of
+
+{% highlight ruby %}
+plsql.sys.login_user
+
+{% endhighlight %}
+
+you can use
+
+{% highlight ruby %}
+plsql.ora_login_user
+
+{% endhighlight %}
+
+h3. Installation
+
+To install the gem as always do
+
+pre(terminal). sudo gem install ruby-plsql
+
+or call the correct gem command version for JRuby or Ruby 1.9.1.
+
+Source code of ruby-plsql is located at <a href="http://github.com/rsim/ruby-plsql">GitHub</a> where you can find usage examples in RSpec tests.
201 _posts/2009-07-21-initial-version-of-datamapper-oracle-adapter.textile
@@ -0,0 +1,201 @@
+---
+layout: post
+title: Initial version of DataMapper Oracle adapter
+tags: datamapper ruby oracle
+---
+
+<img src="/images/datamapper.jpg" alt="datamapper.jpg" border="0" width="347" height="91" align="right" style="padding:0 4px 4px 8px;" /><h3>What is DataMapper?</h3>
+
+<a href="http://www.datamapper.org">DataMapper</a> is Ruby Object/Relational Mapper that is similar to ActiveRecord (component of <a href="http://rubyonrails.org/">Ruby on Rails</a>) but still it handles several things differently than ActiveRecord.
+
+I got interested in DataMapper because I liked better some of its design decisions when compared with ActiveRecord. And in particular DataMapper architecture can suite better if you need to work with legacy Oracle database schemas - that is the area where I use Ruby on Rails a lot and for these purposes I also created <a href="http://github.com/rsim/oracle-enhanced">Oracle enhanced adapter for ActiveRecord</a>.
+
+But as there were no Oracle adapter available for DataMapper I needed to create one :) I started to work on Oracle adapter for DataMapper after the RailsConf and now it is passing all DataMapper tests on all Ruby platforms - MRI 1.8, Ruby 1.9 and JRuby 1.3.
+
+h3. Why DataMapper for Oracle database?
+
+If you would like to learn main differences between DataMapper and ActiveRecord then please start with <a href="http://www.datamapper.org/doku.php?id=getting_started_with_datamapper">this overview</a> and <a href="http://www.datamapper.org/doku.php?id=why_datamapper">this summary of benefits</a>.
+
+Here I will mention specific benefits if you would like to use DataMapper with Oracle database.
+
+h4. Model properties
+
+In DataMapper you always specify in model class definition what Ruby "type" you would like to use for each model attribute (or property as called in DataMapper):
+
+{% highlight ruby %}
+class Post
+ include DataMapper::Resource
+ property :id, Serial
+ property :title, String
+ property :post_date, Date
+ property :created_at, DateTime
+ property :updated_at, Time
+end
+
+{% endhighlight %}
+
+The main benefit for that is that you can explicitly define when to use Ruby Time, Date or DateTime class which is stored as DATE (or sometimes as TIMESTAMP) in Oracle database. In addition you can define your own custom DataMapper types and define how to serialize them into database.
+
+h4. Composite primary keys
+
+DataMapper core library supports composite primary keys for models. If you use ActiveRecord then there is an option to use additional composite_primary_keys gem but it regularly breaks with latest ActiveRecord versions and quite often it also might break in some edge cases. In DataMapper composite primary keys are defined quite simple:
+
+{% highlight ruby %}
+class City
+ include DataMapper::Resource
+ property :country, String, :key => true
+ property :name, String, :key => true
+end
+
+{% endhighlight %}
+
+h4. Legacy schemas
+
+DataMapper is quite useful when you want to put Ruby models on top of existing Oracle schemas. It is possible to provide different database field name for property or provide custom sequence name for primary keys:
+
+{% highlight ruby %}
+class Post
+ include DataMapper::Resource
+ property :id, Serial, :field => "post_id", :sequence => "post_s"
+end
+
+{% endhighlight %}
+
+You can also define one model that can be persisted in two different repositories (e.g. databases or schemas) and use different naming conventions in each repository:
+
+{% highlight ruby %}
+class Post
+ include DataMapper::Resource
+ repository(:old) do
+ property :id, Serial, :field => "post_id", :sequence => "post_s"
+ end
+ repository(:default) do
+ property :id, Serial
+ end
+end
+
+{% endhighlight %}
+
+As a result DataMapper can be used also for data migration between different databases.
+
+h4. Bind variables
+
+ActiveRecord always generates SQL statements for execution as one single string. Therefore Oracle enhanced adapter always initializes Oracle session with setting cursor_sharing='similar'. It instructs Oracle always to take all literals (constants) from SQL statement and replace them with bind variables. It reduces the number of unique SQL statements generated but also it is some overhead for Oracle optimizer.
+
+DataMapper always passes all statement parameters separately to corresponding database adapter and therefore it is possible for Oracle adapter to pass all parameters as bind variables to Oracle.
+
+h4. CLOB and BLOB values inserting and selecting
+
+As for ActiveRecord all inserted values should be passed as literals in INSERT statement it was not possible to insert large CLOB and BLOB values directly in INSERT statement. Therefore ActiveRecord Oracle enhanced adapter did separate call-backs for inserting any CLOB or BLOB data after INSERT of other data. In DataMapper it is possible to insert all data at once as CLOB and BLOB data are passed as bind variables.
+
+DataMapper also handles better lazy loading of large columns. So if you define property as Text then by default it will not be selected from database - it will be selected separately only when you use it. Typically it could reduce amount of data that needs to be sent from database to application as Text properties are quite often not needed in e.g. all web pages.
+
+h4. Wny not DataMapper?
+
+If you are fine with ActiveRecord default conventions and you don't have any issues that I listed previously then probably ActiveRecord is good enough for you and you shouldn't change to DataMapper. There are of course much more Rails plugins that work with ActiveRecord but not yet with DataMapper. And DataMapper is still much less used and therefore there might some edge cases where it is not tested and you will need to find the issue causes by yourself.
+
+But if you like to try new things then please try it out - and also DataMapper community is quite friendly and helpful and will help to solve any issues :)
+
+h3. Installation of DataMapper Oracle adapter
+
+So if you have decided to try to use DataMapper with Oracle database then follow the instructions how to install it.
+
+Oracle support is done for current development version 0.10.0 of DataMapper - therefore you will need to install the latest versions from GitHub (they are still not published as gems on RubyForge).
+
+DataMapper with Oracle adapter can be used both on MRI 1.8.6 (I am not testing it on 1.8.7) and Ruby 1.9.1 as well as on JRuby 1.3. And currently installation is tested on Mac OS X and Linux - if there is anyone interested in Windows support then please let me know.
+
+h4. MRI 1.8.6 or Ruby 1.9.1
+
+At first you need to have the same preconditions as for ActiveRecord:
+
+* Oracle Instant Cient
+* ruby-oci8 gem, version 2.0.2 or later
+
+If you are using Mac then you can use <a href="/2009/09/06/how-to-setup-ruby-and-oracle-instant-client-on-snow-leopard/">these instructions</a> for installation.
+
+Now at first it is necessary to install DataObjects Oracle driver - DataObjects library is unified interface to relational databases (like SQLite, MySQL, PostgreSQL, Oracle) that DataMapper uses to access these databases.
+
+At first validate that you have the latest version of rubygems installed and install necessary additional gems:
+
+pre(terminal). gem update --system
+gem install addressable -v 2.0
+
+As I mentioned currently you need to install the latest version from GitHub (at first create and go to directory where you would like to store DataMapper sources):
+
+pre(terminal). git clone git://github.com/datamapper/extlib.git
+cd extlib
+git checkout -b next --track origin/next
+rake install
+cd ..
+git clone git://github.com/datamapper/do.git
+cd do
+git checkout -b next --track origin/next
+cd data_objects
+rake install
+cd ../do_oracle
+rake compile
+rake install
+cd ../..
+
+Now if DataObjects installation was successful you can install DataMapper. UPDATE: Oracle adapter is now in "next" branch of DataMapper so now you need to install it form there:
+
+pre(terminal). git clone git://github.com/datamapper/dm-core.git
+cd dm-core
+git checkout -b next --track origin/next
+rake install
+
+Now start irb and test if you can connect to Oracle database (change database name, username and password according to your setup):
+
+{% highlight ruby %}
+require "rubygems"
+require "dm-core"
+DataMapper.setup :default, "oracle://hr:hr@xe"
+
+{% endhighlight %}
+
+and try some basic DataMapper operations (I assume that you don't have posts table in this schema):
+
+{% highlight ruby %}
+class Post
+ include DataMapper::Resource
+ property :id, Serial, :sequence => "posts_seq"
+ property :title, String
+end
+DataMapper.auto_migrate!
+p = Post.create(:title=>"Title")
+Post.get(p.id)
+Post.auto_migrate_down!
+
+{% endhighlight %}
+
+h4. JRuby
+
+At first I assume that you have already installed JRuby latest version (1.3.1 at the moment).
+
+Then you need to place Oracle JDBC driver ojdbc14.jar file in JRUBY_HOME/lib directory (other option is just to put somewhere in PATH).
+
+All other installation should be done in the same way - just use "jruby -S gem" instead of "gem" and "jruby -S rake" instead of "rake" and it should install necessary gems for JRuby.
+
+In addition before installing do_oracle gem you need to install do_jdbc gem (which contains general JDBC driver functionality):
+
+pre(terminal). # after installation of data_objects gem
+cd ../do_jdbc
+jruby -S rake compile
+jruby -S rake install
+# continue with do_oracle installation
+
+h4. Other DataMapper gems
+
+DataMapper is much more componentized than ActiveRecord. Here I described how to install just the main dm-core gem. You can see the list of <a href="http://www.datamapper.org/doku.php?id=gem_maintainers">other gems in DataMapper web site</a>.
+
+To install additional DataMapper gems you need to
+
+pre(terminal). git clone git://github.com/datamapper/dm-more.git
+cd dm-more
+git checkout -b next --track origin/next
+cd dm-some-other-gem
+rake install
+
+h3. Questions?
+
+This was my first attempt to describe how to start to use DataMapper with Oracle. If you have any questions or something is not working for you then please write comments and I will try to answer and fix any issues in these instructions.
56 _posts/2009-09-06-how-to-setup-ruby-and-oracle-instant-client-on-snow-leopard.textile
@@ -0,0 +1,56 @@
+---
+layout: post
+title: How to setup Ruby and Oracle Instant Client on Snow Leopard
+tags: ruby oracle mac
+---
+
+h3. Introduction
+
+Mac OS X Snow Leopard is out and many Rubyists are rushing to upgrade to it. The main difference for Ruby after upgrading to Snow Leopard is that Ruby installation has been changed from 32-bit to 64-bit program and version has changed from 1.8.6 to 1.8.7. And it means that all Ruby gems with C extensions should be reinstalled and recompiled using 64-bit external libraries.
+
+After upgrading to Snow Leopard the first thing to do is to follow <a href="http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard">instructions on official Ruby on Rails blog</a>. After that follow instructions below.
+
+h3. Installing 64-bit Oracle Instant Client for Intel Mac
+
+Download <a href="http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/intel_macsoft.html">Oracle Instant Client 64-bit version</a>. Download "Instant Client Package - Basic", "Instant Client Package - SDK" and "Instant Client Package - SQL*Plus".
+
+Unzip downloaded archives and move it where you would like to have it - I am keeping it in @/usr/local/oracle/instantclient_10_2@ (if you have previous 32-bit Oracle Instant Client in this directory then delete it beforehand). Then go to this directory and make symbolic links for dynamic libraries
+
+pre(terminal). sudo ln -s libclntsh.dylib.10.1 libclntsh.dylib
+sudo ln -s libocci.dylib.10.1 libocci.dylib
+
+Then I recommend to create and place somewhere your @tnsnames.ora@ file where you will keep your database connections definitions - I place this file in directory @/usr/local/oracle/network/admin@.
+
+Then finally you need to set up necessary environment variables - I place the following definitions in my @.bash_profile@ script:
+
+{% highlight sh %}
+export DYLD_LIBRARY_PATH="/usr/local/oracle/instantclient_10_2"
+export SQLPATH="/usr/local/oracle/instantclient_10_2"
+export TNS_ADMIN="/usr/local/oracle/network/admin"
+export NLS_LANG="AMERICAN_AMERICA.UTF8"
+export PATH=$PATH:$DYLD_LIBRARY_PATH
+{% endhighlight %}
+
+Use your path to Oracle Instant Client if it differs from @/usr/local/oracle/instantclient_10_2@. And as you see I also define @NLS_LANG@ environment variable - this is necessary if your database is not in UTF8 encoding but in Ruby you want to get UTF-8 encoded strings from the database. Specifying this NLS_LANG environment variable you will force that Oracle Instant Client will do character set translation.
+
+After these steps relaunch Terminal application (so that new environment variables are set), specify database connection in @tnsnames.ora@ file and try if you can access your database with @sqlplus@ from command line.
+
+h3. Install ruby-oci8 gem
+
+The latest versions of ruby-oci8 are available as Ruby gems and therefore I recommend to install it as a gem and not to compile and install as library (as I have recommended previously in my blog).
+
+If you previously installed ruby-oci8 as a library then I recommend to delete it from Ruby installation. Go to @/usr/lib/ruby/site_ruby/1.8@ directory and remove @oci8.rb@ file as well as remove @oci8lib.bundle@ compiled library from either @universal-darwin9.0@ or @universal-darwin10.0@ subdirectory.
+
+Now install ruby-oci8 with the following command:
+
+pre(terminal). sudo env DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH ARCHFLAGS="-arch x86_64" gem install ruby-oci8
+
+It is important to pass @DYLD_LIBRARY_PATH@ environment variable to sudo (as otherwise ruby-oci8 gem installation will not find Oracle Instant Client) as well as specify @ARCHFLAGS@ to compile C extension just for 64-bit platform as otherwise it will try to compile both for 32-bit and 64-bit platform.
+
+Now try
+
+pre(terminal). ruby -rubygems -e "require 'oci8'; OCI8.new('scott','tiger','orcl').exec('select * from dual') do |r| puts r.join(','); end"
+
+or similar (replacing username, password or database alias) to verify that you can access Oracle database from ruby.
+
+That's it! Please write in comments if something is not working according to these instructions.
351 _posts/2009-09-14-how-to-install-oracle-database-10g-on-mac-os-x-snow-leopard.textile
@@ -0,0 +1,351 @@
+---
+layout: post
+title: How to install Oracle Database 10g on Mac OS X Snow Leopard
+tags: oracle database mac
+---
+
+<img src="/images/sl_oracle.jpg" alt="sl_oracle.jpg" border="0" width="250" height="133" align="right">Oracle Database 10g is not yet officially supported on new Mac OS X 10.6 Snow Leopard but thanks to comments at my <a href="http://blog.rayapps.com/2009/04/12/how-to-install-oracle-database-10g-on-mac-os-x-intel/">previous tutorial</a> I managed to do Oracle 10g installation on fresh Mac OS X Snow Leopard.
+
+If you have upgraded from Leopard with Oracle 10g installation to Snow Leopard then most probably Oracle 10g should work fine and you should not do anything. These instructions are just for fresh installation of Snow Leopard.
+
+And also please take in mind that Oracle 10g on Snow Leopard is not supported yet by Oracle and therefore please do not run critical production applications on it :)
+
+So here are my updated Oracle 10g installation instructions for Snow Leopard.
+
+h3. Initial preparation
+
+At first you need Xcode tools installed on your Mac OS X.
+
+Then you need to create oracle user as well as increase default kernel parameters. Open Terminal and switch to root user:
+
+pre(terminal). sudo -i
+
+Create oinstall group and oracle user (I used group and user number 600 to ensure that they do not collide with existing groups and users):
+
+pre(terminal). dscl . -create /groups/oinstall
+dscl . -append /groups/oinstall gid 600
+dscl . -append /groups/oinstall passwd "*"
+dscl . -create /users/oracle
+dscl . -append /users/oracle uid 600
+dscl . -append /users/oracle gid 600
+dscl . -append /users/oracle shell /bin/bash
+dscl . -append /users/oracle home /Users/oracle
+dscl . -append /users/oracle realname "Oracle software owner"
+mkdir /Users/oracle
+chown oracle:oinstall /Users/oracle
+
+Change password for oracle user:
+
+pre(terminal). passwd oracle
+
+Change default kernel parameters:
+
+pre(terminal). vi /etc/sysctl.conf
+
+and enter values recommended by Oracle:
+
+{% highlight text %}
+kern.sysv.semmsl=87381
+kern.sysv.semmns=87381
+kern.sysv.semmni=87381
+kern.sysv.semmnu=87381
+kern.sysv.semume=10
+kern.sysv.shmall=2097152
+kern.sysv.shmmax=2197815296
+kern.sysv.shmmni=4096
+kern.maxfiles=65536
+kern.maxfilesperproc=65536
+net.inet.ip.portrange.first=1024
+net.inet.ip.portrange.last=65000
+kern.corefile=core
+kern.maxproc=2068
+kern.maxprocperuid=2068
+{% endhighlight %}
+
+Oracle DB installation scripts have reference to Java version 1.4.2 which is not present on Snow Leopard. The easiest way to fix it is to create symbolic link to newer version of Java:
+
+pre(terminal). sudo ln -s /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0 /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2
+
+After this reboot your computer so that these new kernel parameters would be taken into effect.
+
+After reboot you need to log in as new "Oracle software owner" user (as now Snow Leopard has stricter control for access to X11 display and therefore I couldn't manage to start Oracle installation just from terminal).
+
+Open Terminal application and set shell settings in .bash_profile
+
+pre(terminal). vi .bash_profile
+
+and enter
+
+{% highlight sh %}
+export DISPLAY=:0.0
+export ORACLE_BASE=$HOME
+umask 022
+ulimit -Hn 65536
+ulimit -Sn 65536
+{% endhighlight %}
+
+As you see I prefer to install all Oracle related files under home directory of oracle user therefore I am setting ORACLE_BASE to home directory. And also include ulimit settings - I forgot to do this initially and got strange TNS service errors because of that.
+
+Now execute this script so that these settings are applied to current shell: