Martinicity: Tag schemaMike Blaketag:www.martinicity.net,2005:TypoTypo2007-06-14T16:01:17+00:00Mike Blakeurn:uuid:1fd946dc-17d2-40fd-abf8-2b4dd34743772007-03-29T21:15:00+00:002007-06-14T16:01:17+00:00Rails on Oracle<p>When rails on jruby and connecting to Oracle via <span class="caps">JDBC</span> ,the following error eventually appears:</p>
Update:
<code>
java.sql.SQLException: Io exception: Broken pipe
</code>
<p><b>Fix:</b></p>
You need a dedicated connection from Oracle. Change the url: line in database.yml from
<code>
url: jdbc:oracle:thin:@localhost:1521:XE
to
url: jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS_LIST = (ADDRESS =(PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))) (CONNECT_DATA =(SERVER = DEDICATED) (SID = XE)))
</code>
<ol>
<li>Workarounds</li>
</ol>
<p>Duplicating an existing Oracle Database using the build in task <code>rake db:test:clone</code> presented a few problems. Here’s what I did to work around them.</p>
<ol>
<li><span class="caps">ORA</span>-01727: numeric precision specifier is out of range</li>
</ol>
<code>
OCIError: ORA-01727: numeric precision specifier is out of range (1 to 38): CREATE TABLE employee (id NUMBER(38) NOT NULL PRIMARY KEY, created_date DATE DEFAULT NULL, start_date DATE DEFAULT NULL, job_id DECIMAL DEFAULT NULL, total_hours NUMBER(126) DEFAULT NULL)
</code>
<p><b>Fix:</b></p>
<p>For some reason whne rails dumps the schema, it reports Oracle type <span class="caps">FLOAT</span> as <acronym title="126">NUMBER</acronym>, so you just need to changed that back to <span class="caps">FLOAT</span> if you want to import that schema.</p>
###OCIError: <span class="caps">ORA</span>-00972 identifier is too long:
<code>
OCIError: ORA-00972: identifier is too long: CREATE SEQUENCE gametime\_responsibility\_ref\_seq START WITH 10000
</code>
<p><b>Fix:</b></p>
<p>Rails tries to create sequences in Oracle to handle <span class="caps">AUTOINCREMENT</span> id fields. It uses <span class="caps">TABLE</span>_NAME = ‘_SEQ’ for the sequence name. If a sqequence name is too long then you have to shorten it in schema.rb .</p>
<h3>OCIError: <span class="caps">ORA</span>-00907: missing right parenthesis</h3>
<code>
OCIError: ORA-00907: missing right parenthesis: CREATE TABLE board (id NUMBER(38) NOT NULL PRIMARY KEY, name VARCHAR2(150) NOT NULL, name VARCHAR2(150) NOT NULL, parent VARCHAR2(150) DEFAULT NULL, log_level DECIMAL DEFAULT NULL, modified_date DATE(6) DEFAULT NULL, token DECIMAL DEFAULT NULL)
</code>
<p><b>Fix:</b></p>
<p>For some reason Rails assigns Date fields a size in schema.rb . You’ll need to change all occurances of <acronym title="6">DATE</acronym> to <span class="caps">DATE</span> .</p>