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 ответов

23 просмотра

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.

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

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

Anyone here suffers from unexplained aural migraines, who would be up for talking for a bit? Doesn't *have* to be aural, but I am not asking about headaches, I mean actual mi...
Martin Rys
55
Привет, нужен совет старших товарищей. Есть глобальная переменная var DefaultDataFolder:string; инициализируем DefaultDataFolder:='a:\_OUT\'; есть примитивная процедур...
Max Otto
14
Вопрос. Теоретический. Есть список команд. Команды отправляю в обработку некой функции, по очереди. Разные команды могут давать разные результаты после обработки. В зависимос...
Serjone
7
Всем вечера. Подскажите как лучше сделать. делаю на Д10 Например будет база данных на SQLite. в ней будет много таблиц. более 50шт Типа справочник. Содержать ID Name Id p...
Андрей Т 🐎
10
Я короче решил скомпилировать Nim в js, я думал он сработает как обычный транслятор. По итогу он мне создал файл с расширением js, и туда поместил кучу кода Вопрос, что это з...
𝕾𝖍𝖆𝖉𝖊 <suspense>
9
это группа токсиков или тех кто помогает?
Ибрагим
9
подскажите пожалуйста, как мне освободить результат записанный в переменную result? в чем проблема подскажите если МОЖЕТЕ?
Михаил Helper
28
я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
мы пытаемся подменить функцию, которая имеет меньше инструкций относительно функции, которой подменяем. https://www.reddit.com/r/jailbreakdevelopers/comments/w06ujy/mshookfun...
Óðinn
6
У кого-нибудь есть под рукой функция кодирования юникода, которая из фразы На русском сделает \u041d\u0430\u0020\u0440\u0443\u0441\u0441\u043a\u043e\u043c ?
Daniil Smolyakov
7
Карта сайта