0

When i run

SELECT XMLElement("product", 
                  XMLAttributes(fp.col2 AS "attr2",fp.col4 as "attr4",fp.col5 as "attr5",fp.col6 as "attr6")
                  XMLElement(SELECT (XMLElement("dataset",
                                    XMLAttributes(ds.col3 AS "attr3")
                                    FROM Table2 ds
                                   WHERE fp.col1 = ds.col1 and fp.col2 = ds.col2 and ds.col2='ABC')) )
                  )
FROM Table2 fp
WHERE fp.col1 = 'XYZ'

I get error

ORA-00917: missing comma
00917. 00000 -  "missing comma"
*Cause:    
*Action:
Error at Line: 5 Column: 18

I am not able to understand why

I am expecting output like

<product>
  <dataset></dataset>
</product>

also can you point me to tutorials / examples where xml is generated from joiing multiple tables. I need to have a closer look at syntax.

Most of the examples i searched for had xml generated from single table ( employee)

1
  • seems like an error to me ... i am new to XMLAttribute , XMLElement , etc .... do i need to use XMLAgg ? can you give me link to a good tutorial ... not looking for simple ones Commented Jul 18, 2013 at 7:16

1 Answer 1

1

---EDIT---

I've modified your query. It should work:

SELECT XMLElement("product"
  , XMLAttributes(fp.col2 AS "attr2",fp.col4 as "attr4",fp.col5 as "attr5",fp.col6 as "attr6")
  , (
    SELECT XMLElement("dataset"
      , XMLAttributes(ds.col3 AS "attr3")
    )
    FROM Table2 ds
    WHERE fp.col1 = ds.col1 and fp.col2 = ds.col2 and ds.col2='ABC'
  )
)
FROM Table2 fp
WHERE fp.col1 = 'XYZ';

In your query there is unnecessary XMLElement clause (second one) and before subquery the comma is missing.

Sign up to request clarification or add additional context in comments.

8 Comments

on adding same, still the issue persists ... not sure if i need to use XMLAgg ... looking for more examples
Thanks KPater87 it worked now , before i accept your answer ... can you point me to good tutorial ... where i need to get parent child elements from joining different tables .... i need to create more complex queries having 5 children and 3 levels of nesting
I don't know good tutorial. But you should start by reading the documentation. Additionaly to creating big queries the clause WITH is quite useful. Good luck!
sorry man , my mistake .... i only get product from above query not child elements dataset ...not sure data is issue or syntax
Syntax is good. Maybe in your database there is nothing to display as dataset (with this conditions). You should know your data!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.