Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Wednesday, May 15, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Data & Imports Forums - T-SQL & Queries
Forum to discuss general T-SQL questions and help with queries related to SalesLogix data. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to T-SQL & Queries | New ThreadView:  Search:  
 Author  Thread: SQL Update Statement Using Multiple Tables In Where Clause
Jim Crowley
Posts: 8
 
SQL Update Statement Using Multiple Tables In Where ClauseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 Aug 07 1:54 PM
Arrggghhhh - I am trying to be friends with the SLX OELDB Provider and we aren't getting along very well.

I have an update statement that works well in Query Analyzer but fails in SLX Admin. Can someone please throw me a bone and point me in a better direction?


Update Opportunity_Ext
set
export_cofa=b.export_cofa
from Opportunity_Ext a inner join
opportunity o on o.opportunityid = a.opportunityid inner join
Aircraft_ext b on a.AircraftId=b.AircraftId inner join
aircraft ac on a.gac_aircraftid = ac.aircraftid
where o.status = 'Won'
or ac.OH = 'T'

Many thanks!
[Reply][Quote]
Phil Parkin
Posts: 819
Top 10 forum poster: 819 posts
 
Re: SQL Update Statement Using Multiple Tables In Where ClauseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 Aug 07 6:24 PM
Jim, as you've found, this type of UPDATE statement (I think it's the FROM clause that stuffs things up) does not work through the provider.

But you might see whether you can get a correlated subquery working:

Update Opportunity_Ext
set
export_cofa=(select b.export_cofa
from opportunity o on o.opportunityid = Opportunity_Ext.opportunityid inner join
Aircraft_ext b on Opportunity_Ext.AircraftId=b.AircraftId inner join
aircraft ac on Opportunity_Ext.gac_aircraftid = ac.aircraftid
where o.status = 'Won'
or ac.OH = 'T')

(Untested - you'll prob have to fix the syntax)
[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: SQL Update Statement Using Multiple Tables In Where ClauseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Aug 07 11:49 AM
Jim,

Sometimes the join statement chokes up an Update statement. Try this and see how it goes:
--c


UPDATE Opportunity_Ext
SET
export_cofa=b.export_cofa
FROM Opportunity_Ext a, opportunity o, Aircraft_ext b, aircraft ac
WHERE o.opportunityid = a.opportunityid
AND a.AircraftId=b.AircraftId
AND a.gac_aircraftid = ac.aircraftid
AND (o.status = 'Won'OR ac.OH = 'T' )

[Reply][Quote]
Martin Rudnick
Posts: 52
 
Re: SQL Update Statement Using Multiple Tables In Where ClauseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Aug 07 1:24 PM
Alternatively, this may work

UPDATE Opportunity_Ext
SET
export_cofa=Aircraft_ext.export_cofa
FROM Opportunity_Ext a
WHERE (Exists (Select opportunity.opportunityid from opportunity where a.opportunityid =opportunity.opportunityid and opportunity.status = 'Won') OR
Exists (Select aircraft.aircraftid from aircraft where a.gac_aircraftid = aircraft.aircraftid and aircraft.OH = 'T'))
AND Exists (Select Aircraft_ext.Aircraftid from Aircraft_ext where a.AircraftId=Aircraft_ext.AircraftId)
[Reply][Quote]
Martin Rudnick
Posts: 52
 
Re: SQL Update Statement Using Multiple Tables In Where ClauseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Aug 07 1:24 PM
Sorry about the dupe

[Reply][Quote]
Jim Crowley
Posts: 8
 
Re: SQL Update Statement Using Multiple Tables In Where ClauseYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Sep 07 4:30 PM
Thanks everybody for all of your help!

The key to the solution was to get the tableid in the subselect (props to mike spragg on "some other board").

For those that may follow in this path in the future, here was the final answer and hopefully you can make it work for you!

update opportunity_ext
set
export_cofa = (select m.export_cofa from aircraft_milestone m where m.aircraftid = opportunity_ext.aircraftid)
where opportunityid in (select o.opportunityid from opportunity o
inner join opportunity_ext oe on o.opportunityid=oe.opportunityid
inner join aircraft a on oe.aircraftid = a.aircraftid
where o.status = 'Won' or ac.OH = 'T')
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 5/15/2024 3:28:43 PM