gpt4 book ai didi

PLSQL 在 ajax 回调中工作不正确

转载 作者:行者123 更新时间:2023-12-05 04:22:05 26 4
gpt4 key购买 nike

我有以下 oracle apex ajax 回调过程:

DECLARE
inspection_id number;
inner_id number;
BEGIN
inspection_id := apex_application.g_x01;
inner_id := apex_application.g_x02;

apex_debug.info('=====================================');
apex_debug.info('DELETE ENTRY WITH INSPECTION_ID: '||inspection_id||' AND INNER_ID: '||inner_id);
DELETE FROM CHLI_IMAGES WHERE (INSPECTION_ID = inspection_id AND INNER_ID = inner_id);
apex_debug.info('ROWS DELETED '|| SQL%ROWCOUNT);

apex_json.open_object;
apex_json.write('success', true);
apex_json.write('message', sqlerrm);
apex_json.write('INSPECTION_ID', inspection_id);
apex_json.write('INNER_ID', inner_id);
apex_json.write('result', true);
apex_json.close_object;
EXCEPTION
WHEN OTHERS THEN
apex_json.open_object;
apex_json.write('success', false);
apex_json.write('message', sqlerrm);
apex_json.close_object;
END;

这里是被js调用的:

apex.server.process("DeleteFromDB", {
x01: 0, //inspection_id
x02: 2, //inner_id
}, {
success: function (pData) {
console.log(pData);
if (pData.success === true) {
resolve(true);
}
},
error: function (request, status, error) {
console.log(request);
resolve(false);
}
});

真正奇怪的是它没有按预期工作。此代码不仅删除 inspection = 0 & inner_id = 2 的行。它还删除表中的所有其他行。这两个 id 正确地进入了我在调试过程中检查过的过程。 JS 片段处于异步循环中,但我还在调试中检查它只运行一次。
奇怪的是它只适用于这条静态线:

DELETE FROM CHLI_IMAGES WHERE (INSPECTION_ID = 0 AND INNER_ID = 2);    

oracle apex 是否存在错误,还是我总是又总是忽略某些事情。

提前致谢,
菲利普。

最佳答案

问题出在这里:

DELETE FROM CHLI_IMAGES WHERE (INSPECTION_ID = inspection_id AND INNER_ID = inner_id);

由于该语言不区分大小写,这仅意味着 inspection_id 和 inner_id 与其自身相等,即不为空。给变量不同的名字,例如:

declare
l_inspection_id number;
l_inner_id number;
begin
l_inspection_id := apex_application.g_x01;
l_inner_id := apex_application.g_x02;

apex_debug.info('=====================================');
apex_debug.info('DELETE ENTRY WITH INSPECTION_ID: '|| l_inspection_id ||' AND INNER_ID: '||l_inner_id);
delete chli_images i where i.inspection_id = l_inspection_id and i.inner_id = l_inner_id;
...

关于PLSQL 在 ajax 回调中工作不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74065473/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com