0

I wrote a Node.js-based action in IBM Cloud Functions / OpenWhisk. The action retrieves data from Db2. The query works when I don't have parameter markers. When I use a parameter as shown below and pass in {"confname" : "IDUGEMEA2018" } then it runs into an error and the exception is raised.

Why? What needs to be changed?

var ibmdb = require('ibm_db');

function queryConferences(dsn, confname) { 
 try {    
    var conn=ibmdb.openSync(dsn);
    var data=conn.querySync("select shortname, location, begindate, enddate, uri from conference where shortname=?", confname);
    conn.closeSync();
    return {result : data};
 } catch (e) {
     return { dberror : e }
 }
}

function main({confname, __bx_creds: {dashDB:{dsn}}}) {
    return queryConferences(dsn,confname);
}
data_henrik
  • 16,724
  • 2
  • 28
  • 49

1 Answers1

1

It fails because the bindingParameters is expecting an array. I got it to work passing in the following:

{"confname" : ["IDUGEMEA2018"] }

In the CLI I tested it with the following:

bx wsk action invoke myAction -p confname "[\"IDUGEMEA2018\"]" -r
data_henrik
  • 16,724
  • 2
  • 28
  • 49