我想将post数据写到表中,但数据在数组中。我写了代码,但由于某些原因它不工作,它可以帮助发现error.it不产生错误,它写入空列!
sCount := APEX_JSON.get_count(p_path => 'quantitative_index' , p_values => tv);
IF sCount > 0 THEN
FOR i in 1 .. sCount LOOP
q_id := apex_json.get_varchar2(p_path => 'quantitative_indexs['|| i ||'].id', p_values => tv);
q_name := apex_json.get_varchar2(p_path => 'quantitative_indexs['|| i ||'].name', p_values => tv);
q_guid := apex_json.get_varchar2(p_path => 'quantitative_indexs['|| i ||'].guid', p_values => tv);
select count(*) into v_det_vol from DETAILS_VOLUME where ID = q_id and NAME = q_name;
if v_det_vol = 0 then
INSERT INTO DETAILS_VOLUME (ID, NAME, guid)
VALUES (q_id, q_name ,q_guid);
commit;
end if;
END LOOP;
END IF; 这是json
{
"quantitative_index": [
{
"id": 12121,
"name": "Менеджер",
"guid": "100"
},
{
"id": 12122,
"name": "Менеджер1",
"guid": "100"
}
]
}
sCount := APEX_JSON.get_count(p_path => 'quantitative_index' , p_values => tv);
IF sCount > 0 THEN
FOR i in 1 .. sCount LOOP
q_id := apex_json.get_varchar2(p_path => 'quantitative_indexs['|| i ||'].id', p_values => tv);
q_name := apex_json.get_varchar2(p_path => 'quantitative_indexs['|| i ||'].name', p_values => tv);
q_guid := apex_json.get_varchar2(p_path => 'quantitative_indexs['|| i ||'].guid', p_values => tv);
select count(*) into v_det_vol from DETAILS_VOLUME where ID = q_id and NAME = q_name;
if v_det_vol = 0 then
INSERT INTO DETAILS_VOLUME (ID, NAME, guid)
VALUES (1, '1' ,'1');
commit;
end if;
END LOOP;
END IF;
如果是这样,它会记录下来!
发布于 2020-02-05 10:41:22
您的代码正在引用quantitative_indexs,但该属性的名称在末尾是quantitative_index No“%s”。
另外,不要在循环中提交,在循环之外提交,或者让APEX为你做。
https://stackoverflow.com/questions/60057278
复制相似问题