Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLException beteen correlation and exposed name

 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I have a little problem with a SQL query I'm running. when ran in SQL this query is fine, but put it into a Java class and call it from a servlet and I get this error.

java.sql.SQLException: The correlation name 'TABLENAME' has the same exposed name as table 'TABLENAME'.

Never seen this before and can;t see anything wrong with the SQL. Anyone seen this error befopre and know what causes it?

Cheers
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell us what db you're using and maybe some example SQL (the DDL used to construct the tables might help too) which causes this problem?
 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure it's a SQL 7 DB and the code is:

SELECT tblJobHeaders.job_number, tblWorkflows.wf_name, tblWorkflowAttributes.att_name, tblSystemKeys.key_description, tblUsers.fname, tblUsers.sname
FROM tblWorkflowLinkList, tblWorkflows, tblWorkflowAttributes, tblJobHeaders, tblJobRepros, tblSystemKeys, tblUsers
WHERE tblWorkflowAttributes.id = tblWorkflowLinkList.current_processid AND
tblWorkflowAttributes.wf_id = tblWorkflows.id AND
tblWorkflowLinkList.process_state = tblSystemKeys.id AND
tblWorkflowLinkList.wf_id = tblWorkflows.id AND
tblJobHeaders.id = tblWorkflowLinkList.jobnumber_id AND
tblJobHeaders.id = tblJobRepros.jobheader_id AND
tblUsers.id = tblWorkflows.createdby_id AND
tblJobRepros.user_id = [userid] (user ID is stored in HTTP session).

Sorry the SQLs quite long.

The table is seems to be having problems with is
'tblWorkflowAttributes', but as I say, put the same query in Enterprise Manager and it runs fine.
 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorted it, I'm an idiot. No space between one of the tablenames and an 'AND'!!!

sometimes the simplest answer...

Cheers anyways
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic