W3C home > Mailing lists > Public > www-ql@w3.org > April to June 2004

Question about Let clause

From: Houman Khorasani <khorasani@web.de>
Date: Sat, 26 Jun 2004 02:17:51 -0500
To: mhk@mhk.me.uk, www-ql@w3.org
Message-id: <01LBQJ1QP3MQAFYXQL@uwplatt.edu>

Hello Everyone,


@Michael: Thanks for the optimization tips and also for the tip for the
decimal places.  Everything works fine.


Right now I was writing on my paper.  I am trying to explain how for and let
clauses work together and I am now a little bit confused.

(I know the following example is not optimized.  I will do it later)
Have a look at the first let clause, which contains a nested FLWOR
expression.

After the main return, the parser jumps back to beginning to get into the
next for clauses and so on.  But does it skip the very first let clause or
does it re-calculate everytime the whole nested FLWOR expression and store
it everytime in $temptltt?

I really need to know it for my paper,

Best regards
Houman



let $temptltt :=	for $wbtt in doc("wisc_berkeley_tracetime.xml")//row
			for $wb in doc("wisc_berkeley_3days.xml")//row
			where ( ($wbtt/dat = '20000801000000') and ($wb/dat
= '20000801000000') and ($wbtt/min = (round($wb/tick div 600000))) )
			return 	<g>	{ $wbtt/min }
					{ $wb/dlay }
					{ $wbtt/dat } 
					{ $wbtt/rID } </g> 

for $distinctMin in distinct-values($temptltt//min)

let $totalDelay_distinctMin := 	for $i in ($temptltt)
				where ($i/min = $distinctMin)
				return $i/dlay

let $rID := 			for $i in $temptltt
				where ($i/min = $distinctMin)
				return $i/rID

let $dat := 			for $i in $temptltt
				where ($i/min = $distinctMin)
				return $i/dat

return
	<ROW> 
		{ $rID[1] }
		<min>{ $distinctMin }</min>
		{ $dat[1] }
		<avgDelay> { round-half-to-even(
(avg($totalDelay_distinctMin)),4 ) } </avgDelay> 
	</ROW>
Received on Saturday, 26 June 2004 03:23:00 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 22 July 2006 00:10:19 GMT