Как вы увидите из моего кода, я уже определил параметры сортировки созданной таблицы и возврата моей функции, но я все еще получаю сообщение об ошибке.Почему это ?
Я получаю следующую ошибку при применении моего запроса в PHPmyAdmin-MYSQL: SQL-запрос: UPDATE tb SET balance = (SELECT fnaccount_getbalance (acguid COLLATE utf8_general_ci, accur COLLATE utf8_general_ci, @ stdate, @ endate)) Ошибка:
1267 - Недопустимое сочетание параметров сортировки (utf8_unicode_ci, IMPLICIT) и (utf8_general_ci, IMPLICIT) для операции '='
Вот мой запрос:
CREATE TEMPORARY TABLE tb (id INT PRIMARY KEY AUTO_INCREMENT,
acguid char(38),
accur char(38),
account varchar(255),
debitsyp float,
creditsyp float,
balance float,
currency varchar(255))
CHARACTER SET utf8
COLLATE utf8_unicode_ci;
SET @stdate = '2011-01-01';
SET @endate = CURDATE();
INSERT INTO tb (acguid,accur,account,debitsyp,creditsyp,balance,currency)
SELECT ac.guid,ac.currencyguid,CONCAT(ac.code,'-',ac.name) AS account,0,0,0,my.code
FROM ac000 ac INNER JOIN my000 my ON ac.currencyguid = my.guid
WHERE ac.guid IN (SELECT accountguid FROM en000);
UPDATE tb SET debitsyp = (SELECT SUM(debit) FROM en000 WHERE accountguid = acguid);
UPDATE tb SET creditsyp = (SELECT SUM(credit) FROM en000 WHERE accountguid = acguid);
UPDATE tb SET balance = (SELECT fnaccount_getbalance(acguid,accur,@stdate,@endate));
SELECT * FROM tb;
Ивот код для моей функции fnaccount_getbalance:
BEGIN
DECLARE acbal float;
SET acbal = (SELECT IFNULL(SUM((CASE
WHEN currencyguid = accur THEN debit / currencyval
ELSE debit / fngetcurval(accur,endate)
END) -
(CASE
WHEN currencyguid = accur THEN credit / currencyval
ELSE credit / fngetcurval(accur,endate)
END)),0) as balance
FROM en000 WHERE accountguid = acguid
AND endate BETWEEN stdate AND endate);
RETURN (acbal COLLATE utf8_unicode_ci);
END