-1

这是我的 sql 命令:

select INCOME_TYPE_ID,
       REGION_CODE,
       FIN_YEAR_CODE,
       PORTION_AMOUNT
  from INCOME.INCOME_TYPE, 
       COMMON.REGION, 
       INCOME.RECEIVE_DOC_PORTION, 
       INCOME.ASSESS_ORDER_ITEM, 
       ACCOUNTING.VOUCHER_ITEM_RECEIVE_DOC, 
       ACCOUNTING.VOUCHER_ITEM, 
       ACCOUNTING.VOUCHER, 
       ACCOUNTING.FIN_YEAR
 where INCOME.RECEIVE_DOC_PORTION.ASSESS_ORDER_ITEM_ID = INCOME.ASSESS_ORDER_ITEM.ASSESS_ORDER_ITEM_ID
   and INCOME.ASSESS_ORDER_ITEM.INCOME_TYPE_ID=INCOME.INCOME_TYPE.INCOME_TYPE_ID
   and INCOME.RECEIVE_DOC_PORTION.RECEIVE_DOC_PORTION_ID = ACCOUNTING.VOUCHER_ITEM_RECEIVE_DOC.RECEIVE_DOC_PORTION_ID
   and ACCOUNTING.VOUCHER_ITEM_RECEIVE_DOC.VOUCHER_ITEM_ID = ACCOUNTING.VOUCHER_ITEM.VOUCHER_ITEM_ID
   and ACCOUNTING.VOUCHER_ITEM.VOUCHER_ID = ACCOUNTING.VOUCHER.VOUCHER_ID
   and ACCOUNTING.VOUCHER.REGION_CODE = COMMON.REGION.REGION_CODE
   and ACCOUNTING.VOUCHER.FIN_YEAR_CODE = ACCOUNTING.FIN_YEAR.FIN_YEAR_CODE

我得到了这个错误:

定义不明确的列

我正在使用 SQL Developer 作为 Oracle 客户端。

4

3 回答 3

6

显然,选择列表中的一个(或多个)列名存在于 FROM 列表的多个表中。

您需要在 SELECT 列表中的每一列前面加上它来自的表(无论它们是否模棱两可,始终这样做也是一个好习惯)

于 2012-07-29T08:18:57.700 回答
1

在选择查询中的每一列之前提及表的名称。不明确的列意味着您在其中一个 SELECT 语句中有多个具有相同名称的列。

于 2012-07-29T08:18:35.333 回答
1

试试这个,用它们的完全限定名称为所有选定的列添加前缀(就像你在你的其他地方所做的那样SELECT):

select INCOME.INCOME_TYPE.INCOME_TYPE_ID,
       COMMON.REGION.REGION_CODE,
       ACCOUNTING.FIN_YEAR.FIN_YEAR_CODE,
       ACCOUNTING.VOUCHER_ITEM_RECEIVE_DOC.PORTION_AMOUNT
  from INCOME.INCOME_TYPE, 
       COMMON.REGION, 
       INCOME.RECEIVE_DOC_PORTION, 
       INCOME.ASSESS_ORDER_ITEM, 
       ACCOUNTING.VOUCHER_ITEM_RECEIVE_DOC, 
       ACCOUNTING.VOUCHER_ITEM, 
       ACCOUNTING.VOUCHER, 
       ACCOUNTING.FIN_YEAR
 where INCOME.RECEIVE_DOC_PORTION.ASSESS_ORDER_ITEM_ID = INCOME.ASSESS_ORDER_ITEM.ASSESS_ORDER_ITEM_ID
   and INCOME.ASSESS_ORDER_ITEM.INCOME_TYPE_ID = INCOME.INCOME_TYPE.INCOME_TYPE_ID
   and INCOME.RECEIVE_DOC_PORTION.RECEIVE_DOC_PORTION_ID = ACCOUNTING.VOUCHER_ITEM_RECEIVE_DOC.RECEIVE_DOC_PORTION_ID
   and ACCOUNTING.VOUCHER_ITEM_RECEIVE_DOC.VOUCHER_ITEM_ID = ACCOUNTING.VOUCHER_ITEM.VOUCHER_ITEM_ID
   and ACCOUNTING.VOUCHER_ITEM.VOUCHER_ID = ACCOUNTING.VOUCHER.VOUCHER_ID
   and ACCOUNTING.VOUCHER.REGION_CODE = COMMON.REGION.REGION_CODE
   and ACCOUNTING.VOUCHER.FIN_YEAR_CODE = ACCOUNTING.FIN_YEAR.FIN_YEAR_CODE

我不得不猜测小马的限定名

ACCOUNTING.VOUCHER_ITEM_RECEIVE_DOC.PORTION_AMOUNT

有可能

INCOME.RECEIVE_DOC_PORTION.PORTION_AMOUNT

但是您应该能够轻松解决该问题。

希望能帮助到你...

于 2012-07-30T10:49:55.640 回答