Help with loading records following SQL select

I’m having trouble loading records into a form after an SQL query. My method looks like this: (‘groups’ is name of table and ‘groupsid’ is primary key, ‘curr_usergroup’ is a global field)

var query = “select groupsid from groups where group_name = curr_usergroup”;
var pkdataset = databaseManager.getDataSetByQuery(forms.groups_list.controller.getServerName(), query, null, 100);
forms.groups_list.controller.loadRecords(pkdataset);

When I execute the script I get an error “Error loading primary key data, null” with no further info. In the debugger against pkdataset I am getting a 'dynamicSQL error SQL error code -104 Token unknown - ’ plus some other info that I cannot scroll onto screen!

I’m probably missing somethign simple here but can’t get it!

If curr_usergroup is a global field in Servoy, the problem lie sin the fact that you fire the SQL to the database and the database does not know the globals.

What you should do is, add the content of the global to the query string:

var query = "select groupsid from groups where group_name = "+curr_usergroup;

This way you make the querystring out of two parts:
"groupsid from groups where group_name = "
and the value of the Global.

Paul

Thanks Paul