Hi all, I'm trying to figure out how to handle looping through an MvOPENVIEW result set and have a question about the best way to do it. I've been using Tess Guefen's Waitlist module for information about how to set up my module, but had a question when it came to how her MvWHILE loop was set up.
Here's a link to the .mv file on github: https://github.com/tessguefen/Waitli.../TGWaitlist.mv
and here's an MvWHILE loop to consider:
As you can see, the MvWHILE loop is based on two counters plus the EOF row.
I couldn't quite wrap my head around what's going on above or what the counters were doing, so I looked in the LSK and found an example where the MvWHILE condition was based just on the EOF row, i.e. (as an example, using the same view name as above)
What's the best practice when it comes to looping over a result set from MvOPENVIEW? And what is the module doing if simply checking for the EOF row is sufficient for the MvWHILE loop? Thanks for any info!
Edit: Also, while I have you here (>:)), is it possible to have nested <MvOPENVIEW> tags? I assume no, but would be interested to know for sure!
Here's a link to the .mv file on github: https://github.com/tessguefen/Waitli.../TGWaitlist.mv
and here's an MvWHILE loop to consider:
HTML Code:
<MvFUNCTION NAME = "Waitlist_Trigger_EmailsXProduct" PARAMETERS = "product_id, variant_id" STANDARDOUTPUTLEVEL = "" ERROROUTPUTLEVEL = ""> <MvIF EXPR = "{ NOT Waitlist_Product_Check( l.product_id, l.variant_id, l.waitlist) }"> <MvFUNCTIONRETURN VALUE = 0 /> </MvIF> <MvOPENVIEW NAME = "Merchant" VIEW = "TGWaitlist" QUERY = "{ 'SELECT * FROM ' $ g.Store_Table_Prefix $ 'TGWaitlist WHERE product_id = ? AND variant_id = ?' }" FIELDS = "l.waitlist:product_id, l.waitlist:variant_id"> <MvIF EXPR = "{ g.MvOPENVIEW_Error }"> <MvFUNCTIONRETURN VALUE = "{ [ g.Module_Library_Utilities ].Error( 'TGWaitlist-CHECK-1003:', 'An error occured while checking a record.' ) }"> </MvIF> <MvASSIGN NAME = "g.WaitlistCount" VALUE = "0"> <MvWHILE EXPR = "{ ( NOT TGWaitlist.d.EOF ) AND ( ( g.WaitlistCount EQ 0 ) OR (l.waitlist_num LT ( g.WaitlistCount + 1) ) ) }"> <MvEVAL EXPR = "{ Waitlist_Read( l.waitlist ) }"> <MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.waitlist:formatted_date" VALUE = "{ Format_Date( l.waitlist:time_added, s.miva_language ) }"> <MvASSIGN NAME = "l.success" VALUE = "{ Waitlist_Trigger_Email_Lowlevel( l.waitlist ) }"> <MvASSIGN NAME = "l.waitlist_num" VALUE = "{ l.waitlist_num + 1 }"> <MvSKIP NAME = "Merchant" VIEW = "TGWaitlist" ROWS = 1> </MvWHILE> <MvCLOSEVIEW NAME = "Merchant" VIEW = "TGWaitlist"> <MvFUNCTIONRETURN VALUE = 1> </MvFUNCTION>
I couldn't quite wrap my head around what's going on above or what the counters were doing, so I looked in the LSK and found an example where the MvWHILE condition was based just on the EOF row, i.e. (as an example, using the same view name as above)
HTML Code:
<MvWHILE EXPR = "{ NOT TGWaitlist.d.EOF }"> ... </MvWHILE>
Edit: Also, while I have you here (>:)), is it possible to have nested <MvOPENVIEW> tags? I assume no, but would be interested to know for sure!
Comment