基本上我试图将一串xml传递给存储过程。
我第一次尝试阅读和解析XML时使用以下工作正常:
select * FROM xmltable('//list//model.ProfilingSync'
passing xmlType.createxml('<list>
<model.ProfilingSync>
<screDocId>106</screDocId>
<evalStatCd>B</evalStatCd>
<evalChgDt>2014-2-13 9:41:49. 260034000</evalChgDt>
<ssn>000001060</ssn>
<evalRptIndivCd>A</evalRptIndivCd>
<rankAb>WO1</rankAb>
<indTypCd>A</indTypCd>
<civPayPlanCd>AB</civPayPlanCd>
<performanceTypCd/>
<performanceCd/>
<redactPerfCd/>
<civPayGrLvlNr>AB</civPayGrLvlNr>
</model.ProfilingSync>
<model.ProfilingSync>
<screDocId>106</screDocId>
<evalStatCd>B</evalStatCd>
<evalChgDt>2014-2-13 9:41:49. 260034000</evalChgDt>
<ssn>724629831</ssn>
<evalRptIndivCd>B</evalRptIndivCd>
<rankAb/>
<indTypCd>A</indTypCd>
<civPayPlanCd>ES</civPayPlanCd>
<performanceTypCd>100</performanceTypCd>
<performanceCd>1000</performanceCd>
<redactPerfCd>1000</redactPerfCd>
<civPayGrLvlNr>6</civPayGrLvlNr>
</model.ProfilingSync>
<model.ProfilingSync>
<screDocId>106</screDocId>
<evalStatCd>B</evalStatCd>
<evalChgDt>2014-2-13 9:41:49. 260034000</evalChgDt>
<ssn>001623791</ssn>
<evalRptIndivCd>D</evalRptIndivCd>
<rankAb>GEN</rankAb>
<indTypCd>A</indTypCd>
<civPayPlanCd>AB</civPayPlanCd>
<performanceTypCd>130</performanceTypCd>
<performanceCd>1160</performanceCd>
<redactPerfCd/>
<civPayGrLvlNr>AB</civPayGrLvlNr>
</model.ProfilingSync>
</list>')
columns SRC_DOC_ID NUMBER path '//screDocId',
EVAL_STAT_CD varchar(4) path '//evalStatCd',
EVAL_CHG_DT VARCHAR(200) path '//evalChgDt',
SSN VARCHAR(9) path '//ssn',
EVAL_RPT_INDIV_CD VARCHAR(4) path '//evalRptIndivCd',
RANK_AB VARCHAR(4) path '//rankAb',
PERFORMANCE_TYP_CD NUMBER path '//performanceTypCd',
PERFORMANCE_CD NUMBER path '//performanceCd',
REDACT_PERF_CD VARCHAR(4) path '//redactPerfCd',
IND_TYP_CD VARCHAR(4) path '//indTypCd',
CIV_PAY_PLAN_CD VARCHAR(4) path '//civPayPlanCd',
CIV_PAY_GR_LVL_NR VARCHAR(4) path '//civPayGrLvlNr') my_profiling_xml_table;
根据以上示例提供的下面提供的存储过程也很好:
create or replace
PROCEDURE CU_SEPS_PROFILING_IMPORT
(
P_XML_STRING IN CLOB
, P_RECORDSET OUT SYS_REFCURSOR
)
/*
Returns a list of evals with person info that have been completed from
today back to the submitted date.
VAR RC REFCURSOR;
EXECUTE CU_SEPS_PROFILING_IMPORT ('P_XML_STRING',P_RECORDSET => :RC)
print :rc;
*/
AS
BEGIN
OPEN P_RECORDSET FOR
SELECT * FROM
xmltable('//list//model.ProfilingSync'
passing XMLTYPE(P_XML_STRING)
columns SRC_DOC_ID xmltype path '//screDocId',
EVAL_STAT_CD xmltype path '//evalStatCd',
EVAL_CHG_DT xmltype path '//evalChgDt',
SSN xmltype path '//ssn',
EVAL_RPT_INDIV_CD xmltype path '//evalRptIndivCd',
RANK_AB xmltype path '//rankAb',
PERFORMANCE_TYP_CD xmltype path '//performanceTypCd',
PERFORMANCE_CD xmltype path '//performanceCd',
REDACT_PERF_CD xmltype path '//redactPerfCd',
IND_TYP_CD xmltype path '//indTypCd',
CIV_PAY_PLAN_CD xmltype path '//civPayPlanCd',
CIV_PAY_GR_LVL_NR xmltype path '//civPayGrLvlNr') my_profiling_xml_table;
END CU_SEPS_PROFILING_IMPORT;
但是,当我尝试测试这个问题时问题就开始了,我希望有人能找到我的错误。
VAR RC REFCURSOR;
EXECUTE CU_SEPS_PROFILING_IMPORT ('<list>
<model.ProfilingSync>
<screDocId>106</screDocId>
<evalStatCd>B</evalStatCd>
<evalChgDt>204-2-13 9:41:49. 260034000</evalChgDt>
<ssn>000001060</ssn>
<evalRptIndivCd>A</evalRptIndivCd>
<rankAb>WO1</rankAb>
<indTypCd>A</indTypCd>
<civPayPlanCd>AB</civPayPlanCd>
<performanceTypCd/>
<performanceCd/>
<redactPerfCd/>
<civPayGrLvlNr>AB</civPayGrLvlNr>
</model.ProfilingSync>
<model.ProfilingSync>
<screDocId>106</screDocId>
<evalStatCd>B</evalStatCd>
<evalChgDt>2014-2-13 9:41:49. 260034000</evalChgDt>
<ssn>724629831</ssn>
<evalRptIndivCd>B</evalRptIndivCd>
<rankAb/>
<indTypCd>A</indTypCd>
<civPayPlanCd>ES</civPayPlanCd>
<performanceTypCd>100</performanceTypCd>
<performanceCd>1000</performanceCd>
<redactPerfCd>1000</redactPerfCd>
<civPayGrLvlNr>6</civPayGrLvlNr>
</model.ProfilingSync>
<model.ProfilingSync>
<screDocId>106</screDocId>
<evalStatCd>B</evalStatCd>
<evalChgDt>2014-2-13 9:41:49. 260034000</evalChgDt>
<ssn>001623791</ssn>
<evalRptIndivCd>D</evalRptIndivCd>
<rankAb>GEN</rankAb>
<indTypCd>A</indTypCd>
<civPayPlanCd>AB</civPayPlanCd>
<performanceTypCd>130</performanceTypCd>
<performanceCd>1160</performanceCd>
<redactPerfCd/>
<civPayGrLvlNr>AB</civPayGrLvlNr>
</model.ProfilingSync>
</list>', p_recordset => :RC);
print :rc;
此时我收到以下错误:
Error starting at line 3 in command:
EXECUTE CU_SEPS_PROFILING_IMPORT ('<list>
Error report:
ORA-06550: line 1, column 33:
PLS-00103: Encountered the symbol "<list>; END;" when expecting one of the following:
( ) - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable>
table continue avg count current exists max min prior sql
stddev sum variance execute multiset the both leading
trailing forall merge year month day hour minute second
timezone_hour timezone_minute timezone_region timezone_abbr
time timestamp interval date
<a string literal with character set spe
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
提前感谢您的帮助!
答案 0 :(得分:1)
EXECUTE
是一个SQL * Plus命令,需要在一行中。问题不是空格而是换行符。