0
我想解析一個大的XML,然後使用FORALL語句將它插入到表中。解析一個大的XML,然後插入使用所有
我創建瞭如下表:
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
非常感謝你 – user1948304 2013-03-28 11:55:29