0

mssql プラットフォームで正常に実行される SQL がありますが、スイッチ ヤード キャメル フロー (SQL バインディング) から実行すると機能しません。

SQLは

SELECT
p.ProductID,p.dtGTIN,p.ProductWeight      
,p.dtPurchasePriceUnit,p.dtItemGroupID,
p.dtPromotionID,p.IntroductionDate,p.dtOnOrder,
p.dtExposureGroup,p.dtPlanogram,p.ProductHeight,
p.ProductWidth,p.ProductLength,p.dtPackageSize1,
p.productHeightUOMID,p.productWidthUOMID,p.productLengthUOMID,
pn.dtProductNameDescription1,pn.dtProductNameDescription2,
pv.VendorID,pr.ReferenceNumber
FROM ODS_Product p
    JOIN ODS_ProductName pn 
ON pn.ProductID=p.ProductID and pn.BusinessUnitId=p.BusinessUnitId
    JOIN ODS_ProductVendor pv 
ON pv.ProductID=p.ProductID and pv.BusinessUnitId=p.BusinessUnitId
    LEFT JOIN ODS_dtProductReference pr 
ON (pr.ProductID=p.ProductID and pr.BusinessUnitId=p.BusinessUnitId and      
    pr.ReferenceID='SRII')
where p.ProductID=# and p.BusinessUnitId=#

メッセージは

Caused by exception of type com.microsoft.sqlserver.jdbc.SQLServerException, 
message: com.microsoft.sqlserver.jdbc.SQLServerException: The multi-part     
identifier "p.ProductID" could not be bound.: 
org.switchyard.HandlerException: org.switchyard.HandlerException: 
org.springframework.jdbc.UncategorizedSQLException: 

PreparedStatementCallback; uncategorized SQLException for SQL. SQL state  
[null]; error code [0]; com.microsoft.sqlserver.jdbc.SQLServerException: The 
multi-part identifier "p.ProductID" could not be bound.; nested exception is 
com.microsoft.sqlserver.jdbc.SQLServerException: 
com.microsoft.sqlserver.jdbc.SQLServerException: The multi-part identifier 
"p.ProductID" could not be bound.

理由はありますか?

4

3 に答える 3

0

それに対する解決策を見つけました。問題は、sql ドライバーがステートメントを準備したことでした。何らかの理由で「p.productId」を解釈できなかったため、SQLからすべてのエイリアスを削除すると機能しました(ただし、理由はわかりません):

 SELECT ODS_Product.ProductID,ODS_Product.dtGTIN,ODS_Product.ProductWeight
 ,ODS_Product.dtPurchasePriceUnit,ODS_Product.dtItemGroupID,
ODS_Product.dtPromotionID,ODS_Product.IntroductionDate,
ODS_Product.dtOnOrder,ODS_Product.dtExposureGroup,ODS_Product.dtPlanogram,
ODS_Product.ProductHeight,ODS_Product.ProductWidth,
ODS_Product.ProductLength,ODS_Product.dtPackageSize1,
ODS_Product.productHeightUOMID,ODS_Product.productWidthUOMID,
ODS_Product.productLengthUOMID,ODS_ProductName.dtProductNameDescription1,
ODS_ProductName.dtProductNameDescription2,ODS_ProductVendor.VendorID,
ODS_dtProductReference.ReferenceNumber
FROM ODS_Product
JOIN ODS_ProductName ON ODS_ProductName.ProductID=ODS_Product.ProductID
 and ODS_ProductName.BusinessUnitId=ODS_Product.BusinessUnitId
JOIN ODS_ProductVendor ON ODS_ProductVendor.ProductID=ODS_Product.ProductID
 and ODS_ProductVendor.BusinessUnitId=ODS_Product.BusinessUnitId
LEFT JOIN ODS_dtProductReference ON         
ODS_dtProductReference.ProductID=ODS_Product.ProductID 
 and ODS_dtProductReference.BusinessUnitId=ODS_Product.BusinessUnitId 
 and ODS_dtProductReference.ReferenceID='SRII')
where ODS_Product.ProductID='2602_1487130'
    and ODS_Product.BusinessUnitId=6
于 2015-10-29T13:40:37.800 に答える
0

私の知る限り、結合句ではandを使用できません。結合ステートメントから and の部分を削除してみてください。

SELECT
p.ProductID,p.dtGTIN,p.ProductWeight      
,p.dtPurchasePriceUnit,p.dtItemGroupID,
p.dtPromotionID,p.IntroductionDate,p.dtOnOrder,
p.dtExposureGroup,p.dtPlanogram,p.ProductHeight,
p.ProductWidth,p.ProductLength,p.dtPackageSize1,
p.productHeightUOMID,p.productWidthUOMID,p.productLengthUOMID,
pn.dtProductNameDescription1,pn.dtProductNameDescription2,
pv.VendorID,pr.ReferenceNumber
FROM ODS_Product p
   JOIN ODS_ProductName pn 
   ON pn.ProductID=p.ProductID 
join ODS_ProductName pn1 pn1.BusinessUnitId=p.BusinessUnitId
 JOIN ODS_ProductVendor pv 
ON pv.ProductID=p.ProductID 
JOIN ODS_ProductVendor  Pv1 pv1.BusinessUnitId=p.BusinessUnitId
LEFT JOIN ODS_dtProductReference pr 
where p.ProductID=# and p.BusinessUnitId=#

よくわかりませんが、お役に立てるかもしれません。

于 2015-10-29T09:42:47.873 に答える