Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
leocrawf
Posts: 47
Registered: ‎06-06-2011
My Device: bolt2
Accepted Solution

Nested queries

I have this nested queryy but the it does not output the results as it should. The nested query works fine because I alerted the values out but I cant get the nested values to be writen in the html. Here is the code: 

 tx.executeSql("select eventdate,strftime('%m',eventdate) as month, strftime('%Y',eventdate) as year from news where flag in ('E','A') and eventdate > '2011-7-6' group by date(eventdate,'start of month','+1 month','-1 day') having eventdate is not null order by date(eventdate,'start of month','+1 month','-1 day')", [],
																																					   
				  function(tx,rs){	
				   if(rs.rows.length > 0){
					   for(var i=0;i<rs.rows.length;i++ ){
						   
				            var row = rs.rows.item(i);
							if(row.month != null){
					        contentDiv += '<tr bgcolor="#62D8FF"><td colspan="2" style="font-size: 12pt;"><strong>'+app.getMonthName(row.month)+" "+row.year+'</strong></td></tr>';
							
							//alert(row.month+" "+row.year)
							
							tx.executeSql("select subject,strftime('%m',eventdate) as month, strftime('%w',eventdate) as day from news where strftime('%m',eventdate) = strftime('%m','"+row.eventdate+"') and strftime('%Y',eventdate) = strftime('%Y','"+row.eventdate+"') and flag in ('E','A') order by eventdate", [],
																																				   
								function(tx,rs2){	
								//alert(rs2.rows.length);	
								 
									 for(var p=0;p<rs2.rows.length;p++ ){
										 var row2 = rs2.rows.item(p);
										// alert(app.getMonthName(row2.month))
										contentDiv += '<tr><td width="20%">'+app.getMonthName(row2.month)+" "+row2.day+'</td><td width="80%">'+row2.subject+'</td></tr>' ;
									 }
								 
								}
							    , app.onError);
							
							
							
							
							
							
							}

				
					   }//end for loop*/
					   
					 showresultDiv.innerHTML += contentDiv+'</table>';  
				   }
				   
				   
				  }
																																					   
																																					   
																																					   
				 , app.onError);

 Please can anyone help with this.

Contributor
leocrawf
Posts: 47
Registered: ‎06-06-2011
My Device: bolt2

Re: Nested queries

Realizing the nature of html5 query i decide not not do my app that way. I made it so that after the main title are built i use an onlick event to call a function that passes the relevant data for me in do a drop down with all the values i needed instead of outputting everything at once on load.