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);
}

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.