SQL Error: lack of space between the CTE's name and 'AS' keyword
See original GitHub issueI 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
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Getting an odd error, SQL Server query using `WITH` clause
When a CTE is used in a statement that is part of a batch, the statement before it must be followed by a...
Read more >SQLSTATE values and common error codes
SQLSTATE values are comprised of a two-character class code value, ... SQLDA for ALL information (i.e. not enough descriptors to return the distinct...
Read more >13.2.20 WITH (Common Table Expressions)
A common table expression (CTE) is a named temporary result set that exists within the scope of a single statement and that can...
Read more >SQL Error when using CTE inside THEN of CASE expression
You are missing the END on your case statement. That's why you get the Incorrect syntax near the keyword 'FROM'. error. You cannot...
Read more >Rules Reference — SQLFluff 0.6.3 documentation
Rules in SQLFluff are implemented as crawlers . These are entities which ... In this example, there is a space missing space between...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For v3 we switched from MyGet feed to Azure Artifacts for preview versions: https://dev.azure.com/linq2db/linq2db/_packaging?_a=feed&feed=linq2db%40Local
Clicking to
Connect to feed
button will get you nuget feed to use with Visual studio@filippobottega, for testing purposes turn queries logging on
And you can read queries in Output. Or redirect to console.