I am retrieving data from xml for insert into table. But I also want to insert an additional data sysdate in to following xmltable table:
sample XML data:
<employee_info>
<employee_id>ID1234</employee_id>
<name>John</name>
</employee_info>
-- This is the query Notice at CREATED_ON :
INSERT INTO TBL_EMPLOYEE TBL (TBL.EMP_ID, TBL.Name, TBL.Created_on)
SELECT x.* FROM XMLTABLE('/employee_info'
PASSING xmlData
COLUMNS EMP_ID VARCHAR2(10) PATH 'employee_id',
Name VARCHAR2(50) PATH 'name',
CREATED_ON DATE PATH '<created_on>sysdate</created_on>');
How can I pass the sysdate
on column CREATED_ON
that is not part of the given xml sample. Please help. Thanks
You don't need to operate on xml level to have column with sysdate:
INSERT INTO tbl_employee tbl
(tbl.emp_id
,tbl.name
,tbl.created_on)
SELECT t.emp_id, t.name, sysdate
FROM xmltable('/employee_info'
passing xmldata
columns
emp_id VARCHAR2(10) path 'employee_id',
NAME VARCHAR2(50) path 'name'
) t;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.