问题描述
我有一个包,需要通过游标输出XML数据。我从来没有在Xml上工作过。
我的XML字符串是
这应该在上述过程中的dbms_output.put_line中使用。
提前谢谢。
create or replace PACKAGE BODY PK_FCP_EXTRACT is
PROCEDURE sp_fcp_extract is
cursor Rev_cur is select * from t_uar_reviews where CREATED_DATE=trunc(sysdate) ;
r Rev_cur%rowtype;
cursor case_cur( c_revid IN t_uar_reviews.uar_review_id%type )
is select *
from t_uar_cases where uar_review_id= c_revid ;
c case_cur%rowtype;
begin
open Rev_cur;
loop
fetch Rev_cur into r;
exit when Rev_cur%notfound;
open case_cur( r.uar_review_id );
loop
fetch case_cur into c;
exit when case_cur%notfound;
dbms_output.put_line(c.UAR_CASE_ID||','||c.UAR_REVIEW_ID||','||c.CASE_TYPE||','||c.CASE_NMBR||','||c.ACTIVE_FLAG||','|| c.CREATED_DATE);
---dbms_output.put_line (XML string) ; #please tel me how to use
end loop;
close case_cur;
end loop;
close Rev_cur;
end;
END PK_FCP_EXTRACT;我的XML字符串是
vXML_Msg := to_clob('1 ' ||
'' ||to_char(sysdate,'yyyy-mm-ddTmm:ss:00')|| ' ' ||
'1 ' ||
'' || t_uar_reviews.REVIEWED_BY || ' ' ||
'0070705 ' ||
'' || t_uar_reviews.SUMMARY_NOTE || ' ' ||
'' ||sum(t_uar_cases.exposure_amt) || ' '||
'' ||t_uar_reviews.UAR_REVIEW_ID || ' ' ||
'' || wells.t_hogan_acct_cust_month.ssn_taxid_ind || ' ' ||
'' || t_uar_cases.ecn ||' '||
'' || t_uar_cases.tax_id ||' ' ||
'' || t_uar_cases.acct_nmbr ||' ' ||
'' || wells.t_hogan_acct_cust_xref.coid || ' ' ||
'' || wells.t_hogan_acct_cust_xref.cis_prod ||' ' ||
'' || wells.t_file_attachment ||' ' ||
'' ||wells.t_file_attachment||' ' ||
'' || uar.t_disposition.disposition_desc || ' ' ||
'' || t_uar_cases.case_type ||' ' ||
'' || t_uar_cases.case_nmbr||' ' ||
'' || t_uar_cases.exposure_amt ||' ' ||
'' || t_uar_cases.full_name||' ' ||
'' || t_uar_cases.created_date ||' ' ||
'' || t_uar_cases.close_date ||' ' ||
'' || t_uar_cases.ring_id ||' ' ||
'' || t_uar_cases.ring_name ||' ' ||
'' || t_uar_cases.uar_case_id ||' ' )这应该在上述过程中的dbms_output.put_line中使用。
提前谢谢。
专家解答
最好在查询运行时使用各种XML函数来生成它。例如:
在以下位置阅读有关此的更多信息:
https://docs.oracle.com/en/database/oracle/oracle-database/12.2/adxdb/generation-of-XML-data-from-relational-data.html#GUID-C14202BB-4D31-4983-B39E-2C1471CC0B9F
select xmlelement (
"DEPT",
xmlelement (
"EMPS",
xmlagg ( xmlforest ( employee_id, first_name ) )
)
)
from hr.employees h
group by department_id;
XMLELEMENT("DEPT",XMLELEMENT("EMPS",XMLAGG(XMLFOREST(EMPLOYEE_ID,FIRST_NAME))))
200 Jennifer
178 Kimberely
...在以下位置阅读有关此的更多信息:
https://docs.oracle.com/en/database/oracle/oracle-database/12.2/adxdb/generation-of-XML-data-from-relational-data.html#GUID-C14202BB-4D31-4983-B39E-2C1471CC0B9F
文章转载自ASKTOM,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




