简体   繁体   English

如何获取此存储过程以使用XML文件?

[英]How do i get this stored procedure to work with an XML file?

Trying to insert some data into two tables from an xml file (generated by pega / java) by using a stored procedure . 尝试使用存储过程从xml文件(由pega / java生成)将一些数据插入到两个表中。 Not sure how i am supposed to define the variables , or define the cursor since most tutorials out there only show you how to write stored procedures writing to tables from other tables within the database... The parts where i am stuck are marked. 不确定我应该如何定义变量或定义光标,因为那里的大多数教程仅向您展示如何编写存储过程,以便从数据库中的其他表写入表中。 An option is that the JAVA developer call my stored procedures with the parameters provided in my stored procedure and push data in that way. 一个选择是JAVA开发人员使用存储过程中提供的参数调用存储过程,并以这种方式推送数据。 If that is the case, how do i define where the cursor is pulling data from? 如果是这样,我如何定义光标从哪里提取数据? (Thanks in advance!) (提前致谢!)

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;
/

Try bulk loading the XML file as a CTE: 尝试将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

This will show you what the data looks like, along with column names. 这将显示数据以及列名。 From there, you can query the "XmlFile" CTE table just like any other table or view. 从那里,您可以像查询其他任何表或视图一样查询“ XmlFile” CTE表。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何获取作为数组的存储过程输出参数? - How do I get a stored procedure output parameter that is an array to work? 如何从Oracle中的SELECT存储过程获取输出到Java? - How do I get output into Java from a SELECT stored procedure in Oracle? 如何从 postgresql 中的存储过程中获取值到 java 应用程序中? 我不断收到错误 - How do you get the values from a stored procedure in postgresql into a java application? I keep getting an error 如何在JDBC中执行没有参数的存储过程? - How do I execute a stored procedure without parameters in JDBC? 如何使用Java存储过程打开文件 - How can I open a file using java stored procedure 我必须配置哪些设置才能使用XML作为输入使用Spring的存储过程与Oracle相关的参数 - Which settings do I have to configure to use XML as input Parameter with Oracle using Spring's stored procedure 如何在此pom.xml文件中执行3次执行? - How do I get the 3 executions in this pom.xml file to execute? 在XSLT中,如果某个XML文件包含在xinclude中,我如何获取该元素的xml文件的文件路径? - In XSLT, how do I get the filepath of the xml file of a certain element if that xml file was included with xinclude? 如何使用log4j xml将存储过程名称记录到日志文件 - How to log stored procedure names to log file using log4j xml 怎么做“ builder.parse(存储在这个罐子里的xml文件)”? - How to do “builder.parse(xml file stored inside of this jar)”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM