我创建了一个带有xmltype列
的表的简单示例--set up the able
CREATE TABLE dept (name varchar2(20), employees XMLTYPE);
--insert a test row
INSERT INTO dept VALUES (
'Sales',
XMLTYPE.createxml(
'<?xml version="1.0" encoding="UTF-8"?>
<People>
<Person>
<Name>TED</Name>
<Age>35</Age>
</Person>
<Person>
<Name>BEN</Name>
<Age>36</Age>
</Person>
<Person>
<Name>EDI</Name>
<Age>37</Age>
</Person>
</People>'
)
);
我只是想通过使用xml表来展平结果(在另一个查询中使用)以便我得到
Sales | Ted | 35
Sales | BEN | 36
Sales | EDI | 37
所以我用xtable
写了这个查询SELECT dept name, people.Name, people.Age
FROM dept,
XMLTABLE('/people'
PASSING dept.employees
COLUMNS
"Name" varchar2(6) PATH '/People/Person/Name',
"Age" varchar2(6) PATH '/People/Person/Age'
people;
但是我收到以下错误
“ORA-01780:需要字符串文字”
并且ide突出显示以下行
"Name" varchar2(6) PATH '/People/Person/Name',
任何人都可以告诉我我错过了什么/做错了吗
答案 0 :(得分:1)
编辑 - 运行此操作 - alter session set cursor_sharing = exact
或者在参数文件中设置cursor_sharing = exact。
然后你可能在COLUMNS(/ Age) -
之后也错过了一个结束括号SELECT dept name, people.Name, people.Age
FROM dept,
XMLTABLE('/people'
PASSING dept.employees
COLUMNS
"Name" varchar2(6) PATH '/People/Person/Name',
"Age" varchar2(6) PATH '/People/Person/Age' )
people;