Question

Basically I am attempting to pass a string of xml to a stored proc.

My first stab at reading and parsing XML with the following works fine:

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;

My stored proceedure provided below based on the above example compiles also fine:

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;

However, the problems begin when I attempt to test the proceedure and this is where I hoping someone could find my mistake.

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;

At this point I get the following errors:

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:

Thanks in advance for the assistance!

Was it helpful?

Solution

EXECUTE is a SQL*Plus command that needs to be in a single line. The problem is not whitespace but newline characters.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top