Query to read XML from CLOB table column
Hi
I want an SQL to get the following information extract from a CLOB table column.
MasterReport/sg:RptDef/sg:RptCell@RealDesc MasterReport/sg:RptDef/sg:RptCell@RealNum
credits 100
debits 100
Sample XML data from table column is:
<?xml version="1.0" encoding="UTF-8" ?>
<MasterReport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sg="http://www.oracle.com/fsg/2002-03-20/" xsi:schemaLocation="http://www.oracle.com/2002-03-20/fsg.xsd">
<sg:LDGName>Vision Portugal</sg:LDGName>
<sg:SOBName>Vision Portugal</sg:SOBName>
<sg:DataAccessSetName>Vision Portugal</sg:DataAccessSetName>
<sg:InternalReportName>Model 30 Report</sg:InternalReportName>
<sg:CustomParam10 />
<sg:RowContext RowId="r100001">
<sg:RowName />
<sg:RowLineItem>Litigation Credits- Total amount from previous period</sg:RowLineItem>
<sg:RowDispUnit>1</sg:RowDispUnit>
<sg:RowDispFormat />
<sg:RowUnitOfMeasure>EUR</sg:RowUnitOfMeasure>
<sg:RowLedgerCurrency>ANY</sg:RowLedgerCurrency>
<sg:RowCurrencyType>T</sg:RowCurrencyType>
<sg:RowChangeSign>0</sg:RowChangeSign>
<sg:RowSeq>1.0000000000000</sg:RowSeq>
</sg:RowContext>
<sg:RowContext RowId="r100002">
<sg:RowName />
<sg:RowLineItem>Litigation credits- Taxed amounts from column2 for Previous period</sg:RowLineItem>
<sg:RowDispUnit>1</sg:RowDispUnit>
<sg:RowDispFormat />
<sg:RowUnitOfMeasure>EUR</sg:RowUnitOfMeasure>
<sg:RowLedgerCurrency>ANY</sg:RowLedgerCurrency>
<sg:RowCurrencyType>T</sg:RowCurrencyType>
<sg:RowChangeSign>0</sg:RowChangeSign>
<sg:RowSeq>2.0000000000000</sg:RowSeq>
</sg:RowContext>
<sg:ColContext ColId="c1000">
<sg:ColAmountType />
<sg:ColPeriod />
<sg:ColPerOffset />
<sg:ColChangeSign />
<sg:ColPosition />
<sg:ColSeq />
<sg:ColWidth>100</sg:ColWidth>
</sg:ColContext>
<sg:ColContext ColId="c1001">
<sg:ColName>Total</sg:ColName>
<sg:ColDescr />
<sg:ColDispUnit>1</sg:ColDispUnit>
<sg:ColUnitOfMeasure>EUR</sg:ColUnitOfMeasure>
<sg:ColLedgerCurrency>ANY</sg:ColLedgerCurrency>
<sg:ColCurrencyType>T</sg:ColCurrencyType>
<sg:ColDispFormat>999999999.99</sg:ColDispFormat>
<sg:ColAmountType>YTD-Actual</sg:ColAmountType>
<sg:ColPerOffset>0</sg:ColPerOffset>
<sg:ColAmntId>14</sg:ColAmntId>
<sg:ColParamId>-1</sg:ColParamId>
<sg:ColType>A</sg:ColType>
<sg:ColStyle>B</sg:ColStyle>
<sg:ColPeriod>10-08</sg:ColPeriod>
<sg:ColPeriodYear>2008</sg:ColPeriodYear>
<sg:ColPeriodNum>11</sg:ColPeriodNum>
<sg:ColPeriodStart>2008-10-01T00:00:00</sg:ColPeriodStart>
<sg:ColPeriodEnd>2008-10-31T00:00:00</sg:ColPeriodEnd>
<sg:ColChangeSign>0</sg:ColChangeSign>
<sg:ColHeadLine1>Totals</sg:ColHeadLine1>
<sg:ColHeadLine2 />
<sg:ColHeadLine3 />
<sg:ColHeadLine4 />
<sg:ColHeadLine5 />
<sg:ColHeadLine6 />
<sg:ColHeadLine7 />
<sg:ColHeadLine8 />
<sg:ColHeadLine9 />
<sg:ColPosition>99</sg:ColPosition>
<sg:ColSeq>1.0000000000000</sg:ColSeq>
<sg:ColWidth>14</sg:ColWidth>
</sg:ColContext>
<sg:RptDef RptId="p1001" RptDetName="Ledger=Vision PT (Vision Portugal)" RptPESegm="" RptPEVal="" RptTabLabel="Output 1 (Vision PT)">
<sg:RptLine RptCnt="p1001" RowCnt="r100001" LineRowSeq="1.0000000000000" LinCnt="l100001">
<sg:RptCell ColCnt="c1000" RealDesc="debits">debits</sg:RptCell>
<sg:RptCell ColCnt="c1001" RealNum="100.000000">100.00</sg:RptCell>
</sg:RptLine>
<sg:RptLine RptCnt="p1001" RowCnt="r100002" LineRowSeq="2.0000000000000" LinCnt="l100002">
<sg:RptCell ColCnt="c1000" RealDesc="creditsd">credits</sg:RptCell>
<sg:RptCell ColCnt="c1001" RealNum="100.000000">100.00</sg:RptCell>
</sg:RptLine>
</sg:RptDef>
<sg:TabCount>1</sg:TabCount>
</MasterReport>
Please help me.
Regards
Giri
Edited by: user576087 on Mar 18, 2012 11:54 PM
I'm not sure if you want the values from the attribute or the element, but this should give you a good start :
SQL> alter session set nls_numeric_characters = ".,";
Session altered
SQL>
SQL> select x.*
2 from my_table t
3 , xmltable(
4 xmlnamespaces('http://www.oracle.com/fsg/2002-03-20/' as "sg")
5 , '/MasterReport/sg:RptDef/sg:RptLine'
6 passing xmltype(t.xmldoc)
7 columns type varchar2(30) path 'sg:RptCell[1]'
8 , amount number path 'sg:RptCell[2]'
9 ) x
10 ;
TYPE AMOUNT
debits 100
credits 100
Similar Messages
-
Displaying data from multiple table/column
hello ..
anybody can help me how to diplaying data from multiple table/ column in PHP. TQFollow the "How do I SELECT, INSERT, UPDATE and DELETE data from PHP?" example from http://wiki.oracle.com/page/PHP+Oracle+FAQ and change the "select ..." query to your favourite join, e.g.
select country_name, region_name from countries, regions where countries.region_id = regions.region_id; -
How to parse/extract XML from clob field using ODI
Hi,
I am very new to ODI. I have an oracle table which has clob field. This clob field contains xml. I would like to parse this xml and convert it to oracle table. Means I would like to make all the tags of xml as oracle table columns.
I have created a PL/SQL procedure and used XMLTABLE function and I have achieved my goal. The same this I am trying to do with ODI. Since I am new to ODI so any help is appreciated.
ThanksIn 9.2, you are limited into your options. Have a look into, among others, updateXML. Updating tp 10gR2 will give you more options to succeed.
-
Select query to read data from a view
Hi friends,
We have been using a query to read data from a custom view which used to work perfectly. Now the program sits at that select query forever. We are able to extract same data from se16. Not sure what could be the problem.
Thanks in advance.Dev
Have a look at the Table Index for the tables involved in the View... I think there is some change in the Indexes.. (Add / Remove / Change)
Thanks
Amol Lohade -
Read data from 2 tables.
Hello everyone,
I created a SQL database in phpMyAdmin. It contains 2 tables.
'Woninginformatie' and 'Makelaars'.
I use the next SQL query in my PHP file to read from the
database:
SELECT DISTINCT * FROM Woninginformatie
INNER JOIN Makelaars ON Woninginformatie.ID_mk =
Makelaars.ID_mk
WHERE Huiscode = $huiscode"
The query works correct and I get all the fields from both
tables. Anyway, in Flash I can only read out the information in the
table 'Woninginformatie'.
I use these kind of codes to read from the database:
eigendomssituatie =
gegevens.childNodes[0].childNodes[24].firstChild.nodeValue;
How can I also read data from the second table?you can't read data from the 2nd table because because you
have a table issue, php issue or you can read data from the table
but are having trouble getting those data into flash? are you using
echo to return data to flash? -
Generating xml from diff tables in a db
hi,
i need to write a oracle procedure, which when called generates xml doc (building xml from different tables in database.). i got the DTDs . but i still dont understand how can the data be pulled from diff tables and put in the one xml? can anyone give me rough idea.. i know that i have to use xmlquery and xml_save packages... but still not much clear..
i m working on oracle 8i database. any help is appreciated.. thanks.Any feedback to the above questions would be greatly appreciated!
-
How can I parse XML from CLOB field? I need to replace or delete the node from XML document and update the database with new XML. I am using Oracle 9i release 2.
Here is the XML. In this XML if section1 and section2 exists then I need to delete the section1 node. If section2 doesn't exist, replace section1 with section2 node.
<Document ID='2' TypeID='2'>
<Body>
<Page Name='Page1'>
<Sec ID='section1' Title='Section 1' GroupID='' />
<Sec ID='section2' Title='Section 2' GroupID='' />
</Page>
</Body>
</Document>
Please help.. Thank you..In 9.2, you are limited into your options. Have a look into, among others, updateXML. Updating tp 10gR2 will give you more options to succeed.
-
Reading Data from a Table With an Expert
Hi all - I'm trying to write an Expert in OWB that would read data from a table and create a new table based on that information. I have the table creation part down, but how can I read data from a table with an Expert? From what I've read, Experts only deal with metadata, and there is no mechanism in Experts to actually read data in the tables. Does OraTcl work in Experts? Has anyone ever came across this problem, and if so, how did you solve it? Thanks in advance for your time! - Don
Hi Don
Can also use Java and JDBC from within Tcl, see the routines in this file below, take modify or whatever;
http://blogs.oracle.com/warehousebuilder/ombora.tcl
source <dir>\ombora.tcl
set g_user scott
set g_upwd zzzzzz
set g_hostname localhost
set g_port 1521
set g_srvname ora111
oraconnect $g_user $g_upwd $g_hostname:$g_port:$g_srvname
oraselect "select * from emp" ""
As well as dumping the results to stdout (you probably want to comment that part out and change any other part you don't like), g_res is a ResultSet object you can use to do whatever.
Cheers
David -
Reading Data from Internal Table
Hi,
Can anyone please tell me how to read data from Internal Tables in the Event Handler without using the Select statement OnInitialization?
Thanks,
GauravHi Siddhartha,
Can you tell me the problem in my code. I tried to work on the way you suggested. Though I have not finished with the coding, I just wanted to know whether I am going in the direction or not.
I have declared the the structure in Type Defination as
TYPES: BEGIN OF TEST_STRUC,
BEGDA TYPE BEGDA,
ENDDA TYPE ENDDA,
END OF TEST_STRUC.
TYPES: TEST_TAB_TYPE TYPE TABLE OF TEST_STRUC.
In the Event Handler, I have added the following code on OnInputProcessing:
event handler for checking and processing user input and
for defining navigation
DATA TEST_INFO LIKE LINE OF TEST_TAB.
DATA: MYTAB6 TYPE TABLE OF PA0006,
MYTAB6_WA LIKE LINE OF MYTAB6.
REFRESH TEST_TAB.
CLEAR TEST_INFO.
MYTAB6_WA-BEGDA = REQUEST->GET_FORM_FIELD( STARTDATE ).
MYTAB6_WA-ENDDA = REQUEST->GET_FORM_FIELD( ENDDATE ).
IF EVENT->NAME EQ 'button'
AND EVENT->SERVER_EVENT EQ 'click'.
LOOP AT MYTAB6 INTO MYTAB6_WA.
TEST_INFO-BEGDA = MYTAB6_WA-BEGDA.
TEST_INFO-ENDDA = MYTAB6_WA-ENDDA.
ENDLOOP.
APPEND TEST_INFO TO TEST_TAB.
CLEAR TEST_INFO.
NAVIGATION->SET_PARAMETER( NAME = 'test_tab'
VALUE = 'begda' ).
NAVIGATION->SET_PARAMETER( NAME = 'test_tab'
VALUE = 'endda' ).
NAVIGATION->GOTO_PAGE( 'MyBSP2.htm').
ENDIF.
P.S. MyBSP2.htm is my next page.
Thanks,
Gaurav -
Do I have to use lock when I am reading data from a table
Hi,
When i am reading data from a table , do I have to set a lock on that table .
Is it necessary for us to set the lock on a table when I am reading data from the table.
When I am updating the table , do I have to set a lock on the table ?
If yes, then what sort of lock-read lock,write lock or shared lock?
Regards,
Sushanth H.S.check it out,
Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.
SAP Provide three type of Lock objects.
- Read Lock(Shared Locked)
protects read access to an object. The read lock allows other transactions read access but not write access to
the locked area of the table
- Write Lock(exclusive lock)
protects write access to an object. The write lock allows other transactions neither read nor write access to
the locked area of the table.
- Enhanced write lock (exclusive lock without cumulating)
works like a write lock except that the enhanced write lock also protects from further accesses from the
same transaction.
You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
Technicaly:
When you create a lock object System automatically creat two function module.
1. ENQUEUE_<Lockobject name>. to insert the object in a queue.
2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.
You have to use these function module in your program.
check this link for example.
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
tables:vbak.
call function 'ENQUEUE_EZLOCK3'
exporting
mode_vbak = 'E'
mandt = sy-mandt
vbeln = vbak-vbeln
X_VBELN = ' '
_SCOPE = '2'
_WAIT = ' '
_COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
if sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Normally ABAPers will create the Lock objects, because we know when to lock and how to lock and where to lock the Object then after completing our updations we unlock the Objects in the Tables
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
purpose: If multiple user try to access a database object, inconsistency may occer. To avoid that inconsistency and to let multiple user give the accessibility of the database objects the locking mechanism is used.
Steps: first we create a loc object in se11 . Suppose for a table mara. It will create two functional module.:
1. enque_lockobject
1. deque_lockobject
before updating any table first we lock the table by calling enque_lockobject fm and then after updating we release the lock by deque_lockobject.
Select the radio button "Lock object"..
Give the name starts with EZ or EY..
Example: EYTEST
Press Create button..
Give the short description..
Example: Lock object for table ZTABLE..
In the tables tab..Give the table name..
Example: ZTABLE
Save and generate..
Your lock object is now created..You can see the LOCK MODULES..
In the menu ..GOTO -> LOCK MODULES..There you can see the ENQUEUE and DEQUEUE function
Reward if helpful -
How to read Data from ZL table
Can someone give me function module or sample code to read data from ZL table in B2 cluster
Edited by: Saurabh Desai on Jan 13, 2010 9:13 PMYou wanted to extract data, ZL table to precise, from B2 cluster, is that right?
For this the snipped I gave you can be used.
First you need an inlcude with appropriate declarations
INCLUDE rpc2b201. "-> here b2 structure, ZL table are declared
Now you provide key for the cluster which is what below does
b2-key-pernr = "ee number
b2-key-pabrj = "year to extract data for
b2-key-pabrp = "month to extract data for
b2-key-cltyp = 1.
Now all you need is to extract ZL table form B2 cluster
IMPORT zl "get ZL table
FROM DATABASE pcl2(b2) "from cluster B2
ID b2-key. "for this key
That's it. Now you have correct data in ZL table which you can process further.
Hope now it is clear.
Regards
Marcin -
Reading data from BSEG table with Non-key fields in where clause
Hi All,
I have to read data from BSEG table based on WBS element field (PROJK). As I'm not passing key fields to WHERE clause system couldnt run the select statement. Since BSEG is a cluster table I cant even create secondary index on PROJK field.
Could you please tell me, how to improve its performance.
Regards
Jaker.SELECT bukrs
belnr
gjahr
shkzg
dmbtr
hkont
lifnr
matnr
werks
menge
meins
ebeln
FROM bseg
INTO TABLE it_bseg
PACKAGE SIZE 10
FOR ALL ENTRIES IN it_final
WHERE bukrs EQ it_final-bukrs
AND belnr EQ it_final-belnr
AND gjahr EQ it_final-gjahr
AND buzei EQ it_final-buzei
AND hkont EQ it_final-hkont
AND werks IN s_werks.
By using package and fetch from BSEG table. gathering all other information to a final internal table.This will reduce the hit to database.And also try to put that data in hashed internal table which is it_bseg....then definetly improve the performance.
<REMOVED BY MODERATOR>
Dara.
Edited by: Alvaro Tejada Galindo on Apr 21, 2008 12:47 PM -
Read XML from a hardware sensor file into ODI
Read XML from a hardware sensor file into ODI
Hi,
I am trying to extract xml data from a flowmeter that generates XML data.
The xml file is found in http://ip_address/history.xml
I’ve defined my Topology as such
JDBC Driver: com.sunopsis.jdbc.driver.xml.SnpsXmlDriver
JDBC URL: jdbc:snps:xml?f=http://192.168.0.202/history.xml&ro=true
Please note to access the file I have to supply a username and password so I did in the definition But when testing my setup I get an error:
ava.sql.SQLException: The DTD file "http://192.168.0.202/history.dtd" doesn't exist: Server redirected too many times (20)
Please note I cannot write dtd to the device as it is a read only device.
Has anyone came across such an issue, how can I achieve this.
Thanks
HichamHi David,
Thanks for your reply.
I've tried this jdbc url
jdbc:snps:xml?f=http://192.168.0.202/history.xml&d=c:\temp\history.dtd
but when I test the connection i get the following error
java.sql.SQLException: While generating the DTD from the XML file, a java.io.IOException exception occurred saying: Server returned HTTP response code: 401 for URL: http://192.168.0.202/history.xml
If I browse http://192.168.0.202/history.xml and i supply the username and password I get an xml page.
I've supplied the username and password in the definition tab of the Data Server windows but still getting the above error.
THanks
Hicham -
Hi,
I met a problem.
How to read data from cluster tables using:
b2-key-pernr = 20.
b2-key-pabrj = 2006.
b2-key-pabrp = 09.
b2-key-cltyp = '1'.
import saldo from database pcl2(b2) id b2-key.
the problem is that the sy-subrc is always 4, could anyone help me?
thank you very much!Hi,
Import and export to database is used in two programs and not in the same program.
<b>ZPROGRAM1.</b>
tables : indx.
Data : SALDO type i,
indxkey LIKE indx-srtfd VALUE 'ZAB1'.
indx-aedat = sy-datum.
indx-usera = sy-uname.
indx-pgmid = sy-repid.
EXPORT SALDO TO DATABASE indx(zc) ID indxkey.
In another program,
<b>ZPROGRAM2.</b>
tables : indx.
Data : SALDO type i,
indxkey LIKE indx-srtfd VALUE 'ZAB1'.
indx-aedat = sy-datum.
indx-usera = sy-uname.
indx-pgmid = sy-repid.
IMPORT SALDO FROM DATABASE indx(zc) ID indxkey.
Best regards,
Prashant -
Failed to read data from Lock tables
Hi,
When i trying to update data using T_CODE j1i8. I am getting message (Failed to read data from Lock tables ) but where as my database tables are not been locked. can anyone plz help me out.
Regards,
AnaveerHi
Probably some other transation is modifying the Database table you are using & it may have locke the table using FOR UPDATE stmt.
Using Deque_all FM module you can remove the locks
Thanks
Sandeep
Reward if helpful
Maybe you are looking for
-
Custom 404-page for a single directory ?
Is it possible to change the 404 error response for a single directory (and ist subdirectories)? Like I can do with a ".htaccess" - file on an apache webserver? I know it's possible to do it global with weblogic.httpd.errorPage.xxx=URL in weblogic.pr
-
Adobe Reader XI hangs Internet Explorer!
We support several clients and as each PC upgrades to Adobe Reader XI it breaks the IE Add-On (view in browser) capability. The pdf starts to download, pops up in the browser, and then in about 5-10 seconds hangs until it times out (45 minutes later)
-
For about 2 weeks thats starts to happening.. I dont know what it is but i want to fix it! had someone the same problem?
-
Ps -ef command shows uidnumber instead of uid
Hi, I configured pam to use Identity Server 6.0 in addition to the unix for login, session and account management. Every thing seems fine, exept one thing. The ps command is not working normally for the process owned by the user stored in the Identit
-
PC Crashed and can't activate reinstalled photoshop
My PC Crashed and a new hard drive was needed. I reinstalled Photoshop Elements 8 on the PC but now I can't activate the product without deactivating the programme on the redundant hard drive. How do I fix this?