Here is a sample channel link that covers multiple methods as well as a for loop for NK1 segments and how to query your inserted data.
You can do an update query in qvera and reference the HL7 nodes.
var sqlQuery = "INSERT INTO myTable \n" +
"(tableid, patientid, lastname, firstname)\n" +
"VALUES (" + qie.formatDate('yyyyMMddHHmmss') + ", '" + message.getNode('PID-3.1') + "', '" + message.getNode('PID-5.1') + "', '" + message.getNode('PID-5.2') + "')";
var updateResult = qie.doUpdateQuery('MyDB', sqlQuery);
// qie.doUpdateQuery is the better way to do this since
// we should get back a response of one row added.