Re: [web2py] Re: Running multiple lines of SQL in executesql

2015-03-12 Thread Naveed Ahmed
order by type, price ) as x where x.row_number <= 2;""")But it returns a null. From: Brian M Sent: Tuesday, March 10, 2015 9:42 PM To: web2py@googlegroups.com Subject: [web2py] Re: Running multiple lines of SQL in executesql Actually just surround your big long multi li

Re: [web2py] Re: Running multiple lines of SQL in executesql

2015-03-11 Thread Naveed Ahmed
Yes it works from the DB’s interface and yes, I’m using MySQL. From: Brian M Sent: Wednesday, March 11, 2015 3:18 PM To: web2py@googlegroups.com Subject: Re: [web2py] Re: Running multiple lines of SQL in executesql Strange. Does that same query work if you enter it directly in your DB&#

Re: [web2py] Re: Running multiple lines of SQL in executesql

2015-03-11 Thread Brian M
ty, price, > @num := if(@type = type, @num + 1, 1) as row_number, > @type := type as dummy > from fruits > order by type, price > ) as x where x.row_number <= 2;""") > > But it returns a null. > > > > *Sent:* Tuesday, M

[web2py] Re: Running multiple lines of SQL in executesql

2015-03-10 Thread Brian M
Actually just surround your big long multi line SQL statement with triple quotes and it will work fine. I do that all the time. No need for the \ at each line break then either. You can declare and set your @variables all within one executesql query too. On Tuesday, March 10, 2015 at 2:36:28 PM

[web2py] Re: Running multiple lines of SQL in executesql

2015-03-10 Thread naveed
> > Ok, I moved it to a stored procedure and it works. Thanks for your help. >> > It would be nice to be able to run multiple queries in one call - I prefer to keep my code in code, not in the database, but I'm probably asking for too much. -- Resources: - http://web2py.com - http://web2py

[web2py] Re: Running multiple lines of SQL in executesql

2015-03-10 Thread Niphlod
executesql doesn't allow more than one statement per invocation. You'll get the same issues running execute() with the underlying driver. What are you really trying to execute isn't a query: it's more of a stored procedure that returns a set of results. On Tuesday, March 10, 2015 at 8:36:28 PM