Help on Xquery writing
I have a table as below ; and i get to a record in the table using the primary key
create table raees_test
unique_rec_id varchar2(16) not null primary key ,
racn_nbr number(5),
blob_value blob,
invoice_data SYS.XMLTYPE
I want to query the xml type column using Xquery where I want to reach to it through the unique_rec_id
please let me know how to implement the query
Thanks
Raees
Basically, I want the query to return the flight-data for both aircraft and then, on that total return, find the unique fault IDs. However, the second part operates on the unique fault IDs for each aircraft separately. It gives the unique fault IDs for the first aircraft and then the unique fault IDs for the second aircraft.You can do it like the following, by first retrieving the whole sequence of attributes for both aircrafts, then applying distinct-values() :
distinct-values(
for $z in collection("brickdata2")/flight-data
where $z/@aircraft-id = "1"
or $z/@aircraft-id = "2"
return $z/maintenance-raw-data/@fault-id
)
Similar Messages
-
help needed for writing query
i have the following tables(with data) as mentioned below
FK*-foregin key (SUBJECTS)
FK**-foregin key (COMBINATION)
1)SUBJECTS(table name)
SUB_ID(NUMBER) SUB_CODE(VARCHAR2) SUB_NAME (VARCHAR2)
2 02 Computer Science
3 03 Physics
4 04 Chemistry
5 05 Mathematics
7 07 Commerce
8 08 Computer Applications
9 09 Biology
2)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2) SUB_ID1(NUMBER(FK*)) SUB_ID2(NUMBER(FK*)) SUB_ID3(NUMBER(FK*)) SUBJ_ID4(NUMBER(FK*))
383 S1 9 4 2 3
384 S2 4 2 5 3
---------I actually designed the ABOVE table also like this
3) a)COMBINATION
COMB_ID(NUMBER) COMB_NAME(VARCHAR2)
383 S1
384 S2
b)COMBINATION_DET
COMBDET_ID(NUMBER) COMB_ID(FK**) SUB_ID(FK*)
1 383 9
2 383 4
3 383 2
4 383 3
5 384 4
6 384 2
7 384 5
8 384 3
Business rule: a combination consists of a maximum of 4 subjects (must contain)
and the user is less relevant to a COMB_NAME(name of combinations) but user need
the subjects contained in combinations
i need the following output
COMB_ID COMB_NAME SUBJECT1 SUBJECT2 SUBJECT3 SUBJECT4
383 S1 Biology Chemistry Computer Science Physics
384 S2 Chemistry Computer Science Mathematics Physics
or even this is enough(what i actually needed)
COMB_ID subjects
383 Biology,Chemistry,Computer Science,Physics
384 Chemistry,Computer Science,Mathematics,Physics
you can use any of the COMBINATION table(either (2) or (3))
and i want to know
1)which design is good in this case
(i think SUB_ID1,SUB_ID2,SUB_ID3,SUB_ID4 is not a
good method to link with same table but if 4 subjects only(and must) comes
detail table is not neccessary )
now i am achieving the result by program-coding in C# after getting the rows from oracle
i am using oracle 9i (also ODP.NET)
i want to know how can i get the result in the stored procedure itsef.
2)how it could be designed in any other way.
any help/suggestion is welcome
thanks for your time --PradeeshWell I forgot the table-alias, here now with:
SELECT C.COMB_ID
, C.COMB_NAME
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID1) AS SUBJECT_NAME1
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID2) AS SUBJECT_NAME2
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID3) AS SUBJECT_NAME3
, (SELECT SUB_NAME
FROM SUBJECTS
WHERE SUB_ID = C.SUB_ID4) AS SUBJECT_NAME4
FROM COMBINATION C;
As you need exactly 4 subjects, the columns-solution is just fine I would say. -
Hi,
Could anyone help me in writing below query without syntax errors.
I tried but no luck
select xmlelement("g", XMLATTRIBUTES(g.contentgroup_id as "id",g.groupname as "label",
(select xmlagg(xmlelement ("c",XMLATTRIBUTES(c.title as "title",c.content_id as "id")))) as "A"))
as "A" from
(SELECT g.contentgroup_id AS id, g.groupname AS label, c.title AS label, c.content_id AS id
FROM content_ec c FULL OUTER JOIN contentgroup_ec g ON c.group_id = g.contentgroup_id
oRDER BY g.groupname ,c.title ASC );
Any help really appreciated.
ThanksFew tips to get your question answered here
1. Give your database version. Some thing that does not work in one version works fine in the next. And 8i,9i or 10g is not version. best way to give the version is to query your v$version table like this.
SQL> select * from v$version where rownum = 1
2 /
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod2. You should understand we don't have what you have, meaning you should provide your data structure and some sample data for us to help.
3. "I got an error"... "Its not working"... and the list goes on. Sentences like this does not help. If you got a error past the entire error. If stuff does not work, tell us the details.
4. Just don't throw some output and say i want it. Please explain to every one how you derive it.
5. And the most important thing. Use \...\ tag to format. Please.. Please.. Please.. use it. It helps every one a lot. When you use it your SQL looks some thing like this.
SELECT xmlelement("g", XMLATTRIBUTES(g.contentgroup_id as "id",g.groupname as "label",
(select xmlagg(xmlelement ("c",XMLATTRIBUTES(c.title as "title",c.content_id as "id")))) as "A")) as "A"
FROM (SELECT g.contentgroup_id AS id,
g.groupname AS label,
c.title AS label,
c.content_id AS id
FROM content_ec c
FULL OUTER JOIN contentgroup_ec g
ON c.group_id = g.contentgroup_id
ORDER BY g.groupname ,c.title ASC );6. And also do search this forum. Most of your my queries are answered by simple search.
Thanks,
Karthick. -
Help needed in writing a function.
I am using Oracle 11g and SQL plus. I am a complete newbie, so I need some help here in writing a function. I guess my question is more about writing the trigonometric functions within the function.
latA, longA latB, longB // these are the four input parameters,
theta = longA - longB
distX = sin( latA * PI / 180) * sin ( latB * PI /180) + cos ( latA * PI/180) * cos ( latB * PI/180) * cos ( theta * PI / 180)
distY = acos(distX) // this is arc cosine
distZ = distY * 180 / PI // PI refers to the mathematical PI
distP = distZ * 60 * 1.1515; // this value should be returned. Of course the intermediate variable names don't matter.
Please help. Thanks.CREATE OR REPLACE FUNCTION fucntion_name(latA IN NUMBER, longA IN NUMBER, latB IN NUMBER, longB IN NUMBER) RETURN NUMBER
IS
pi CONSTANT NUMBER:=3.14159;
theta NUMBER;
distX NUMBER;
distY NUMBER;
distZ NUMBER;
distP NUMBER;
BEGIN
theta :=longA - longB;
distX :=sin( latA * PI /180) * sin ( latB * PI /180) + cos ( latA * PI/180) * cos ( latB * PI/180) * cos ( theta * PI / 180);
distY :=acos(distX); --this is arc cosine
distZ :=distY * 180/PI; --PI refers to the mathematical PI
distP :=distZ * 60 * 1.1515; --this value should be returned. Of course the intermediate variable names don't matter.
RETURN distP;
END;Edited by: Ora on May 3, 2011 11:46 PM -
Help required in writing an sql to fetch the the difference of the data.
Hi Gurus,
Could some one help me in writing an sql to pull data the difference between two same structured tables from two different database and to store that data in an temperory table.
many many thanks in advanceLets say you have two db SOURCE and DEST
SOURCE is the DB that you have Logged in into. Now you do the following.
1. Createa DBLink to DEST database.
2. Check if the DBLink works properly.
3. Then execute the following sql.
select <column_list> from <table_name>
minus
select <column_list> from <table_name>@<dblink>
union all
select <column_list> from <table_name>@<dblink>
minus
select <column_list> from <table_name> -
Please help me in writing the SQL
Hi,
I am new to oracle.. Can you please help me in writing a SQL
I have a table which has the following columns
Start_date m1 ---- Start month of each quarter (Jan,Apr,Jul,oct)
end_date m3---- End month of each quarter
m1_start_date,
m1_end_date,
m2_start_date,
m2_end_date,
m3_start_date,
m3_end_date,
M1_act_rev,
m2_act_rev,
m3_act_rev
If a user selects the dates from Jan,2011 to Jun, 2011
I should get the aggregate of the revenues (m1+m2+m3+m1+m2+m3)Hi Gurus,
Will this work
select
b.DISTRICT_NAME,
count(c.CONTRACT_NUMBER),
sum(C.M1_ACT_REV),
sum(C.M2_ACT_REV),
sum(C.M3_ACT_REV),
sum(C.M1_EXP_PRICE),
sum(C.M2_EXP_PRICE),
sum(C.M3_EXP_PRICE)
from
clm_mn_compliance_data c,
CLM_MN_CUSTOMER_ALIGNMENT_DATA b
where
((m1_start_date between '01-01-2011' and '03-31-2011' ) and (m1_end_date between '01-01-2011' and '03-31-2011')) or
((m2_start_date between '01-01-2011' and '03-31-2011' ) and (m3_end_date between '01-01-2011' and '03-31-2011')) or
((m3_start_date between '01-01-2011' and '03-31-2011' ) and (m3_end_date between '01-01-2011' and '03-31-2011')) and
b.CUSTOMER_ID = C.CUST_CTRT_ID
group by
B.DISTRICT_NAME; -
Could you please help me in writing query
Hi,
Data in table
ID -- H_squ -- D_squ --- Note
0001 1 1 he is
0001 1 2 coming
0001 1 3 from US
0001 2 2 he is going
0001 2 5 Back to US
0002 1 3 he took
0002 1 2 his laguage
0002 2 3 bi
output shouldbe
ID -- H_squ -- D_squ --- Note
<0001> <1> <1,2,3> <he is coming from US>
<0001> < 2 > <2,5> < he is going Back to US>
<0002> <1> <3,2> <he took his laguage>
<0002> <2> <3> <bi>
Actually I used STRAGG function But i am not getting expected output
group by ID, H_squ concat data order by D_squ column
Note should contain concat of D_squ(1,2,3) in this order
Could you please help me in writing queryThis forum is for issues related to Advanced Queuing.
Please only post in forums where your questions are appropriate. -
Help me for writing the password script on solaris
hi,
help me for writing password scripts to change the user/root password.
in the script itself myself want to mention the new password.
now user want to login with the new password only.
model script:
echo $test:`perl -e '$x=crypt('$test123','test');
print $x'`::::::: >> /etc/shadow
test--->username
test123---->new password.
the above script is not working.
kindly help me for writing the script.
Regards,
rajaWell. For one thing, if you just append the new password to the /etc/shadow file there will be two entries for the user in that file (at least if the user already had a password). Which probably is a bad thing.
-
How doest jdk docs help as in writing java code?
hi i wonder how does jdk docs help as in writing java code because if i google a java code the jdk docs always becomes the result of my search but in my experience jdk docs never helps me.
is there any one know how to use jdk docs? and how to get the code from there.
im telling about jdk docs from here http://download.oracle.com/javase/1.4.2/docs/api/
cross posted from http://www.thenewboston.com/forum/viewtopic.php?f=119&t=13778
Edited by: 871484 on Jul 18, 2011 4:18 PM871484 wrote:
ok can any one give me example how to use jdk docs? for example this code
Your question still does not make any sense, and you still haven't clarified what you're not understanding.
However, if you think that just by reading the API docs, with no other training or study, that you will be able to write that code, then you are seriously misunderstanding the purpose of the docs.
Obviously English is not your native language. You grew up speaking some other language at home and with your friends, and at some point in school or as private study, you started to learn English. You learned about the grammar and the alphabet and pronunciation, sentence structure, word order, etc. Now you have the basics of how the language works, and you know some words. When you want to learn new words to fit into the structure you have learned, you use a dictionary.
If you didn't study the grammar, sentence structure, etc., and just said, "I want to learn English. I will look at a dicationary," clearly that would not work.
Right?
So, since you now understand and agree with the English example, let me state something that I hope is obvious to you by now: The API docs are your dictionary. They are not a substitute for learning the language basics.
Furthermore, once you know the language basics in English and have your dictionary, you still won't know how to write a resume (which you may know as a CV). You will look at examples and perhaps take a course on resume (CV) writing. Just reading a dictionary won't help you write a resume(CV). Similarly, if you know some Java basics, you can't learn how to write a Swing app just by reading the Javadocs. You'll look at tutorials and examples. Then, once you know the basic structure of a Swing app, you'll look to the javadocs for more details about more kinds of GUI classes--different buttons and windows and panes and panels and layout managers, etc. -
Help needed in writing a Query/Procedure
Hello All,
Need all ur help in writing a query or procedure
Lets say the Table name is DEMO
There i have one column like num it has values
1
2
3
4
5
8
9
10
my query output should be
1-5
8-10
i,e .. if the diff between two rows is greater than 1 then it result should be in a separate group
I need a query/Procedure for this. Kindly help
Regards,
ChandraTried obtaining the output using SQL and the result is as follows:
SQL> WITH T AS
2 (
3 SELECT 1 COL1 FROM DUAL
4 UNION
5 SELECT 2 COL1 FROM DUAL
6 UNION
7 SELECT 3 COL1 FROM DUAL
8 UNION
9 SELECT 4 COL1 FROM DUAL
10 UNION
11 SELECT 5 COL1 FROM DUAL
12 UNION
13 SELECT 8 COL1 FROM DUAL
14 UNION
15 SELECT 9 COL1 FROM DUAL
16 UNION
17 SELECT 10 COL1 FROM DUAL
18 UNION
19 SELECT 13 COL1 FROM DUAL
20 UNION
21 SELECT 14 COL1 FROM DUAL
22 UNION
23 SELECT 15 COL1 FROM DUAL
24 UNION
25 SELECT 16 COL1 FROM DUAL
26 UNION
27 SELECT 23 COL1 FROM DUAL
28 UNION
29 SELECT 24 COL1 FROM DUAL
30 )
31 SELECT OUTPUT FROM
32 (
33 SELECT DECODE(COL3,NULL,COL1, COL2) || '-' || LEAD(DECODE(COL3,NULL,COL3, COL1)) OVER (ORDER BY DECODE(COL3,NULL,COL1, COL2)) OUTPUT FROM
34 (
35 SELECT COL1, LEAD(COL1) OVER (ORDER BY COL1) COL2, LAG(COL1) OVER (ORDER BY COL1) COL3 FROM T
36 )
37 WHERE
38 (COL2 - COL1 > 1 OR COL2 IS NULL OR COL3 IS NULL)
39 )
40 WHERE OUTPUT != '-';
OUTPUT
1-5
8-10
13-16
23-24 -
Help required in writing And Reading Xml From Database
Hi
i m new to java.
i m facing problem while writing Xml file from Mysql Database in java i m using the WebRowSet
and also for Reading WebRowSet
after reading the Xml i have to save this in Database
(required source code)
is there any one to help me in this way
regards
aamirshadab_think_globally wrote:
{noformat}*hi everybody,
please send me a ajax with jsp application
suppose i enter a word in text area ajax will populate/suggest all string from database ,who started
from that entering character(s).like a google string search.
please send full source code
*{noformat}how about you do it yourself? -
[ALSB 3.0] help help about xquery transformation
Hi all,
I should transform a xml doc from
<val_date>20081004</val_date>
<par>
<key>rpp</key>
<value>10</value>
</par>
<par>
<key>curry</key>
<value>CHF</value>
</par>
to
<val_date>20081004</val_date>
<par>
<key>rpp</key>
<value>10</value>
</par>
<par>
<key>curry</key>
<value transcoder="CURRENCY">CHF</value>
</par>
I'm using WorkspaceStudio but I've some troubles in my xquery transformation.
I tried as below:
<ns1:val_date>{ data($dummyProviderEvent/ns0:val_date) }</ns1:val_date>
for $par in $dummyProviderEvent/ns0:par
return
<ns1:par>
<ns1:key>{ data($par/ns0:key) }</ns1:key>
if ($par/ns0:key="curry") then <ns1:value transcoder="CURR">{ data($par/ns0:value) }</ns1:value>
else <ns1:value>{ data($par/ns0:value) }</ns1:value>
</ns1:par>
</ns1:dummyEvent>
but is not working:
i) WorkspaceStudio raises a warning at 'else' line with message "XML element does not match the target schema"
ii) testing the transformation it seems that if condition is always true
Could you help me to find out the correct solution ?
Regards
ferpI know there were some changes to the packaging of the public API in 3.0. You may want to be sure you include all the necessary jar in your classpath. I think there is another post in the forum covering this.
Gregory Haardt
ALSB Prg. Manager
[email protected] -
Hello Friends,
I am trying to do a XQuery transformation which does not like straight one to one. I am not an expert so I don't know what I am trying to achieve is capable or not.
So please Guys me ...
My Source Element are like :
<Node1>
<Node2>
<Node3>
<Node4>
<Node5>
<Node6>
My Destination elements are :
<Dest1>
<Dest2>
<Dest3>
<Dest4>
Now in transformation I need put some logic like this :
1. check if node1 and node 2 has some data then copy node1 + node 2 data in Data1 othwise if node 2 present then copy only node 2 data.
2. similary if node 1 and node 2 node are not present then copy node 3 (if present) in dest 1 and node 4 data in dest2 subsequently.
So, like this different combination of source nodes data will map to 4 destination nodes.
I am trying my hands but no success yet.
So please help me.If it is possible then can anyone write a simple example for this.
Thanking in Anticipation.For the conditional part check http://www.w3schools.com/xquery/xquery_syntax.asp
and to combine the nodes check http://www.xqueryfunctions.com/xq/fn_concat.html
hth,
Peter Paul -
Hi,
I am having a replace in proxy service to transform AIA format to custom format.
I have a XQuery file for this.
In Replace :
XPath - .
In variable - body
Expression - browsed the xquery resource
- in bind variables:
variable name - createssalesorder1
binding - $body (what should I give for binding??)
Replace node contents
The XQuery file is :
(:: pragma bea:global-element-parameter parameter="$createSalesOrder1" element="ns5:CreateSalesOrder" location="../../aia_11_1/AIAComponents/EnterpriseObjectLibrary/Core/EBO/SalesOrder/V2/SalesOrderEBM.xsd" ::)
(:: pragma bea:global-element-return element="ns1:order" location="../schemas/ean.ucc/order/Order.xsd" ::)
declare namespace ns2 = "http://xmlns.oracle.com/EnterpriseObjects/Core/Custom/EBO/SalesOrder/V2";
declare namespace ns1 = "urn:ean.ucc:order:2";
declare namespace ns4 = "http://xmlns.oracle.com/EnterpriseObjects/Core/Common/V2";
declare namespace ns3 = "http://xmlns.oracle.com/EnterpriseObjects/Core/Custom/Common/V2";
declare namespace ns0 = "urn:ean.ucc:2";
declare namespace ns5 = "http://xmlns.oracle.com/EnterpriseObjects/Core/EBO/SalesOrder/V2";
declare namespace xf = "http://tempuri.org/df.om_1.0/transforms/AIASalesOrder2GS1OrderProxy/";
declare function xf:AIASalesOrder2GS1OrderProxy($createSalesOrder1 as element(ns5:CreateSalesOrder))
as element(ns1:order) {
<ns1:order>
<orderIdentification>
<uniqueCreatorIdentification>{ fn:string($createSalesOrder1/ns4:Identification/ns4:ID/@schemeID) }</uniqueCreatorIdentification>
<contentOwner>
<additionalPartyIdentification>
<additionalPartyIdentificationType>BUYER_ASSIGNED_IDENTIFIER_FOR_A_PARTY</additionalPartyIdentificationType>
</additionalPartyIdentification>
</contentOwner>
</orderIdentification>
<orderPartyInformation>
<seller>
<additionalPartyIdentification>
<additionalPartyIdentificationType>SUPPLIER_ASSIGNED_IDENTIFIER_FOR_A_PARTY</additionalPartyIdentificationType>
</additionalPartyIdentification>
</seller>
</orderPartyInformation>
</ns1:order>
declare variable $createSalesOrder1 as element(ns5:CreateSalesOrder) external;
xf:AIASalesOrder2GS1OrderProxy($createSalesOrder1)
When I test the proxy service using console, I get
BEA-382513: OSB Replace action failed updating variable "body": Error parsing XML: {err}XP0006: "element {http://schemas.xmlsoap.org/soap/envelope/}Body { {http://www.w3.org/2004/07/xpath-datatypes}untypedAny }": bad value for type element {http://xmlns.oracle.com/EnterpriseObjects/Core/EBO/SalesOrder/V2}CreateSalesOrder { {http://www.w3.org/2001/XMLSchema}anyType }
I am new to XQuery and any help on where am I going wrong on this?
Also is there an example/tutorial for the above scenario?
Thanks
GaneshHello Ganesh,
Try with "$body/*" in the binding.
If it does not work then please paste the input xml of the proxy here. Actualiy, your proxy's input xml must be having an element of type "ns5:CreateSalesOrder" and you have to give that element's X-path in Xquery binding.
Regards,
Anuj -
I have 2 xml documents Team and Player
Here is how they look like
team.xml
<Teams>
<Team>
<Lost>59</Lost>
<Name>NewYork</Name>
<Won>103</Won>
</Team>
<Team>
</Team>
<Teams>
player.xml
<Players>
<Player>
<Age>24</Age>
<Team>NewYork</Team>
<BOB>67</BOB>
<SOT>265</SOT>
<IPT>229.3</IPT>
</Player>
<Player>
</Player>
<Players>I want to write a xquery to dsiplay for each team; the number of good* players, the avg age of good players, the number of total players and avg age of total players.
The criteria for a good player is (BOB + SOT) / IPT < 0.91.
This what I tried
for $x in distinct-values (doc("team.xml")/Teams/Team/Team)
let $y:= doc("player.xml")/Players/Player[Team=$x]
return
<Team>
<Team_Name>{data($x)}</Team_Name>
<Total_players>{count($y)}</Total_players>
<Average_Age>{avg($y/Age)}</Average_Age>
</Team>Using this I get the the number of total players and avg age of total players. However, i'm not sure how I can modify this to return the information about good players as well.
Can someone please help me with this.
Thanks.Try something like this
xquery version "1.0";
<Table>
for $x in distinct-values (doc("team.xml")/Teams/Team/Name)
let $y:= doc("player.xml")/Players/Player[Team=$x]
let $z:= $y[(BOB + SOT) div IPT < 0.91]
return
<Team>
<Team_Name>{data($x)}</Team_Name>
<Total_players>{count($y)}</Total_players>
<Good_players>{count($z)}</Good_players>
<Average_Age>{avg($y/Age)}</Average_Age>
{for $p in $y
return
<PlayerRating>
{$p/Age}
<GoodPlayer>{$p/BOB + $p/SOT div $p/IPT lt 0.91}
</GoodPlayer>
<PlayerScore>
{$p/BOB + $p/SOT div $p/IPT}
</PlayerScore>
</PlayerRating>
</Team>
</Table>HTH,
chris
Edited by: chrisis on Nov 28, 2009 1:59 PM
Maybe you are looking for
-
Buongiorno Pests- How to get your money back and why you should
Buogiorno, make millions from thousands of us who unknowingly are subscribed to services which we had no idea about. It is easy to get a refund and the service stopped because they are very aware that what they are doing is wrong, but they rely on th
-
Itunes on W8 will not play any files after upgrade to 11.0.4.4
After following the prompt and updating Itunes on Windows 8 to version 11.0.4.4 on 6 June, Itunes no longer plays any audio or video files from my library. Pick a file and Itunes shows that it is playing (Pause button only) however nothing happens. T
-
Moving Raid0 stripe from sata 1&2 to 3&4
Like topic says, I wanna move my raid0 stripe from sata1&2 to 3&4, I'm pretty new to raid setups so I tought I'd ask first if it's possible without losing data & still beyin able to boot from that array. Also some info on how it should be done would
-
Default colors displayed in Mail
I would like to know how to change this damned pink color of the sidebar of Mail. Are Others sidebars colors also customizable ?? (iPhoto is light blue, Finder is light green,...) Do you experienced this ??
-
Can you retreive emails that have been deleted
Can you retreive emails that have been deleted??