# Oracle 8i find with :include broken because of LEFT OUTER JO

**URL:** <https://www.ruby-forum.com/t/oracle-8i-find-with-include-broken-because-of-left-outer-jo/84224>\
**Category:** Rails\
**Created:** [February 2, 2007, 2:46pm UTC](https://www.ruby-forum.com/t/oracle-8i-find-with-include-broken-because-of-left-outer-jo/84224 "2007-02-02T14:46:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ianzabel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b77776/32.png) [@ianzabel](https://www.ruby-forum.com/u/ianzabel)\
**Post date:** [February 2, 2007, 2:46pm UTC](https://www.ruby-forum.com/t/oracle-8i-find-with-include-broken-because-of-left-outer-jo/84224/1 "2007-02-02T14:46:31Z")

</div>

In Oracle 8i, the syntax “LEFT OUTER JOIN” is not supported. It is  
supported in Oracle 9i.

If I try to find some records using something like this on model  
called Work, I get an error:  
:include =\> [:project, :function, :account]

The error is:  
OCIError: ORA-00933: SQL command not properly ended: SELECT  
count(DISTINCT work.workno) AS count\_all FROM work LEFT OUTER JOIN  
project ON project.projectno = work.projectno LEFT OUTER JOIN  
function ON function.functionno = work.functionno LEFT OUTER JOIN  
account ON account.accountno = work.accountno WHERE (developerid =  
‘iwz’)

If you take a look at the query, it is using syntax not supported by  
Oracle 8i.  
SELECT count(DISTINCT work.workno) AS count\_all  
FROM work  
LEFT OUTER JOIN project ON project.projectno = work.projectno  
LEFT OUTER JOIN function ON function.functionno = work.functionno  
LEFT OUTER JOIN account ON account.accountno = work.accountno  
WHERE (developerid = ‘iwz’)

Here is how the SQL should be formatted:

SELECT count(DISTINCT work.workno) AS count\_all  
FROM work, project, function, account  
WHERE (developerid = ‘iwz’) and  
project.projectno(+) = work.projectno and  
function.functionno(+) = work.functionno and  
account.accountno(+) = work.accountno

Does anyone know of a workaround, patch, or anything regarding this?

Thanks!  
Ian.

---

<div class="post-metadata">

**Author:** ![ianzabel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b77776/32.png) [@ianzabel](https://www.ruby-forum.com/u/ianzabel)\
**Post date:** [February 2, 2007, 5:10pm UTC](https://www.ruby-forum.com/t/oracle-8i-find-with-include-broken-because-of-left-outer-jo/84224/2 "2007-02-02T17:10:50Z")

</div>

> In Oracle 8i, the syntax “LEFT OUTER JOIN” is not supported.  
> LEFT OUTER JOIN function ON function.functionno =  
> account ON account.accountno = work.accountno WHERE  
> account.accountno(+) = work.accountno
> 
> Does anyone know of a workaround, patch, or anything regarding this?

Project.find\_by\_sql, I’m afraid.

Unless there’s a way to alter the sql generation method that I don’t  
know about. If not, I would consider this a bug.

Regards,

Dan

This communication is the property of Qwest and may contain confidential  
or  
privileged information. Unauthorized use of this communication is  
strictly  
prohibited and may be unlawful. If you have received this communication  
in error, please immediately notify the sender by reply e-mail and  
destroy  
all copies of the communication and any attachments.

---

<div class="post-metadata">

**Author:** ![ianzabel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b77776/32.png) [@ianzabel](https://www.ruby-forum.com/u/ianzabel)\
**Post date:** [February 6, 2007, 11:23pm UTC](https://www.ruby-forum.com/t/oracle-8i-find-with-include-broken-because-of-left-outer-jo/84224/3 "2007-02-06T23:23:24Z")

</div>

Is  
ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation  
the correct place to look at to potentially fix this issue?

Or would it be in some Oracle specific part of Rails? Certainly, not  
every database supported by rails supports the “LEFT OUTER JOIN”  
syntax? Or, do they all?

Ian.
