Create Table from XML Data
XML info: D:\XMLDATA\mytable.xml
create directory XML_dir as 'D:\XMLDATA';
<INFO>
<Column_Name>Col1</Column_Name>
<Data_Type>Char(1)</Data_Type>
</INFO>
<INFO>
<Column_Name>Col2</Column_Name>
<Data_Type>VARCHAR2(50)</Data_Type>
</INFO>
I need to create a table based on the XML data.
Create Table mytable
Col1 Char(1),
Col2 Varchar2(50)
How to read and execute the xml data to create a table.
Thanks!
Something like this :
SQL> declare
2
3 v_xmlinfo clob;
4 v_ddl varchar2(32767) := 'CREATE TABLE mytable ( #COLUMN_LIST# )';
5 v_column_list varchar2(4000);
6
7 begin
8
9 v_xmlinfo := dbms_xslprocessor.read2clob('TEST_DIR', 'info.xml');
10
11 select column_list
12 into v_column_list
13 from xmltable(
14 'string-join(
15 for $i in /INFO
16 return concat($i/Column_Name, " ", $i/Data_Type)
17 , ", "
18 )'
19 passing xmlparse(content v_xmlinfo)
20 columns column_list varchar2(4000) path '.'
21 ) ;
22
23
24 v_ddl := replace(v_ddl, '#COLUMN_LIST#', v_column_list);
25 --dbms_output.put_line(v_ddl);
26
27 execute immediate v_ddl;
28
29 end;
30 /
PL/SQL procedure successfully completed
SQL> select * from mytable;
COL1 COL2
Similar Messages
-
Having difficulty creating pdf from XML data source
I have a 'rpt' file built with a classic install of Crystal 10, using xml as a data source. I have tried using both ADO.NET(XML) connection and ODBC CR ODBCXML Driver 4.20.
The rpt file was built on Windows2000 NT platform. The report runs, and displays data from the sample xml file in the preview tab.
I am attempting to feed xml data into the rpt file with the intent to create pdf formatted output. I am using java with the Crystaldecisions packages. I am running this app out of an Apache server on an Ubuntu VM Hardy Heron release. This does not have any version of Crystal Reports installed on it.
I have followed the examples and I am comfortable that I have the correct package imports, I am able to open the rpt file, and convert both the xml and xsd to byte arrays. When I issue the command
reportClientDocument.getDatabaseController().setDataSource(xmlDataSet, '', '')
I get the response
Cannot find corresponding table information in the XML file
Set data source failed: The table 'criminal_case' could not be found.
Request failed and JRC Command failed to be undone
JRCAgent1 detected an exception: The table 'criminal_case' could not be found.
at com.crystaldecisions.reports.reportdefinition.datainterface.g.a(Unknown Source)
The xsd does validate the xml which contains a noNamespaceSchemaLocation pointer to the xsd.
The xml is the same data that was used to design the report on the NT box. This means that I see the same elements being byte streamed as were used to create the rpt file.
Is this as simple as I am running my webserver on Linux? I do see the connection attribute properties reference a Database DLL that is clearly windows based. What can I do?So why develop a report if there is no data? I can only think that you have a bunch of static text, maybe an instruction page you want to publish? If so, you still need a data source, it can be a dummy source
<?xml version="1.0"?>
<ROOT/>
ie no data per se. BIP needs a source even if there is not data to merge.
Cheers
Tim -
Create table from external data with dates
I have a CSV that looks somewhat like this:
abcuser,12345,5/12/2012,5,250.55
xyzuser,67890,5/1/2012,1,50
ghjuser,52523,1/1/1900,0,0
When I create the external table, then query it I get a date error:
CREATE TABLE xtern_ipay
userid VARCHAR2(50),
acctnbr NUMBER(20, 0),
datelastused DATE,
number_rtxns NUMBER(12, 0),
amtused NUMBER(12, 0)
organization external ( TYPE oracle_loader DEFAULT directory "XTERN_DATA_DIR"
ACCESS parameters (
records delimited BY newline fields terminated BY "," )
location ('SubscriberStatistics.csv') ) reject limit UNLIMITED;
Error I see in the reject log:
Field Definitions for table XTERN_IPAY
Record format DELIMITED BY NEWLINE
Data in file has same endianness as the platform
Rows with all null fields are accepted
Fields in Data Source:
USERID CHAR (255)
Terminated by ","
Trim whitespace same as SQL Loader
ACCTNBR CHAR (255)
Terminated by ","
Trim whitespace same as SQL Loader
DATELASTUSED CHAR (255)
Terminated by ","
Trim whitespace same as SQL Loader
NUMBER_RTXNS CHAR (255)
Terminated by ","
Trim whitespace same as SQL Loader
AMTUSED CHAR (255)
Terminated by ","
Trim whitespace same as SQL Loader
error processing column DATELASTUSED in row 1 for datafile g:\externaltables\SubscriberStatistics.csv
ORA-01858: a non-numeric character was found where a numeric was expected
error processing column DATELASTUSED in row 2 for datafile g:\externaltables\SubscriberStatistics.csv
ORA-01858: a non-numeric character was found where a numeric was expected
error processing column DATELASTUSED in row 3 for datafile g:\externaltables\SubscriberStatistics.csv
ORA-01858: a non-numeric character was found where a numeric was expected
Any ideas on this? I know I need to tell oracle the format of the date on the external file, but I can't figure it out.Try this:
CREATE TABLE xtern_ipay
userid VARCHAR2 (50)
, acctnbr NUMBER (20, 0)
, datelastused DATE
, number_rtxns NUMBER (12, 0)
, amtused NUMBER (12, 2)
ORGANIZATION EXTERNAL
( TYPE oracle_loader DEFAULT DIRECTORY "XTERN_DATA_DIR"
ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE FIELDS TERMINATED BY "," MISSING FIELD VALUES ARE NULL
( userid
, acctnbr
, datelastused DATE 'mm/dd/yyyy'
, number_rtxns
, amtused)
location ('SubscriberStatistics.csv') ) reject LIMIT unlimited;
select * from xtern_ipay;
USERID ACCTNBR DATELASTU NUMBER_RTXNS AMTUSED
abcuser 12345 12-MAY-12 5 250.55
xyzuser 67890 01-MAY-12 1 50
ghjuser 52523 01-JAN-00 0 0
{code}
Sorry I had to correct the previous statement again for the date format and for the column amtused that was defined without decimals.
Regards
Al
Edited by: Alberto Faenza on May 31, 2012 6:34 PM
wrong date format mm/dd/yy instead of dd/mm/yy
Edited by: Alberto Faenza on May 31, 2012 6:40 PM
Fixed again the date format and the amtused defined with 2 decimals -
HI,
is there any possibilty to create a relational table from a XML schema?Can you use a schema when we compose XML doc from Database tables?
Actually, I'm using SQL Server (sorry, wrong forum). But, I thought a Java tool would have a solution for me. -
Insert data into oracle table from XML file
I need to insert data into oracle table from XML file
If anybody handled this type of scenario, Please let me know how to insert data into oracle table from XML file
Thanks in advanceThe XML DB forum provides the best support for XML topics related to Oracle.
Here's the FAQ on that forum:
XML DB FAQ
where there are plenty of examples of shredding XML into Oracle tables and such like. ;) -
Spry Tables and Xml Data Sets viewed in IE7
Has anyone ever run into a problem with Spry Tables and Xml
Data Sets viewed in IE7? Work fine in IE6 and Firefox, but get the
error "exception caught while loading feed.xml: [object Error]" in
IE 7. Any ideas?
Attached is the xml I'm using.
ThanksI came looking for the answer to this question. I could not
find an answer. Eventually I found it the answer that worked for
me, a graphic designer with not much experience in xml.
The following url provided an errata file in PDF format:
www.peachpit.com/dwcs3cib
which includes the following addendum to the incomplete
instructions in the book i was using to learn about spry:
"If Internet Explorer 7 is your primary browser, you'll nee
to take some extra steps to view spry dynamic content locally.
First, your site must be within the local server webroot; be sure
your Lessons folder is stored within the Inetpub>wwwroot folder.
Next, double-click the site name in the files panel to open the
Site Definition dialogue. Click the Testing Server category; from
the Access List choose Local/Network. Click Okay to close the Site
Definition dialogue. Now, when you preview your page with Internet
Explorer, your local Web server (localhost) serves the page as
designed."
Horray for me! Now i can move on from here and actually get
some work done! -
Union tables from multiply data srouces in OBIEE
Hi Pros,
Recenetly I am doing a POC about union the same structure table from multiply data sources through OBIEE, uptill now I still can't make that out, I have tried below ways :
Precondition: I have configured those two tables under one physical folder with two connection pool
1. When do the union in physical level, can not implement since either can not create a view union two tables or using SQL.
2. When do the union in Logical level, can not implement also
I know that this kind of data integration should be done before we import into OBIEE model, but there is some policy that we can't integrate, so I just wondering whether OBIEE has this functionlity that can union data from different data source. Please advise.
thanksHi Srinivas
After a second thought, I am wondering what you mean in the post, but the situation is that there are two tables in different data sources, Table-A and Table-B in the Physical layer, they are not yet integrated into one table(let's say Table-C), you mean add a data source indictor column into a table in BMM layer, I want to know how can we integrate data (UNION), because from my perspective, if TABLE-A have bleow column ID,NAME,ADDRESS, while the TABLE-B have the same, the difference is the data bwtween them, even we create a logicl table in BMM, drag those those columns, we only get ID,NAME,ADDRESS,ID#,NAME#,ADDRESS#, but the table structure is different.
The problem is how to create a logic table like TABLE-D (ID,NAME,ADDRESS) which have the data both from TABLE-A and TABLE-B in Physical Layer. While no need to filter by prompt about the data sources. We need to show the data altoghter.
Please advise if I missing you point.
thanks
Edited by: Henry He on Dec 28, 2010 3:21 PM -
How to get internal table from SAP Data Provider C#
Hello.
ABAP:
DATA: lt_t001 TYPE TABLE OF t001.
DATA: url(1000) TYPE c.
SELECT * INTO TABLE lt_t001 FROM t001.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'APPLICATION'
subtype = 'X-R3TABLE'
TABLES
data = lt_t001
CHANGING
url = url
EXCEPTIONS
OTHERS = 4.
C#:
using SAPDataProvider;
using SAPTableFactoryCtrl;
public void SetDataFromUrl(string url)
SAPDataProviderClass p = new SAPDataProviderClass();
p.SetDataFromURL("APPLICATION", "X-R3TABLE", url);
ISapDPR3Table tbl = p.GetDataAsR3Table("APPLICATION", "X-R3TABLE");
SAPTableFactoryClass tf = new SAPTableFactoryClass();
Table tb = (Table)tf.NewTable();
tb.ISAPrfcITab = tbl.DataTable; // Exception !!!!!!
How to get internal table from SAP Data Provider ?Hi Sergey,
I'm trying to do the same, have you found a solution to solved it?
thanks for your help.
Regards.
Jonathan -
Create jms queue xml data server
Hi,
What's the difference between jms queue and jms queue xml data servers and how to create jms queue xml data server.
Thanks.Hello,
JMS messages can principally be processed by Oracle Data Integrator in two formats:
- JMS Messages: containers for rows of data, handled through JMS Queue/JMS Topic Technologies. With JMS Queue/JMS Topic technologies, each JMS destination is defined similarly to a flat file datastore. Each message in the destination is a record in the datastore.
- XML Messages: containers for XML files, handled through JMS XML Queue/JMS XML Topic Technologies. With JMS XML Queue/JMS XML Topic technologies, each messages payload contains a complete XML data structure. This structure is mapped into a relational schema (XML Schema) which appears as a model. This use the Oracle DI Driver for XML (see the driver documentation in Oracle DI documentation).
Find below a step by step creation process for such a destination:
1. Data Server
To create a JMS XML Queue data server, you declare a simple JNDI connection. The only JMS XML specific information is added to the URL. This information defines the XML file format.
The JNDI URL should be : <JMS_RESOURCE>?d=<DTD_FILE>&f=<XML_FILE>&s=<SCHEMA>&JMS_DESTINATION=<JMS_DESTINATION_NAME>
- JMS_RESOURCE: JNDI resource corresponding to your JMS queue that will contain the XML payload. You would specify this URL if you were managing normal JMS messages.
- DTD_FILE: path to a DTD file that describes the XML structure. Mandatory if the parameter XML_FILE is omitted.
- XML_FILE: path to the XML file with a structure similar to the expected XML messages. Mandatory if the DTD_FILE parameter is omitted.
- SCHEMA: schema name that will contain the XML structure. This value must match the one set for the physical schema attached to this data server. This parameter is mandatory.
- JMS_DESTINATION_NAME: name of the JMS queue or topic. This parameter is mandatory.
2. Schema
Creation is straightforward: In the Schema (Schema) and Schema (Work Schema), enter the name of the <SCHEMA> defined in the data server JNDI URL.
3. Model
Use standard reverse-engineering. As the Oracle DI Driver for XML is used the XML structure will be reversed as a relational structure.
Regards,
- FX -
Creating af:Table programatically : XML Data coming from CLOB
Hi ,
This is my Use case ::
JDev version :: 11.1.2.3
I am presenting my use case in XE database format.
1) We have a procedure say:
PROCEDURE GET_EMP_FOR_DEPT(DeptId IN Number,XMLDeptData OUT CLOB);
based on DeptId Input it returns the Employees Under Department.
2) Have created JaxB class using xsd say EmpUnderDeptDataSet.java
3) I have created method for calling this proc and and receiving the CLOB as output in the object of Type
EmpUnderDeptDataSet , in AMImpl class
4) We don't have the choice for creating EJB or other Data Control....and Programmatic EO..VO...
So added method to expose the Data received as List using client Interface in AMImpl
public List<EmpUnderDeptDataSet> getEmpUnderDeptCollection();
5) Now we need to have 1 Page where on Left Panel we have LOV to select the Dept.
On right panel, based on DeptId selected we have to show the Table of Employees returned
by the procedure.Refreshed every time the DeptId changes
Also, the Left Panel has to be Region.
How can we implement this. Please advise.Use the EXTRACTVALUE SQL function.
XMLType Operations -
Use of PL/SQL to populate table columns from XML data file
I'm trying to find the easiest way to transfer data from a flat file that is in XML format into a traditional Oracle table. Not retaining the XML but actually map an XML element to a column so standard SQL, Forms, Reports, etc can access like it was created using a Form.
Example: Table A has column names Tom, Dick and Harry and the XML file has elements Tom, Dick and Harry and I just want a function that maps and inserts/loads the data into Table As individual columns.
The process needs to be easily initiated by an end user. The user gets the XML data file via an email attachment and needs to do something like a Concurrent Request to pull in the file and load it. Using PL/SQL would be great.
I appreciate any help that can be provided.Hi,
HELP!!!!!
We are having the same problem and we are using oracle 10ir2.
We create an object type (sql type globally not in a package):
CREATE OR REPLACE TYPE G_EX AS OBJECT
( EX_ID NUMBER ,
EX_CON VARCHAR2 ( 100 ) ,
EX_L VARCHAR2 ( 30 ) ,
EX_T VARCHAR2 ( 4000 ) );
CREATE OR REPLACE TYPE G_EX LIST AS TABLE OF GEX AS ;
then we insert data through a bulk collect within the package with the table declared of this array of object types:
v_table G_EX _LIST:= NULL;
SELECT G_EX (ex_id
,ex_con
,ex_l
,ex_t )
BULK COLLECT INTO v_table
FROM exs_lookup;
I am using the syntax (below) but it gives PL/SQL: ORA-00902: invalid datatype
sometimes not always:
SELECT G_EX ( ex_id
,ex_con
,ex_l
,ex_t )
BULK INTO v_data_record
FROM TABLE (v_table)
WHERE ex_id = p_key;
where p_key - is a number type
and v_data_record is a G_EX object type.
I was wondering if anyone else encountered a similar problem, and knows what we may have done wrong. Since we dont understand why this piece of code is throwing this ora-00902 errors occasionally not always.
Also, if we restart the database up once this errors occurs it appears to stop throwing this ora_00902 error for a lenght of time. Then it comes up with the ora-00902 error again (why?)
thanks -
Please help me in inserting data into table from XML message.
Hi Experts,
Please provide a procedure to implement my below requirement.
Since I am new to queue concept.
[code]- <MESSAGES>
- <MESSAGE ID="3026900">
<MSG_ID>3026900</MSG_ID>
<DT_POSTED>6/20/2013 08:15:48</DT_POSTED>
<POSTED_BY>GPD_MSG_EXTRACTOR</POSTED_BY>
<DT_LAST_QUEUED />
- <MSG>
- <WORK_SET TRANSACTION_ID="@TRANS_ID" TRANSACTION_TYPE="Batch" IS_ACID="@IS_ACID">
- <WORK_UNIT GROUP="LEAD_TIME" ACTION="UPDATE" AFFECTED="LEAD_TIME">
- <RECORDSET TABLE_NAME="LEAD_TIME">
- <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
- <rs:data>
<z:row business_unit_id="3838" geo="AT" sku="A0814818" dw_maint_flag="False" stock_status_id="0" lead_time="30" est_qty="0" leadtime_lock="False" update_dts="2013-06-12T02:08:30.367" update_uid="DEACTIVATE_SKU_PROCESS" leadtime_dts="2010-05-22T02:21:21.707" leadtime_uid="Lead_Time_Rules" />
<z:row business_unit_id="202" geo="GB" sku="A0814819" dw_maint_flag="False" stock_status_id="0" lead_time="30" est_qty="0" leadtime_lock="False" update_dts="2013-06-12T02:08:30.367" update_uid="DEACTIVATE_SKU_PROCESS" leadtime_dts="2010-05-22T02:21:21.707" leadtime_uid="Lead_Time_Rules" />
<z:row business_unit_id="2828" geo="BE" sku="A0814820" dw_maint_flag="False" stock_status_id="0" lead_time="30" est_qty="0" leadtime_lock="False" update_dts="2013-06-12T02:08:30.367" update_uid="DEACTIVATE_SKU_PROCESS" leadtime_dts="2010-05-22T02:21:21.707" leadtime_uid="Lead_Time_Rules" />
</rs:data>
</xml>
</RECORDSET>
</WORK_UNIT>
- <WORK_UNIT GROUP="LEAD_TIME" ACTION="ADD" AFFECTED="LEAD_TIME">
- <RECORDSET TABLE_NAME="LEAD_TIME">
- <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
- <rs:data>
<z:row business_unit_id="202" geo="GB" sku="A0814821" dw_maint_flag="False" stock_status_id="0" lead_time="30" est_qty="0" leadtime_lock="False" update_dts="2013-06-12T02:08:30.367" update_uid="DEACTIVATE_SKU_PROCESS" leadtime_dts="2010-05-22T02:21:21.707" leadtime_uid="Lead_Time_Rules" />
<z:row business_unit_id="2828" geo="BE" sku="A0814822" dw_maint_flag="False" stock_status_id="0" lead_time="30" est_qty="0" leadtime_lock="False" update_dts="2013-06-12T02:08:30.367" update_uid="DEACTIVATE_SKU_PROCESS" leadtime_dts="2010-05-22T02:21:21.707" leadtime_uid="Lead_Time_Rules" />
</rs:data>
</xml>
</RECORDSET>
</WORK_UNIT>
- <WORK_UNIT GROUP="LEAD_TIME" ACTION="DELETE" AFFECTED="LEAD_TIME">
- <RECORDSET TABLE_NAME="LEAD_TIME">
- <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
- <rs:data>
<z:row business_unit_id="202" geo="GB" sku="A0814817" dw_maint_flag="False" stock_status_id="0" lead_time="30" est_qty="0" leadtime_lock="False" update_dts="2013-06-12T02:08:30.367" update_uid="DEACTIVATE_SKU_PROCESS" leadtime_dts="2010-05-22T02:21:21.707" leadtime_uid="Lead_Time_Rules" />
<z:row business_unit_id="2828" geo="BE" sku="A0814816" dw_maint_flag="False" stock_status_id="0" lead_time="30" est_qty="0" leadtime_lock="False" update_dts="2013-06-12T02:08:30.367" update_uid="DEACTIVATE_SKU_PROCESS" leadtime_dts="2010-05-22T02:21:21.707" leadtime_uid="Lead_Time_Rules" />
</rs:data>
</xml>
</RECORDSET>
</WORK_UNIT>
</WORK_SET>
</MSG>
</MESSAGE>
</MESSAGES>[/code]
The above XML message is receieved by our oracle queue.Once the message is receieved to our queue.
We have to process the message according to the action(UPDATE ADD DELETE).
From this message we have to process only 3 fields (geo sku lead_time).
These three feilds data should be processed into the SKU_LEAD_TIME table based on the action.
Req1:
IF the action is update then the records should be updated in the "LEAD_TIME_TABLE" table
IF the action is update then the records should be updated in the "LEAD_TIME_TABLE" table
based on the below condition.
[code]UPDATE LEAD_TIME_TABLE SET lead_time= lead time from xml message
WHERE LEAD_TIME_TABLE.SKU=sku from xml message AND LEAD_TIME_TABLE.GEO=geo from xml message;[/code]
Req2:
IF the action is delete then the records should be deleted from the "LEAD_TIME_TABLE" table.
based on the below condition.
[code]DELETE FROM LEAD_TIME_TABLE
WHERE LEAD_TIME_TABLE.SKU=sku from xml message AND LEAD_TIME_TABLE.GEO=geo from xml message;[/code]
Req3:
IF the action is add then the records should be inserted in the "LEAD_TIME_TABLE" and "LEAD_TIME_TABLE_STAGING" table
based on the below conditions.
Req3.1:
If SKU from XML message is available in "SKU_TABLE" table
then the three parameter(GEO SKU LEAD_TIME) values from XML message should be inserted into "LEAD_TIME_TABLE" table.
Req3.2:
If SKU from XML message is not available in "SKU_TABLE" table
then the three parameter(GEO SKU LEAD_TIME) values from XML message should be inserted into "LEAD_TIME_TABLE_STAGING" table.
Req3.3:
Once the new SKU is avilable in "SKU_TABLE" table then the corresponding SKU record should be
inserted into "LEAD_TIME_TABLE" table and that record should be deleted from "LEAD_TIME_TABLE_STAGING" table.
I am posting required scripts and test cases.
[code]CREATE TABLE LEAD_TIME_TABLE(sku VARCHAR2(20),model VARCHAR2(20),class CHAR(1),geo VARCHAR2(6),lead_time NUMBER,created DATE);
CREATE TABLE LEAD_TIME_TABLE_STAGING(sku VARCHAR2(20),geo VARCHAR2(6),lead_time NUMBER);
CREATE TABLE SKU_TABLE(sku VARCHAR2(20),geo VARCHAR2(6),lead_time NUMBER);
INSERT INTO SKU_TABLE VALUES('A0814817','GB',30);
INSERT INTO SKU_TABLE VALUES('A0814818','AT',30);
INSERT INTO SKU_TABLE VALUES('A0814819','GB',30);
INSERT INTO SKU_TABLE VALUES('A0814820','BE',30);
INSERT INTO SKU_TABLE VALUES('A0814821','GB',30);
INSERT INTO LEAD_TIME_TABLE(SKU,GEO,LEAD_TIME) VALUES('A0814817','GB',30);
INSERT INTO LEAD_TIME_TABLE(SKU,GEO,LEAD_TIME) VALUES('A0814818','AT',20);
INSERT INTO LEAD_TIME_TABLE(SKU,GEO,LEAD_TIME) VALUES('A0814819','GB',20);
INSERT INTO LEAD_TIME_TABLE(SKU,GEO,LEAD_TIME) VALUES('A0814820','BE',20);
INSERT INTO LEAD_TIME_TABLE_STAGING VALUES('A0814822','BE',30);[/code]
From the above message.
Test case for req3.1:
The action for SKU numbers "A0814821" "A0814822" are insert.
The SKU number "A0814821" is available in SKU_TABLE table.
so the record should be inserted in the LEAD_TIME_TABLE.
[code]SELECT * FROM LEAD_TIME_TABLE;
SKU GEO LEAD_TIME
A0814817 GB 30
A0814818 AT 20
A0814819 GB 20
A0814820 BE 20
A0814821 GB 30[/code]
Test case for req3.2:
The action for SKU numbers "A0814821" "A0814822" are insert.
The SKU number "A0814822" is not available in SKU_TABLE table.
so the record should be inserted in the LEAD_TIME_TABLE_STAGING.
[code]SELECT * FROM LEAD_TIME_TABLE_STAGING;
SKU GEO LEAD_TIME
A0814822 BE 30[/code]
Test case for req3.3:
The action for SKU numbers "A0814821" "A0814822" are insert.
The SKU number "A0814822" is not available in SKU_TABLE table.
Once I insert SKU number "A0814822" in SKU_TABLE table.
The corresponding records automatically should be inserted in the LEAD_TIME_TABLE
and should be deleted from LEAD_TIME_TABLE_STAGING.
[code]SELECT * FROM LEAD_TIME_TABLE_STAGING; --- should return NULL.
SELECT * FROM LEAD_TIME_TABLE;
SKU GEO LEAD_TIME
A0814817 GB 30
A0814818 AT 20
A0814819 GB 20
A0814820 BE 20
A0814821 GB 30
A0814822 BE 30[/code]
Please help me.
Thanks in advance.Hi,
I have resolved this issue.
But I have stuck up in implementing some of the scenarios.
Req1:
IF the action is update then the records should be updated in the "LEAD_TIME_TABLE" table
IF the action is update then the records should be updated in the "LEAD_TIME_TABLE" table
based on the below condition.
UPDATE LEAD_TIME_TABLE SET lead_time= lead time from xml message
WHERE LEAD_TIME_TABLE.SKU=sku from xml message AND LEAD_TIME_TABLE.GEO=geo from xml message;
Req3:
IF the action is add then the records should be inserted in the "LEAD_TIME_TABLE" and "LEAD_TIME_TABLE_STAGING" table
based on the below conditions.
Req3.1:
If SKU from XML message is available in "schema_name.SKU_TABLE" table.
The schema_name.SKU_TABLE table should be selected based on "business_unit_id" of XML message and "sid" of MAPPING table WHERE business_unit_id=sid.
then the three parameter(GEO SKU LEAD_TIME) values from XML message and two fields MODEL,CLASS from SKU_TABLE
should be inserted into "LEAD_TIME_TABLE" table.
Req3.2:
If SKU from XML message is not available in "schema_name.SKU_TABLE" table
The schema_name.SKU_TABLE table should be selected based on "business_unit_id" of XML message and "sid" of MAPPING table WHERE business_unit_id=sid.
then the four parameter(BUSINESS_UNIT_ID GEO SKU LEAD_TIME) values from XML message
should be inserted into "LEAD_TIME_TABLE_STAGING" table.
Req3.3:
Once the new SKU is avilable in "schema_name.SKU_TABLE" table then the corresponding SKU record should be
inserted into "LEAD_TIME_TABLE" table and that record should be deleted from "LEAD_TIME_TABLE_STAGING" table.
The schema_name.SKU_TABLE table should be selected based on "business_unit_id" of LEAD_TIME_TABLE_STAGING and "sid" of MAPPING table WHERE business_unit_id=sid.
I am posting required scripts and test cases.
[code]CREATE TABLE LEAD_TIME_TABLE(sku VARCHAR2(20),model VARCHAR2(20),class CHAR(1),geo VARCHAR2(6),lead_time NUMBER,created DATE);
CREATE TABLE LEAD_TIME_TABLE_STAGING(business_unit_id NUMBER,sku VARCHAR2(20),geo VARCHAR2(6),lead_time NUMBER);
CREATE TABLE SKU_TABLE(sku VARCHAR2(20),model VARCHAR2(20),class VARCHAR2(10));
CREATE TABLE mapping(sid NUMBER,schema_name VARCHAR2(20));
INSERT INTO LEAD_TIME_TABLE(SKU,GEO,LEAD_TIME) VALUES('A0814817','GB',30);
INSERT INTO LEAD_TIME_TABLE(SKU,GEO,LEAD_TIME) VALUES('A0814818','AT',20);
INSERT INTO LEAD_TIME_TABLE(SKU,GEO,LEAD_TIME) VALUES('A0814819','GB',20);
INSERT INTO LEAD_TIME_TABLE(SKU,GEO,LEAD_TIME) VALUES('A0814820','BE',20);
INSERT INTO SKU_TABLE VALUES('A0814817','M125','C111');
INSERT INTO SKU_TABLE VALUES('A0814818','M127','A111');
INSERT INTO SKU_TABLE VALUES('A0814819','M126','A111');
INSERT INTO SKU_TABLE VALUES('A0814820','N100','B111');
INSERT INTO SKU_TABLE VALUES('A0814821','P123','B111');
INSERT INTO mapping VALUES(202,'WEDB');
INSERT INTO mapping VALUES(2828,'HR');
INSERT INTO mapping VALUES(3838,'BB');
[/code]
Test case for req3.1:
The action for SKU numbers "A0814821" "A0814822" are insert.
The SKU number "A0814821" is available in schema_name.SKU_TABLE table.
so the record should be inserted in the LEAD_TIME_TABLE.
[code]SELECT * FROM LEAD_TIME_TABLE;
SKU MODEL CLASS GEO LEAD_TIME
A0814817 M125 C111 GB 30
A0814818 M127 A111 AT 20
A0814819 M126 A111 GB 20
A0814820 N100 B111 BE 20
A0814821 P123 B111 GB 30
[/code]
Test case for req3.2:
The action for SKU numbers "A0814821" "A0814822" are insert.
The SKU number "A0814822" is not available in SKU_TABLE table.
so the record should be inserted in the LEAD_TIME_TABLE_STAGING.
[code]SELECT * FROM LEAD_TIME_TABLE_STAGING;
BUSINESS_UNIT_ID SKU GEO LEAD_TIME
2828 A0814822 BE 30[/code]
Test case3.3.3:
The action for SKU numbers "A0814821" "A0814822" are insert.
The SKU number "A0814822" is not available in SKU_TABLE table.
Once I insert SKU number "A0814822" in SKU_TABLE table.
The corresponding records automatically should be inserted in the LEAD_TIME_TABLE
and should be deleted from LEAD_TIME_TABLE_STAGING.
[code]INSERT INTO SKU_TABLE VALUES('A0814822','P123','B111');
SELECT * FROM LEAD_TIME_TABLE_STAGING; --- should return NULL.
SELECT * FROM LEAD_TIME_TABLE;
SKU MODEL CLASS GEO LEAD_TIME
A0814817 M125 C111 GB 30
A0814818 M127 A111 AT 20
A0814819 M126 A111 GB 20
A0814820 N100 B111 BE 20
A0814821 P123 B111 GB 30
A0814822 P123 B111 GB 30[/code]
I am able to implement Req1 and Req3.1 for action UPDATE and INSERT in single merge statement.
However my code is not taking care of all my requirements.
Please find my below code.
[code] CREATE OR REPLACE PACKAGE BODY messg_values_process
AS
procedure ProcessInboundLtimeMessage(p_xml_message XmlType)
is
begin
for work_unit in (
select message.MESSAGE_ID
, work_unit.ACTION
, work_unit.LEADTIME_NODES
from XmlTable(
'/MESSAGES/MESSAGE'
passing p_xml_message
columns
MESSAGE_NO for ordinality
, MESSAGE_ID number path '@ID'
, WORK_UNIT_NODES XmlType path 'MSG/WORK_SET/WORK_UNIT'
) message
, XmlTable(
XmlNamespaces(
'urn:schemas-microsoft-com:rowset' as "rs"
, '#RowsetSchema' as "z"
'/WORK_UNIT'
passing message.WORK_UNIT_NODES
columns
WORK_UNIT_NO for ordinality
, ACTION varchar2(10 char) path '@ACTION'
, LEADTIME_NODES XmlType path 'RECORDSET[@TABLE_NAME="LEAD_TIME"]/xml/rs:data/z:row'
) work_unit
LOOP
CASE work_unit.ACTION
WHEN 'ADD' THEN MergeData(work_unit.LEADTIME_NODES);
WHEN 'UPDATE' THEN MergeData(work_unit.LEADTIME_NODES);
WHEN 'DELETE' THEN RemoveData(work_unit.LEADTIME_NODES);
ELSE null;
END CASE;
END LOOP;
END ProcessInboundLtimeMessage;
procedure MergeData(p_leadtime_nodes XmlType)
is
begin
if (p_leadtime_nodes is not null) then
merge into LEAD_TIME_TABLE old
using(
select *
from XmlTable(
XmlNamespaces(
'urn:schemas-microsoft-com:rowset' as "rs"
, '#RowsetSchema' as "z"
'/z:row[not(@business_unit_id=following-sibling::z:row/@business_unit_id)]'
passing p_leadtime_nodes
columns
ITEM_NO for ordinality
, BUSINESS_UNIT_ID number path '@business_unit_id'
, GEO varchar2(20 char) path '@geo'
, SKU varchar2(20 char) path '@sku'
, LEAD_TIME number path '@lead_time'
) NEW
ON (old.VK_UNIT = new.SKU
AND old.GEO=new.GEO)
when matched then update
set old.LEAD_TIME = new.LEAD_TIME
when not matched then INSERT
( old.VK_UNIT
, old.MODEL
, old.CLASS
, old.GEO
, old.LEAD_TIME
, old.COUNTDOWN
, old.LAST_UPDATED_DATE
values
( new.SKU
,'A123'
,'A1234'
, new.GEO
, new.LEAD_TIME
, 'N'
, sysdate
end if;
exception
when others then
LogDataError(
'MergeData Procedure Failed #: '||chr(10)||sqlerrm
, null
, null
END MergeData;
END messg_values_process;
/[/code]
Please help me.
Thanks. -
Can I create an XSD from XML data in a CLOB?
Environment:
Oracle 11.2.0.3 EE on Solaris.
Very much an XML newbie so please be kind!
I have spent the past few days pouring through the documentation and various blogs, especially this one, but ... I need some help.
I am trying to extract XML data stored in a CLOB and produce a flat file for the user's consumption.
They have sent me what they think is the XSD for the XML data but when I look at the data in the CLOB I don't see the tags documented in the XSD.
I'd like to produce an XSD based on the actual data to compare with what they've sent.
Is this possible?
I am able to query the XML data using the tags I see in the data using XMLTable and it's working fine.
Any help is greatly appreciated.
-garyWelcome to the XML side of the world, where you will love it and curse it, just like any other piece of technology.
So as I understand it, the scope of your operation is to extract information from an XML file and then write that information to disk, correct?
Some questions
- Why is the XML stored in a CLOB instead of an XMLType column? Without knowing the system history, it is a valid question.
- How big are the XML? The reason I ask this is because when the XML is stored in XMLType columns (of Object Relational structure or SECUREFILE BINARY XML format), then Oracle can parse the XML substantially easier than when it is stored as a CLOB. If the XML is fairly small, you may see no performance difference between the two.
The Oracle DB itself has no built in ability to generate a schema from an XML file. In order to do that, you would need to use some third party tool that has that functionality built in. For example, XML Spy can do this. Other tools can as well, but that is what came to mind first as it is what I use. The one thing to remember is that the schema it builds represents that one instance of XML. Other instances of XML may be different and not validate against the schema you generated, but still have been valid against the unknown original schema.
You can register the schema in the database and then use the XML to create an XMLType instance associated to the schema and then validate the XML that way. One example can be found at XML DB FAQ and here is another example Re: XML Schema validation
Hope that helps you continue on. -
HELP ME! Creating a table from a data file
Hi
I'm writing an application for data visualization. The user can press the "open file" button and a FileChooser window will come up where the user can select any data file. I would like to take that data file and display it as a table with rows and columns. The user needs to be able to select the coliumns to create a graph. I have tried many ways to create a table, but nothing seems to work! Can anyone help me?! I just want to read from the data file and create a spreadsheet type table... I won't know how many rows and columns I'll need in advance, so the table needs to be dynamic!
If you have ANY tips, I'd REALLY appreciated.....I won't know how many rows and columns I'll need in advance, so the table needs to be dynamic!You may use a List (ArrayList, LinkedList or Vector) for that.
Lists allow you (dynamically) add elements. -
Automatically creating non-interactive PDF forms from XML data
Hi All,
I am a newbie to the whole Adobe LifeCycle Designer product and have been trying to find a definitive technical article on a way to automatically create pdf documents from template forms using XML data. I can create the XML, I can create the form based on the XML schema but I can't seem to find anything which explains how to automatically associate the form with the each xml file that I create and produce a pdf document based on the xml data.
The project I am working involves creating marketing brochures, driven from our enterprise databases, to be sent to a printer. No user interaction is required, and I estimate that we'll need to create around 500-1000 pdf's per day.
To me this seems like it should be quite a simple task but I can't find anything which gives me a starting point.
Any help would be greatly appreciated.
Regards
Nick SmithHi Nick,
Just curious if you figured out how to generate a PDF out of a template? I've a similar requirement where I transform XML schemas into templates, convert the template into a PDF document, and at run time bind the PDF with the form data.
To sort of answer your question of how to bind an XML instance file to a form, if that form is an XML-FORM, then all you'd need to do is open that document as a PDF document using the PDFFactory, and invoke the importFormData() method on it, passing the XML instance as the input stream.
The harder part though is getting the PDF out of the template in the first place, without using any adobe user interface period.
Karthick
Maybe you are looking for
-
Setting a New Default "Output To" Template in the Render Que Does Not Work
I'm trying to change the default "Output To" template in the Render Que to not show the timecode for a PSD file, but when I change the default template by clicking on "Custom" from the dropdown menu and using the checkbox to set a preset as the defau
-
Can the NEC P221 monitor with DVI-D and VGA 15-pin D-sub be connected up directly to the Mac Pro? I just want to be certain that I am not compromising either machine's potential trying to connect via adapters etc. Mac Pro (Early 2009) Graphics and di
-
Error during Goods Receipt for Production Order
Hi All, When using MIGO to post Goods Receipt for a Production Order, I got a customize message saying that the posting is only available between 2010.08.25 to 2010.08.27. I have checked in Business Add-in using SE19 but there are no implementation
-
After I updated to iOS 7.1 I can't download any apps
I have an iPhone 4 and I am not able to download any apps at all. The loading circle will spin for a minute and then nothing appears on my phone. Does anyone know why??
-
"unable to find certificate" in Sun One Web Server 6.1
I have created a CA and a self-signed cert with the certutil command as described at this URL: http://www.mozilla.org/projects/security/pki/nss/tools/certutil.html I can use certutil to verify that the cert shows up with the nickname I gave it, and t