SQL Error: lack of space between the CTE's name and 'AS' keyword #2061
Closed
Description
I have created a CTE and I need to get the row count letting the server to calculate the result.
There is an error on emitted SQL:
-- Wip Oracle.Managed Oracle
WITH AllowedNcCodeAS -- Should be AllowedNcCode AS
(
SELECT DISTINCT
ncCode.HANDLE as NcCodeBo,
ncCode.NC_CODE as NcCode,
ncCode.DESCRIPTION as NcCodeDescription
FROM
WIPUSER.NC_CODE ncCode
INNER JOIN WIPUSER.NC_GROUP_MEMBER ncGroupMember ON ncCode.HANDLE = ncGroupMember.NC_CODE_OR_GROUP_GBO
WHERE
((ncGroupMember.NC_GROUP_BO = 'NCGroupBO:' || ncCode.SITE || ',CATAN_AUTO' OR ncGroupMember.NC_GROUP_BO = 'NCGroupBO:' || ncCode.SITE || ',CATAN_MAN') OR ncGroupMember.NC_GROUP_BO = 'NCGroupBO:' || ncCode.SITE || ',CATAN_ALL')
)
SELECT
COUNT(*) as Count_1
FROM
AllowedNcCode item
I'm using the CTE as:
var countQuery = wipCte.AllowedNcCode().Select(item => new { Count = Sql.Ext.Count().ToValue() });
var sqlText = ((IExpressionQuery)countQuery).SqlText;
Code project:
LinqToDb.Sample3.zip
Environment details
linq2db version: 3.0.0-preview.1
Database Server: Oracle
Database Provider: Oracle.ManagedDataAccess.Core (3.0.0-preview.1)
Operating system: Windows 10
.NET Framework:.NET Core 3.1