XQuery and relational queries with the RAW data

So, I have a table like this setting:
CREATE TABLE book_frag
(
  book_id RAW(16),
  xpath_id INT,
  last_modified_ts TIMESTAMP,
  created_date TIMESTAMP,
  book_data XmlType,
  PRIMARY KEY(book_id, xpath_id),
  FOREIGN KEY (book_id) REFERENCES book(book_id),
  FOREIGN KEY (xpath_id) REFERENCES book_xpath(xpath_id)
);

CREATE TABLE book_xpath
(
  xpath_id INT,
  book_element_name VARCHAR2(32),
  PRIMARY KEY(xpath_id)
);
I am trying a query which will regroup the different XMLTypes book_frag into one. If I use this query, it works, but it is slow and sometimes times out:
SELECT 
    e.book_id,
    
    e.title_txt,
    e.subj_txt,
    
    e.target_mkt,
    e.target_lcl_mkt,
    
    e.catg,
    e.lang_code,
    e.out_of_stock_reas,
    
    e.sucsr_title,
    e.sucsr_sub_txt,
    
    e.orig_copy_ref,
    e.orig_subj_txt,
    
    XMLQuery(
    'declare namespace invtdata="http://www.mrbook.com/InventoryData";
    
     copy $invtData := $orig/invtdata:inventory
     
     modify
     (
       for $bkRow in fn:collection("oradb:/BOOKSCHEMA/BOOK_FRAG")
       let $bk := $mpfRow/ROW/BOOK_DATA/node()
       where xs:string($bkRow/ROW/ID)=$bookId
       return insert node $bk into $invtData
     ) return $invtData'
     PASSING XmlType('<inventory xmlns="http://www.mrbook.com/InventoryData" />') AS "orig",
     CAST(e.book_id AS VARCHAR2(64)) AS "bookId" RETURNING CONTENT
     ) AS invt_data
FROM
  entity e
WHERE e.title_txt = 'Finite Variable Analysis' OR e.subj_txt = 'Finite Mathematics';
However, if I try this, it works at all.
SELECT 
    e.book_id,
    
    e.title_txt,
    e.subj_txt,
    
    e.target_mkt,
    e.target_lcl_mkt,
    
    e.catg,
    e.lang_code,
    e.out_of_stock_reas,
    
    e.sucsr_title,
    e.sucsr_sub_txt,
    
    e.orig_copy_ref,
    e.orig_subj_txt,
    
    XMLQuery(
    'declare namespace invtdata="http://www.mrbook.com/InventoryData";
    
     copy $invtData := $orig/invtdata:inventory
     
     modify
     (
       for $bkRow in fn:collection("oradb:/BOOKSCHEMA/BOOK_FRAG")
       let $bk := $mpfRow/ROW/BOOK_DATA/node()
       where $bkRow/ROW/ID=$bookId
       return insert node $bk into $invtData
     ) return $invtData'
     PASSING XmlType('<inventory xmlns="http://www.mrbook.com/InventoryData" />') AS "orig",
     e.id AS "bookId" RETURNING CONTENT
     ) AS invt_data
FROM
  entity e
WHERE e.title_txt = 'Finite Variable Analysis' OR e.subj_txt = 'Finite Mathematics';
The error I get with this query is:
ORA-00932: inconsistent datatypes: expected - got BINARY
00932. 00000 -  "inconsistent datatypes: expected %s got %s"
*Cause:    
*Action:
Error at Line: 52 Column: 5
Is it possible to leave the XQuery to use the RAW data type (16) without casting?

KnightOfBlueArmor wrote:
Is it possible to leave the XQuery to use the RAW data type (16) without casting?

You are overloading the things, no need to XQuery Update in this case.
As far as I understand it, all you need is XMLAgg:

SELECT e.book_id
     , e.title_txt
     , e.subj_txt
     , XMLElement("inventory"
       , XMLAttributes('http://www.mrbook.com/InventoryData' as "xmlns")
       , XMLAgg( b.book_data )
       ) as inv_data
