problem with using with xmlnamespaces in query

Hello

IK have a document xml with the following content:

"" < xmlns:qdt invoice = "" urn: oasis: names: specification: ubl:schema:xsd:QualifiedDatatypes - 2 "xmlns:ccts =" urn: oasis: names: specification: ubl:schema:xsd:CoreComponentParameters - 2 "xmlns:stat =" "urn: oasis: names: specification: ubl:schema:xsd:DocumentStatusCode - 1.0" xmlns:cbc = "urn: oasis: names: specification: ubl:schema:xsd:CommonBasicComponents - 2" xmlns:cac = "" urn: oasis: names: specification: ubl:schema:xsd:CommonAggregateComponents - 2 "xmlns:udt =" urn: one: unece:uncefact: data: draft "" :UnqualifiedDataTypesSchemaModule:2"xmlns =" urn: oasis: names: specification: ubl:schema:xsd:Invoice - 2 "xmlns: xsi ="http://www.w3.org/2001/XMLSchema-instance"xsi: schemaLocation =" urn: oasis: names: specification: ubl:schema:xsd:Invoice - UBL 2-Bill - 2.0.xsd ">".
< cbc:UBLVersionID > 2.0 < / cbc:UBLVersionID >
< cbc:ID > 1587968432 < / cbc:ID >
< cbc:CopyIndicator > false < / cbc:CopyIndicator >
< SRC: IssueDate > 2009 - 08 - 12 < / SRC: IssueDate >
< cbc:InvoiceTypeCode > 1 < / cbc:InvoiceTypeCode >
< cbc:Note > you is < / cbc:Note >
< cbc:DocumentCurrencyCode > EUR < / cbc:DocumentCurrencyCode >
< cbc:AccountingCostCode > 45586 < / cbc:AccountingCostCode >
-< cac:OrderReference >
< cbc:ID > AFN-ORDER-156 < / cbc:ID >
< cbc:SalesOrderID > 15616156BB < / cbc:SalesOrderID >
< cbc:CustomerReference > 400 < / cbc:CustomerReference >
< / cac:OrderReference >

Now, I want to retrieve the entries.

I tried this sql statement:

SELECT inv_id
xml2sql.versie
xml2sql.cbcid
Of invoicexml_col
XMLTABLE)
XMLNAMESPACES ("urn: oasis: names: specification: ubl:schema:xsd:CommonAggregateComponents - 2' AS 'ACC'")
, "urn: oasis: names: specification: ubl:schema:xsd:CommonBasicComponents - 2' AS 'SRC'"
By default "urn: oasis: names: specification: ubl:schema:xsd:Invoice - 2'"
),
"/ Invoice" ADOPTION invoicexml_col.inv_doc
COLUMNS
Versie varchar2 (30) PATH "cbc:UBLVersionID" - DEFAULT "na".
, cbcid varchar2 (30) path 'cbc:ID '.
) xml2sql
WHERE inv_id = 2;

but I get an error that / * / cbc:UBL is not right.

When I change the order in with xmlnamespaces the query works fine:

SELECT inv_id
xml2sql.versie
xml2sql.cbcid
Of invoicexml_col
XMLTABLE)
XMLNAMESPACES ("urn: oasis: names: specification: ubl:schema:xsd:CommonBasicComponents - 2' AS 'SRC'")
, "urn: oasis: names: specification: ubl:schema:xsd:CommonAggregateComponents - 2' AS 'ACC'"
By default "urn: oasis: names: specification: ubl:schema:xsd:Invoice - 2'"
),
"/ Invoice" ADOPTION invoicexml_col.inv_doc
COLUMNS
Versie varchar2 (30) PATH "cbc:UBLVersionID" - DEFAULT "na".
, cbcid varchar2 (30) path 'cbc:ID '.
) xml2sql
WHERE inv_id = 2;

Need the use the two namespaces to retrieve the part of Orderreference.
Something like: varchar2 (30) path of the column OrderrefID ' cac:OrderReference / cbc:ID'
This does not work because only the first namespace is used.
Version of database is 10.2.0.1.0.
Someone an idea?

Try this:

