Error calling SQL adapter in IBM MobileFirst

I am trying to insert data into a database using the SQL adapter in the IBM mobilefirst platform, however my code is reaching the failure function ...

main.js:

function insertData(){

  alert("Function InsertData called");
  var fname = document.forms["form1"]["fname"].value.toString();
  var lname = document.forms["form1"]["lname"].value.toString();
  var email = document.forms["form1"]["email"].value.toString();
  var pwd = document.forms["form1"]["pwd"].value.toString();
  // alert("fname"+fname);

  var invocationData = {
    adapter: 'SQLDemo',
    procedure: 'procedure4',
    parameters:[fname,lname,email,pwd]
  };

  var options = {
    onSuccess : InsertDataSuccess,
    onFailure : InsertDataFailed,
    timeout : 30000
  };
  WL.Client.invokeProcedure(invocationData, options);
}

function InsertDataSuccess(result){
  alert("Success");
  WL.Logger.debug("Retrieve success" +  JSON.stringify(result));
}

function InsertDataFailed(result){
  alert("Failure");
  WL.Logger.debug("Retrieve success" +  JSON.stringify(result));
}

      

Adapter'sSQLDemo-impl.js:

var procedure4Statement = WL.Server.createSQLStatement("INSERT INTO INNOVATION (FIRSTNAME,LASTNAME,EMAIL,PASSWORD) VALUES(?,?,?,?)");
function procedure4(fname,lname,email,password) {
  return WL.Server.invokeSQLStatement({
      preparedStatement : procedure4Statement, 
      parameters : [fname,lname,email,password] 
  });
}

      

+3


source to share


1 answer


From messages.log file:

E FWLSE0099E: An error occurred while calling procedure [project DemoProject] SQLDemo / SqlStatementFWLSE0100E: parameters: [project DemoProject] DB2 SQL error: SQLCODE = -104, SQLSTATE = 42601, SQLERRMC = from; AJAX set FIRSTNAME =?; .., DRIVER = 3.61.75. Query: update AJAX set FIRSTNAME =? from AJAX where id =? FWLSE0101E: Called from: [DemoProject] com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL error: SQLCODE = -104, SQLSTATE = 42601, SQLERRMC = from; AJAX set FIRSTNAME =?; .., DRIVER = 3.61.75java.lang.RuntimeException: DB2 SQL error: SQLCODE = -104, SQLSTATE = 42601, SQLERRMC = from; AJAX set FIRSTNAME =?; .., DRIVER = 3.61.75.

...

Invalid Data Conversion: The vinod instance is not valid for the requested conversion. ERRORCODE = -4461, SQLSTATE = 42815



And there are a few more exceptions.

Make sure you are actually expecting strings in your database schema and not too long a value, etc.

0


source







All Articles