Коллеги, добрый день!

Не подскажете, почему при генерации запроса (в атачменте) под пользователем на выходе получаем скрипт, который неправильно подменяет внутри WHERE view без учета алиаса (в FROM)?
Запрос отваливается: multipart identifier could not be bound.

В качестве временного решения пришлось задать алиас таблице в FROM совпадающий с именем view.
(Подозреваю, что это будет работать только для обычных пользователей, под Администратором - отвалится)

Версия бинарников у пользователей 3.3.2.244
У меня есть 267 сборка, но на ней не проверял.

Вот какой запрос получаем в результате:

exec sp_executesql N'SELECT
[tbl_Request].[ID] AS [ID]
FROM
[dbo].[vw_Request] AS [tbl_Request]
WHERE([vw_Request].[AccountID] = @P1 AND
[vw_Request].[OpportunityID] = @P2 AND
(
(SELECT
[tbl_RequestStatus].[IsFinish] AS [IsFinish]
FROM
[dbo].[tbl_RequestStatus] AS [tbl_RequestStatus]
WHERE([tbl_RequestStatus].[ID] = [vw_Request].[StatusID])) = @P3 OR

(SELECT
[tbl_RequestStatusNull].[IsFinish] AS [IsFinish]
FROM
[dbo].[tbl_RequestStatus] AS [tbl_RequestStatusNull]
WHERE([tbl_RequestStatusNull].[ID] = [vw_Request].[StatusID])) IS NULL) AND
[vw_Request].[ResultID] = @P4 AND
[vw_Request].[TypeID] > @P5 AND
NOT [vw_Request].[DepartmentID] = @P6)',N'@P1 varchar(8000),@P2 varchar(8000),@P3 int,@P4 varchar(8000),@P5 varchar(8000),@P6 varchar(8000)','{F96EAD0A-E944-4E4D-ACC2-F3CCF4D2155E}','{E0A4ED0A-2EBC-43DD-9BF1-1FFB865FE0BE}',0,'{B6594F37-D0F3-4748-B441-02279E01EBA6}','{DB5E7C60-58C8-47E1-A309-9DAA51A3167E}','{31897B29-FA6B-4FB2-9A0C-C498FB5A8085}'

Нравится

1 комментарий

Здравствуйте!

Проверил на 3.3.2.257, ситуация не воспроизводится. Попробуйте обновиться на более новую версию сборки, направив запрос на обновление на support@terrasoft.ru

SELECT
	[tbl_Account22].[ID] AS [ID],
	[tbl_Account22].[Name] AS [Name],
	[tbl_Account22].[OfficialAccountName] AS [OfficialAccountName],
	[tbl_Account22].[AnnualRevenue] AS [AnnualRevenue],
	[tbl_Account22].[EmployeesNumber] AS [EmployeesNumber],
	[tbl_Account22].[Address] AS [Address],
	[tbl_Account22].[AddressTypeID] AS [AddressTypeID],
	[tbl_Account22].[Communication1] AS [Communication1],
	[tbl_Account22].[Communication1TypeID] AS [Communication1TypeID],
	[tbl_Account22].[Communication2] AS [Communication2],
	[tbl_Account22].[Communication2TypeID] AS [Communication2TypeID],
	[tbl_Account22].[Communication3] AS [Communication3],
	[tbl_Account22].[Communication3TypeID] AS [Communication3TypeID],
	[tbl_Account22].[Communication4] AS [Communication4],
	[tbl_Account22].[Communication4TypeID] AS [Communication4TypeID],
	[tbl_Account22].[Communication5] AS [Communication5],
	[tbl_Account22].[Communication5TypeID] AS [Communication5TypeID],
	[tbl_City].[Name] AS [CityName],
	[tbl_Account22].[CityID] AS [CityID],
	[tbl_Account22].[ZIP] AS [ZIP],
	[tbl_Campaign].[Name] AS [CampaignName],
	[tbl_Account22].[CampaignID] AS [CampaignID],
	[tbl_Contact].[Name] AS [PrimaryContactName],
	[tbl_Account22].[PrimaryContactID] AS [PrimaryContactID],
	[tbl_Country].[Name] AS [CountryName],
	[tbl_Account22].[CountryID] AS [CountryID],
	[tbl_State].[Name] AS [StateName],
	[tbl_Account22].[StateID] AS [StateID],
	[tbl_Territory].[Name] AS [TerritoryName],
	[tbl_Account22].[TerritoryID] AS [TerritoryID],
	[Owner].[Name] AS [OwnerName],
	[tbl_Account22].[OwnerID] AS [OwnerID],
	[tbl_Account22].[ActivityID] AS [ActivityID],
	[tbl_Activity].[Name] AS [ActivityName],
	[tbl_Account22].[FieldID] AS [FieldID],
	[tbl_Field].[Name] AS [FieldName],
	[tbl_Account22].[AccountTypeID] AS [AccountTypeID],
	[tbl_AccountType].[Name] AS [AccountTypeName],
	[tbl_AddressType].[Name] AS [AddressTypeName],
	[CommunicationType1].[Name] AS [Communication1TypeName],
	[CommunicationType2].[Name] AS [Communication2TypeName],
	[CommunicationType3].[Name] AS [Communication3TypeName],
	[CommunicationType4].[Name] AS [Communication4TypeName],
	[CommunicationType5].[Name] AS [Communication5TypeName],
	[tbl_Account22].[Code] AS [Code],
	[tbl_Account22].[TaxRegistrationCode] AS [TaxRegistrationCode],
	[tbl_Account22].[CreatedOn] AS [CreatedOn],
	[tbl_Account22].[CreatedByID] AS [CreatedByID],
	[CreatedBy].[Name] AS [CreatedByName],
	[tbl_Account22].[ModifiedOn] AS [ModifiedOn],
	[tbl_Account22].[ModifiedByID] AS [ModifiedByID],
	[ModifiedBy].[Name] AS [ModifiedByName],
	[tbl_Job].[NameOf] AS [JobNameOf],
	[tbl_Account22].[SettledCredit] AS [SettledCredit],
	[tbl_Account22].[PostponementPayment] AS [PostponementPayment]
