Question

Case Statement in Lobby Data Source Designer is not working

  • 17 March 2023
  • 4 replies
  • 93 views

Badge +1

Hi all,

This following case statement is executing successfully in quick reports but it will not work in data source designer. When I preview the data source, it loads for awhile like it wants to run but then it fails.

Any ideas?

 

(SELECT CASE WHEN INVENTORY_TRANSACTION_HIST.TRANSACTION_CODE='OESHIP' AND PART_CATALOG_CFV.PART_MAIN_GROUP='DOMESTIC FG' THEN  INVENTORY_TRANSACTION_HIST.QUANTITY * PART_CATALOG_CFV.CF$_PROOF_GALLONS WHEN INVENTORY_TRANSACTION_HIST.TRANSACTION_CODE='OESHIP' AND PART_CATALOG_CFV.PART_MAIN_GROUP='EXPORT FG' THEN INVENTORY_TRANSACTION_HIST.QUANTITY * PART_CATALOG_CFV.CF$_PROOF_GALLONS WHEN INVENTORY_TRANSACTION_HIST.TRANSACTION_CODE='SHIPTRAN' AND PART_CATALOG_CFV.PART_MAIN_GROUP='DOMESTIC FG' THEN INVENTORY_TRANSACTION_HIST.QUANTITY * PART_CATALOG_CFV.CF$_PROOF_GALLONS WHEN INVENTORY_TRANSACTION_HIST.TRANSACTION_CODE='SHIPTRAN' AND PART_CATALOG_CFV.PART_MAIN_GROUP='EXPORT FG' THEN 0 END FROM INVENTORY_TRANSACTION_HIST, PART_CATALOG_CFV WHERE INVENTORY_TRANSACTION_HIST.PART_NO=PART_CATALOG_CFV.PART_NO)


4 replies

Userlevel 3
Badge +8

Hi,

Does it run as the same user in quick report mode as it does in the lobby?

What error does it actually fail with?

Badge +1

Thanks for the reply. It does run as the same user in quick report mode as it does in lobby data source designer. I don’t get an exact error message. It just says to make sure my columns are configured correctly

Userlevel 3
Badge +8

I’ll hazard a quick guess - the case statements would work as straight SQL because the column name is worked out on the fly, but the lobby designer may actually need a output field name to work.  Try changing the case statement so that you specify a column name for the output data e.g.

 

( SELECT
CASE
WHEN inventory_transaction_hist.transaction_code = 'OESHIP'
AND part_catalog_cfv.part_main_group = 'DOMESTIC FG' THEN inventory_transaction_hist.quantity * part_catalog_cfv.cf$_proof_gallons
WHEN inventory_transaction_hist.transaction_code = 'OESHIP'
AND part_catalog_cfv.part_main_group = 'EXPORT FG' THEN inventory_transaction_hist.quantity * part_catalog_cfv.cf$_proof_gallons
WHEN inventory_transaction_hist.transaction_code = 'SHIPTRAN'
AND part_catalog_cfv.part_main_group = 'DOMESTIC FG' THEN inventory_transaction_hist.quantity * part_catalog_cfv.cf$_proof_gallons
WHEN inventory_transaction_hist.transaction_code = 'SHIPTRAN'
AND part_catalog_cfv.part_main_group = 'EXPORT FG' THEN 0
END as value
FROM
inventory_transaction_hist,
part_catalog_cfv
WHERE
inventory_transaction_hist.part_no = part_catalog_cfv.part_no
)

here I’ve taken your code and specified a field name of “value”.

Badge +1

I thought the same thing at first as well. In the data source designer you define the column name beside the select statements. Thanks again!

Reply