尝试通过使用存储过程将一些数据从XML文件(由PEGA/Java生成(插入两个表中。不确定我应该如何定义变量,或定义光标,因为大多数教程都向您展示了如何将存储过程写入数据库中其他表的桌子...我被卡住的部分都标记了。一个选择是Java开发人员将我的存储过程称为我存储过程中提供的参数,并以这种方式推动数据。如果是这样,我如何定义光标从哪里获取数据?(预先感谢!(
Create or Replace Procedure Cascade_Load (
a Number,
b Number,
c Number,
d Varchar2,
e Varchar2,
f Number,
g Varchar2,
h Varchar2,
i Timestamp,
j Number,
k Varchar2,
l Date,
m Number,
n Date,
o Number,
p Date,
q Date
)
AS
BEGIN
IF b is not null
THEN
INSERT INTO Value(Value_Id, Product_Id, Data_Source_Id, Unit_CD, Value_TX, UTC_OFFSET, DATA_DATE, HR_UTC, HR, HR_NUM, DATA_CODE, CREATE_DT, CREATE_USER_ID, MODIFY_DT, MODIFY_USER_ID, EFFECTIVE_DT, INACTIVE_DT)
VALUES(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q);
INSERT INTO XML_Load_STAGING(Code, Product_Name, Product_number, Product_Version, Technical_Contact)
VALUES(a, b, c, d, e);
COMMIT;
END IF;
END;
/
DECLARE
a Number,
b Number,
c Number,
d Varchar2,
e Varchar2,
f Number,
g Varchar2,
h Varchar2,
i Timestamp,
j Number,
k Varchar2,
l Date,
m Number,
n Date,
o Number,
p Date,
q Date
CURSOR cXmlHoursLoadCursor IS (SELECT **WHAT DO I SELECT since Im calling from a xml file rather than from a table?**);
BEGIN
For v in cXmlHoursLoadCursor LOOP
Cascade_Load(v.a, v.b, v.c, v.d, v.e, v.f, v.g, v.h, v.i, v.j, v.k, v.l, v.m, v.n, v.o, v.p, v.q);
COMMIT;
END LOOP;
END;
/
尝试将XML文件加载为CTE:
--query the XML Blob using a CTE (pulling from the XML file each time)
WITH XmlFile (Contents) AS (
SELECT CONVERT (XML, BulkColumn)
FROM OPENROWSET (BULK 'C:Books.xml', SINGLE_BLOB) AS XmlData
)
SELECT *
FROM XmlFile
GO
这将向您显示数据的外观以及列名。从那里,您可以像其他任何表或查看一样查询" XMLFILE" CTE表。