首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >顶端甲骨文中的职位

顶端甲骨文中的职位
EN

Stack Overflow用户
提问于 2020-02-04 20:18:14
回答 1查看 37关注 0票数 0

我想将post数据写到表中,但数据在数组中。我写了代码,但由于某些原因它不工作,它可以帮助发现error.it不产生错误,它写入空列!

代码语言:javascript
复制
    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

代码语言:javascript
复制
{

  "quantitative_index": [
    {
      "id": 12121,
      "name": "Менеджер",
		  "guid": "100"
    },
		{
      "id": 12122,
      "name": "Менеджер1",
		  "guid": "100"
    }
  ]
}

代码语言:javascript
复制
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;

如果是这样,它会记录下来!

EN

回答 1

Stack Overflow用户

发布于 2020-02-05 10:41:22

您的代码正在引用quantitative_indexs,但该属性的名称在末尾是quantitative_index No“%s”。

另外,不要在循环中提交,在循环之外提交,或者让APEX为你做。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60057278

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档