Joined: 26 Nov 2002 Posts: 11813 Topics: 74 Location: San Jose
Posted: Tue May 24, 2016 11:25 am Post subject: Re: SQL vs Cobol loop
I need to check the above query for four conditions.
either or both D7128.ACCT, STOCK can be zeros.
So First passing all the four values WS-MANF, WS-ACCT, WS-STOCK, and WS-PROD.
then passing zeros to STOCK, then for ACCT, then zeros for both
I like to check if this could be done using case\switch in the above SQL itself without checking it outside the query.
Why complicate a simple requirement? If your intention is to get the record when ACCT and STOCK are missing the values then change those two columns to IN and use that in your where clause. something like this
D7218.ACCT_NUM IN (:WS-zero-acct,:WS-ACCT) AND
D7218.STOCK_NUM In (:Ws-zero-stock,:WS-STOCK) AND
Once you get the results you can pick the record that you want first. You can add an order by to put zero records at the bottom of the result or at top of the result list. _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
I was trying to fetch only one record out of the SQL as I need to process this one record further and the priority is it should first check without zeros, if there is a hit then fetch the row and stop,
else try with zeros on STOCK, if no hit,
then try with zeros on ACCT, if no hit
then try with zeros on both.
You are telling that I could fetch the first row by using order by...I got it. thanks.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum