ich SQL-Adapter verwenden und versuche Reihe von MySQL-Datenbank zu löschen, aber ich bin immer Fehler wie worklight.js:5355 Procedure invocation error. Runtime: No value specified for parameter 1. Performed query: delete from customer where id=?
Erste Fehler auf Löschvorgang mit Hilfe von SQL-Adapter
// ******** *********** SQL Adapter *****************************
var procedurestat7 = WL.Server.createSQLStatement("delete from customer where id=?");
//preparedStatement.setLong(1, id);
function procedure7(id) {
return WL.Server.invokeSQLStatement({
preparedStatement : procedurestat7,
parameters : [id]
});
}
// ******************** Main.js ************************** *********
function wlCommonInit(){
/*
* Use of WL.Client.connect() API before any connectivity to a MobileFirst Server is required.
* This API should be called only once, before any other WL.Client methods that communicate with the MobileFirst Server.
* Don't forget to specify and implement onSuccess and onFailure callback functions for WL.Client.connect(), e.g:
*
* WL.Client.connect({
* onSuccess: onConnectSuccess,
* onFailure: onConnectFailure
* });
*
*/
// Common initialization code goes here
$("#view").load("pages/login.html");
};
function register(){
$("#view").load("pages/register.html");
}
function validateLogin(u,p){
var u = $("#usr").val();
var p = $("#pass").val();
localStorage.setItem('username', u);
var invocationData = {
adapter : 'SQL', // adapter name
procedure : 'procedure4',
parameters : [u,p]
};
WL.Client.invokeProcedure(invocationData,{
onSuccess : loadSQLQueerySuccess, //success callback
onFailure : loadSQLQueeryFailure // failure callback
});
function loadSQLQueerySuccess(result){
var data = result.invocationResult;
data = data.resultSet;
console.log(data);
if(data == "" || data == null || data == undefined || data == [] || u == "" || u == " " || u == null || u == undefined || p == "" || p == " " || p == null || p == undefined){
$("#lgError").show();
console.log('error');
}
else{
console.log(u+" :: "+p);
$("#view").load("pages/data.html");
var uname = localStorage.getItem('username');
console.log(uname);
$("#uname").append(uname);
}
};
function loadSQLQueeryFailure(result){
var data = result.invocationResult;
console.log("failed");
};
};
function RegLogin(ru,rp){
var ru = $("#rusr").val();
var rp = $("#rpass").val();
localStorage.setItem('username', ru);
var invocationData = {
adapter : 'SQL', // adapter name
procedure : 'procedure5',
parameters : [ru,rp]
};
WL.Client.invokeProcedure(invocationData,{
onSuccess : rloadSQLQueerySuccess, //success callback
onFailure : rloadSQLQueeryFailure // failure callback
});
function rloadSQLQueerySuccess(result){
var data = result.invocationResult;
data = data.resultSet;
if(data == "" || data == null || data == undefined || data == []){
alert("User Registered successfully");
$("#view").load("pages/login.html");
}
else{
alert("Error");
}
};
function rloadSQLQueeryFailure(result){
var data = result.invocationResult;
$("#rgError").show();
};
};
var invocationData = {
adapter : 'SQL', // adapter name
procedure : 'procedure3'
};
WL.Client.invokeProcedure(invocationData,{
onSuccess : loadSQLQueerySuccess1, //success callback
onFailure : loadSQLQueeryFailure1 // failure callback
});
function loadSQLQueerySuccess1(result){
var data = result.invocationResult;
console.log("success");
};
function loadSQLQueeryFailure1(result){
var data = result.invocationResult;
console.log("failed");
};
function custTable(){
var custInvokeData = {
adapter:'SQL',
procedure:'procedure6'
}
WL.Client.invokeProcedure(custInvokeData,{
onSuccess: custSuccess,
onFailure: custfailure
});
}
function custSuccess(result){
var data = result.responseJSON;
var isSuccess = data.isSuccessful;
var resultSet = data.resultSet;
console.log(resultSet.length);
console.log('Success Customer Data: '+JSON.stringify(data));
if(isSuccess == true){
console.log('true');
var out = "";
for(var i = 0; i<resultSet.length; i++){
out += "<tr><td>"+resultSet[i].name+"</td><td>"+resultSet[i].des+"</td><td><span class='custid' onclick='deleteData("+resultSet[i].id+")'>X</span></td></tr>";
}
document.getElementById('data').innerHTML = "<table><tr><th>Name</th><th>Desc</th><th>Del</th></tr>" +out+"</table>";
}
else
{
console.log('false');
}
}
function custfailure(result){
var data = result;
console.log('Success Failure Data: '+JSON.stringify(data));
}
function deleteData(id){
console.log('Delete function called');
var id = "";
var custDelData = {
adapter:'SQL',
procedure:'procedure7',
parameter: [id]
}
WL.Client.invokeProcedure(custDelData,{
onSuccess: DelSuccess,
onFailure: Delfailure
});
}
function DelSuccess(){
console.log('deleted');
}
function Delfailure(){
console.log('not deleted');
}