Hitesh Shah
17th January 2022, 15:04
Hi All ,
I have following SQL select code in my code
select tijwx895.*,tijwm993.* ,
CASE when tijwm993.cwar = :tdsls401.cwar then 1
when tijwm993.wtyp = tdloctyp.buyback then 4
when tijwm993.wtyp = tdloctyp.order then 2
when tijwm993.wtyp = tdloctyp.cunostk then 5
when tijwm993.wtyp = tdloctyp.certified then 3
else 999
end
Compiling this gives following error
ptdjwm4500m0020( 880): Fatal Error: Macro 'end': Illegal number of arguments.
Any idea what am i doing wrong here. I want to order by the value in case expression . So appropriate syntax may be shared.
JaapJD
18th January 2022, 10:39
You can try
#undef end()
andreas.toepper
18th January 2022, 11:30
I think CASE needs ENDCASE for closing the command.
Hitesh Shah
18th January 2022, 14:31
You can try
#undef end()
Thanks Jaap for quick help . I have not tried this as I could work with endcase as suggested by with following code for my customer ordering of table records
select
CASE when tijwm993.cwar = :tdsls401.cwar then 1
when tijwm993.wtyp = tdloctyp.buyback then 4
when tijwm993.wtyp = tdloctyp.order then 2
when tijwm993.wtyp = tdloctyp.cunostk then 5
when tijwm993.wtyp = tdloctyp.certified then 3
else 999
endcase:priority ,tijwx895.*,tijwm993.*
from tijwx895 ,tijwm993
where tijwm993._index1 = {:tdsls401.ofbp}
and tijwm993.wtyp in (3,4,8,10)
and tijwm993.popl = tcyesno.yes
and tijwx895._index3= {:tdsls401.item,tijwm993.cwar}
and tijwx895.bqty > 0
order by 1
selectdo
endselect
Andreas, Thanks very much . Unfortunately documentation is not elaborate and illustrative and mentions only END and not ENDCASE . Nevertheless my code has compiled and i think it will work too.
OmeLuuk
25th January 2022, 12:15
Thanks for sharing your query, it opened my eyes to possibilities I did not know yet.
OmeLuuk
25th January 2022, 12:34
You can try #undef end()
Probably the safer option (if this is used) would be to only temporary "un-Reserve Word" the end() by parking it before your query and reset it afterwards?#define ORIGINAL.END() end()
#undef end()
<QUERY>
#define end() ORIGINAL.END()?
Hitesh Shah
28th January 2022, 16:19
Thanks for sharing your query, it opened my eyes to possibilities I did not know yet.
Query processor in Ln is quite powerful to help developer do more with less . I am happy that you found it useful.
Hitesh Shah
28th January 2022, 16:21
Probably the safer option (if this is used) would be to only temporary "un-Reserve Word" the end() by parking it before your query and reset it afterwards?#define ORIGINAL.END() end()
#undef end()
<QUERY>
#define end() ORIGINAL.END()?
Will definitely try this suggestion later on and share feedback on this .