Any limitations to SQL in getDataSetByQuery()?

Questions and answers regarding general SQL and backend databases

Any limitations to SQL in getDataSetByQuery()?

Postby swingman » Fri Apr 15, 2005 8:39 am

LoadRecords() only accepts a specific subset of SQL.
Does getDataSetByQuery() have similar limitations?

Have some queries which work fine from 3rd party tools, but not inside Servoy. Here is one example:

Code: Select all
(SELECT clients.client_name, sum(invoices.invoice_amount), (CASE WHEN clients.client_new_fy_id = 4  THEN 'new' ELSE 'old' END) as isnew FROM invoices, clients
WHERE invoice_fy_id = 4
AND invoices.invoice_client_id = clients.client_id
GROUP BY isnew,client_name ORDER BY isnew,client_name)


PostgreSQL 8, Servoy 2.2rc3, Mac OS X 10.3.8
User avatar
swingman
 
Posts: 1483
Joined: Wed Oct 01, 2003 10:20 am
Location: Venice / London

Postby swingman » Fri Apr 15, 2005 3:40 pm

It is working now. Maybe there was a return character in my query?
User avatar
swingman
 
Posts: 1483
Joined: Wed Oct 01, 2003 10:20 am
Location: Venice / London

Postby Jan Aleman » Fri Apr 15, 2005 4:36 pm

Javascript sees returns as codeline separators so, yes, if there are returns in your sql it could not work. When something doesn't work I always recommend turning the debugger on and reading in the variables what's really going on. Great way to find bugs in little time. If you want to split your statement accross multilines try something like:

var theSql = "select name from users "
theSql += " where category = 'sud'"
theSql += " etc"
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Postby bcusick » Fri Apr 15, 2005 6:09 pm

You can also use the concatenation "+" symbol to continue a line like:

Code: Select all
var query = "SELECT first, last" +
  " FROM customers" +
  " WHERE id IN (101,102,104)" +
  " ORDER BY last, first"
Bob Cusick
bcusick
 
Posts: 1262
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Postby swingman » Tue Apr 19, 2005 8:58 am

Thank you for the advice.

The reason I ended up with returns in the queries was that I defined a database of reports with a query field. Once I have worked out a query in DBVisualiser or Aqua Data Studio I paste it into a new record in my reports database and I have a new report :-)
User avatar
swingman
 
Posts: 1483
Joined: Wed Oct 01, 2003 10:20 am
Location: Venice / London


Return to SQL Databases

Who is online

Users browsing this forum: No registered users and 4 guests