Solved

column ambiguously defined error when convert oracle to sql

Posted on 2010-08-30
12
659 Views
Last Modified: 2012-05-10
Trying to convert an Oracle to sql OPENQUERY and it should work when I bracket it but I get tons or errors when i tried to do this so i am just rewriting.

Here is my next error on the join of the 2 tables.  Teh differencet is on the RSC column in ACN.ACN_CURRENT_SLOTS it has 7 letters versus just the 6 letters in ACN.ACN_BONUS_PERCENT_TLKP  but I get this error when trying to connect on it

column ambiguously defined so here is the Oracle query part
FROM      ACN_ACN_CURRENT_SLOTS INNER JOIN
            ACN_ACN_BONUS_PERCENT_TLKP ON (Left([ACN_ACN_CURRENT_SLOTS].[RSC],6) = ACN_ACN_BONUS_PERCENT_TLKP.RSC6) AND
            (ACN_ACN_CURRENT_SLOTS.DMOS = ACN_ACN_BONUS_PERCENT_TLKP.DMOS)


Here is my sql equivalent

from	ACN.ACN_CURRENT_SLOTS a INNER JOIN			ACN.ACN_BONUS_PERCENT_TLKP b ON (LEFT(a.RSC, 6) = b.RSC6) and a.DMOS = b.DMOS



I also tried this

from	ACN.ACN_CURRENT_SLOTS a INNER JOIN			ACN.ACN_BONUS_PERCENT_TLKP b ON Substring(a.RSC,0, 6) = b.RSC6 and a.DMOS = b.DMOS

Open in new window

0
Comment
Question by:kdeutsch
  • 5
  • 5
  • 2
12 Comments
 
LVL 2

Expert Comment

by:Subramanyeswara
Comment Utility
Try this below query:
from    ACN.ACN_CURRENT_SLOTS a INNER JOIN            ACN.ACN_BONUS_PERCENT_TLKP b ON Substr(a.RSC,0, 6) = b.RSC6 and a.DMOS = b.DMOS

Open in new window

0
 
LVL 10

Expert Comment

by:Jini Jose
Comment Utility
can u please put you select query here ?

you need to give the alias name in front of every field name if the field is repeating in more than one table in that select query
0
 
LVL 2

Expert Comment

by:Subramanyeswara
Comment Utility
Ignore my previous message.try  this  below query


from    ACN.ACN_CURRENT_SLOTS a INNER JOIN            ACN.ACN_BONUS_PERCENT_TLKP b ON (Substring(a.RSC,0, 6) = b.RSC6) and a.DMOS = b.DMOS
0
 

Author Comment

by:kdeutsch
Comment Utility
Here is my whole select query,
Select * from OPENQUERY(SIDPERS,
                        'Select a.UPC,
                                    a.ADDR_CITY,
                                    a.POSN_TITLE,
                                    a.PARA,
                                    a.LINE,
                                    a.RANK,
                                    a.DMOS,
                                    a.GENDER,
                                    a.AUTH,
                                    a.OS,  
                                    a.ASGN,
                                    a.ACN,
                                    b.B_PERC,
                                    a.AUTH + a.OS - a.ASGN - nvl(a.ACN, 0) as VAC,
                                    a.UNIT_TYPE
                        from    ACN.ACN_CURRENT_SLOTS a INNER JOIN            
                                    ACN.ACN_BONUS_PERCENT_TLKP b ON Substr(a.RSC,0, 6) = b.RSC6 and a.DMOS = b.DMOS
                        where      DMOS = ''25B1''')
0
 

Author Comment

by:kdeutsch
Comment Utility
Subramanyeswara,
Tried your version but got the same error
0
 
LVL 10

Expert Comment

by:Jini Jose
Comment Utility
this is your oracle query. kindly paste your sql query.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:kdeutsch
Comment Utility
all,
I am told the oracle query version works fine here is the whole oracle query.
SELECT      ACN_ACN_CURRENT_SLOTS.RSC,
            ACN_ACN_CURRENT_SLOTS.UPC,
            ACN_ACN_CURRENT_SLOTS.POSN_TITLE,
            ACN_ACN_CURRENT_SLOTS.DMOS,
            ACN_ACN_CURRENT_SLOTS.AUTH,
            ACN_ACN_CURRENT_SLOTS.OS,
            ACN_ACN_CURRENT_SLOTS.ASGN,
            ACN_ACN_CURRENT_SLOTS.ACN,
            IIf(IsNull([ACN]),[AUTH]+[OS]-[ASGN],[AUTH]+[OS]-[ASGN]-[ACN]) AS VAC,
            ACN_ACN_BONUS_PERCENT_TLKP.B_PERC
FROM      ACN_ACN_CURRENT_SLOTS INNER JOIN
            ACN_ACN_BONUS_PERCENT_TLKP ON (Left([ACN_ACN_CURRENT_SLOTS].[RSC],6) = ACN_ACN_BONUS_PERCENT_TLKP.RSC6) AND
            (ACN_ACN_CURRENT_SLOTS.DMOS = ACN_ACN_BONUS_PERCENT_TLKP.DMOS)
WHERE      (((IIf(IsNull([ACN]),[AUTH]+[OS]-[ASGN],[AUTH]+[OS]-[ASGN]-[ACN]))>0) AND
            ((ACN_ACN_CURRENT_SLOTS.OESTS)="N") AND
            ((ACN_ACN_CURRENT_SLOTS.CRIT_BONUS) Is Null) AND
            ((ACN_ACN_CURRENT_SLOTS.MOB) Is Null))
ORDER BY ACN_ACN_CURRENT_SLOTS.RSC, ACN_ACN_CURRENT_SLOTS.UPC, ACN_ACN_CURRENT_SLOTS.PARA,
                  ACN_ACN_CURRENT_SLOTS.LINE; ====================
0
 
LVL 10

Expert Comment

by:Jini Jose
Comment Utility
the problem is for the DMOS field. kindly add from which table for that field
0
 
LVL 10

Accepted Solution

by:
Jini Jose earned 350 total points
Comment Utility
where      DMOS = ''25B1''')

is this field is from which table ?
0
 

Author Comment

by:kdeutsch
Comment Utility
gmailjini:


aahaahahahahahaahahahah UGH!
Thanks
0
 
LVL 10

Expert Comment

by:Jini Jose
Comment Utility
column ambiguously defined error means any of the fields defined in select, update, delete, where etc is referring two tables. so you have to give the exact table name or alias name
0
 

Author Closing Comment

by:kdeutsch
Comment Utility
THanks
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now