Hi All,
Request your suggestion, we have a program which call's an api,
the output of the api is parsed using json parser and the result
is stored in an array(Array!string[string] data), then these
stored result are inserted into MySQL table, for inserting the
data into the table we use the below code, this code is a small
code which just contains 2 data items (Type,Hostname) and we have
similar api's which contains 15-20 data items, hence request
your suggestion on is there any better way than the below code,
using the below logic the foreach line is will run into multiple
lines eg:
foreach(i, ref a, ref b,.......ref 20,
lockstep(data["D1"][],data["D2"][],.....data["D20"])
Code:
Statement stmt = con.db.prepare("INSERT INTO test(Type,Hostname)
VALUES(:Type,:Hostname");
foreach(i,ref t,ref h; lockstep(data["Type"][],
data["Hostname"][]) {
stmt.setParameter("Type", data["Type"][i]);
stmt.setParameter("Hostname", data["Hostname"][i]);
result = stmt.execute();
}
From,
Vino.B