The moose likes Java in General and the fly likes SQLException beteen correlation and exposed name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "SQLException beteen correlation and exposed name" Watch "SQLException beteen correlation and exposed name" New topic

SQLException beteen correlation and exposed name

Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
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?

James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
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?

James Carman, President<br />Carman Consulting, Inc.
Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
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

Joined: Feb 18, 2005
Posts: 362
Sorted it, I'm an idiot. No space between one of the tablenames and an 'AND'!!!

sometimes the simplest answer...

Cheers anyways
I agree. Here's the link: http://aspose.com/file-tools
subject: SQLException beteen correlation and exposed name
Similar Threads
SQL Injection prevention
Correlation in SQL to distinguish tables
Adding elements to a database!
help with getting the table name from the user input
Create procedure for inserting record into table : Table name dynamically as an Param