FROM
	[dbo].[tbl_Account] AS [tbl_Account22]
LEFT OUTER JOIN
	[dbo].[tbl_Contact] AS [tbl_Contact] ON [tbl_Contact].[ID] = [tbl_Account22].[PrimaryContactID]
LEFT OUTER JOIN
	[dbo].[tbl_Territory] AS [tbl_Territory] ON [tbl_Territory].[ID] = [tbl_Account22].[TerritoryID]
LEFT OUTER JOIN
	[dbo].[tbl_Contact] AS [Owner] ON [Owner].[ID] = [tbl_Account22].[OwnerID]
LEFT OUTER JOIN
	[dbo].[tbl_Campaign] AS [tbl_Campaign] ON [tbl_Campaign].[ID] = [tbl_Account22].[CampaignID]
LEFT OUTER JOIN
	[dbo].[tbl_City] AS [tbl_City] ON [tbl_City].[ID] = [tbl_Account22].[CityID]
LEFT OUTER JOIN
	[dbo].[tbl_State] AS [tbl_State] ON [tbl_State].[ID] = [tbl_Account22].[StateID]
LEFT OUTER JOIN
	[dbo].[tbl_Country] AS [tbl_Country] ON [tbl_Country].[ID] = [tbl_Account22].[CountryID]
LEFT OUTER JOIN
	[dbo].[tbl_Activity] AS [tbl_Activity] ON [tbl_Activity].[ID] = [tbl_Account22].[ActivityID]
LEFT OUTER JOIN
	[dbo].[tbl_Field] AS [tbl_Field] ON [tbl_Field].[ID] = [tbl_Account22].[FieldID]
LEFT OUTER JOIN
	[dbo].[tbl_AccountType] AS [tbl_AccountType] ON [tbl_AccountType].[ID] = [tbl_Account22].[AccountTypeID]
LEFT OUTER JOIN
	[dbo].[tbl_Contact] AS [CreatedBy] ON [CreatedBy].[ID] = [tbl_Account22].[CreatedByID]
LEFT OUTER JOIN
	[dbo].[tbl_Contact] AS [ModifiedBy] ON [ModifiedBy].[ID] = [tbl_Account22].[ModifiedByID]
LEFT OUTER JOIN
	[dbo].[tbl_AddressType] AS [tbl_AddressType] ON [tbl_AddressType].[ID] = [tbl_Account22].[AddressTypeID]
LEFT OUTER JOIN
	[dbo].[tbl_CommunicationType] AS [CommunicationType1] ON [CommunicationType1].[ID] = [tbl_Account22].[Communication1TypeID]
LEFT OUTER JOIN
	[dbo].[tbl_CommunicationType] AS [CommunicationType2] ON [CommunicationType2].[ID] = [tbl_Account22].[Communication2TypeID]
LEFT OUTER JOIN
	[dbo].[tbl_CommunicationType] AS [CommunicationType3] ON [CommunicationType3].[ID] = [tbl_Account22].[Communication3TypeID]
LEFT OUTER JOIN
	[dbo].[tbl_CommunicationType] AS [CommunicationType4] ON [CommunicationType4].[ID] = [tbl_Account22].[Communication4TypeID]
LEFT OUTER JOIN
	[dbo].[tbl_CommunicationType] AS [CommunicationType5] ON [CommunicationType5].[ID] = [tbl_Account22].[Communication5TypeID]
LEFT OUTER JOIN
	[dbo].[tbl_Job] AS [tbl_Job] ON [tbl_Job].[ID] = [tbl_Contact].[JobID]
WHERE([tbl_Account22].[ID] = :ID)
Показать все комментарии