Number of WITH clause column names does not match number of elements in select list (ORA-32038)
See original GitHub issueHi,
I’m developing a complex query made by some CTEs.
I can compile without problem but the emitted SQL query contains some errors.
I have added four comments like -- Error: ...
to explain the corrections needed to run the query.
-- Wip Oracle.Managed Oracle
DECLARE @SfcBo_1 Varchar2(20) -- String
SET @SfcBo_1 = 'SFCBO:8110,C17C05016'
WITH GetAllowedNcCode (NcCodeBo, NcCode, NcCodeDescription)
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')
),
FindProductionFailedNcData
(
SfcBo,
CurrentOperationBo,
Site,
UserBo,
ShopOrderBo,
ResourceBo,
WorkCenterBo,
ItemBo,
NcCodeBo,
NcCode,
NcCodeDescription,
OperationColumn,
OperationBo,
Description,
SfcColumn,
Handle,
PartitionDate
)
AS
(
SELECT
sfc.HANDLE as SfcBo,
'OperationBO:' || ncData.SITE || ',' || operationItem.OPERATION || ',#' as CurrentOperationBo,
ncData.SITE as Site,
ncData.USER_BO as UserBo,
sfc.SHOP_ORDER_BO as ShopOrderBo,
ncData.RESOURCE_BO as ResourceBo,
ncData.WORK_CENTER_BO as WorkCenterBo,
sfc.ITEM_BO as ItemBo,
ncCodeItem.NcCodeBo,
ncCodeItem.NcCode,
ncCodeItem.NcCodeDescription,
operationItem.OPERATION as Operation_1,
ncData.OPERATION_BO as OperationBo,
operationItem.DESCRIPTION as OperationDescription,
sfc.SFC as Sfc,
ncData.HANDLE as NcDataBo,
ncData.PARTITION_DATE as PartitionDate
FROM
WIPUSER.NC_DATA ncData
INNER JOIN GetAllowedNcCode ncCodeItem ON ncCodeItem.NcCodeBo = ncData.NC_CODE_BO
INNER JOIN WIPUSER.SFC sfc ON ncData.NC_CONTEXT_GBO = sfc.HANDLE
INNER JOIN WIPUSER.OPERATION operationItem ON ncData.OPERATION_BO = operationItem.HANDLE
INNER JOIN WIPUSER.CUSTOM_FIELDS customFields_1 ON sfc.SHOP_ORDER_BO = customFields_1.HANDLE AND 'ORDER_TYPE' = customFields_1.ATTRIBUTE AND 'ZPRN' = customFields_1.VALUE
),
FilterByTestOperation
(
Site,
UserBo,
ShopOrderBo,
ResourceBo,
WorkCenterBo_1,
ItemBo_1,
RouterOperationBo,
SfcBo,
NcCodeBo,
NcCode,
NcCodeDescription,
OperationColumn,
OperationBo,
Description,
SfcColumn,
Handle,
PartitionDate,
Handle_1,
ItemBo, -- Error: Already declared as ItemBo_1
WorkCenterBo -- Error: Already declared as WorkCenterBo_1
)
AS
(
SELECT
inputItem_1.Site,
inputItem_1.UserBo,
inputItem_1.ShopOrderBo,
inputItem_1.ResourceBo,
inputItem_1.WorkCenterBo,
inputItem_1.ItemBo,
routerOperation.HANDLE as RouterOperationBo,
inputItem_1.SfcBo,
inputItem_1.NcCodeBo,
inputItem_1.NcCode,
inputItem_1.NcCodeDescription,
inputItem_1.OperationColumn,
inputItem_1.OperationBo,
inputItem_1.Description,
inputItem_1.SfcColumn,
inputItem_1.Handle,
inputItem_1.PartitionDate,
sfcStep.HANDLE as SfcStepBo
FROM
FindProductionFailedNcData inputItem_1
INNER JOIN WIPUSER.SFC_ROUTING sfcRouting ON inputItem_1.SfcBo = sfcRouting.SFC_BO
INNER JOIN WIPUSER.SFC_ROUTER sfcRouter ON sfcRouting.HANDLE = sfcRouter.SFC_ROUTING_BO
INNER JOIN WIPUSER.SFC_STEP sfcStep ON sfcRouter.HANDLE = sfcStep.SFC_ROUTER_BO
INNER JOIN WIPUSER.ROUTER_STEP routerStep ON sfcRouter.ROUTER_BO = routerStep.ROUTER_BO AND sfcStep.STEP_ID = routerStep.STEP_ID
INNER JOIN WIPUSER.ROUTER_OPERATION routerOperation ON routerStep.HANDLE = routerOperation.ROUTER_STEP_BO AND inputItem_1.CurrentOperationBo = routerOperation.OPERATION_BO
INNER JOIN WIPUSER.CUSTOM_FIELDS customFields_2 ON routerOperation.HANDLE = customFields_2.HANDLE AND 'OPERATION_TYPE' = customFields_2.ATTRIBUTE AND 'T' = customFields_2.VALUE
INNER JOIN WIPUSER.ROUTER router ON sfcRouter.ROUTER_BO = router.HANDLE
WHERE
(sfcRouter.COMPLETED = 'false' AND sfcRouter.IN_USE = 'true' OR sfcRouter.COMPLETED = 'true' AND router.ROUTER_TYPE = 'U')
),
GetAdditionalData
(
SfcBo,
Description,
NcCodeBo,
NcCode,
NcCodeDescription,
OperationColumn,
OperationBo,
UserBo,
Description_1,
Site,
SfcColumn,
ShopOrderBo,
ItemBo,
Handle,
ResourceBo,
WorkCenterBo,
PartitionDate,
Handle_1,
RouterOperationBo,
ShopOrderColumn,
ResrceColumn,
Description_2,
WorkCenterColumn,
Description_3,
WorkCenterColumn_1,
Description_4,
ItemColumn,
Description_5,
Value,
Value_1,
ItemGroupColumn,
Description_6,
Value_2,
UserId,
BadgeNumber
)
AS
(
SELECT
inputItem_2.SfcBo,
site.DESCRIPTION as SiteDescription,
inputItem_2.NcCodeBo,
inputItem_2.NcCode,
inputItem_2.NcCodeDescription,
inputItem_2.OperationColumn,
inputItem_2.OperationBo,
inputItem_2.UserBo,
inputItem_2.Description,
inputItem_2.Site,
inputItem_2.SfcColumn,
inputItem_2.ShopOrderBo,
inputItem_2.ItemBo, -- Error: should be ItemBo_1
inputItem_2.Handle,
inputItem_2.ResourceBo,
inputItem_2.WorkCenterBo, -- Error: should be WorkCenterBo_1
inputItem_2.PartitionDate,
inputItem_2.Handle_1,
inputItem_2.RouterOperationBo,
shopOrder.SHOP_ORDER as ShopOrder,
resrce.RESRCE as Resrce,
resrce.DESCRIPTION as ResrceDescription,
workCenter.WORK_CENTER as Workcenter,
workCenter.DESCRIPTION as WorkcenterDescription,
line.WORK_CENTER as Line,
line.DESCRIPTION as LineDescription,
item.ITEM as Item,
item.DESCRIPTION as ItemDescription,
customField_1.VALUE as ProductLine,
customField_2.VALUE as ProductGroup,
itemGroup.ITEM_GROUP as ItemGroup,
itemGroup.DESCRIPTION as ItemGroupDescription,
customField_3.VALUE as TestCategory,
usr.USER_ID as UserId,
usr.BADGE_NUMBER as BadgeNumber
FROM
FilterByTestOperation inputItem_2
LEFT JOIN WIPUSER.SITE site ON site.SITE = inputItem_2.Site
LEFT JOIN WIPUSER.USR usr ON usr.HANDLE = inputItem_2.UserBo
LEFT JOIN WIPUSER.SHOP_ORDER shopOrder ON shopOrder.HANDLE = inputItem_2.ShopOrderBo
LEFT JOIN WIPUSER.RESRCE resrce ON resrce.HANDLE = inputItem_2.ResourceBo
LEFT JOIN WIPUSER.WORK_CENTER workCenter ON workCenter.HANDLE = inputItem_2.WorkCenterBo -- Error: Should be WorkCenterBo_1
LEFT JOIN WIPUSER.WORK_CENTER_MEMBER workCenterMember ON workCenterMember.WORK_CENTER_OR_RESOURCE_GBO = inputItem_2.WorkCenterBo_1
LEFT JOIN WIPUSER.WORK_CENTER line ON line.HANDLE = workCenterMember.WORK_CENTER_BO
LEFT JOIN WIPUSER.ITEM item ON item.HANDLE = inputItem_2.ItemBo -- Error: Should be ItemBo_1
LEFT JOIN WIPUSER.ITEM_GROUP_MEMBER itemGroupMember ON itemGroupMember.ITEM_BO = inputItem_2.ItemBo_1
LEFT JOIN WIPUSER.ITEM_GROUP itemGroup ON itemGroup.HANDLE = itemGroupMember.ITEM_GROUP_BO
LEFT JOIN WIPUSER.CUSTOM_FIELDS customField_1 ON customField_1.ATTRIBUTE = 'PRODUCT_LINE' AND customField_1.HANDLE = inputItem_2.ItemBo_1
LEFT JOIN WIPUSER.CUSTOM_FIELDS customField_2 ON customField_2.ATTRIBUTE = 'SPART' AND customField_2.HANDLE = inputItem_2.ItemBo_1
LEFT JOIN WIPUSER.CUSTOM_FIELDS customField_3 ON customField_3.ATTRIBUTE = 'TEST_CATEGORY' AND customField_3.HANDLE = inputItem_2.RouterOperationBo
)
SELECT
inputItem_3.Description,
inputItem_3.NcCodeBo,
inputItem_3.NcCode,
inputItem_3.NcCodeDescription,
inputItem_3.OperationColumn,
inputItem_3.OperationBo,
inputItem_3.UserBo,
inputItem_3.Description_1,
inputItem_3.Site,
inputItem_3.SfcBo,
inputItem_3.SfcColumn,
inputItem_3.ShopOrderBo,
inputItem_3.ItemBo,
inputItem_3.Handle,
inputItem_3.ResourceBo,
inputItem_3.WorkCenterBo,
inputItem_3.PartitionDate,
inputItem_3.Handle_1,
inputItem_3.RouterOperationBo,
inputItem_3.ShopOrderColumn,
inputItem_3.ResrceColumn,
inputItem_3.Description_2,
inputItem_3.WorkCenterColumn,
inputItem_3.Description_3,
inputItem_3.WorkCenterColumn_1,
inputItem_3.Description_4,
inputItem_3.ItemColumn,
inputItem_3.Description_5,
inputItem_3.Value as Value_3,
inputItem_3.Value_1,
inputItem_3.ItemGroupColumn,
inputItem_3.Description_6,
inputItem_3.Value_2,
inputItem_3.UserId,
inputItem_3.BadgeNumber
FROM
GetAdditionalData inputItem_3
WHERE
inputItem_3.SfcBo = :SfcBo_1
If can help I have exported the DebugView of the expression: Expression.DebugView.txt
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
Oracle SQL - number of WITH clause column names does ...
Oracle SQL - number of WITH clause column names does not match number of elements in select list. Can anyone explain why this...
Read more >Oracle Error ORA-32038: number of WITH clause column ...
Oracle Error ORA-32038: number of WITH clause column names does not match number of elements in select list · Oracle Error Message. ORA-32038:...
Read more >Oracle Database Error Code ORA-32038 Description
Cause: A list of column aliases or names was specified for a WITH clause query name but the number of elements in the...
Read more >OraFAQ Forum: SQL & PL/SQL » Help w/ REGEXP_SUBSTR
ORA-32038 : number of WITH clause column names does not match number of elements in select list 32038. 00000 - "number of WITH...
Read more >ORA-32038: number of WITH clause column names does ...
Cause: A list of column aliases or names was specified for a WITH clause query name but the number of elements in the...
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
This could help https://github.com/linq2db/linq2db/wiki/Issue-reporting#generating-the-test , but it’s not ideal currently #1752
Will fix that ASAP.