0

I have DB2 query where inside I have to concacte with "|" to get the result. Here's the query :

SELECT DISTINCT npkdcb,
                npkdps,
                npcob,
                npureg,
                npbktg,
                npblrg,
                npthrg,
                npends,
                nptgln,
                npblnn,
                npthnn,
                dkl.dkkdcb,
                dkl.dkkdps,
                dkl.dkcob,
                dkl.dkureg,
                dkl.dkbktg,
                dkl.dkblrg,
                dkl.dkthrg,
                npttg1,
                npttg2,
                npunit,
                nmbnk,
                nmunit,
                npdeb1,
                npdeb2,
                npdeb3,
                npdeb4,
                npdeb5,
                npdeb6,
                clnama,
                clbdhk,
                npjasa,
                dknilk,
                nmasei,
                nppoto,
                npkomi,
                nppph,
                npppn,
                npadmn,
                npmtri,
                product
FROM   aseindta.acrnpp npp
       INNER JOIN aseindta.acrdkl dkl
               ON npp.dkkdcb = dkl.dkkdcb
                  AND npp.dkkdps = dkl.dkkdps
                  AND npp.dkcob = dkl.dkcob
                  AND npp.dkureg = dkl.dkureg
                  AND npp.dkbktg = dkl.dkbktg
                  AND npp.dkblrg = dkl.dkblrg
                  AND npp.dkthrg = dkl.dkthrg
       INNER JOIN aseindta.msunit unit
               ON npp.npttg1 = unit.kdttg1
                  AND npp.npttg2 = unit.kdttg2
                  AND npp.npunit = unit.kdunit
       INNER JOIN aseindta.mstbnk bank
               ON npp.npttg1 = bank.kdjnbn
                  AND npp.npttg2 = bank.kdnmbn
       INNER JOIN aseindta.mstcln cln
               ON dkl.dkdeb1 = cln.clnpw1
                  AND dkl.dkdeb2 = cln.clnpw2
                  AND dkl.dkdeb3 = cln.clnpw3
                  AND dkl.dkdeb4 = cln.clnpw4
                  AND dkl.dkdeb5 = cln.clnpw5
                  AND dkl.dkdeb6 = cln.clnpw6
       INNER JOIN aseindta.tblcbg cbg
               ON npp.dkkdcb = cbg.kdasei
                  AND npp.dkkdps = cbg.kdpmsr
       LEFT JOIN aseindta.trx_bws
              ON dklnum = DKL.dkkdcb
                          || RIGHT('0'
                                   || DKL.dkkdps, 2)
                          || RIGHT('0'
                                   || DKL.dkcob, 2)
                          || RIGHT('0000'
                                   || DKL.dkureg, 5)
                          || RIGHT('0000'
                                   || dkl.dkbktg, 4)
                          || RIGHT('0'
                                   || DKL.dkblrg, 2)
                          || RIGHT('0000'
                                   || dkl.dkthrg, 4)
WHERE  npp.npthrg = 2020 

I tried this query on DBVis and it works. The result are shown. But when I tried to Visual Studio, I got this error

Error Message : Token |? for use skip wait with fetch order union except optimize was not valid

Is there a way around this? I tried surrounding it in quotes but that doesn't help.

mao
  • 11,321
  • 2
  • 13
  • 29
Syafiqur__
  • 531
  • 7
  • 15
  • Don't know why your VS (which version?) is behaving this way, but you can eliminate the concatenation operator `||` and replace by the CONCAT function. Either the query will then work, or you will get a more revealing error. – mao Sep 23 '20 at 09:06
  • I'll try that, thanks. – Syafiqur__ Sep 24 '20 at 07:23

0 Answers0