SQL>  WITH invoicexml_col AS
  2   (SELECT 2 inv_id, XMLTYPE('
  3   2.0
  4   1587968432
  5   false
  6   2009-08-12
  7   1
  8   te Betalen
  9   EUR
 10   45586
 11   
 12   AFN-ORDER-156
 13   15616156BB
 14   400
 15   ') inv_doc
 16      FROM dual)
 17   SELECT inv_id
 18          , extractvalue(inv_doc,'/Invoice/cbc:UBLVersionID/text()', 'xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"') versie
 19          , extractvalue(inv_doc,'/Invoice/cbc:ID/text()', 'xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"') cbcid
 20          , extractvalue(inv_doc,'/Invoice/cac:OrderReference/cbc:ID/text()', 'xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"') orderrefid
 21     FROM invoicexml_col
 22    WHERE inv_id = 2;

              INV_ID VERSIE     CBCID      ORDERREFID
-------------------- ---------- ---------- --------------------
                   2 2.0        1587968432 AFN-ORDER-156

1 row selected.

Max
[My Italian blog Oracle | http://oracleitalia.wordpress.com/2010/01/17/supporto-di-xml-schema-in-oracle-xmldb/]

Tags: Database

Similar Questions

  • Pool pane there problem with long sql query?

    Hello

    I use Jdeveloper 11.1.2.2.0

    In the application I'm developing, there is a long sql query to call (it's a function from a package, which may take a few minutes to run) and I want to display a progress bar for the user.

    The progress bar component is a "progress indicator" and the percentage of achivement is refreshed by a component 'pool' with 1-second interval.

    The two components are connected in a javabean.

    The function with the sql query is the javabean too.

    To run the sql query that is long on background I am calling from a thread, and the pool component get the advancement of the percentage of a pipe filled with the sql function.

    If the function to run is just a long loop of java operations the progress bar works fine, but if I put my long sql query instead, stop listener pool should be performed to stop long, s sql queryo progress are updated only at the end of the long sql query.

    You have any ideas?

    Thank you

    Thanks for your replies. Unfortunately, it was not the solution to my case, sql procedures to block the entire application while ADF awaits them at the end...

    To solve my problem, I finally used a PL SQL Job to call my sql procedure (dbms_job.submit).

    The application is released right after the call and the component of the pool is not more secure!

    Kind regards

    Yann

  • Problem with the input query mode. FRM 41009, 40301

    Hi all

    I have a problem with the mode of input query. What can I say, I'm in the mode of input query, and I click on a button. I get the error THAT FRM-41009 displayed.

    Now, I've wanted handled. So I created a trigger of error in order to handle the error.

    IF ERR_CODE = 41009 THEN
    NULL;
    END IF;

    A problem is that when you use the null value, it will not terminate the mode of input query, and then I get frm-40301 error.

    Second, it's that I can't use exit_form in a trigger of the error.

    I am aware that I can press F4 to exit this mode, but I don't want to do whenever I'm sure I'll get the user complaints.

    Another solution would be to put the following code in the trigger when key pressed for each button in the form:

    If: system.mode = "ENTER-QUERY" then
    exit_form;
    end if;

    But I don't want to reproduce this code in my form.

    Please can you give me an idea how to handle this correctly?

    Thank you
    Michael

    PS: Version of the form = > ORACLE FORMS 10g (Forms [32 bit] Version 10.1.2.3.0)

    I have a problem with the mode of input query. What can I say, I'm in the mode of input query, and I click on a button. I get the error THAT FRM-41009 displayed.

    What is the code in the trigger of your button When-Button-Pressed (WBP)? Maybe you should check to see if the form is in the Mode query in your WBP rather than try and remove the error? In other words, eliminate error - do not delete it. :)

    If you want instead to remove the error, there is a technique to built-ins call restricted to a trigger that does not allow them. Do this by the use of a millisecond zero Timer. For example:

    /* Sample On-Error Trigger */
    DECLARE
      n_err_cd   NUMBER := ERROR_CODE;
      t_on_error TIMER;
      ZERO  NUMBER := 0;
    BEGIN
      IF ( n_err_cd = 41009 ) THEN
        /* Create Timer to execute Exit_Form() */
        /* to Cancel Query-Mode. */
        t_timer := Create_Timer('ON_ERROR', ZERO, NO_REPEAT);
      ELSE
        /* Handle all other errors here... */
      END IF;
    END;
    
    /* Sample When-Timer-Expired Trigger */
    DECLARE
      v_Timer  VARCHAR2(30);
    BEGIN
      v_timer := Get_Application_Property(TIMER_NAME);
    
      IF ( v_timer = 'ON_ERROR' ) THEN
        /* Notice, the timer name is case sensative! */
        Exit_Form;
      END IF;
    END; 
    

    I am aware that I can press F4 to exit this mode, but I don't want to do whenever I'm sure I'll get the user complaints.

    Well, it's just standard features of Oracle Forms. If you switch the Mode request form - you must run a query or cancel the query Mode! This is how it works. Your users need to understand that and accept it - just as they accept the functional also for other programs. ;) Another option would be to add a "Cancel request" button to your form and make it so it is enabled only when the form is placed in Query Mode. Just a thought...

    I personally prefer to prevent the occurrence of an error rather than remove the error. :)
    I hope this helps.
    Craig...

  • Problem with the simple query.

    Hi all

    I am facing problem with the query below

    Select A.COL1, A.COL2

    B.COL1, B.COL2

    FROM TABLE1 A

    TABLE 1 B

    WHERE A.header = '123'

    AND B.header = '123'

    AND nvl (A.COL6, 'ABC') = 'ABC '.

    AND NVL (B.COL6, 'DEF') = 'DEF '.

    Basically, my requiremenyt is: I have only one table, TABLE1 here, which has a line two lines (for the same header) as "ABC" and another is "DEF". Table 1 has two columns (col1, col2) that should be displayed for both lines.

    When the header has two records in table1 top query works. and but if I do not have a record for any header example there are a record for "abc" in col6 only. so my query above does not work because there is no record for 'DEF' in col6. But I want to again request to fecth the output (for b.col1 and b.col2 should have null values)

    could you pls suggest me how to get the 4 columns.

    Thanks in advance

    Kind regards

    UVA.

    Try to place the status of outer join on column: analytical_criterion_code as

    and nvl (AUDIT.analytical_criterion_code, 'AUDIT2') = 'verification2. '

    .

    .

    and nvl (TRANS.analytical_criterion_code, 'TRANS2') = 'TRANS2.

    In the sub query based on the opinions that you have given in post # 1, although there is no value "DEF * ' for col6 due to the condition of outer join on b.col6 (+) line is extracted with b.col [1,2,3] as NULL values. Try to remove the (+) sign b.col6 and test.

    with t as)

    Select 111 col1, col2 'aaa', 'ABC' col6 123 header of all the double union

    Select 222 'bbb', 'DEF' col6, 123 double header

    )

    q as (select 123 double header)

    Select A.COL1, A.COL2, A.COL6

    B.COL1, B.COL2, b.COL6

    q.header

    T a

    t b

    q

    where a.col6 (+) = 'ABC '.

    and b.col6 (+) = "DEF."

    and q.header = a.header (+)

    and q.header = b.header (+)

  • Problem with REGEXP_SUBSTR related query.

    I'm having a problem with this query:

    SELECT *.

    FROM (SELECT REGEXP_SUBSTR ('{SUMMER} |)) {} POINT OF SALE}',

    '({)([A-Z]+ *[A-Z]*)(})',

    1,

    LEVEL,

    'I,

    2)

    Val

    OF THE DOUBLE

    CONNECT BY LEVEL < =.

    REGEXP_COUNT ('{SUMMER} |) {} POINT OF SALE} ',' |') + 1)

    WHERE val IS NOT NULL

    I need the output in 2 rows in this format:

    VAL

    ====

    SUMMER

    POINT OF SALE

    But I'm not able to get the "POINT OF SALE" in the output due to space, or perhaps another reason. Anyone can correct my query?

    So, you want something like that?

    SQL > ed
    A written file afiedt.buf

    1. SELECT *.
    2 (SELECT REGEXP_SUBSTR ('{SUMMER} |)) {} POS} ',' [^ {|}] + ", LEVEL, 1, 'i') val"
    3 FROM TWO
    4. CONNECT BY LEVEL<>
    5 REGEXP_COUNT ('{SUMMER} |) {} POINT OF SALE} ',' [^ |] +'))
    6 * val WHERE IS NOT NULL
    SQL > /.

    VAL
    ------------------------
    SUMMER
    POINT OF SALE

    SQL >

  • Lost my copy and I tried to download the iso from the Microsoft web site, but my product key will not validate, pass this message: we had a problem with the validation query

    Original title: error Windows 7 installation files

    I bought a copy of Windows 7 at Tiger Direct on 22/05/2014.  I lost my copy and I tried to download the iso from the Microsoft web site, but my product key is not valid.  I get this error message

    We had a problem with the request for approval.

    FAQ

    See for other directions:

    http://answers.Microsoft.com/en-us/Windows/wiki/Windows_7-update/how-to-what-are-my-options-for-obtaining-Windows-7/528163c1-0b2e-4AD2-a26d-7112851d1dc2

  • Problem with pseudo-HIERARCHICAL query

    Hi all

    I'm writing a piece of SQL to validate the check digit in wines

    (http://en.wikipedia.org/wiki/Vehicle_identification_number#Check_digit_calculation)


    using
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    PL/SQL Release 10.2.0.5.0 - Production


    The logic in the wikipedia article can be encapsulated as follows:
    with val as (select '0' ch, 0 val from dual
                 union all
                 select '1', 1 from dual
                 union all 
                 select 'A',1 from dual
                 union all 
                 select 'J',1 from dual
                 union all 
                 select '2',2 from dual
                 union all 
                 select 'B',2 from dual
                 union all 
                 select 'K',2 from dual
                 union all 
                 select 'S',2 from dual
                 union all 
                 select '3',3 from dual
                 union all 
                 select 'C',3 from dual
                 union all 
                 select 'L',3 from dual
                 union all 
                 select 'T',3 from dual
                 union all 
                 select '4',4 from dual
                 union all 
                 select 'D',4 from dual
                 union all 
                 select 'M',4 from dual
                 union all 
                 select 'U',4 from dual
                 union all 
                 select '5',5 from dual
                 union all 
                 select 'E',5 from dual
                 union all 
                 select 'N',5 from dual
                 union all 
                 select 'V',5 from dual
                 union all 
                 select '6',6 from dual
                 union all 
                 select 'F',6 from dual
                 union all 
                 select 'W',6 from dual
                 union all 
                 select '7',7 from dual
                 union all 
                 select 'G',7 from dual
                 union all 
                 select 'P',7 from dual
                 union all 
                 select 'X',7 from dual
                 union all 
                 select '8',8 from dual
                 union all 
                 select 'H',8 from dual
                 union all 
                 select 'Y',8 from dual
                 union all 
                 select '9',9 from dual
                 union all 
                 select 'R',9 from dual
                 union all 
                 select 'Z',9 from dual)
       ,weight as (select 1 pos, 8 weight from dual
                    union all 
                    select 2, 7 from dual
                    union all 
                    select 3, 6 from dual
                    union all 
                    select 4, 5 from dual
                    union all 
                    select 5, 4 from dual
                    union all 
                    select 6, 3 from dual
                    union all 
                    select 7, 2 from dual
                    union all 
                    select 8, 10 from dual
                    union all 
                    select 9, 0 from dual
                    union all 
                    select 10, 9 from dual
                    union all 
                    select 11, 8 from dual
                    union all 
                    select 12, 7 from dual
                    union all 
                    select 13, 6 from dual
                    union all 
                    select 14, 5 from dual
                    union all 
                    select 15, 4 from dual
                    union all 
                    select 16, 3 from dual
                    union all 
                    select 17, 2 from dual)
    I can easily get the check digit for a WINE of the following logic:

        ,vm as (select row_number() over(partition by vin order by level) rn
                       , substr(vin, level,1) v
                       , vin
                    from (select 'ZAR91600006043427' vin
                            from dual
                         )
                 connect by level <= length(vin))
    select vin
         , mod(sum(checksum),11) calculated_check
         , substr(vin,9,1) existing_check
         , regexp_instr(substr(vin,9,1),mod(sum(checksum),11)) correct
      from (select val.val * weight.weight checksum
                  ,vm.vin 
              from vm
              join val on (val.ch = vm.v)
              join weight on (weight.pos = vm.rn)
      order by vm.rn)
    group by vin;
    which produces:
    VIN                              CALCULATED_CHECK                       EXISTING_CHECK                   CORRECT                                
    ZAR91600006043427                4                                      0                                0                                      
    However, I am having a little problem when I try to combine several wines of a table which I want to do rather than calculate each wine by programming:


    This, for example, produces a line for each letter of the wine ready to match with the other two CTES:
    with vehicle as (select 1000 as vehicle_id, 'ZAR91600006043427' as vin from dual
                       union all 
                     select 1001, 'XXX91600006043427' from dual)
    select level
           , substr(vin, level,1) v
           , vin
        from (select *
                from vehicle
               where vehicle_id = 1000
             )
     connect by level <= length(vin);
    I want ideally is a line for each character of each WINE. but this:
    with vehicle as (select 1000 as vehicle_id, 'ZAR91600006043427' as vin from dual
                       union all 
                     select 1001, 'XXX91600006043427' from dual)
    select level
           , substr(vin, level,1) v
           , vin
        from (select *
                from vehicle
               where vehicle_id in (1000,1001)
             )
     connect by level <= length(vin);
    product 262142 lines!

    and adding
    where vin = prior vin
    just reduced to 131070 lines...


    place a different one on the SQL produced the result that I want, but it is not scalable product lines by adding a third vehicle are exponentially more than two.

    so, in short: what is happening with my connect by statement that I'm missing?

    Hello

    Samir says:
    ... I want ideally is a line for each character of each WINE. but this:

    with vehicle as (select 1000 as vehicle_id, 'ZAR91600006043427' as vin from dual
    union all
    select 1001, 'XXX91600006043427' from dual)
    select level
    , substr(vin, level,1) v
    , vin
    from (select *
    from vehicle
    where vehicle_id in (1000,1001)
    )
    connect by level <= length(vin);
    

    product 262142 lines!

    and adding

    where vin = prior vin
    

    just reduced to 131070 lines...

    place a different one on the SQL produced the result that I want, but it is not scalable product lines by adding a third vehicle are exponentially more than two.

    so, in short: what is happening with my connect by statement that I'm missing?

    Whenever you want to debug a CONNECT BY query, put SYS_CONNECT_BY_PATH in the SELECT clause, to see how the lines are related.
    We will also cut the sting down to only 3 characters, in order to make things faster and easier to read and add ROWNUM just to make it easier to talk about the results:

    with vehicle as (select 1000 as vehicle_id, 'ABC' as vin from dual
                       union all
                     select 1001, 'XYZ' from dual)
    select level
           , substr(vin, level,1) v
           , vin
           , sys_connect_by_path ( vin
                        , ','
                        )     AS path_3
           , sys_connect_by_path ( substr (vin, level, 1)
                        , ','
                        )     AS path_1
           , ROWNUM
        from (select *
                from vehicle
               where vehicle_id in (1000,1001)
             )
    -- where     vin     = PRIOR vin
     connect by level <= length(vin);
    

    Output:

    `    LEVEL V    VIN PATH_3               PATH_1         ROWNUM
    ---------- ---- --- -------------------- ---------- ----------
             1 A    ABC ,ABC                 ,A                  1
             2 B    ABC ,ABC,ABC             ,A,B                2
             3 C    ABC ,ABC,ABC,ABC         ,A,B,C              3
             3 Z    XYZ ,ABC,ABC,XYZ         ,A,B,Z              4
             2 Y    XYZ ,ABC,XYZ             ,A,Y                5
             3 C    ABC ,ABC,XYZ,ABC         ,A,Y,C              6
             3 Z    XYZ ,ABC,XYZ,XYZ         ,A,Y,Z              7
             1 X    XYZ ,XYZ                 ,X                  8
             2 B    ABC ,XYZ,ABC             ,X,B                9
             3 C    ABC ,XYZ,ABC,ABC         ,X,B,C             10
             3 Z    XYZ ,XYZ,ABC,XYZ         ,X,B,Z             11
             2 Y    XYZ ,XYZ,XYZ             ,X,Y               12
             3 C    ABC ,XYZ,XYZ,ABC         ,X,Y,C             13
             3 Z    XYZ ,XYZ,XYZ,XYZ         ,X,Y,Z             14
    
    14 rows selected.
    

    There is no START WITH clause, so it will start by each of the 2 rows. It is very good; Take the first case of 'ABC'.
    Level = 1, we have row "ABC", so the substring added to this level is 'A'
    The lines are connected to this line to LEVEL = 2? All rows that satisfy the condition of LEVEL<= length="" (vin),="" which,="" in="" this="" sample="" set,="" means="" both="" rows.="" let's="" take="" 'abc'="" first,="" which="" is="" what="" happened="" on="" the="" line="" where="" rownum="">
    The lines are connected to this line (the line at the end of the path_3 ", ABC, ABC' ') = 3 level? All rows that satisfy the condition of LEVEL<= length="" (vin),="" which,="" in="" this="" sample="" set,="" means="" both="" rows.="" let's="" take="" 'abc'="" first,="" which="" is="" what="" happened="" on="" the="" line="" where="" rownum="">
    So far, so good; the results were exactly what we wanted. But here's where it won't.
    The lines are connected to the line at the end of the path ", ABC, ABC, ABC' level = 4?" All rows that satisfy the condition of LEVEL<= length="" (vin),="" which,="" in="" this="" sample="" set,="" means="" no="" rows.="" so="" let's="" back="" up="" the="" tree="" and="" see="" if="" any="" of="" the="" nodes="" we've="" already="" vistited="" has="" any="" other="" children.="" we="" back="" up="" to="" the="" row="" where="" path_3=',ABC,ABC' does="" 'abc'="" have="" any="" other="" children="" (that="" is,="" rows="" that="" meet="" the="" condition="" 3="">< length="" (vin)?="" yes,="" 'xyz'="" meets="" that="" condition,="" so="" 'xyz'="" is="" a="" child="" of="" 'abc',="" and="" we="" get="" the="" output="" row="" where="" rownum="">

    A CONNECT BY query WHERE clause is applied after the CONNECT BY is done. Adding a WHERE clause only deletes the rows from the result set once they have been generated. If we have a comment the WHERE clause above, the results are:

    `    LEVEL V    VIN PATH_3               PATH_1         ROWNUM
    ---------- ---- --- -------------------- ---------- ----------
             2 B    ABC ,ABC,ABC             ,A,B                1
             3 C    ABC ,ABC,ABC,ABC         ,A,B,C              2
             3 Z    XYZ ,ABC,XYZ,XYZ         ,A,Y,Z              3
             3 C    ABC ,XYZ,ABC,ABC         ,X,B,C              4
             2 Y    XYZ ,XYZ,XYZ             ,X,Y                5
             3 Z    XYZ ,XYZ,XYZ,XYZ         ,X,Y,Z              6
    

    Better, but it is still bad. All the 14 ranks were always generated, and then some of them have been excluded by the WHERE clause.
    Why the lines like the one with ROWNUM = included 3? Because the WHERE 'wine = wine PRIOR' condition is true: on this line, the wine is "XYZ", and wine PRIOR is also "XYZ". The status of research only in the last 2 levels. (PREREQUISITE may only be 1 level.) It does not matter that, earlier in the path, there is a knot where wine! = wine BEFOREHAND; This condition applies only to the finished result set. So the output row with path_3 =', ABC, XYZ "was excluded the result defined by the WHERE clause, but the descendants of this line can remain.

    Moral: If you do a query CONNECT BY and provided to connect BY is 'LEVEL '.<= x",="" then="" the="" table="" had="" better="" have="" only="" one="">
    Odie showed how to use CONNECT BY in this problem, by making the relative to the double CONNECT BY and joining your table of multiple row results.

  • problems with basic spatial query

    I am trying to learn Oracle Spatial, in collaboration with 11 g R2 and georeferenced 3D data (specifically buildings describing data in a city).

    But I'm unable to get a basic query to work on my dataset (he works for the example in the book), and I'm doing it exactly as is done in the space for 11 g Developer Guide.

    To learn how queries work, I implemented the cola_markets tables in the documentation, makes manual registration in the view user_sdo_geom_metadata and created the index. Having done this, I can run the following simple query (as well as others in the manual) on the book tables:

    SELECT SDO_GEOM. SDO_DISTANCE (c_b.shape, c_d.shape, 0.005)
    OF cola_markets c_b, c_d cola_markets
    WHERE c_b.name = 'cola_b' AND c_d.name = 'cola_d ';

    but when I try to do the same thing on my own paintings (created from citygml data), I get an error. There is the difference that the data is 3D, and that the index was created with no PARAMETERS (...), is therefore just 2D. But still I do not understand why the following query does not work:

    SELECT SDO_GEOM. SDO_DISTANCE (c_w.envelope, c_b.envelope, 0.0005)
    OF cityobject c_w,.
    cityobject c_b
    WHERE c_w.id = 50025
    AND c_b.id = 50018;

    The id for the buildings is valid, and I used the same tolerance used by software which has set up the database.

    Here is the error I get in SQL Developer:

    ORA-29532: Java call terminated by eception Java exception: java.lang.Exception: 54535
    ORA-06512: at the 'MDSYS. SDO_3GL', line 637
    ORA-06512: at the 'MDSYS. SDO_GEOM", line 1973
    ORA-06512: at the 'MDSYS. SDO_GEOM", line 1990
    29532 00000 - "Java call terminated by eception Java exception: %s."
    * Cause: A mistake or a Java exception has been reported and could not be
    solved by Java code.
    * Action: Modify Java code, if this behavior is not expected.

    So, thinking it could have something to do with the fact that it's a Java interface, I also tried to run from the command-line SQL/PL and get essentially the same thing:

    ERROR on line 1:
    ORA-29532: Java completed by eception Java exception appeal:
    java.lang.Exception: 54535
    ORA-06512: at the 'MDSYS. SDO_3GL', line 637
    ORA-06512: at the 'MDSYS. SDO_GEOM", line 1973
    ORA-06512: at the 'MDSYS. SDO_GEOM", line 1990

    Any ideas why it does not work?

    54535 error means that the geometry data are not valid.
    If you run validate_geometry_with_context on the data to check for errors and correct the data first.

    Siva

  • Problem with a join query

    Having trouble getting my head around that, so would appreciate any help.

    I run the query below, which includes a join. If I run this query through Navicat (for those who don't know, a MySQL GUI) - I get the expected result.

    I also have a similar query running on the site elsewhere with success, so I am struggling to understand why it does not work.

    The request is;

    < name cfquery = "getwatched" datasource = "#datasource #" >
    SELECT r.retailer_name, r.id, r.shortname, d.id, d.merchant_id, d.user_id, d.e_updates
    OF cc_watchlists d
    LEFT JOIN merchant r
    ON d.merchant_id = r.id
    WHERE d.user_id = #SESSION. Auth.ID #.
    ORDER BY r.retailer_name ASC
    < / cfquery >

    and the exit;

    < cfoutput query = "getwatched" >
    < TD > < a href = "page.cfm? for = #shortname #" > #retailer_name # < /a > < /dt >
    < / cfoutput >

    Error States;

    coldfusion.runtime.UndefinedVariableException: Variable SHORTNAME is undefined.

    I would appreciate any help!

    Make a the entire query just before the line which is the slightest error, and
    Make sure that it contains what you think that it contains.

    --
    Adam

  • What is the problem with this dynamic query? help

    with the following code, I get the correct answer.
    I just want to know maxempno current (and care for the 3rd, 4th tank only)

    declare
    Temp varchar2 (2);
    Start

    Select substr (A1.empno, 3, 2) in the emp A1 temp where A1.empno = (select (max (A2.empno) of emp A2) and rownum = 1;)
    HTP.p ('temp' is |) Temp)
    end;

    Temp is 34

    =====================================
    Now I need to make a call to the procedure and pass the name of a table and column

    P_CHECK_MAX
    ('emp' = > p_table,)
    ('empno' = > p_column)

    create or replace procedure 'P_CHECK_MAX '.
    (p_table in VARCHAR2,
    p_column in varchar2)

    is
    Temp varcahr2 (2);
    d_select varchar2 (500);

    Start
    d_select: ='SELECT substr (A1.'| p_column | 3: 2) IN ' | "temp" | 'FROM ' | p_table | "A1 WHERE A1.' | p_column | "= (SELECT max (A2.' | p_column |')) OF ' | p_table | ("A2) AND rownum = 1';
    immediately run d_select;

    end;

    I'm getting ORA - 00905 missing keywords. Can you help me what is the missing word here? I am stomped for hours on it.

    Published by: wanwan63 on September 29, 2009 06:23
    Sorry I reverse the setting in the call. must be p_table = > 'emp', p_column = > 'empno '.

    P_CHECK_MAX
    ("emp"-online p_table,
    'empno'-online p_column)

    It must be

    p_check_max(p_table=>'emp', p_column=> 'empno)
    

    d_select: ='SELECT substr (A1.'| p_column | 3: 2) IN ' | "temp" | 'FROM ' | p_table | "A1 WHERE A1.' | p_column | "= (SELECT max (A2.' | p_column |')) OF ' | p_table | ("A2) AND rownum = 1';
    immediately run d_select;

    IN is not part of the SQL syntax. Its syntax PL. If you can not use dynamic SQL. It should be like this

    d_select:='SELECT substr(A1.'||p_column|| ',3,2)  FROM ' || p_table || '  A1 WHERE A1.' ||p_column ||'= (SELECT max(A2.' ||p_column||') FROM ' || p_table||' A2) AND rownum=1';
    execute immediate d_select into temp;
    
  • Problem with a simple query

    Hello, I'll start by saying that I am a noob. in any case, I'm trying to do what I thought was a simple query for records that are greater or equal to the date of the day: it's my request...

    < cfquery name = "getUpcoming" datasource = 'events' >
    SELECT title, eventDate FROM event WHERE eventDate > = #Now () # ORDER BY ASC eventDate
    < / cfquery >

    It works, so, I get the records that are greater than the current date, but all records that match to are not.

    I guess that it is looking at the time as well, or should I completely wrong. I do not know? Any help would be greatly appreciated.

    Good reading up on top of (http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7f 6f.html), which you must use when you pass dynamic values to the DB, instead of hard-coding the in your SQL string.  And when using , use a param of CF_SQL_DATE type, and must ignore the time portion of the date/time value, you pass (I'm not 100% certain of this... only about 99% certain... but give it a go).  Or spend only the date part of the date/time value in the query.  Using createOdbcDate() fact, without all the extra horsing around adding things together and using the dateFormat() attribute as the previous poster suggested.

    --

    Adam

  • Wat is the problem with this simple query?

    I use 10gxe.
    This is the query that does not work
    Whenever I'm him running a pop-up windows is coming
    and asks me to enter the bind variables... Should wat I do?
    Here's a question prntscrn.

    http://potupaul.webs.com/at.html


    G_message VARIABLE VARCHAR2 (30)
    BEGIN
    : g_message: = "Œuvres of My PL/SQL block;
    END;
    /
    G_message IMPRESSION

    Edited by: user4501184 may 18, 2010 12:42 AM

    use sqlplus 't's work' ng

    run
    cmd
    sqlplus / as sysdba
    G_message VARIABLE VARCHAR2 (30)
    BEGIN
    : g_message: = "Œuvres of My PL/SQL block;
    END;
    /
    G_message IMPRESSION

    hope this helps
    Daniele

  • Can someone tell me what is the problem with this LOV query please?

    This query works very well...

    Select filter_name display_value, FILTER_ID return_value
    from OTMGUI_FILTER where username = 'ADAM '.

    But this one...

    Select filter_name display_value, FILTER_ID return_value
    from OTMGUI_FILTER where username = apex_application.g_user

    Gives the following error.

    1 error has occurred

    * LOV query is not valid, a display and a return value is needed, the column names must be different. If your query contains a query online, the first CLAUSE in the SQL statement must not belong to the query online.

    Thank you very much

    -Adam vonNieda

    Adam:

    Define the LOV query as follows

    declare
    l_val varchar2(100) := nvl(apex_application.g_user,'ADAM');
    begin
    return  'select enAME display_value, empno return_value
    from emp where deptno = '''|| l_val || ''''
    end;
    

    CITY

  • Problem with subquery

    Dear all,

    Hope that your door

    I'm having a problem with the sub query. I have to pass several ID for my sub query... but with my request, I only get the correct result...

    Here is the my sample data and my table structure...

    Employee table:

    ------------------------

    EMPLOYEE_IDNOT NULLNUMBER (16)
    EXTERNAL_ID_1VARCHAR2 (200)
    EXTERNAL_ID_2VARCHAR2 (200)
    JOB_PROFILE_TYPEVARCHAR2 (4)
    FIRST NAMENOT NULLVARCHAR2 (200)
    MIDDLE_NAMEVARCHAR2 (200)

    Table alignment:

    -------------------------

    ALIGNMENT_IDNOT NULLNUMBER (16)
    TEAM_IDNOT NULLNUMBER (16)
    EMPLOYEE_IDNUMBER (16)
    ALIGNMENT_NAMENOT NULLVARCHAR2 (200)
    EXTERNAL_ID_1VARCHAR2 (200)
    STATUSNOT NULLVARCHAR2 (4)
    STATUS_CHANGE_DATENOT NULLDATE
    MANAGER_ALIGNMENT_IDNUMBER (16)


    Event table:

    -------------------

    EVENT_IDNOT NULLNUMBER (16)
    EMPLOYEE_IDNOT NULLNUMBER (16)
    AFFILIATION_IDNUMBER (16)
    CUSTOMER_IDNUMBER (16)
    EXTERNAL_ID_1VARCHAR2 (200)

    Sample data:

    ALIGNMENT_IDALIGNMENT_NAMEEMPLOYEE_IDROLEMANAGER_ALIGNMENT_ID
    1006034672SII-KRN-BANG-A0117452000001661REP1006034513
    1006034673SII-KRN-BANG-A0218910000219453REP1006034513
    1006034674SII-KRN-BANG-A0360000001963804REP1006034513
    1006034675SII-KRN-BANG-A0560000001963706REP1006034514
    1006034676SII-KRN-BANG-A0618910000081856REP1006034514
    1006034677SII-KRN-BANG-B0160000001963699REP1006034513

    My query:

    [code]

    SELECT *.

    Ev EVENT

    INNER JOIN employee e ON e.employee_id = ev.employee_id

    INNER JOIN alignment one ON e.employee_id = a.employee_id AND alignment_id in(:alignment_id)

    [/ code]

    Description:

    I have the data stored in the table in the alignment with the child records and parent records... in the table of alignment, I have the id of the alignment_id alignment and data manager.

    Each rep there would be a single Manager. (manager_alignment_id).

    I have to integrate this query at the front end. .

    At the end I drop down values and will select more than one pass to this request...

    If the selection for alignment_id (rep) then no prob... If they select manager_alignemnt_id then how to pass this value to the query of mu...

    Thanks a lot for your help.

    I'm using the version of oracle 11g.

    Sihem...

    Ideally, the front-end server would be best to store the values in a table (global temporary) and then the request would just join this table to limit the records returned.

    If, for some reason, you can do that, and him are spent as a delimited string (not ideal according to the standards of most of the people), then you have to splits the string to provide the individual values for example

    SQL > ed
    A written file afiedt.buf

    1 Select
    2 of PEM
    3 where empno in)
    4 with t as (select '& input_string' as double txt)
    5 Select REGEXP_SUBSTR (txt, ' [^,] +', 1, level)
    6 t
    7. connect by level<=>
    8*   )
    SQL > /.
    Enter the value of input_string: 7369,7844,7788
    4 old: with t as (select '& input_string' as double txt)
    4 new: with t as (select ' 7369,7844,7788' as double txt)

    EMPNO, ENAME, JOB HIREDATE DEPTNO COMM SAL MGR
    ---------- ---------- --------- ---------- -------------------- ---------- ---------- ----------
    7369 SMITH CLERK 7902 DECEMBER 17, 1980 00:00:00 800 20
    7844 TURNER SALESMAN 7698 1981 - SEP - 08 00:00:00 1500 0 30
    7788, SCOTT, ANALYST, 7566 19 APRIL 1987 00:00:00 3000 20

  • Problem with output

    I'm trying to decode the values in the column sequence where id = 1 and the sequence is equal to 0, BUT only where there is only a single row returned for this year here.


    Oracle: 10.2 G
    -Seq_2 table data
    SEQUENCE     NAME               YEAR     NAME               ID
    1          CLE423423RK342          2002     CLE423423RK342          1
    0          MANAGE42432432R2     2002     MANAGE42432432R2     1
    2          CLE423423RK342          2002     CLE423423RK342          1
    1          SAL423423ESMAN42432     2003     SAL423423ESMAN42432     1
    0          MANA4234324GER          2003     MANA4234324GER          1
    2          SAL423423ESMAN42432     2003     SAL423423ESMAN42432     1
    0          SALES2343242MAN          2004     SALES2343242MAN          1
    2          SALESMAN42432          2005     SALESMAN42432          1
    1          CLERK342          2005     CLERK342          1
    0          CLERK               2006     CLERK               1
    0          SALESMAN          2007     SALESMAN          1
    0          SALESMAN          2007     SALESMAN          1
    2          MANAGER               2008     MANAGER               3
    1          SALESMAN          2008     SALESMAN          3
    2          MANAGER               2008     MANAGER               3
    1          SALESMAN          2008     SALESMAN          3
    1          MANAGER2          2009     MANAGER2          3
    1          MANAGER2          2009     MANAGER2          3
    Desired output
    NEW_SEQ     SEQUENCE     NAME               YEAR     NAME               ID     
    1     1          CLE423423RK342          2002     CLE423423RK342          1          
    0     0          MANAGE42432432R2     2002     MANAGE42432432R2     1                    
    2     2          CLE423423RK342          2002     CLE423423RK342          1          
    1     1          SAL423423ESMAN42432     2003     SAL423423ESMAN42432     1                    
    0     0          MANA4234324GER          2003     MANA4234324GER          1          
    2     2          SAL423423ESMAN42432     2003     SAL423423ESMAN42432     1                    
    1     0          SALES2343242MAN          2004     SALES2343242MAN          1          
    2     2          SALESMAN42432          2005     SALESMAN42432          1          
    1     1          CLERK342          2005     CLERK342          1          
    1     0          CLERK               2006     CLERK               1
    0     0          SALESMAN          2007     SALESMAN          1          
    0     0          SALESMAN          2007     SALESMAN          1          
    2     2          MANAGER               2008     MANAGER               3
    1     1          SALESMAN          2008     SALESMAN          3          
    2     2          MANAGER               2008     MANAGER               3
    1     1          SALESMAN          2008     SALESMAN          3          
    1     1          MANAGER2          2009     MANAGER2          3          
    1     1          MANAGER2          2009     MANAGER2          3          
    Current query
      select 
      case 
            when (id = 1 and sequence not in (1,2) and count(year) = 1) then
                 '1'
            else
                 sequence 
            end as new_seq,
            sequence,
            name,
            year,
            id
      from seq_2
      group by year, id, name, sequence
      order by year
    The problem with the above query is that it tunrs all 0 s 1 s in the new_sequence column, where I only want the 0 is transformed into 1 when there is only a sequence of 0 for this year.

    Published by: user652714 on February 8, 2010 10:18

    Hello

    I think you should use analytical functions, not to aggrtegate functions, for that.
    For example:

    WITH       got_year_cnt     AS
    (
         SELECT     sequence, name, year, id
         ,     COUNT (*) OVER ( PARTITION BY  year)     AS year_cnt
         FROM     seq_2
    )
    SELECT       CASE
              WHEN  id     = 1
              AND   sequence     NOT IN (1, 2)
              AND   year_cnt     = 1     THEN  1
                                     ELSE  sequence
           END     AS new_seq
    ,       sequence, name, year, name, id
    FROM       got_year_cnt
    ORDER BY  year
    ;
    

    This assumes that the sequence is a NUMBER. If it is a string, add quotes.

    If you had likke poster CREATE TABLE and INSERT instructions for the sample data, and then I could test this.

Maybe you are looking for