json 返回数组而不是字符串

qvk1mo1f  于 2023-08-08  发布在  其他
关注(0)|答案(1)|浏览(106)

谁能帮我返回一个数组而不是一个字符串,作为一个初学者我有一个困难的时间。先谢谢你
下面是我的代码:

IF (sBnsStat= 'REN') THEN
        OPEN cPrevPermit  FOR SELECT  permit_no  FROM  buss_hist  WHERE bin = m_sBin AND tax_year < sTaxYear;

    DECLARE
                oPrevPermitRow pljson_list;
            BEGIN
                LOOP
                    FETCH cPrevPermit  INTO s_PrevPermitNo ;
                    EXIT WHEN cPrevPermit%NOTFOUND;
            oPrevPermitRow := pljson_list();
            oPrevPermitRow.append(s_PrevPermitNo);
            sPrevPermitNo.append(oPrevPermitRow.to_json_value);
                END LOOP;
            END;
            CLOSE cPrevPermit;
        END if;

             oBusinessInfo.put('prevPermitNo',sPrevPermitNo);

字符串
结果如下:

prevPermitNo":[[" "],[" "],[" "],["2019-00093"],["2020-00311"],["2021-00509"]


我需要将其转换为字符串而不是数组,原因是该网站崩溃,因为数组的结果

k7fdbhmy

k7fdbhmy1#

这可能会为您做:

IF (sBnsStat = 'REN') THEN
    OPEN cPrevPermit FOR SELECT permit_no FROM buss_hist WHERE bin = m_sBin AND tax_year < sTaxYear;
    
    DECLARE
        oPrevPermitRow pljson_list;
        oPrevPermits pljson_list := pljson_list();  -- Initialize an array for the permits
        
        -- Declare s_PrevPermitNo variable here if not already declared
        
    BEGIN
        LOOP
            FETCH cPrevPermit INTO s_PrevPermitNo;
            EXIT WHEN cPrevPermit%NOTFOUND;
            
            oPrevPermitRow := pljson_list();  
            
            oPrevPermitRow.append(s_PrevPermitNo);
            
            oPrevPermits.append(oPrevPermitRow);  
        END LOOP;
    END;

    CLOSE cPrevPermit;
    
    oBusinessInfo.put('prevPermitNo', oPrevPermits); 
END IF;

字符串

  • 在循环之前初始化'oPrevPermits',这将存储数组
  • 仅在循环内将“oPrevPermitRow”追加到“oPrevPermits”

相关问题