我想在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所以我的问题集中在select语句的第四行
case Pheadpr.BLNO when <> '' then Pheadpr.BLNO else STOCKTR.PHEADPR end as BLNO我希望这会产生1列的输出。在pervasive 8中有没有解决这个问题的方法,这样我就可以从我的查询中获得类似于案例的行为?
顺便提一下,我使用JDBC驱动程序并从Java程序执行查询。
发布于 2012-03-15 21:11:56
您可以使用IF语句。语法为:
搜索IF (
-condition,expression,expression )
因此,在您的情况下,您可能需要如下内容:
IF ( Pheadpr.BLNO <> '‘,Pheadpr.BLNO,STOCKTR.PHEADPR) as BLNO
如果可能的话,您应该考虑升级到当前版本的PSQL,V11支持CASE和COALESCE语句,并且是受支持的PSQL版本。
https://stackoverflow.com/questions/9719237
复制相似问题