Hello,
I'm trying to run a SQL Query with joins, and some fields share the same names in two different tables, but I need there status, my query works perfectly directly in MySQL, and to keep a record which column is from which table i'm creating an alias on it.
SELECT n.status as rds, i.status as installation FROM serveur as s join nas as n on n.id=s.nas_id join installation as i on i.id=s.installation_id WHERE s.id=447;
Normally the results look like this:
+---------+--------------+
| rds | installation |
+---------+--------------+
| created | created |
+---------+--------------+
But in my scriptable task, I see this:
[2016-08-30 13:00:19.371] [I] SELECT n.status as rds, i.status as installation FROM serveur as s join nas as n on n.id=s.nas_id join installation as i on i.id=s.installation_id WHERE s.id=447;
[2016-08-30 13:00:19.415] [I] DynamicWrapper (Instance) : [SQLActiveRecord]-[class com.vmware.o11n.plugin.database.ActiveRecord] -- VALUE : ActiveRecord: {status=created}
[2016-08-30 13:00:19.424] [E] Error in (Workflow:Validation des étapes pré-installation / Get server request id (item0)#24) Couldn't get a response from the database
[2016-08-30 13:00:19.525] [E] Workfow execution stack:
***
item: 'Validation des étapes pré-installation/item0', state: 'failed', business state: 'null', exception: 'Couldn't get a response from the database (Workflow:Validation des étapes pré-installation / Get server request id (item0)#24)'
workflow: 'Validation des étapes pré-installation' (d3bff982-2107-4585-b0aa-ef92f6eba4ae)
| 'attribute': name=database type=SQL:Database value=dunes://service.dunes.ch/CustomSDKObject?id='c9402fe2-f833-4411-8c8e-f0ed37130c96'&dunesName='SQL:Database'
| 'attribute': name=serverRequestId type=string value=
| 'input': name=vmid type=string value=447
| 'output': name=nstatus type=string value=null
| 'output': name=istatus type=string value=null
*** End of execution stack.
I have no clue which status is this and then the rest of my code doesn't work.
Here's my complete scriptable task:
var result = null;
var query = 'SELECT n.status as rds, i.status as installation ' +
'FROM serveur as s join nas as n on n.id=s.nas_id join installation as i on i.id=s.installation_id ' +
'WHERE s.id=' + vmid + ';';
System.log(query);
var response = database.readCustomQuery(query);
System.log(response);
for (var i = 0; i < response.length; i += 1) {
if (response != null && response.lenght == 1) {
nstatus = response[i].getProperty("rds");
istatus = response[i].getProperty("installation");
break;
}
}
if (result) {
nstatus = result.toString();
istatus = result.toString();
System.log('Result: ' + nstatus);
System.log('Result: ' + istatus);
} else {
throw 'Couldn\'t get a response from the database';
}