Feedback
Did this article resolve your question/issue?

   

Article

Specific SQL statement with two joins does not work with Salesforce JDBC driver 6.0

Information

 
TitleSpecific SQL statement with two joins does not work with Salesforce JDBC driver 6.0
URL Namespecific-sql-statement-with-two-joins-does-not-work-with-datadirect-salesforce-jdbc-driver-6-0
Article Number000118543
EnvironmentProduct: Progress DataDirect for JDBC for Salesforce Driver
Version : 6.0.0.000140
OS: JAVA
Database : Salesforce
Application: All supported applications
Question/Problem Description

When writing a SQL with several joins, at some point the query stopped returning any rows. The joins "failed" silently with no error. The joins did not fail because the data did not support the join, as the example shows. Re-writing as two parts using nested SQL avoids the problem. It does not seem to be an issue of the number of joins used.

– 1) this works and returns three rows
select t0.id as oppo_id, t0.name, t0.OWNERID, t1.role from sforce.opportunity t0
join sforce.OPPORTUNITYCONTACTROLE t1 on t0.id = t1.OPPORTUNITYID
where t0.id = '0064100000K4xVKAAZ'

--OPPO_ID NAME OWNERID ROLE
--0064100000K4xVKAAZ SomeCompany 005410000036bQSAAY Seller Counsel
--0064100000K4xVKAAZ SomeCompany 005410000036bQSAAY Seller Counsel
--0064100000K4xVKAAZ SomeCompany 005410000036bQSAAY Seller Counsel

– 2) this works and returns a lastname from user
select t0.id as oppo_id, t0.name, t0.OWNERID, t2.LASTNAME from sforce.opportunity t0
join sforce.USER t2 on t0.ownerid = t2.id
where t0.id = '0064100000K4xVKAAZ'

--OPPO_ID NAME OWNERID LASTNAME
--0064100000K4xVKAAZ SomeCompany 005410000036bQSAAY Martin

– 3) *** FAILS: this returns no rows at all and has no error
select t0.id as oppo_id, t0.name, t0.OWNERID, t1.role, t2.LASTNAME from sforce.opportunity t0
join sforce.OPPORTUNITYCONTACTROLE t1 on t0.id = t1.OPPORTUNITYID
join sforce.USER t2 on t0.ownerid = t2.id
where t0.id = '0064100000K4xVKAAZ'

– 4) this works and returns 3 rows with all columns populated
select t3.oppo_id, t3.oppo_name, t3.ownerid, t3.role, t4.lastname
from
( select t0.id as oppo_id, t0.name as oppo_name, t0.OWNERID, t1.role from sforce.opportunity t0
join sforce.OPPORTUNITYCONTACTROLE t1 on t0.id = t1.OPPORTUNITYID
where t0.id = '0064100000K4xVKAAZ'
) t3
join sforce.user t4 on t3.ownerid = t4.id

--OPPO_ID OPPO_NAME OWNERID ROLE LASTNAME
--0064100000K4xVKAAZ SomeCompany 005410000036bQSAAY Seller Counsel Martin
--0064100000K4xVKAAZ SomeCompany 005410000036bQSAAY Seller Counsel Martin
--0064100000K4xVKAAZ SomeCompany 005410000036bQSAAY Seller Counsel Martin

Steps to Reproduce
Clarifying Information
Error Message
Defect NumberDefect XDBC-15477
Enhancement Number
Cause

There was an issue with the way the driver was processing the foreign key columns.

Resolution
Fixed in hot fix 6.0.0.000293. 

Refer to Connect for JDBC hot fix download and install instructions for instructions on how to download and install the hot fix.
Workaround
Notes
Last Modified Date12/10/2019 5:23 PM
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.