gpt4 book ai didi

java - Pervasive 8 中的案例陈述

转载 作者:太空宇宙 更新时间:2023-11-04 08:20:06 25 4
gpt4 key购买 nike

我想在 Pervasive 中使用 case 语句,因为它也缺乏对 Coalesce 的支持。但似乎 Pervasive 8 也缺乏对 Case 语句的支持。

所以我想检查是否有替代解决方案来解决我的问题。

SELECT top 100 
STOCKTR.PHEADPR,
'' as tom
,case Pheadpr.BLNO when <> '' then Pheadpr.BLNO else STOCKTR.PHEADPR end as BLNO
,Pheadpr.custno
,Pheadpr.cust_name
,Pheadpr.company_name
,Pheadpr.company_city
,Pheadpr.invno
,Pheadpr.curr_code
,STOCKTR.RECID
,STOCKTR.ARTNO
,STOCKTR.DATE
,STOCKTR.QTY_PCS
,STOCKTR.PRICE_SEK_PCS
,STOCKTR.ULAND
FROM STOCKTR INNER JOIN PHEADPR
ON PHEADPR.NO = STOCKTR.PHEADPR
WHERE STOCKTR.TRCODE='02' AND STOCKTR.PHEADPR <> '0'
order by STOCKTR.DATE desc

所以我的问题集中在我的选择语句中的第四行,上面写着

case Pheadpr.BLNO when <> '' then Pheadpr.BLNO else STOCKTR.PHEADPR end as BLNO

我希望这会产生 1 列输出。在 Pervasive 8 中是否有办法解决这个问题,以便我可以从查询中获得类似案例的行为?

作为旁注,我正在使用 JDBC 驱动程序并从 Java 程序执行查询。

最佳答案

您可以使用 IF 语句。语法为:

IF ( search-condition , expression , expression )

所以,在你的情况下,你可能需要这样的东西:

IF ( Pheadpr.BLNO <> '' , Pheadpr.BLNO, STOCKTR.PHEADPR) as BLNO

如果可能的话,您应该考虑升级到当前版本的 PSQL V11,支持 CASE 和 COALESCE 语句,并且成为受支持的 PSQL 版本。

关于java - Pervasive 8 中的案例陈述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9719237/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com