FROM entity e
     LEFT OUTER JOIN book_frag b
                  ON b.book_id = e.book_id
WHERE e.title_txt = 'Finite Variable Analysis'
   OR e.subj_txt = 'Finite Mathematics'
GROUP BY e.book_id
       , e.title_txt
       , e.subj_txt
;

(the OUTER JOIN may or may not be necessary, depending on the relationship between the two tables)

Published by: odie_63 on March 27, 2013 23:16

Tags: Database

Similar Questions

  • quickly create with filter-date and initialize it with the current date

    Oracle BI 11 g

    Hello!

    I need to create guest of dashboard with filter-date and initialize it with the current date. How can I do?

    I tried to create the repository initialization block and add a variable. But I don't know what should I write to DataSource? I tried using the Current_Date, Now(), sysdate functions (for example, SELECT Now() FROM tbl_Calendar) but without results - when I pressed the button "Test"... "I have errors - something like 'Now() is unknown function' or 'incorrect syntax near keyword Current_Date.

    After that, I made to use presentation Variable in the command prompt, but also without success (())

    Please, help me.

    Use "Server Variable.

  • Bad high and low value with the varchar2 data type

    Hello

    It is an application on e - biz on database 9205, with inventory module.

    In one of the mtl_txn_request_headers of the table, the data for the number of application type is varchar2 (30). When I checked the low_value & high_value in dab_tab_columns, I see that the low_value is 100001 (6 digits) and high_value is 99999 (5 digits).

    I used the utl_raw.cast_to_varchar2 (low_value) to convert the value.

    In our case, we save a large part of the value in incremental number and some of our query will be in the predicate of the range (between).

    How should I handle this kind of situation and which option do I?

    Appreciate any help. Thank you.

    Accepted this looks like a classic bad-data type problem, but as this picture seems be part of Oracle E-Business Suite the OP should probably talk first Oracle.

  • Im just get a blue screen, where the image should be in the develop module. What is happening with the Raw and Jpeg images. The display of the preview in the toolbar. Any ideas?

    Im just get a blue screen, where the image should be in the develop module. What is happening with the Raw and Jpeg images. The display of the preview in the toolbar. Any ideas?

    Disable GPU acceleration. Under preferences-> Performance, clear the check box

  • I have a Nikon D 810 camera and Photoshop CS5.  I downloaded camera 8.8 Raw and DNG converter.  I can't open the raw (.nef) files, and treat them with the DNG Converter. What's not?

    I have a Nikon D 810 camera and Photoshop CS5.  I downloaded camera 8.8 Raw and DNG converter.  I can't open the raw (.nef) files, and treat them with the DNG Converter. What's not?  Thank you!

    As I said earlier, the DNG Converter works ONLY on files, not on files.

    Do not target the individual files.  Target Of THE FOLDER that contains them.

    Make sure that said FILE DO NOT contain any other files , you have already settled before, or your settings will be eliminated when re-converted to DNG.

    No need to write long explanations.  More messages are, the more chances you have of receiving relevant responses.

  • do all updates to date and new features with the plan of photography?

    It's a little unclear to me if this is the case.

    Hello

    Yes absolutely, you get all the updates and new features with the plan of photography.

    You'll have to use lightroom as well as photoshop.

    Reference:-Creative Cloud price and membership plans | Adobe Creative Cloud

  • I can not get the automatic updates on my samsung jack sgh-i616. _ "connection to the update server is not available. Check your data connection settings and make sure that the device date and time are correct "___RESULT CODE: 80072ee7__ _"

    I can't get the automatic updates on my samsung jack sgh-i616.

     

    "Connection to the update server is not available. "Check your data connection settings and make sure that the device date and time are correct.

     

    RESULT CODE: 80072ee7

     

    -It is a windows mobile 6.1

    Thank you very much! = D

    As a guide.

    This error code translates ERROR_INTERNET_CANNOT_CONNECT.

    You may encounter temporary connection related errors when you use Windows Update or Microsoft Update to install updates
    http://support.Microsoft.com/kb/836941

    Harold Horne / TaurArian [MVP] 2005-2011. The information has been provided * being * with no guarantee or warranty.

  • Download all packages or just the sound with the latest dates?

    Hi, maybe it's a stupid question, but when you go to the drivers and it shows are all pilots who are selected to download to your laptop you wanted to install only those with the latest dates or each package that is there?

    Hello:

    You must install the driver with the most recent date if you are sure this is a driver that you are interested in.

  • How to create two different smart albums with photos with the same date?

    I created a smart album by using 'Date is' and ' keyword is EAA.»  (The photos have a keyword like "EAA" or "Flower".  Photos of keyword EAA & flower have the same date.)  When I use "Corresponding to all" are has no pictures in the album.  When I use "Match any" all the photos are in the album - EAA & flower.  I would like an album with only pictures of CEA for that date and another album with photos of flower with the same date.

    I get the same answer.  I can get the date and to a key word to work with 'all' selected, but not date and keywords.  So you will need two smart albums: one with date and ECA ('all' selected) and the other with date and flowers ('all' selected).

    Use the file menu option ➙ new Smart Album.

    Report the problem to Apple via https://www.apple.com/feedback/photos.html.

  • problem with the backup data in text file

    Hello

    The problem I am facing wihile, saving the data in the text file is that everytime when I'm slecting the path of the façade, data that are recorded are added with the previous data, not only in the new text, the new data set is saved but also, is there any previuos run for the program , the corresponding data is also present in this text file.

    However, when I change the same ''(file path) to 'constant' in the control block diagram, and then add the path of the file, it doesn't have this problem. Basically, changing the "file path" constant in the diagram of control block (so that it is displayed in the front panel) is at the origin of the problem.

    Help, please!

    Thank you

    Your shift on the loop Register For is not initialized. It will keep the value of the string since the last time that he performed. That initialize and it should solve your problem.

  • DLL for LabWindows/CVI 8.0 with the bool data type

    Hello

    I want to use a new SWIR camera in LabWindows/CVI 8.0 (Windows XP 32bits).

    The company delivered with the camera produced a 32-bit dll by using Microsoft Visual C++ 2010. The .dll and .lib and .h files include a working SDK/API (some functions with the bool data type)

    Compilation-online syntax error, variable Boolean is not a data type in LabWindows/CVI 8.0

    Generate the import of DLL-online syntax error library

    I tried to convert bool char (typedef unsigned char bool => no more syntax error but the functions does not work.)

    What can I do?

    Martin

    Hello again, Naumann!

    Microsoft Visual C++ 2010 represents Boolean using 1 byte, as stated by MSDN: https://msdn.microsoft.com/en-us/library/tf4dy80a(v=vs.100).aspx

    I guess that you import C++ functions using the syntax for extern "C". Otherwise, because of the C++ name mangling wouldn't you able to bind C++ library against your code CVI.

    You can also specify how you import C++ functions?

    In addition, because you have not described the problem as a corruption of heads or runtime error, I guess the C++ library function is called correctly the CVI. That said, I tend to believe that the problem is not really in the mechanism of interaction of C/C++, but in the C++ library. If you would start calling a dummy C++ function returning an integer from a simple CVI application that should work, because redefine bool in CVI 1 byte must ensure that settings are correctly transferred onto the stack.

    If you need to create a wrapper function of C++ that is not using bool and calls the C++ function, I expect to return the same result.

    Maybe you are missing a few prior initialization steps required? The provider of the camera also comes all example code?

    Best regards!

    -Johannes

  • Get the raw data to map its (SDK)

    I did a search on sound cards and many forums have been useful.  I have just a few quick questions.

    I have a card his (CardDeluxe http://www.digitalaudio.com/) connected to the computer through a PCI.  My goal is to get the raw data from the card and plug and it blow in analytics in CVI.  I don't know how to "talk" to my sound card.

    Of course, my main question is above, but to the refine some concerns...

    I guess I need the SDK libraries for that.  For this, I just need to install the MSN help libraries?

    Is this possible in the Basic Version, or if the full Package of CVI is necessary?

    I have not done things well at low altitude, but it looks like getting a wav file is necessary.  I can't use anything outside of the applications I want to eventually create a program automatically record and play at a time (sync) précis.

    Thanks in advance.

    This site is what I was looking for.  The zip file contains an exe as file c source code.

    http://paulhoule.com/phsrec/index.php

    Edit:

    There is also some info here - http://forums.ni.com/t5/LabWindows-CVI/wav/m-p/235344

  • As an operator with the long data type

    Oracle 10g.

    Hi gurus

    I want to apply as an operator on the long data type, but I get the error message, can you please help me why is that I use as an operator with the long data type. I did some research and but unable to find a solution, see query for more details below...

    Query

    SELECT trigger_body FROM user_triggers

    WHERE trigger_body LIKE '% UPDA % CASE % ';

    Error

    ORA-00932: inconsistent data types: expected NUMBER got LONG

    00932 00000 - ' incompatible data types: wait %s %s got. "

    * Cause:

    * Action:

    Error on line: column 2: 7

    Concerning

    Muzz

    Adrian Billington wrote to the top of your options.

    working with long columns

  • Problem with the RAW of Nikon NEF in Lightroom 4.4 format files

    Hello, I am trying to import files to NEF Raw of my DSLR Nikon D7200 in Lightroom 4.4. I can't preview or import the files.

    I tried to give administrative privileges Lightroom and it did not help. I copied the files directly from the SD card on my hard drive using Windows Explorer, no utility has been used.

    Are there other options for me to get these files into Lightroom for editing? I prefer not to lose the raw data I want to adjust the exposure.

    Thank you!

    Looking for the D7200 Lightroom 6. As an alternative, you can download the latest DNG Converter and use it to create copies DNG that you can use in your Lightroom. There is no native support for NEF D7200 files in Lightroom 4.4.

  • Insert/update the column with the clob data type

    Hi all

    ORCL Version: 11g.

    I have a table with the clob data type.

    Test12

    (col1 clob);

    I'm trying to insert/update to update the column with more than 4000 characters.

    But due to the limitation of tank 4000, I could not Insert/Update.

    Need your help in resolving this issue.

    THX

    Rod.

    The limit of 4000 characters is incorrect.  That pertains only to the varchar2 data type.  A clob can hold more than 4 G.

    Here is an example that shows how to insert it, I found...

    Otherwise, here is a way 'dirty' to do.

    insert into your_table (COLA, COLB)

    values

    (PRIMARY_KEY, PART 1 OF DATA)

    ;

    Update your_table

    Define COLB = COLB | PART 2 OF BIG DATA

    where COLA = PRIMARY_KEY;

    Update your_table

    Define COLB = COLB | PART 3 OF BIG DATA

    where COLA = PRIMARY_KEY;

    .. and so on...

    I don't know that I personally recommend the second style...  But he could do the job.

Maybe you are looking for

  • Cannot open Web pages in Safari of Mail

    Hello! Lately when I try to open a link from an email someone sent me it does not work with Safari. I tried to look for a solution, but I am not able to find it. Can someone help me? Thank you! Ana

  • Errors after downloading and trying to install on Vista SP2

    Running Vista Home Premimum, SP1 64-bit.  Downloaded the SP2 for Vista and get this error - ERROR_SHARING_VIOLATION (0 x 80070020) I turned weird my program McAfee and it still gives me the error.  Any help?

  • Cyber Patriots practice question!

    I joined this competition and it is to harden the computer and make sure that there is no way to be used by another host etc. And I'm running a dirty picture on a VMare and I have a problem with XP and I was wondering if I can get some tips on how to

  • "DV1000" laptop computer dv1331se

    What is the maximum hard disk Go I use in this laptop 14 dv1331se?

  • A process to save drive H F-Player performs actions writing on C drive?

    Hello Windows 8.1 runs on my SSD - c drive. Every day, I create a backup of my drive f (data) to my h drive (backup) and my i-drive (backup of backup). This cause of action will write actions on my c drive? In other words, Windows copy the source dis