Topic: Bug in gl/includes/db/gl_journal.inc
I found this incorrect sql query:
It's much more fun, when you can discuss your problems with others...
You are not logged in. Please login or register.
FrontAccounting forum → Report Bugs here → Bug in gl/includes/db/gl_journal.inc
I found this incorrect sql query:
Can you elaborate the issue in text?
I found this incorrect sql query:
The SQL Query is wrong. INSERT INTO .... SELECT FROM ...
Instead of
$sql = "INSERT INTO ".TB_PREF."debtor_trans (trans_no, type, debtor_no, branch_code, tran_date, reference, ov_amount, rate)
SELECT "
.db_escape($trans_no).", ".db_escape($trans_type).", debtor_no,"
.db_escape($branch_id).",'".date2sql($date)."', ".db_escape($ref).","
.db_escape($amount).", ".db_escape($rate)."
FROM ".TB_PREF."cust_branch WHERE branch_code=".db_escape($branch_id);
It should be
$sql = "INSERT INTO ".TB_PREF."debtor_trans (trans_no, type, debtor_no, branch_code, tran_date, reference, ov_amount, rate)
VALUES ("
.db_escape($trans_no).", ".db_escape($trans_type).", (SELECT debtor_no FROM ".TB_PREF."cust_branch WHERE branch_code=".db_escape($branch_id). ") ,"
.db_escape($branch_id).",'".date2sql($date)."', ".db_escape($ref).","
.db_escape($amount).", ".db_escape($rate).")";
The sub query SELECT debtor_no ... result should bebecome the debtor_no column when inserting.
@joe,
Can you update the code and commit it to stable version downloads.
This has been fixed and committed to stable repo. Thanks @barbarian for finding this.
A fixed copy can be downloaded and replaced.
/Joe
Thanks. U have checked this bug has persisted since at least 2.4.2 and it is quite critical because data entry via journal entry feature that relate to account receivable will write the cust_trans using this method and it will fail because the query is wrong.
Yes, it is amazing that this bug is first detected now after so many minor releases.
Maybe because the entrance is mostly done by the Sales routines.
Joe
Actually the old query INSERT INTO table1 SELECT col.. FROM table2 is a right syntax.
But better to keep the new query because if the subquery SELECT return null the system will raise an error meanwhile the old query can run successfully even when the SELECT subquery returns null
FrontAccounting forum → Report Bugs here → Bug in gl/includes/db/gl_journal.inc
Powered by PunBB, supported by Informer Technologies, Inc.
Currently installed 4 official extensions. Copyright © 2003–2009 PunBB.