BizTalk WCF-SQL Adapter Selecting from a view

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 00:52:26

So; having given up on the Select from View operation which should be simple and suspecting there is a problem with the code for this particular part of the adapter i decided to try a "trick".

I created a stored procedure that simply does SELECT * FROM VIEW WHERE ID = @Param (same view that was causing issues earlier) where Param is the AccountNum i was passing in to the ViewOp criteria

Then used the adapter wizard to generate the schemas for TypeStoredProcedure operation instead of the ViewOp Changed the map to produce this new message Redploy And presto ... i can now happily switch between two environments without any errors!

this clearly says to me that there is a problem with the ViewOp portion of the SQL adapter!?!? Anybody got any other ideas / explanations as to why this would be happening other than a problem with the adapter?

I know most people say don't use Views and go to Stored Procedures instead, but there is a very strong reason why we are using Views. We're selecting against a Microsoft Dynamics AX database. AX publishes these Views for external systems to use. Creating a stored procedure against the AX schema is not supported by Microsoft as it changes their database. The same goes if we were using Views on CRM, we can't go creating stored procedures at will.

So the solution i have now might work, but it's not supported. It'll have to stay for now until we get this resolved though

Dmitry Golubets

I met the same problem recently. After spending a day I finally started an SQL Profiler and found a cause. For some reason in some DBs, including Ax2009 DB, there is a difference in column order listed in view and column order that biztalk wants. It executes the following code and wants the columns to be in exact order ('*' won't work for you):

exec sp_executesql N'SELECT sp.type AS [ObjectType], modify_date AS [LastModified] FROM sys.all_objects AS sp WHERE (sp.name=@ORIGINALOBJECTNAME and SCHEMA_NAME(sp.schema_id)=@ORIGINALSCHEMANAME);SELECT clmns.name AS [Name], usrt.name AS [DataType], SCHEMA_NAME(usrt.schema_id) AS DataTypeSchemaName, usrt.is_assembly_type AS [IsAssemblyType], clmns.is_identity AS [IsIdentity], ISNULL(baset.name, N'''') AS [SystemType], CAST(CASE WHEN baset.name IN (N''nchar'', N''nvarchar'') AND clmns.max_length <> -1 THEN clmns.max_length/2 ELSE clmns.max_length END AS int) AS [Length], CAST(clmns.[precision] AS int) AS [NumericPrecision], CAST(clmns.[scale] AS int) AS [NumericScale], clmns.is_nullable as [IsNullable], clmns.is_computed as [IsComputed], 0 as [IsFileStream], AT.assembly_qualified_name AS AssemblyQualifiedName, defCst.definition AS [DefaultValue] FROM sys.columns as clmns LEFT OUTER JOIN sys.default_constraints defCst on defCst.parent_object_id = clmns.object_id and defCst.parent_column_id = clmns.column_id LEFT OUTER JOIN sys.types AS usrt ON usrt.user_type_id = clmns.user_type_id LEFT OUTER JOIN sys.types AS baset ON baset.user_type_id = clmns.system_type_id and baset.user_type_id = baset.system_type_id LEFT JOIN sys.assembly_types AT ON AT.[name] = usrt.name AND AT.schema_id = usrt.schema_id WHERE clmns.object_id = (SELECT object_id FROM sys.objects o WHERE o.name=@ORIGINALOBJECTNAME and SCHEMA_NAME(o.schema_id)=@ORIGINALSCHEMANAME)',N'@ORIGINALOBJECTNAME nvarchar(13),@ORIGINALSCHEMANAME nvarchar(3)',@ORIGINALOBJECTNAME=N'CRM_CFU',@ORIGINALSCHEMANAME=N'dbo'

Just replace @ORIGINALOBJECTNAME value with your view name, and put columns in your select in the exact order.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!