@JdbcInsert insert multiple entries

2019-06-13 01:22发布

问题:

I'm trying to insert an entry into my DB2 db by using JavaScript @JdbcInsert method. And it works perfect.

var myData={  
    DOCTYPE: "type",  
    DOCID: 1,  
    DOCNAME: "name"  
}

@JdbcInsert("db2", "MYTABLE", myData);  

What I need is to insert multiple entries at a time.. So I need to change myData object somehow.. But how should I do that.. Assume I need something like

var myData={{  
    DOCTYPE: "type",  
    DOCID: 1,  
    DOCNAME: "name1"  
},{
    DOCTYPE: "type",  
    DOCID: 1,  
    DOCNAME: "name2"  
}}

but it doesn't really work..

回答1:

try this, var myData=[{
DOCTYPE: "type",
DOCID: 1,
DOCNAME: "name1"
},{ DOCTYPE: "type",
DOCID: 1,
DOCNAME: "name2"
}]