“无法绑定由多个部分组成的标识符 “解决方案

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/hduzh/article/details/5251853

select D.ID from UFIDA::U9::CBO::SCM::Customer::Customer as C inner join UFIDA::U9::Base::FlexField::ValueSet::DefineValue as D on
D.Code =C.Segment1 and D.ValueSetDef.Code='008'

上面的OQL看似没什么大问题,而且OQL引擎也可以将它翻译过来:

select  A1.[ID] from  CBO_Customer as A  inner join Base_DefineValue as A1 on ((A1.[Code] = A.[Segment1]) and (A2.[Code] = '008'))  left join [Base_ValueSetDef] as A2 on (A1.[ValueSetDef] = A2.[ID])

但是在执行的时候却报错:Error is: 无法绑定由多个部分组成的标识符 "A2.Code"。出现这个错误的原因是没有理解透彻inner join … on… 的使用方式。其实on子句是设置两个表连接的条件,D.ValueSetDef.Code='008' 并不是两个表关联的条件,而应该作为where条件。正确的写法如下:

select D.ID from UFIDA::U9::CBO::SCM::Customer::Customer as C inner join UFIDA::U9::Base::FlexField::ValueSet::DefineValue as D on
D.Code =C.Segment1 where  D.ValueSetDef.Code='008'

展开阅读全文

100分求解 无法绑定多个部分组成标识符

06-07

我在看一个ASP.NET数码商店的网站时发现源代码有问题,下面这句代码会有异常:rndata.RunProc("upOrdersAdd", prams); //这句话是把订单信息存入数据库OrdersrnrnupOrdersAdd是一个存储过程的名字,内容如下:rnUSE [D:\MIKECATCSHARP\CHAPTER10\DS\APP_DATA\DIGITALSHOP.MDF]rnGOrn/****** 对象: StoredProcedure [dbo].[upOrdersAdd] 脚本日期: 06/07/2008 22:58:11 ******/rnSET ANSI_NULLS ONrnGOrnSET QUOTED_IDENTIFIER ONrnGOrnrnALTER PROCEDURE [dbo].[upOrdersAdd]rn(rn @xml varchar(8000)rn)rnASrnrn DECLARE @idoc int -- xml docrn DECLARE @orderid int -- new orderrnrn -- parse xml docrn EXEC sp_xml_preparedocument @idoc output, @xmlrnrnrn SET NOCOUNT ONrn DECLARE @CurrentError intrnrn -- start transaction, updating three tablesrn BEGIN TRANSACTIONrnrn -- add new order to Orders tablern INSERT INTO Ordersrn SELECT userid, orderdate, shipaddr1, shipaddr2, shipcity, shipstate, rn shipzip, shipcountry, billaddr1, billaddr2, billcity, billstate, billzip,rn billcountry, courier, totalprice, billtofirstname, billtolastname,rn shiptofirstname, shiptolastname, creditcard, exprdate, cardtype, localern FROM OpenXML(@idoc, '/Orders')rn WITH Ordersrnrn -- check for errorrn SELECT @CurrentError = @@Errorrnrn IF @CurrentError != 0rn BEGINrn GOTO ERROR_HANDLERrn ENDrnrn -- get new order idrn SELECT @orderid = @@IDENTITYrnrn -- add line items to LineItem tablern INSERT INTO LineItemrn SELECT @orderid, linenum, itemid, quantity, unitpricern FROM OpenXML(@idoc, '/Orders/LineItem')rn WITH LineItemrnrn -- check for errorrn SELECT @CurrentError = @@Errorrnrn IF @CurrentError != 0rn BEGINrn GOTO ERROR_HANDLERrn ENDrnrn -- add status to OrderStatus tablern INSERT INTO OrderStatusrn SELECT @orderid, @orderid, getdate(), 'P'rnrn -- check for errorrn SELECT @CurrentError = @@Errorrnrn IF @CurrentError != 0rn BEGINrn GOTO ERROR_HANDLERrn ENDrnrn -- update inventoryrn UPDATE Inventoryrn SET Inventory.qty = Inventory.qty - LineItem.quantityrn FROM OpenXML(@idoc, '/Orders/LineItem')rn WITH LineItemrn WHERE Inventory.itemid=LineItem.itemidrnrn -- check for errorrn select @CurrentError = @@Errorrnrn IF @CurrentError != 0rn BEGINrn GOTO ERROR_HANDLERrn ENDrnrn -- end of transactionrn COMMIT TRANSACTIONrnrn SET NOCOUNT OFFrnrn -- done with xml docrn EXEC sp_xml_removedocument @idocrnrn -- return the new orderrn RETURN @orderidrnrn ERROR_HANDLER:rn ROLLBACK TRANSACTIONrn SET NOCOUNT OFF rn RETURN 0 rn rnrnprams数组只有一项为@xml,xml的内容是:rn""rnrnrn运行时出现了异常,我跟踪了一下,发现异常的内容如下:rnex.Messagern"无法绑定由多个部分组成的标识符 \"LineItem.itemid\"。"rnrnex.ToString()rn"System.Data.SqlClient.SqlException: 无法绑定由多个部分组成的标识符 \"LineItem.itemid\"。\r\n 在 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)\r\n 在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)\r\n 在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)\r\n 在 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)\r\n 在 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)\r\n 在 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)\r\n 在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)\rrn\n 在 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)\r\n 在 System.Data.SqlClient.SqlCommand.ExecuteNonQuery()\r\n 在 digitalshop.Components.Database.RunProc(String procName, SqlParameter[] prams) 位置 d:\\Visual Studio 2005\\WebSites\\数码商店\\App_Code\\Components\\Database.cs:行号 41\r\n 在 digitalshop.Components.Order.Add(String xml) 位置 d:\\Visual Studio 2005\\WebSites\\数码商店\\App_Code\\Components\\Order.cs:行号 27"rnrnrn代码比较多,请高手耐心看一下,如果问题解决,将非常感谢 论坛

救命啊!无法绑定多个部分组成标识符

09-05

[code=SQL]SET ANSI_NULLS ONrnGOrnSET QUOTED_IDENTIFIER ONrnGOrnALTER PROCEDURE [dbo].[GetRecordList] rn @CurrentWarehouse INT,rn @Code NVARCHAR(50),rn @LocationID NVARCHAR(50),rn @Begin DATETIME,rn @End DATETIME,rn @Page INT,rn @PageSize INT,rn @RowCount INT OUTPUTrnAS rn DECLARE @iTemp INTrn IF @CurrentWarehouse = 0rn SET @CurrentWarehouse = '%%'rn ELSErn SET @CurrentWarehouse=LTRIM(@CurrentWarehouse)rn IF @Code = ''rn SET @Code = '%%'rn SET @RowCount = 0rnrn SELECT @RowCount = COUNT(1) FROM (rn SELECT L.Amount,L.warehouseID,L.LocationID,Locations.LastUpdate,P.* FROM Products P INNER JOIN LocationStorage L ON P.ID=L.ProductID rn JOIN dbo.Locations ON Locations.ID=L.LocationID ) AS Checkp WHERE Code LIKE '%'+@Code+'%' AND warehouseID LIKE @CurrentWarehousern AND LocationID LIKE '%'+@LocationID+'%' AND Locations.LastUpdate BETWEEN @Begin AND @End rn rn IF(@RowCount = 0)rn RETURN 0rn SET @iTemp = (@Page - 1) * @PageSize ;rn WITH tmp_tablern ASrn (rn SELECT ROW_NUMBER() OVER(ORDER BY Code) AS row_id,* FROM (SELECT L.Amount,L.warehouseID,L.LocationID,Locations.LastUpdate,P.* FROM Products P INNER JOIN LocationStorage L ON P.ID=L.ProductID rn JOIN dbo.Locations ON Locations.ID=L.LocationID) AS Checkprn )rn SELECT TOP (@PageSize) * FROM tmp_table WHERE row_id>@iTemp AND Code like '%'+@Code+'%' AND warehouseID LIKE @CurrentWarehouse AND LocationID LIKE '%'+@LocationID+'%' AND Locations.LastUpdate BETWEEN @Begin AND @End ORDER BY Code ASCrnrn[/code]rnrn[color=#FF0000]消息 4104,级别 16,状态 1,过程 GetRecordList,第 25 行rn无法绑定由多个部分组成的标识符 "Locations.LastUpdate"。rn消息 4104,级别 16,状态 1,过程 GetRecordList,第 25 行rn无法绑定由多个部分组成的标识符 "Locations.LastUpdate"。rn消息 4104,级别 16,状态 1,过程 GetRecordList,第 33 行rn无法绑定由多个部分组成的标识符 "Locations.LastUpdate"。rn消息 4104,级别 16,状态 1,过程 GetRecordList,第 33 行rn无法绑定由多个部分组成的标识符 "Locations.LastUpdate"。[/color] 论坛

没有更多推荐了,返回首页