Tuning sql by using the xmltable() function.
Hi allWith Oracle 10g 10.2.0.1, Solaris 10
Under query very slow... for 25 k at all just 100 KB xml documents.
SELECT HQ_FLAG ,
REGSTR_FLAG ADDRESS_STAMP ,
BUILDING ,
street_address ,
PO_BOX ,
CITY ,
STATE_REGION ,
POSTAL_CODE ,
country_code ,
a.ORG_ID
FROM common.BID_XML_DATA a,
xmltable( 'for $i in IntegrationBID/Organization
return <Row OrgID="{$i/OrgID}">{ $i/OrgGeneralInformation/Address } </Row>' passing xml_data
columns
hq_flag varchar2(5) path 'Address/@HeadquartersFlag',
regstr_flag varchar2(5) path 'Address/@RegisteredFlag',
address_stamp varchar(10) path 'Address/@LastUpdated',
building varchar(40) path 'Address/Building',
street_address varchar(40) path 'Address/StreetAddress',
po_box varchar(40) path 'Address/POBox',
city varchar(40) path 'Address/City',
state_region character(3) path 'Address/StateOrRegion',
postal_code varchar(10) path 'Address/PostalCode',
country_code character(3) path 'Address/Country/@Code',
Org_ID NUMBER(19) path '@OrgID') b;
SQL> desc common.BID_XML_DATA
Name Null? Type
----------------------------------------------------------------------------------- -------- --------------------------------------------------------
XML_DATA XMLTYPE
BID_INSERT_STAMP DATE
RN NUMBER(5)
ORG_ID NUMBER(19)
--------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 8168 | 749K| 27 (0)| 00:00:01 |
| 1 | MERGE JOIN CARTESIAN | | 8168 | 749K| 27 (0)| 00:00:01 |
| 2 | TABLE ACCESS FULL | BID_XML_DATA | 1 | 92 | 3 (0)| 00:00:01 |
| 3 | BUFFER SORT | | 8168 | 16336 | 24 (0)| 00:00:01 |
| 4 | COLLECTION ITERATOR PICKLER FETCH| XMLSEQUENCEFROMXMLTYPE | | | | |
--------------------------------------------------------------------------------------------------------------
I tried to create indexes on this table... but in vain...SQL> CREATE INDEX common.XML_DATA_IDX ON common.BID_XML_TABLE (xml_data)
2 INDEXTYPE IS XDB.XMLIndex
PARAMETERS ('PATHS (INCLUDE (IntegrationBID/Organization/OrgID
3 4 IntegrationBID/Organization/OfficerInformation/Officer/ID
5 IntegrationBID/Organization/WebLinkInfo
6 IntegrationBID/Organization/FilingSpecificInformation/FilingInformation/CompanyID
IntegrationBID/Organization/FilingSpecificInformation/FilingInformation/ContactInfo
7 8 IntegrationBID/Organization/FilingSpecificInformation/FilingInformation/Advisors/TransferAgent/Name
9 IntegrationBID/Organization/OfficerInformation/Officer/PersonInformation/Name
10 IntegrationBID/Organization/OfficerInformation/Officer/OfficerContacts
11 IntegrationBID/Organization/OfficerInformation/Officer/PersonInformation/EducationHistory/Education
12 IntegrationBID/Organization/OfficerInformation/Officer/PositionInformation/TenureDates
13 IntegrationBID/Organization/OfficerInformation/Officer/PositionInformation/Titles/Designation
14 IntegrationBID/Organization/OfficerInformation/Officer/PositionInformation/CommitteeMemberships/Committee
IntegrationBID/Organization/OfficerInformation/Officer/SalaryInformation/CompensationPeriod
15 16 )
17 NAMESPACE MAPPING
18 (xmlns="http://www.schemas.thomsonreuters.com/IntBID03")
19 )
20 PATH TABLE BID_XML_path_table
21 PATH ID INDEX BID_XML_pathid_ix
22 ORDER KEY INDEX BID_XML_orderkey_ix
23 ASYNC (SYNC ALWAYS) STALE (FALSE)
24 ');
CREATE INDEX common.XML_DATA_IDX ON common.BID_XML_TABLE (xml_data)
*
ERROR at line 1:
ORA-29896: Length of PARAMETER string longer than 1000 characters
SQL> CREATE INDEX common.BID_XML_DATA_IDX ON common.BID_XML_DATA (xml_data)
2 INDEXTYPE IS XDB.XMLIndex
PARAMETERS ('PATHS (INCLUDE (IntegrationBID/Organization/OrgID
3 4 IntegrationBID/Organization/OfficerInformation/Officer/ID
5 IntegrationBID/Organization/WebLinkInfo
6 IntegrationBID/Organization/FilingSpecificInformation/FilingInformation/CompanyID
)
7 8 NAMESPACE MAPPING
9 (xmlns="http://www.schemas.thomsonreuters.com/IntBID03")
)
10 11 PATH TABLE BID_XML_path_table
12 PATH ID INDEX BID_XML_pathid_ix
13 ORDER KEY INDEX BID_XML_orderkey_ix
14 ASYNC (SYNC ALWAYS) STALE (FALSE)
15 ');
CREATE INDEX common.BID_XML_DATA_IDX ON common.BID_XML_DATA (xml_data)
*
ERROR at line 1:
ORA-29958: fatal error occurred in the execution of ODCIINDEXCREATE routine
ORA-30955: internal event to enable value index creation
Could someone help me in creating xmlindex... and also to grant this request.-Yasser
You have 2 options for this make effective and efficient:
1) move to 11gRx and change the XMLTYPE (based CLOB) column as XML binary XMLType
(2) in 10 g, the only option to make this work is to change the CLOB, XMLType column base in a relational object XMLType one.
HTH
M.
Tags: Database
Similar Questions
-
SQL query using the MAX function
I am trying to display only those records where the "date_entered" is the most recent by case number.
Right now, it's the output im get.SELECT distinct c.case_number, u.email,c.assigneddate_chart, --m.date_entered, max(m.date_entered)as last_date_entered, trunc(sysdate)-trunc(c.assigneddate_chart)days_late, trunc(sysdate)-trunc(m.date_entered)addl_days_late from chart c, chart_user_roles u,comments m where (c.case_status IN ('Open','Pending')) and c.case_number=m.case_number group by c.case_number, u.email,c.assigneddate_chart,m.date_entered
Output:
CASE_NUMBER---EMAIL---ASSIGNEDDATE_CHART---LAST_DATE_ENTERED---DAYS_LATE--ADDL_DAYS_LATE
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
I am wanting to achieve this result:
Therefore, based on the data below, are the only records I am wanting to display:
[email protected]
[email protected]
Thank you
DeannaSELECT case_number, email, assigneddate_chart, date_entered, trunc(sysdate)-trunc(assigneddate_chart) days_late, trunc(sysdate)-trunc(date_entered) addl_days_late FROM ( SELECT c.case_number, u.email, c.assigneddate_chart, m.date_entered, dense_rank() over(partition by c.case_number order by m.date_entered DESC) rnk FROM chart c, chart_user_roles u, comments m WHERE c.case_status IN ('Open','Pending') AND c.case_number=m.case_number ) WHERE rnk = 1 /
SY.
-
SQL using the analytic function
Hi allI want a help in the creation of my SQL query to retrieve the data described below:
I have a test of sample table containing data as below:
State ID Desc
MICHAEL 1 T1
ACTIVE 2 T2
T3 3 SUCCESS
DISABLE THE T4 4
The thing I want to do is to select all the lines with an ACTIVE status in the table but is there is no ACTIVE status, my request will give me the last line with MICHAEL status.
I can do this in a single request by using the analytical function for example, if yes can yiu help me on the request of unpacking.
Kind regards
Raluce
Something like that?
I had to fix it.
with testdata until)
Select 1 id, "T1" dsc "DISABLED" status of Union double all the
Select 2 id, 'T2' dsc, the status "ACTIVE" of all the double union
Select id 3, "T3" dsc, the status of 'SUCCESS' of all the double union
Select 4 id, "T4" dsc "DISABLED" status of double
)Select
ID
dsc
status
of testdata
where
status =
-case when (select count (*) in testdata where status = 'ACTIVE') > 0
then 'ACTIVE '.
Another 'DISABLED '.
end
and)
ID in (select id from testdata where status = ' ACTIVE')
or
ID = (select max (id) in testdata when status = 'DISABLED')
)STATE ID DSC
'2' 'T2' 'ACTIVE '.
Maybe it's more efficient
Select
ID
dsc
status
of testdata
where
status =
-case when (select count (*) in testdata where status = 'ACTIVE') > 0
then 'ACTIVE '.
Another 'DISABLED '.
end
and
ID =)
-case when (select count (*) in testdata where status = 'ACTIVE') > 0
then id
on the other
(select max (id) in testdata when status = 'DISABLED')
end
)Post edited by: correction of chris227
Post edited by: chris227
extended -
help in the application without using the pivot function
Hi gurus,
Can you please help write the query without using the PIVOT function.
Thanks in advance!...WITH indata AS (SELECT 1 sn, '123:456,789,323:456,213,344,345:5454' x from dual UNION ALL SELECT 2, 'abcd:fgrfr,rfrf,rfred,tg:tg,tg:ophhh,op,vdfgbh:poijn' x from dual), instr AS (SELECT a.SN, rownum RN, B.column_value || CASE WHEN B.column_value NOT LIKE '%:%' THEN ':' END column_value FROM indata a, TABLE(CAST(multiset (SELECT trim(SUBSTR(x, (CASE LEVEL WHEN 1 THEN 1 ELSE instr(x, ',', 1, LEVEL - 1) + 1 END), (CASE instr(x, ',', 1, LEVEL) WHEN 0 then 4000 ELSE instr(x, ',', 1, LEVEL) - 1 - (CASE LEVEL WHEN 1 THEN 0 ELSE instr(x, ',', 1, level - 1) END) END))) FROM dual CONNECT BY level <= LENGTH(x) - LENGTH(REPLACE(x, ',', '')) + 1) AS sys.odcivarchar2list)) b) SELECT col1_val2, col1_val1, col2_val2, col2_val1, systimestamp FROM (select SN, ROW_NUMBER() over(partition by SN order by RN) RN, SUBSTR(column_value, INSTR(column_value, ':') + 1) VAL1, substr(column_value, 1, instr(column_value, ':') - 1) val2 FROM instr ) PIVOT(MAX(VAL1) VAL1, MAX(VAL2) VAL2 FOR SN IN(1 as col1,2 as col2));
Any help would be appreciated.user590978 wrote:
Can you please help write the query without using the PIVOT function.
with indata as ( select 1 sn,'123:456,789,323:456,213,344,345:5454' x from dual union all select 2, 'abcd:fgrfr,rfrf,rfred,tg:tg,tg:ophhh,op,vdfgbh:poijn' x from dual ), t1 as ( select x from indata where sn = 1 ), t2 as ( select x from indata where sn = 2 ), t3 as ( select level lvl, substr( x, instr(',' || x,',',1,level), instr(x || ',',',',1,level) - instr(',' || x,',',1,level) ) col1 from t1 connect by level <= length(x) - length(translate(x,'A,','A')) + 1 ), t4 as ( select level lvl, substr( x, instr(',' || x,',',1,level), instr(x || ',',',',1,level) - instr(',' || x,',',1,level) ) col2 from t2 connect by level <= length(x) - length(translate(x,'A,','A')) + 1 ), t5 as ( select lvl, substr(col1,1,instr(col1 || ':',':') - 1) col1_val1, substr(col1,instr(col1 || ':',':') + 1) col1_val2 from t3 ), t6 as ( select lvl, substr(col2,1,instr(col2 || ':',':') - 1) col2_val1, substr(col2,instr(col2 || ':',':') + 1) col2_val2 from t4 ) select col1_val1, col1_val2, col2_val1, col2_val2, systimestamp from t5 full join t6 on ( t6.lvl = t5.lvl ) order by coalesce(t5.lvl,t6.lvl) / COL1_VAL1 COL1_VAL2 COL2_VAL1 COL2_VAL2 SYSTIMESTAMP ---------- ---------- ---------- ---------- ------------------------------------- 123 456 abcd fgrfr 23-OCT-12 11.50.12.015000 AM -04:00 789 rfrf 23-OCT-12 11.50.12.015000 AM -04:00 323 456 rfred 23-OCT-12 11.50.12.015000 AM -04:00 213 tg tg 23-OCT-12 11.50.12.015000 AM -04:00 344 tg ophhh 23-OCT-12 11.50.12.015000 AM -04:00 345 5454 op 23-OCT-12 11.50.12.015000 AM -04:00 vdfgbh poijn 23-OCT-12 11.50.12.015000 AM -04:00 7 rows selected. SQL>
SY.
-
How to use the TRUNC function with dates in the expression builder in OBIEE.
Hello
How to use the TRUNC function with dates in the expression builder in OBIEE.
TRUNC (SYSDATE, 'MM') returns 1 July 2010"where sysdate is July 15, 2010 ' in SQL. I need to use the same in the expression builder in the logical layer mdb column.
Thanks in advanceUse it instead:
TIMESTAMPADD (SQL_TSI_DAY, (DAYOFMONTH (CURRENT_DATE) *-1) + 1, CURRENT_DATE) -
Do I need to use the NVL function for this request?
I seem to have some problems using the NVL function on a date. I'm trying to create a query pulls back just a date a file was sent between the sysdate and the date_sent more a minute. Here is the code I use...
Oracle: 10.2 G
Currently Output (null):SELECT date_sent as date_sent INTO iDateSent FROM tableX WHERE file_id= 9999 AND date_sent BETWEEN sysdate AND date_sent + 1/1440;
Desired output when date_sent is null:DATE_SENT
Note:DATE_SENT 0:0:000 0:00:00
date_sent column is in a normal date - same format as sysdate format.
The problem I encounter is when date_sent is null, the stored procedure, I built crashes because date_sent returns a null and a null value cannot be stored in the variable 'iDateSent '. I was thinking about using the NVL function here to resolve, however, I'm not entirely sure who will work with the above query. Any thoughts?
Published by: user652714 on July 9, 2010 12:58
Published by: user652714 on July 9, 2010 13:11Hello
you said: "desired output when date_sent is null: date_sent: 0".
It is not possible to have a date of 'zero '."and a null value cannot be stored in the variable 'iDateSent'. '.
I do not think: If this variable is declared normally (without any not null not constrained to this topic) so that it can contain a null value. (it's 99% of the time in PL/SQL).
I think it's that your SQL retrieves no rows, to manage what you should put an exception handler:
begin SELECT date_sent as date_sent INTO iDateSent FROM tableX WHERE file_id= 9999 AND date_sent BETWEEN sysdate AND date_sent + 1/1440; exception when NO_DATA_FOUND then iDateSent:=null; end;
So what you can do if you don't want the date empty a nvl:
return(nvl(iDateSent,sysdate)); -- or another date ...
Published by: user11268895 on July 9, 2010 22:09
-
How to extract the second sysdate value using the EXTRACT function
Hello
I want to extract the second sysdate value using the EXTRACT function.
When I run the following query I get an error;
SELECT extract (second OF SYSDATE) FROM dual;
ORA-30076: field of invalid extract for the source of the extract.
When I do to extract the month I get the correct result.
Is there some necessary formatting by specifying the sysdate (or any other date value) in the query. ?
Thank you.You can extract only the year/month / day, day
SQL> Select extract(year from sysdate) from dual; EXTRACT(YEARFROMSYSDATE) ------------------------ 2008 SQL> Select extract(day from sysdate) from dual; EXTRACT(DAYFROMSYSDATE) ----------------------- 20 SQL> Select extract(month from sysdate) from dual; EXTRACT(MONTHFROMSYSDATE) ------------------------- 11 IF you enter Minute or Seconds SQL> Select extract(minute from sysdate) from dual; Select extract(minute from sysdate) from dual * ERROR at line 1: ORA-30076: invalid extract field for extract source but with timestamp you can get the seconds SQL> select EXTRACT(second FROM current_timestamp) from dual; EXTRACT(SECONDFROMCURRENT_TIMESTAMP) ------------------------------------ 39.473 SQL> select EXTRACT(second FROM current_timestamp) from dual; EXTRACT(SECONDFROMCURRENT_TIMESTAMP) ------------------------------------ 57.474 SQL> / EXTRACT(SECONDFROMCURRENT_TIMESTAMP) ------------------------------------ 59.787 SQL> / EXTRACT(SECONDFROMCURRENT_TIMESTAMP) ------------------------------------ .412 SQL> / EXTRACT(SECONDFROMCURRENT_TIMESTAMP) ------------------------------------ .99 SQL> / EXTRACT(SECONDFROMCURRENT_TIMESTAMP) ------------------------------------ 1.458 SQL> / EXTRACT(SECONDFROMCURRENT_TIMESTAMP) ------------------------------------ 1.896 SQL> / EXTRACT(SECONDFROMCURRENT_TIMESTAMP) ------------------------------------ 2.334
Edited by: Viswarayar Maran on November 20, 2008 14:30
-
How doi send texts using the speech function without hitting the Send button?
using the speech function in texting, how to send the text without actually pushing the Send button? When I say 'send' or 'send message' he just keeps typing
"Hey, Siri, send a message to Bob. Siri will then ask you what you want text Bob. Once you stop dictating, Siri will ask then if you're ready to send the message. Say, "Yes." It's really very nice.
If you are already in the message app and using speech-to-text, you must press the Send button.
-
Cannot use the Val function in a script use
I'm trying to convert a text string (binary number) in a number by using the Val function in a script of use but the colors of tiara the term Val in red and the script produces an error indicating "Variable is undefined:"Val"
Why is that happen? Some functions are not allowed in use scripts?
In addition, it seems impossible to use debugging in my use - if I try to add a variable to the Watch window, there never have any value even if I put a breakpoint on this line of code. Would it not possible to debug scripts use?
David,
regarding your question on "Val" I would like to direct you to the "File.Formatter.ParseString" function which is part of the API available at DataPlugins.
CDbl and CLng do a good job in general, but they are dependent on the local configuration of the PC. 'ParseString' is so much more reliable.
Andreas
-
How to connect the parallel test using the logarithmic function Teststand database result
Hello
How can I connect a test result of 4 EHR tested in parallel using the logarithmic function Teststand database
I use Labview 2013, 2013 Teststand and sequential model.
The test is performed using a single digital card (SMU-6556). The FSD 4 is connected to the port of the digital map and is tested in parallel.
Currently at the end of the test, I would have a report with all the measures, but I need 4 reports (1 report / dut)
TKS
-
When I use the library function node call in real time, is loaded only once for all or load the DLL every time when it is called?
I have a critical application in real time, in which I use a piece of DLL function developed in C++. It is ok? Make sure any senior developer?
Thank you in advance.
The user interface thread is the thread that is used to update the user interface. It's slow. And it's supposed to be that way because humans are slow.
The call library function node can be configured as this thread to use in the configuration for it dialog box. Please visit the LabVIEW documentation on how to do this.
-
How can I use the BCGTransform function to treat the 16-bit Image?
Hi ~
I use LabWindowsCVI8.5 and NI Vision to make the treatment of the Image. When I read the "IMAQ Vision for LabWindowsCVI Reference Manual", I found that the imaqBCGTransform function only supports 8-bit Image, while I do the BCG to turn on 16-bit image. Are there solutions to use the BCGTransform function to deal with the 16-bit Image? Or any other feature that could make the correction Gamma, contrast and brightness on the 16-bit Image?
Thank you very much!
because imaqBCGTransform is implemented as a lookup table, we can understand why it is limited to 8-bit images.
Now let's take a look at the definition of each of this mandate (from the NI Vision Concepts documentation):
-brightness: a constant added to the components red, green, and blue pixel of color over color, decoding of the process;
-contrast: a constant multiplication factor applied to the components of the luma and chroma of a pixel of color in color to decoding process.
-gamma correction: expand high gray-level information in an image while removing information of low level of gray. (the chapter on lookup tables gives some examples of corrections gamma)
now that you understand that this transformation is a simple mathematical function, simply calculate the correction for each pixel on your 16-bit images.
I know not the exact formula used by the imaqBCGTransform function, but you should be able to approach by performing some tests on images 8 bits with the original function... or you can make your own formula... or find one on the net... or you can ask someone at home OR you give the formula...
-
Does anyone have an example VI for using the SendInput function in User32.dll?
Hi all
I am creating a VI that creates a click of the mouse. I looked at the MSDN Web site and found that I need to use the SendInput function in User32.dll. The problem is that some of the parameters for this function are nested structures. How to use this function in a call library function node? Is there already a LabVIEW wrapper for this function?
Thank you
MechEman
I would use rather MouseEvent. I looked at my VI and it can be cleaned up a bit, but it works for what you want to do.
-
Using the comparison function where 2 data tables various types
Is it possible to use the comparison function in Labview you to compare 2 arrays of types of different data (e.g. Boolean and double-precision)?
Would this work? Nested for loops of index on the TRUE values of the Boolean table.
-
How to copy an image that is in format .pdf using the paint function paste in Word?
I would like to copy a table that is in a non-protected PDF document using the paint function in accessories to paste it in a Word document that I'm working on. Please help as soon as POSSIBLE.
Hello, Edward Namalima,.
1. first open the pdf page you want to copy.
2. when the page is displayed on your screen, press prtscrn on your keyboard.
3. a copy of the screen has now sent in the windows clipboard.
4. now open Paint.
5. on the Paint toolbar, click on edit and then click on paste. The image will now be pasted in a Paint window. You may need to accept a dialog resize if the image is larger than the current document.
6. now, from the toolbar to the left of your screen, click on the Selection (the oblong dotted box) tool. With the selection tool, select the entire surface of the table you want to copy. Once selected, click on modifier change again, then select Copy.
7. now, open Microsoft Word.
8. then place the cursor where you want the table to set, and then press the CTRL and V together on your keyboard.
9. the image of the table should now be pasted into your Word document.
Alternatively, you can use the cutting tool (click on the Start button and type snipping tool in the search field). Select the table you want in the pdf page using the cutting tool and then open word and paste the table in word.
This forum post is my own opinion and does not necessarily reflect the opinion or the opinion of Microsoft, its employees or other MVPS.
John Barnett MVP: Windows XP Expert associated with: Windows Expert - consumer: www.winuser.co.uk | vistasupport.mvps.org | xphelpandsupport.mvps.org | www.silversurfer-Guide.com
Maybe you are looking for
-
Facebook doesn't work does not correctly in 14.0.1
Since the 14.0.1 update (maybe a 14 precedents), I could not post, or even ' like' items on Facebook. I can read pages fine, but am not able to grasp anything. I get a Facebook page that says, oops something does not etc. However, if I switch to IE,
-
CASE structure: Can I use a bit word to choose a particular case?
I know that I can use 'STRUCTURE CASE' in which I can put 2 different situation: TRUE AND FALSE. I know that I can also add other cases, but... How can I change a Boolean value. I know that I can also use integers, but... it is possible to use Boolea
-
host vi data only appears in fixed point format
Hello The FIFO DMA are configured as fixed point integer length 16 and with note 19. When they are acquired by DMA FIFO in FPGA entire watch and mantissa. But when acquired his watch only the integer in host and I lose mantissa. He get rounding upwar
-
Cannot send an e-mail video of the iPad user to yahoo email.
E-mail of the recipient displays "delivery failure".
-
I must have deleted at one time or another, I have re-installed my updated windows program in place the disc but it says to start the program, how can I do this?