我正在尝试解析大型 XML,然后使用 FORALL 语句将其插入表中。
我创建了下表:
create table users(EMPNO NUMBER(4),SAL NUMBER(4),HIREDATE DATE);
这是我的代码
declare
TYPE import_q_rec IS RECORD (
EMPN dbms_sql.NUMBER_TABLE,
SALN dbms_sql.NUMBER_TABLE,
HIREDATE dbms_sql.Date_Table );
l_import_q_tab import_q_rec;
l_row_index number := 0;
l_temp_nd XMLTYPE;
l_result_xml XMLTYPE:=XmlType('<ROWSET>
<ROW>
<EMPNO>2290</EMPNO>
<SAL>2000</SAL>
<HIREDATE>31-DEC-1992</HIREDATE>
</ROW>
</ROWSET>');
begin
WHILE l_result_xml.Existsnode('/ROWSET/Row[' || To_Char(l_row_index) || ']') > 0
LOOP
l_temp_nd :=l_result_xml.Extract('/ROWSET/Row[' || To_Char(l_row_index) || ']');
l_import_q_tab.EMPN(l_row_index) := (l_temp_nd, '/Row/EMPNO/text()', NULL);
l_import_q_tab.SALN(l_row_index) := (l_temp_nd, '/Row/SAL/text()', NULL);
l_import_q_tab.HIREDATE(l_row_index) := (l_temp_nd, '/Row/HIREDATE/text()', NULL);
l_row_index := l_row_index + 1;
END LOOP;
FORALL i IN 1 .. l_row_index - 1
INSERT INTO users
VALUES (l_import_q_tab.EMPN(i), l_import_q_tab.SALN(i), l_import_q_tab.HIREDATE);
end;
它给了我以下错误
ORA-06550: line 21, column 38:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 21, column 2:
PL/SQL: Statement ignored
ORA-06550: line 22, column 39:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 22, column 2:
PL/SQL: Statement ignored
ORA-06550: line 23, column 42:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 23, column 2:
PL/SQL: Statement ignored
ORA-06550: line 30, column 51:
PLS-00382: expression is of wrong type