从ORACLE pl sql cursor data

时间:2016-01-13 13:45:39

标签: xml oracle

我有一个包含3个游标的包,我需要在读取游标1的每次迭代时生成一个新的XML字符串。我循环游标1并循环游标2并在游标2中循环游标3建立我的数据行。如果我只是尝试构建一个字符串并附加到它,因为我处理通过我最终吹出局部变量(限制为32767)。我已经尝试将其写入表格中的clob列,但我得到的是“不能在查询中执行DML操作”。错误。为了进一步复杂化,我需要发送第三方软件提供商以将XML作为字符串作为JSON API的元素。 任何想法都会非常感激!

编辑:代码按要求...

for r1 in SQLW_HEAR.HEAR_c1(p_term_code, p_id, p_major_code, p_grad_date_time, p_grad_status_code, p_start_last_name, p_end_last_name) loop

v_xml_string := NULL;
v_xml_string := '<?xml version="1.0" encoding="UTF-8"?>
<achievementReport xmlns="http://hear.org/" xmlns:credit="http://purl.org/net/cm" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:hear="http://hear.org/" xmlns:mlo="http://purl.org/net/mlo" xmlns:xcri="http://xcri.org/profiles/1.2/catalog" xmlns:xcriTerms="http://xcri.org/profiles/catalog/terms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hear.org/ HEAR_1.2.xsd" id="219061-BA/CST" status="1">
<issuer>
<dc:identifier>http://www.liverpool.ac.uk/</dc:identifier>
<dc:title>University of Liverpool</dc:title>
<issuerDescription>This HEAR issued by Liverpool University</issuerDescription>
</issuer>';

p_ast_xml_write(v_xml_string);
v_xml_string := NULL;

v_xml_string := v_xml_string||'<learner>
<dc:identifier xsi:type="hear:husid">1011782185501</dc:identifier>
<dc:identifier xsi:type="hear:uln">'||r1.SPRIDEN_ID||'</dc:identifier>
<fullName>'||r1.full_name||'</fullName>
<dateOfBirth>'||r1.BIRTH_DATE||'</dateOfBirth>
</learner>';

v_xml_string := v_xml_string||'<provider>
<dc:identifier>http://www.liverpool.ac.uk/</dc:identifier>
<course>
<dc:identifier>pro1</dc:identifier>
<dc:title>'||r1.field_of_study||'</dc:title>
<qualification>
<dc:identifier>'||r1.STVDEGC_DESC||'</dc:identifier>
<issueDateQualification>'||r1.date_of_award||'</issueDateQualification>
</qualification>
<presentation>
<dc:identifier>http://www.liverpool.ac.uk/courses/201011/WPQ0</dc:identifier>
<mlo:start>'||r1.degree_start||'</mlo:start>
<mlo:end>'||r1.end_date||'</mlo:end>
<assessment>
<dc:identifier>'||r1.STVDEGC_DESC||'</dc:identifier>
<result>'||r1.field_of_study||'</result>
</assessment>
</presentation>
</course>';

for r2 in SQLW_HEAR.HEAR_c2(p_term_code, p_id, p_major_code, p_grad_date_time, p_grad_status_code, p_start_last_name, p_end_last_name, r1.spriden_id) loop

v_xml_string := v_xml_string||'
<course>
<dc:identifier>py1</dc:identifier>
<dc:type>Programme Year</dc:type>
<dc:title>'||r1.field_of_study||'</dc:title>
<isPartOf>pro1</isPartOf>
<dc:qualificationType>'||r1.level_of_study||'</dc:qualificationType>
<presentation>
<dc:identifier>'||r2.stvterm_desc||' for Year of Study: '||r2.seq_no||' at '||r2.sect4_text||'</dc:identifier>
<assessment>
<dc:identifier />
<assessmentType />
<gradingScheme />
</assessment>
</presentation>
</course>';


for r3 in SQLW_HEAR.HEAR_c3(p_term_code, p_id, p_major_code, p_grad_date_time, p_grad_status_code, p_start_last_name, p_end_last_name, r2.seq_no, r2.spriden_id,r2.hear_c2_term_code) loop

v_xml_string := v_xml_string||'
<course>
<dc:identifier>'||r3.course_description||'</dc:identifier>
<dc:title>'||r3.long_course_title||'</dc:title>
<dc:type>Module</dc:type>
<isPartOf>py1</isPartOf>
<mlo:credit>
<credit:level>Certificate Level</credit:level>
<credit:value>'||r3.latest_grade_credit||'</credit:value>
</mlo:credit>
<presentation>
<dc:identifier>'||r3.course_description||'</dc:identifier>
<assessment>
<result resultType="Mark">'||r3.latest_grade||'</result>
<attempts>'||r3.asterix_display||'</attempts>
</assessment>
</presentation>
</course>';

end loop; -- r3
--
end loop; -- r2

0 个答案:

没有答案