0

我在数据模型中的 ORDER BY 条件有问题。我想将参数传递给 ORDER BY 并根据参数的值对数据进行排序。这是代码:

select *
from   (
   select t1.header_id,
          t1.ebs_trx_number BROJ_FAKTURE,
          t1.premise_or_group_code OZNAKA_PROSTORA_ILI_GRUPE,
          t1.SHIP_TO_ADDRESS ADRESA_PROSTORA_ILI_GRUPE,
          to_number(t1.code_customer) SIFRA_KUPCA,
          t1.name_customer NAZIV_KUPCA,
          t1.heating_type VRSTA_GREJANJA,
          t1.amount_vat_excluded IZNOS_BEZ_PDV,
          t1.amount_vat PDV,
          t1.amount_vat_included IZNOS_SA_PDV
   from   XXBILL.XXBILL_INVOICE_HEADERS_HISTORY t1
   where  t1.billing_period = :P_PERIOD
   and    t1.heating_type = nvl(:P_HEATING_TYPE, t1.heating_type)
   UNION
   select t2.header_id,
          t2.ebs_trx_number,
          t2.premise_or_group_code,
          t2.SHIP_TO_ADDRESS,
          to_number(t2.code_customer),
          t2.name_customer,
          t2.heating_type,
          t2.amount_vat_excluded,
          t2.amount_vat,
          t2.amount_vat_included
   from   XXBILL.XXBILL_INVOICE_HEADERS t2
   where  exists (select 1
                  from   xxbill.xxbill_period t3
                  where  t3.ID_PERIOD = :P_PERIOD
                  and    t3.STATUS = 'OTV')
   and    t2.heating_type = nvl(:P_HEATING_TYPE, t2.heating_type)
   )
order  by :P_SORT

P_SORT 可以是 2、3 或 5,BIP 接受此代码,但它只是想对数据进行排序。

有谁知道我该如何解决这个问题?

在此先感谢,斯特凡

4

1 回答 1

2

如果您想按列排序:p_short,它应该包含多个值。要将多个值作为参数,您必须为此创建 LOV。如果您将为参数输入单个值,则 order by 可能不起作用。

希望这是有道理的。

如果您还有其他问题,请更新?

于 2016-04-01T12:29:39.953 回答