我把3个参数放在里面
run_id = 10 run_version = 2 contract_id = 34
我试图将其作为
node index.js run_id=10 run_version=2 contract_id=34
它给了我错误:
node index.js run_id =10 run_version=2 contract_id=34
operator does not exist: integer = boolean
它是可执行的nodejs模块
无法弄清楚我的错误在哪里...在pgAdmin3中,一切都很完美。
这是我的Sql:
WITH q1 AS (
SELECT ao.run_id,
ao.run_version,
ao.ee_id,
ao.posting_id,
ao.acc_standard_id,
eec.contract_id,
ao.wt_id,
ao.credit_debit_ind,
ao.account,
SUM(ao.amount) AS suma
FROM accounting_output AS ao
JOIN ee_contract AS eec
ON eec.ee_id = ao.ee_id
WHERE ao.run_id = ${run_id}
AND ao.run_version = ${run_version}
AND eec.contract_id = ${contract_id}
GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9
),
q2 AS (
SELECT co.run_id,
co.run_version,
q1.ee_id,
q1.posting_id,
q1.acc_standard_id,
co.wt_id,
q1.credit_debit_ind,
q1.account,
ROUND(q1.suma - SIGN(q1.suma) * ABS(COALESCE(SUM(co.amount), 0))::numeric, 2) AS diff
FROM q1
JOIN calculation_output AS co
ON co.run_id = q1.run_id
AND co.run_version = q1.run_version
AND co.contract_id = q1.contract_id
AND co.wt_id = q1.wt_id
GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, q1.suma
),
q3 AS (
SELECT DISTINCT ao.run_id,
ao.run_version,
MAX(ao.run_line_id) OVER(PARTITION BY ao.posting_id,
ao.acc_standard_id,
ao.ee_id,
ao.wt_id,
ao.credit_debit_ind,
ao.account) AS rl,
q2.diff
FROM q2
JOIN accounting_output AS ao
ON ao.run_id = q2.run_id
AND ao.run_version = q2.run_version
AND ao.ee_id = q2.ee_id
AND ao.posting_id = q2.posting_id
AND ao.acc_standard_id = q2.acc_standard_id
AND ao.wt_id = q2.wt_id
AND ao.credit_debit_ind = q2.credit_debit_ind
WHERE q2.diff != 0
)
INSERT INTO accounting_output
SELECT ao.run_id,
ao.run_version,
(
SELECT MAX(run_line_id)
FROM accounting_output
WHERE run_id = ao.run_id
AND run_version = ao.run_version) + row_number() OVER() AS run_line_id,
posting_id,
acc_standard_id,
wt_id,
le_acc_value_1,
le_acc_value_2,
le_acc_value_3,
wc_acc_value_1,
wc_acc_value_2,
wc_acc_value_3,
intra_acc_value_1,
intra_acc_value_2,
intra_acc_value_3,
treatment_acc_value_1,
treatment_acc_value_2,
treatment_acc_value_3,
ee_acc_value_1,
ee_acc_value_2,
ee_acc_value_3,
wt_acc_value_1,
wt_acc_value_2,
wt_acc_value_3,
credit_debit_ind,
account,
account_desc,
sub_account,
sub_account_desc,
ee_cost_center,
ee_pofit_center,
wt_code,
wt_short_name,
wt_acc_text,
-q3.diff,
cost_center_desc,
profit_center_desc,
ee_id
FROM q3
JOIN accounting_output AS ao
ON ao.run_id = q3.run_id
AND ao.run_version = q3.run_version
AND ao.run_line_id = q3.rl
这是我的index.js页面:
// const Promise = require('bluebird');
const database = require('./database');
const args = require('parser')(process.argv);
const MODULE_NAME = 'ACC-ROUND';
const sqlQuery = database.query;
const sqlFiles = database.files;
(async function main() {
try {
console.time('Calculation done');
await sqlQuery.none(sqlFiles.accRound, args);
console.timeEnd('Calculation was done successfully');
process.exit(0);
} catch (e) {
console.error(e.message || e);
process.exit(1);
}
}());