Last active
July 5, 2016 16:13
-
-
Save frenchbread/2f72a67b9de0d389a72df07e888eb016 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import oracledb from 'oracledb'; | |
Meteor.methods({ | |
submitStatement (data) { | |
const oracleResponse = Async.runSync(function (done) { | |
oracledb.getConnection(oracleConf, (err, connection) => { | |
if (err) done(err); | |
const script = `Begin doc_gc_pkg.add_from_webform( | |
:x_return_status, | |
:x_return_message, | |
:x_return_doc_num, | |
:x_return_doc_date, | |
:p_surname, | |
:p_name, | |
:p_patronymic, | |
:p_sex, | |
:p_citizenship, | |
:p_dateofbirth, | |
:p_document_type, | |
:p_document_series, | |
:p_document_number, | |
:p_document_author, | |
:p_document_date, | |
:p_region, | |
:p_district, | |
:p_city, | |
:p_street, | |
:p_house, | |
:p_building, | |
:p_appartment, | |
:p_phone, | |
:p_polis_datefrom, | |
:p_polis_dateto, | |
:p_polis_period, | |
:p_brend, | |
:p_model, | |
:p_category, | |
:p_gover_number, | |
:p_insurance_territory, | |
:p_is_dangerous, | |
:p_personal_agreement, | |
:p_created_by); END;`; | |
const isDangerous = (data.is_dangerous) ? 'Y' : 'N'; | |
const personalAgreement = (data.personal_agreement) ? 'Y' : 'N'; | |
const vals = { | |
x_return_status: { type: oracledb.STRING, dir: oracledb.BIND_OUT }, | |
x_return_message: { type: oracledb.STRING, dir: oracledb.BIND_OUT }, | |
x_return_doc_num: { type: oracledb.STRING, dir: oracledb.BIND_OUT }, | |
x_return_doc_date: { type: oracledb.STRING, dir: oracledb.BIND_OUT }, | |
p_surname: data.surname, | |
p_name: data.name, | |
p_patronymic: data.patronymic, | |
p_sex: data.sex, | |
p_citizenship: data.citizenship, | |
p_dateofbirth: data.dateofbirth, | |
p_document_type: data.document_type, | |
p_document_series: data.document_series, | |
p_document_number: data.document_number, | |
p_document_author: data.document_author, | |
p_document_date: data.document_date, | |
p_region: data.region, | |
p_district: data.district, | |
p_city: data.city, | |
p_street: data.street, | |
p_house: data.house, | |
p_building: data.building, | |
p_appartment: data.appartment, | |
p_phone: data.phone, | |
p_polis_datefrom: data.polis_datefrom, | |
p_polis_dateto: data.p_polis_dateto, | |
p_polis_period: data.polis_period, | |
p_brend: data.brend, | |
p_model: data.model, | |
p_category: data.category, | |
p_gover_number: data.gover_number, | |
p_insurance_territory: data.insurance_territory, | |
p_is_dangerous: isDangerous, | |
p_personal_agreement: personalAgreement, | |
p_created_by: 'User' | |
}; | |
connection.execute(script, vals, (err, res) => { | |
if (err) done(err.message); | |
done(null, res.outBinds); | |
}); | |
}); | |
}); | |
if (oracleResponse.error) { | |
console.log(oracleResponse.error.message); | |
} | |
return oracleResponse.result; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment