ORA-00907: lack the right parenthesis when using Group by clause with xmlagg

I have the following query and I am getting ORA-00907 error when I use the clause with the xmlagg function group.
select xmlelement("Mitigation",
                xmlelement("m_szMethodName",tm.DisplayName),
                xmlelement("SubstanceInterferenceProtocolList",
                            (select xmlagg(xmlelement("MitigationProtocol",
                                    xmlelement("m_szMethodName",tm.DisplayName),
                                    xmlelement("m_szInterferenceProtocolName",tmp.protocol_name),
                                    xmlelement("m_szInterferenceSubstance",tmp.intf_mtrl_prod_code),
                                    xmlelement("m_ProtocolParameters",
                                        xmlelement("m_szProtocolName",tmp.protocol_name),
                                            xmlelement("m_Consumables",
                                                xmlelement("Consumable",
                                                    xmlelement("m_szConsumId", xrl.rgnt_pack_name),
                                                    xmlelement("m_szProductCode",xrl.pack_prod_code),
                                                    xmlelement("m_nVolume",tmp.fluid_vol),
                                                    xmlelement("m_szProtocolStep",xps.protocol_step_name))),
                                                xmlelement("m_ProtParamList",
                                                    xmlagg(
                                                    xmlelement("ParameterValues",
                                                        xmlelement("m_szProtocolName",tmp.protocol_name),
                                                        xmlelement("m_Time",xpsd.parameter_ntime_value))
                                                    group by tmp.ccd_test_id,tmp.intf_mtrl_prod_code)
                )))
                order by tmp.ccd_test_id, tmp.intf_mtrl_prod_code, xps.protocol_step_intprotocolstep )
                from XPR_tdef_mitigation_protocol tmp, xp_reagentlist xrl,
                xpr_protocol_settings xps, xpr_protocol_settings_default xpsd
                where tmp.ccd_test_id = tm.ccd_test_id
                and tmp.ccd_test_id = xrl.ccd_test_id
                and tmp.pack_prod_code = xrl.pack_prod_code
                and tmp.intf_type = 1
                and xps.protocol_name = xpsd.protocol_name
                and xps.protocol_step_name = xpsd.protocol_step_name
                and xps.ps_action_parameterlist = xpsd.ps_action_parameterlist
                and xps.protocol_name =  tmp.PROTOCOL_NAME
                )))
from XPtoXPRTdef_defn_mapping tm
where tm.DisplayName = 'SYPH'
If I remove the clause xmlagg and the group by clause, the query works well and not give me the result.
But in this code XML, the output format is incorrect for my application.

Could someone help out here?

Now my problem is that this unique coating is more than 32767 characters and utl_file can write 32767 bytes per line.
Someone deal with this?

Serialize the output as CLOB and DBMS_XSLPROCESSOR.clob2file procedure used to write to a file:

DECLARE
  xml_output CLOB;
BEGIN
  SELECT XMLElement("Department",
           XMLAgg(
             XMLElement("Employee",e.job_id||' '||e.last_name)
             ORDER BY e.last_name
           )
         ).getClobVal() AS "Dept_list"
  INTO xml_output
  FROM hr.employees e
  WHERE e.department_id = 30 OR e.department_id = 40;

  DBMS_XSLPROCESSOR.clob2file(xml_output, 'XML_DIR', 'test.xml');
END;
/

Tags: Database

Similar Questions

  • ORA-00907 - "lack the right parenthesis.

    Hello

    I am trying to create a procedure to add table scores each month. This is my code:

    create or replace procedure add_partitions

    as

    v_partition all_tab_partitions.partition_name%type;

    v_limit varchar2 (50);

    LONG v_sql;

    Start

    Select to_char (trunc (add_months(sysdate,1), 'MM'), 'Mon_YYYY')

    in v_partition

    Double; -napr. 072014

    Select to_char (trunc (add_months(sysdate,2), 'MM'), 'DD-MM-YYYY')

    in v_limit

    Double; -napr. 08/01/2014

    v_sql: = ' ALTER TABLE CENTRUMADMIN. AUD$ _BACKUP ADD PARTITION '. v_partition | «VALUES LESS THAN (' |)» v_limit | ') tablespace BACKUP_AUDIT';

    immediately run v_sql;

    end;

    /

    The procedure is compiled without errors, but when I run it I get this error:

    ORA-00907 - "lack the right parenthesis.

    After some tests, I am sure that this problem is here: VALUES LESS THAN (' | v_limit |) (')... but I'cant understand whats wrong

    Any ideas? Thanks in advance

    Honza

    Hi Mika,

    Try

    VALUES LESS THAN ("' | v_limit |) (') - three times - 2 gives you a ' in your statement - the 3rd chain delimited

    concerning
    Kay

  • Using DBMS_METADATA. GET_DDL get error: ORA-00907: lack the right parenthesis

    Hello

    I try to extract the schema DDL to a base (10.2.0.4.0 - 64-bit Enterprise Edition on Solaris 10). I ran the query below and get an ORA-00907: parenthesis right absent error.

    SELECT DBMS_METADATA. GET_DDL (REPLACE(object_type,' ','_') AS object_type, object_name) FROM user_objects WHERE object_type NOT IN ('TABLE_PARTITION', "INDEX_PARTITION", "LOB");

    This is the output when executing the above in the sqlplus worksheet

    Select DBMS_METADATA. GET_DDL (REPLACE (object_type, ", '_') as object_type, object_name) FROM user_objects if object_type in ('TABLE_PARTITION',"INDEX_PARTITION","LOB")
    *
    ERROR on line 1:
    ORA-00907: lack of right parenthesis

    remove the where the clause gives the following:

    Select DBMS_METADATA. GET_DDL (REPLACE (object_type, ", '_') as object_type, object_name) FROM user_objects
    *
    ERROR on line 1:
    ORA-00907: lack of right parenthesis

    Pointers would be welcome. I know I could get the DDL using exp/imp, but I'd like to understand why I get the error of missing parenthesis.

    see you soon,

    Ewan

    SELECT DBMS_METADATA. GET_DDL (REPLACE(object_type,' ','_') AS object_type, object_name) FROM user_objects WHERE object_type NOT IN

    You don't need an alias here. Getting rid of the "as long as object_type' and it should work.

  • error: ora-00907 lack the right parenthesis

    Hello


    I don't know where I am doing wrong, please help me


    update of tmp_data_mins p

    SET p.DISPLAY_VOLUME = ((select display_volume from tmp_data_mins

    where RULE_APPLIED =' rule 2: three consecutive time intervals are

    missing with the period ') q

    where (to_char (p.DAYASDATE,'DD/MM/YYYY HH24')) =

    (to_char (q.DAYASDATE,'DD/MM/YYYY HH24'))

    AND p.HOURASNUMBER = q.HOURSNUMBER);


    Thanks in advance

    Your syntax is disabled, you try to make a mixture of subquery and join that is not valid.  It should be something more like:

    update of tmp_data_mins p

    SET p.DISPLAY_VOLUME = (select display_volume

    of tmp_data_mins q

    where q.RULE_APPLIED =' rule 2: three consecutive time intervals are missing the period ' and

    trunc (p.DAYASDATE, 'hh24') = trunc (q.DAYASDATE, 'hh24')

    AND p.HOURASNUMBER = q.HOURSNUMBER)

    where exists (select display_volume

    of tmp_data_mins q

    where q.RULE_APPLIED =' rule 2: three consecutive time intervals are missing the period ' and

    trunc (p.DAYASDATE, 'hh24') = trunc (q.DAYASDATE, 'hh24')

    AND p.HOURASNUMBER = q.HOURSNUMBER);

    I'm not ethat you really need the trunc applied to dates, but it is equivalent to your expression to_char, and it is generally much safer to compare dates in dates rather than convert a date to a string and compare those.

    Also note that, as wrote your query and mine updates all rows in the parameter tmp_data_mins display_volume table to null for rows that do not match the subquery.  You would (probably) need to add another predicate in the outer query the identifu only the lines that you want to update, and there are predicate using the same query in the clause set would be a likely candidate.

    That said, I don't understand what you're trying to accomplish with this update because you're updating at the same table you are querying of.  As said by Frank, a few examples of data and an explanation of what you're trying to accomplish would be useful.

    John

    After seeing just this thread https://community.oracle.com/thread/3560425 I think I understand what you're trying to do and changed the query above (I think) do the update that you want, and it seems that you have the trunc applied to dates.

    Post edited by: John Spencer

  • [Error] Run (): ORA-00907: lack the right parenthesis

    Hello world

    help out me fom this problem

    SELECT (SELECT LPAD (s.b_borough_no, 2, 0) |) '/' || LPAD (s.site_no, 6, '0')

    OF s app.sites@sfm

    ID WHERE = sit_id)

    as full_id,

    TRS.*,

    VP. FINPERID,

    VP. FINPERCH

    OF tr_review_schedules trs, TIMINGREVIEW. VP VW_FINANCIAL_PERIODS

    WHERE the trs.sched_closeout_date BETWEEN (vp. PERSTARTDATE = TO_DATE (APRIL 1, 2011 00:00:00 "," MM/DD/YYYY HH24:MI:SS')))

    AND (vp. PERENDDATE = TO_DATE (APRIL 30, 2011 00:00:00 "," MM/DD/YYYY HH24:MI:SS')))

    AND trs.trd_id IS NOT NULL

    AND trs.reportable = 'Y '.

    ORDER BY 1;

    Your problem is in him between predicate.  The format of is:

    column between value1 and value2

    I don't quite know what you're trying to do with the columns perstartdate and perenddate, but maybe something more like:

    Select (select lpad (s.b_borough_no, 2, 0) |) '/' || LPAD (s.site_no, 6, '0')

    of app.sites@sfm s

    where id = sit_id) as full_id,

    TRS.*, vp.finperid, vp.finperch

    of tr_review_schedules trs, timingreview.vw_financial_periods vp

    where trs.sched_closeout_date between vp.perstartdate and vp.perenddate and

    TRS.trd_id is not null and

    TRS.reportable = 'Y' and

    VP.perstartdate = to_date (April 1, 2011 00:00:00 ',' dd/mm/yyyy hh24:mi:ss') and

    VP.perenddate = to_date (April 30, 2011 00:00:00 ',' hh24:mi:ss' of dd/mm/yyyy)

    order by 1;

    However, I am not convinced that this is between a reasonable join between tr_review_schedules and vw_financial_periods.

    John

  • ORA-00907: lack of right parenthesis

    Hi all

    on 11.2.0.4 on Win 2008

    When executing:

    Select creele, TRUNC ((creele, 'DD')) of loans;

    I get:

    ORA-00907: missing a closing parenthesis (on column 28).

    Any idea?

    Let's see creele format:

    Select creele loans;

    CREELE

    --------

    10/11/14

    21/10/14

    Thank you.

    Can you tell me please why column A and B have different results:

    Select trunc (AVG (trunc(rendule,'DD')-trunc(creele+1,'DD')), 2) A.

    TRUNC (AVG (trunc(rendule,'DD')-trunc(creele,'DD') + 1), (2) B

    details, loans

    WHERE details.emprunt = emprunts.numero

    and borrowing. NUMBER = dΘtails. LOAN

    AND details.rendule is not null

    GROUP Member;

    Because you say to do different things. Suppose that there is just a line in your table, with a rendule of 30/04/2015 and a creele from 20/04/2015.

    A = 30/04/2015 - (20/04/2015 + 1) = 30/04/2015 - 21/04/2015 = 9

    B = 30/04/2015-4/20/2015 + 1 = 10 + 1 = 11

    If you want to arithmetic operations to be performed in a particular order, it is best to use parentheses to make the order without ambiguity. This would return the same value as the A (if that's what you want):

    TRUNC (AVG (trunc(rendule,'DD') - (TRUNC(creele,'DD') + 1)), 2).

  • My web site have a blank space in the right side when using chrome

    It seems perfectly on Safari, desktop and mobile, but in my android phone, I use chrome and nothing when I get this white ditch on the right. I even test in resizer to google to check it out and it seems fine. I only get this problem when using chrome. Has it to do with the fact that I'm the test catalyst for business?

    I think it's a bug. because when I delete some items, it works well and everything seems to be good.

    Please help me!

    Here is the link to the site

    http://bufeteostos02.BusinessCatalyst.com/index.html

    Thanks for sharing the file with me.

    You have created a black rectangle in the home page to give it a black background. This rectangle is the origin of the problem.

    I tried now to get rid of the question.

    1 remove the black rectangle of the homepage.

    2. go in the master page and fill color of the browser set to black.

    3 publish the file and it works perfectly.

    I am also you send the file with my changes.

    Kind regards

    Vivek

  • Formula node error: lack the right parenthesis

    Community salvation OR,.

    I work with the structure of nodes formula for the first time and I came across this error that I can't fix.

    He says he finds a character #, but the strange thing is that there is no character. Is there someone who can help me with this one please?

    Kind regards

    Thomas Ruts

    On your first long form you are missing a closing parenthesis.  It is in the last half of the formula.  You have two left parenthesis, but only a right.

  • One more time: lack of right parenthesis

    Hi guys,.

    I searched the forum for another thread that might give me the answer I'm looking for, but I found no one.

    I'm new to APEX and I have to build a crosstab. To do this, I founded my development on really force crosstab / Pivot report example.

    My package is completely identical it is on that page and I have adapted to the query of the report (= classic, non-interactive) based on PL/SQL, so it fits my needs, the result is:

    DECLARE

    l_return_value VARCHAR2 (32767).

    BEGIN

    l_return_value: = PK_PIVOT. PivotSQL ("SELECT * FROM"Ploegrapport - view "', 'SOD_OMSCHR_LANG, OOD_OMSCHR_LANG, ACT_OMSCHR_LANG, TAAK_OMSCHR_LANG, ORG_NIV4, ORG_NIV5', 'NK_WERKNEMER', 'MIN', 'J_N', nvl (:P2_PAGENUMBER,1));)

    RETURN l_return_value;

    END;

    When I try to run it, I get the error ORA-00907: lack the closing parenthesis.

    When I click on "debug", it changes to:

    debug logging error ORA-06502: PL/SQL: digital or value error: character string of the buffer too small ORA-00907: lack the right parenthesis

    Failed to parse the SQL query:

    ORA-00907: lack of right parenthesis

    When I then click on "debug mode" I get the following:

    ... Run the statement: declare function x return varchar2 is begin DECLARE l_return_value VARCHAR2 (32767). BEGIN l_return_value: = PK_PIVOT. PivotSQL ("SELECT * FROM"Ploegrapport - view "', 'SOD_OMSCHR_LANG, OOD_OMSCHR_LANG, ACT_OMSCHR_LANG, TAAK_OMSCHR_LANG, ORG_NIV4, ORG_NIV5', 'NK_WERKNEMER', 'MIN', 'J_N', nvl (:P2_PAGENUMBER,1));) RETURN l_return_value; END; Returns a null value. end; begin wwv_flow.g_computation_result_vc: = x; end;

    ...... Result = SELECT SOD_OMSCHR_LANG, OOD_OMSCHR_LANG, ACT_OMSCHR_LANG, TAAK_OMSCHR_LANG, ORG_NIV4, ORG_NIV5, MIN (DECODE (NK_WERKNEMER 'XXXXX' J_N, null)) as "XXXXX", MIN (DECODE (NK_WERKNEMER 'XXXXX' J_N, null)) as "XXXXX", MIN (DECODE (NK_WERKNEMER 'XXXXX' J_N, null)) as "XXXXX", MIN (DECODE(NK_WERKNEMER,XXXXX',J_N,null)) as "XXXXX", MIN (DECODE (NK_WERKNEMER Null 'XXXXX' ((, J_N,)) as "XXXXX" MIN (DECODE (NK_WERKNEMER 'XXXXX' J_N, null)) as "XXXXX", MIN (DECODE (NK_WERKNEMER 'XXXXX' J_N, null)) as "XXXXX", MIN (DECODE (NK_WERKNEMER 'XXXXX' J_N, null)) 'XXXXX', MIN (DECODE (NK_WERKNEMER 'XXXXX' J_N, null)) as "XXXXX", MIN (DECODE (NK_WERKNEMER 'XXXXX' J_N, null)) as "XXXXX", MIN (DECODE (NK_WERKNEMER, J_N ' XXXXX', null)) as 'XXXXX '. MIN (DECODE(NK_WERKNE~), MIN (DECODE (NK_WERKNEMER 'XXXXX' J_N, null)) as 'XXXXX'

    (Don't worry the XXXXX, I put it there manually because this is sensitive information, the field is actually correct and represents the names of people.) The query works when I cut the last piece, which is broken, and when I add a group, so the query he built seems to be OK

    As you can see the query in debug is actually broken after 999 characters, this is simply due to the fact that debugging will show no more than 999 characters, or is this really my problem, that the query is broken before the full statement is complete.

    If this is the first option: then where would my problem? If it's the latter: I checked the report query code and the package code and I can't find a reason why this request would be accepted to exist out of 999 characters.

    I am currently working with the test environment Oracle supplied us, because we test if we can use APEX in our company.

    The version is Application Express 4.2.2.00.11 and it is running on Oracle 11 g.

    If you need more information, just ask and I'll post it as soon as possible.

    During the validation of the responses, please keep in mind that I am a beginner at this and have trouble understanding complex responses .

    Thanks for your help!

    NDG

    Hello

    I discovered what the problem was.

    In my data, there is an employee with a '-character in his name and that's what makes the query returns an error. I tried again, this time without taking account of all the names with a '-character and that the query ran successfully, now a column made dynamically for each employee, just as I wanted.

    Thank you Tom for your efforts!

  • He had to know the right outer join using...

    He had to know the right outer join using...

    For example: first query left outer join for the emp table: SELECT EMPNO, ENAME, D.DEPTNO FROM EMP E, Department D WHERE the E.DEPTNO = D.DEPTNO)

    Second query left outer join for the Dept table: SELECT EMPNO, ENAME, D.DEPTNO FROM EMP E, Department D WHERE the D.DEPTNO = E.DEPTNO)

    In the example above I just Exchange where condition condition to get an outer join of two table with a left outer join itself. Wat is use right outer join, instead, I can swap the status of table name for the result. Please suggest...

    Hello

    chan001 wrote:

    He had to know the right outer join using...

    For example: first query left outer join for the emp table: SELECT EMPNO, ENAME, D.DEPTNO FROM EMP E, Department D WHERE the E.DEPTNO = D.DEPTNO)

    Second query left outer join for the Dept table: SELECT EMPNO, ENAME, D.DEPTNO FROM EMP E, Department D WHERE the D.DEPTNO = E.DEPTNO)

    In the example above I just Exchange where condition condition to get an outer join of two table with a left outer join itself. Wat is use right outer join, instead, I can swap the status of table name for the result. Please suggest...

    The two examples above use the old syntax outer join of Oracle. (I guess there should be a sign inside the parentheses, e.g.. +)

    ...  WHERE E.DEPTNO = D.DEPTNO (+)

    )

    The LEFT OUTER JOIN and RIGHT OUTER JOIN terms apply only to the ANSI join syntax, e. g.

    .

    .. FROM EMP E

    DEPT LEFT OUTER JOIN D ON E.DEPTNO = D.DEPTNO

    As Blushadow said above, there's no real point in having LEFT OUTER JOIN and RIGHT OUTER JOIN;  What you can do with one (or a combination of both) can be done with the other.  Most people use LEFT OUTER JOIN systematically and never use RIGHT OUTER JOIN.

    There are situations where using a combination of the two would mean a little less striking, but only a little less and this kind of situation is very common, and one may wonder if the somewhat shorter code is more specific.  I suggest that forget you RIGHT OUTER JOIN.

  • I don't have the Edit option when using my iPad

    I don't have the Edit option when using on my iPad

    The forum of cloud is not on the use of individual programs

    The forum of cloud is on the cloud as a delivery & installation process

    If you start the https://forums.adobe.com/welcome Forums Index

    You will be able to select a forum for the specific Adobe products you use

    Click on the symbol "arrow down" on the right (where it says all communities) to open the drop-down list and scroll

  • How to find the right server to use windowsmail to send and receive e-mails?

    How to find the right server to use windowsmail to send and receive e-mails?

    Who is your current e-mail server? (Which is after the @ in your address).
     
  • Error: you have an error in your SQL syntax; consult the manual for your version of the MySQL server for the right syntax to use near ')' at line 5

    Original title: how to solve this problem:

    System error

    You have an error in your SQL syntax; consult the manual for your version of the MySQL server for the right syntax to use near ')' at line 5

    Hi Roger,

    It seems that you have problems with the SQL syntax. The question you have posted is related to encoding and it would be better suited to the MSDN Community. Please report it in the community below.

    http://social.msdn.Microsoft.com/forums/SQLServer/en-us/home

    Hope this is useful.

  • Is it possible to blackBerry smartphones can remove the BBM5.0 when using OS5.0?

    Is there a way to remove the BBM5.0 when using OS5.0? I tried using DM6.0 but BBM is marked as a component of basic impossible to remove.

    I hate BBM in general because it is always on. I don't want to install an older version.

    If anyone can help me, thanks in advance.

    lusilveira wrote:

    Is there a way to remove the BBM5.0 when using OS5.0? I tried using DM6.0 but BBM is marked as a component of basic impossible to remove.

    I hate BBM in general because it is always on. I don't want to install an older version.

    If anyone can help me, thanks in advance.

    • with a few OSes 5.0.X.X, BBm is a basic application and cannot be deleted.
    • BUT the other OSes, the BBm 5.0.X.X became an addon application and can be removed. (i.e. 5.0.0.43 6 and 5.0.0.462)

    If you have the first category OS, I suggest you try and install BBm for example using AppWorld. Perhaps by upgrading BBm, it will become an add-on.

  • How to avoid opening the right panel when starting Adobe reader?

    When I open a pdf file by clicking on it, the windows acrobat opens but a lot of space is taken by a list of options on the side panel right / (such as comments, fill and sign, export file aso)-that I didn't need, and also it takes a lot of space and reduced the size of my document.

    How to avoid opening the right panel when starting Adobe reader?

    You can't avoid it.

Maybe you are looking for