169 похожих чатов

This is my updated procedure: CREATE PROCEDURE updateChat (IN p_chat_id

INT, IN unique_chat_name VARCHAR(255), IN name TINYTEXT, IN is_private BOOLEAN, IN description TINYTEXT)
BEGIN
DECLARE p_unique_chat_name VARCHAR(255);
DECLARE p_name TINYTEXT;
DECLARE p_is_private BOOLEAN;
DECLARE p_description TINYTEXT;

DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'An errorMessage has occurred, operation rollbacked and the stored procedure was terminated';
END;

START TRANSACTION;

CREATE TABLE xxx_t(zzz json);
INSERT into xxx_t(zzz)
values(JSON_OBJECT('p_chat_id', p_chat_id, 'unique_chat_name', unique_chat_name, 'name', name, 'is_private', is_private, 'description', description));

IF unique_chat_name IS NULL THEN
SELECT unique_chat_name INTO p_unique_chat_name FROM chat_settings cs WHERE cs.chat_id = p_chat_id;
ELSE
SET p_unique_chat_name = unique_chat_name;
END IF;

IF name IS NULL THEN
SELECT name INTO p_name FROM chat_settings cs WHERE cs.chat_id = p_chat_id;
ELSE
SET p_name = name;
END IF;

IF description IS NULL THEN
INSERT into xxx_t(zzz) values(JSON_OBJECT('DESC', (select description FROM chat_settings cs WHERE cs.chat_id = p_chat_id)));
SELECT description INTO p_description FROM chat_settings cs WHERE cs.chat_id = p_chat_id;
ELSE
SET p_description = description;
END IF;

IF is_private IS NULL THEN
SELECT is_private INTO p_is_private FROM chat c WHERE c.chat_id = p_chat_id;
ELSE
SET p_is_private = is_private;
END IF;

INSERT into xxx_t(zzz)
values(JSON_OBJECT('p_chat_id', p_chat_id, 'unique_chat_name', p_unique_chat_name, 'name', p_name, 'is_private', p_is_private, 'description', p_description));

UPDATE chat_settings
SET unique_chat_name = p_unique_chat_name, name = p_name, description = p_description
WHERE chat_id = p_chat_id;

UPDATE chat
SET is_private = p_is_private
WHERE chat_id = p_chat_id;

COMMIT;
END

I was debugging and that what I have in xxx_t table:
{"name": null, "p_chat_id": 1, "is_private": 0, "description": null, "unique_chat_name": "ruslan_postoiuk_chat_2"}
{"DESC": null}
{"name": null, "p_chat_id": 1, "is_private": 0, "description": null, "unique_chat_name": "ruslan_postoiuk_chat_2"}

So this query: select description FROM chat_settings cs WHERE cs.chat_id = p_chat_id
returns NULL
but when I do it like this: select description FROM chat_settings cs WHERE cs.chat_id = 1
then it returns correct data, it means that description exists in chat_settings with chat_id = 1

And as you see here from debugging logs:
{"name": null, "p_chat_id": 1, "is_private": 0, "description": null, "unique_chat_name": "ruslan_postoiuk_chat_2"}
p_chat_id is equal 1, so what is the problem ?

1 ответов

50 просмотров

It seems like there might be an issue with how the p_chat_id variable is handled within the procedure. The debug logs indicate that description is null when retrieved using p_chat_id. This could be due to the way the variables are assigned or the logic within the IF-ELSE conditions. To troubleshoot this: 1. Check if the variable p_chat_id is being set correctly or if there's any manipulation that could affect its value before using it in the queries. 2. Ensure the flow of control within the IF-ELSE statements is correct and that the variables are set appropriately based on the conditions. One possible cause might be that the p_chat_id variable is not carrying the expected value when used within your queries. Double-check its assignment and usage within the procedure. Also, validate the flow of the IF-ELSE conditions to ensure that the correct branches are being executed. Additionally, consider printing or logging the value of p_chat_id at different stages of the procedure to verify its value and track any changes. Debugging through printing values or using temporary logging tables could help pinpoint where the issue arises and assist in resolving the problem with retrieving the description based on the p_chat_id.

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
Чёт не понял, я ж правильной функцией воспользовался чтобы вывести отладочную информацию? но что-то она не ловится
notme
18
У меня есть функция где происходит это: write_bit(buffer, 1); write_bit(buffer, 0); write_bit(buffer, 1); write_bit(buffer, 1); write_bit(buffer, 1); w...
~
14
Добрый день! Скажите пожалуйста, а какие программы вы бы рекомендовали написать для того, чтобы научиться управлять памятью? Можно написать динамический массив, можно связный ...
Филипп
7
Недавно Google Project Zero нашёл багу в SQLite с помощью LLM, о чём достаточно было шумно в определённых интернетах, которые сопровождались рассказами, что скоро всех "ибешни...
Alex Sherbakov
5
Ребят в СИ можно реализовать ООП?
Николай
33
https://github.com/erlang/otp/blob/OTP-27.1/lib/kernel/src/logger_h_common.erl#L174 https://github.com/erlang/otp/blob/OTP-27.1/lib/kernel/src/logger_olp.erl#L76 15 лет назад...
Maksim Lapshin
20
Карта сайта