Query, Xquery

I'm an italian student and I need your help:
I have the following xml document that is called tiny5_LTQ-FT.mzML0.99.1.xml :
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- edited with XMLSPY v5 rel. 4 U (http://www.xmlspy.com) by Twana Johnson (Institute for Systems Biology) -->
<mzML xmlns="http://psi.hupo.org/schema_revision/mzML_0.99.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://psi.hupo.org/schema_revision/mzML_0.99.1 mzML0.99.1.xsd" accession="" id="urn:lsid:psidev.info:mzML.instanceDocuments.tiny1" version="0.99.1">
     <cvList count="1">
          <cv cvLabel="MS" fullName="Proteomics Standards Initiative Mass Spectrometry Ontology" version="2.0.2" URI="http://psidev.sourceforge.net/ms/xml/mzdata/psi-ms.2.0.2.obo"/>
     </cvList>
</mzML>
I want to select the value of the cv attribute but
-if I write doc ('dbxml:/container1.dbxml/tiny4_LTQ-FT.mzML0.99.1.xml')/*/*/*/ @ fullName it returns the exact result!
-if I write doc ('dbxml:/container1.dbxml/tiny4_LTQ-FT.mzML0.99.1.xml')/mzML/cvList/cv/@ fullName it doesn't indicate errors but the resultset remains empty
it's just an example, my document is very long and I can't use the wild cards to interrogate him.
the following class makes it:
package searchmzml2;
import com.sleepycat.dbxml.XmlDocument;
import com.sleepycat.dbxml.XmlDocumentConfig;
import com.sleepycat.dbxml.XmlManagerConfig;
import com.sleepycat.dbxml.XmlQueryExpression;
import com.sleepycat.dbxml.XmlContainer;
import com.sleepycat.dbxml.XmlException;
import com.sleepycat.dbxml.XmlInputStream;
import com.sleepycat.dbxml.XmlManager;
import com.sleepycat.dbxml.XmlUpdateContext;
import com.sleepycat.dbxml.XmlQueryContext;
import com.sleepycat.dbxml.XmlResults;
import com.sleepycat.dbxml.XmlValue;
import com.sleepycat.db.DatabaseException;
import com.sleepycat.db.Environment;
import com.sleepycat.db.EnvironmentConfig;
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.FileNotFoundException;
import javax.swing.JOptionPane;
public class VisualizzaDocumento {
public String doc="tiny4_LTQ-FT.mzML0.99.1.xml";
private static File path2DbEnv = new File("C:/mynbprogect1/search mzML2");
private static String theContainer = "container1.dbxml";
public static String id="";
/** Creates a new instance of VisualizzaDocumento */
public VisualizzaDocumento() {
// metodo per visualizzare l'id del documento
public static void asPresentazione()throws Throwable{
myDbEnv env = null;
     XmlContainer openedContainer = null;
     try {
XmlDocumentConfig conf= new XmlDocumentConfig();
conf.setWellFormedOnly(true);
     //Create an environment
     env = new myDbEnv(path2DbEnv);
     XmlManager theMgr = env.getManager();
     //Open a container in that environment
     openedContainer = theMgr.openContainer(theContainer);
     XmlQueryContext context = theMgr.createQueryContext();
String query="doc ('dbxml:/container1.dbxml/tiny5_LTQ-FT.mzML0.99.1.xml')/*/*/*/@ fullName";
XmlQueryExpression qe = theMgr.prepare(query, context);
XmlResults results = qe.execute(context);
if(results.size()==0){
// JOptionPane.showMessageDialog(null,"la query non ha prodotto risultati \n Riprova!!");
System.out.print("il resultset è vuoto");
XmlValue value = results.next();
qe.delete();
while (value != null) {
id = value.asString();
System.out.println("il valore del resulset è: "+id);
value.delete();
value = results.next();
results.delete();
     } catch (Exception e) {
System.err.println("Error performing query against " + theContainer);
System.err.println(" Message: " + e.getMessage());
throw e;
     finally {
     cleanup(env, openedContainer);
System.out.println("il metodo sembra che sia andato a buon fine");
}// end method
private static void cleanup(myDbEnv env, XmlContainer openedContainer) {
     try {
     if (openedContainer != null)
          openedContainer.close();
     if (env != null)
          env.cleanup();
     } catch (Exception e) {
System.out.println("l'errore in chiusura è il seguente" +e.getMessage());
THANK YOU SO MUCH.!
Francesco Galati

hi! I made what you wrote me and now the programm recognizes the elements but it doesen't recognize the attributes. what do I have to do for this situation?
for example:
-if I write doc ('dbxml:/container1.dbxml/tiny4_LTQ-FT.mzML0.99.1.xml')/mzML/cvList/cv/ @ * ---------it returns the exact result!
-if i write doc ('dbxml:/container1.dbxml/tiny4_LTQ-FT.mzML0.99.1.xml')/mzML/cvList/cv/ @ fullName ------------------- it doesn't indicate errors but the resultset remains empty
I wait for your answer and I send best reguards to you!
ciao ciao :)
Francesco Galati

Similar Messages

  • Multiple threads block each other, but its not a deadlock!

    I have recently upgraded to Berkeley 2.4.16/DB 4.6.21 on Linux 2.6.9-68.9.ELsmp #1 SMP 2008 x86_64 GNU/Linux
    Right away I noticed that when I run two threads, one doing a putDocument, another doing a query, they get stuck, as if they were deadlocked, however running db_deadlock does not change the quagmire.
    Here is the simplest class I could come up with that produces the problem I have been dealing with:
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.Environment;
    import com.sleepycat.db.EnvironmentConfig;
    import com.sleepycat.db.ReplicationManagerAckPolicy;
    import com.sleepycat.db.ReplicationTimeoutType;
    import com.sleepycat.dbxml.XmlContainer;
    import com.sleepycat.dbxml.XmlContainerConfig;
    import com.sleepycat.dbxml.XmlDocumentConfig;
    import com.sleepycat.dbxml.XmlManager;
    import com.sleepycat.dbxml.XmlManagerConfig;
    import com.sleepycat.dbxml.XmlQueryContext;
    import com.sleepycat.dbxml.XmlResults;
    import com.sleepycat.dbxml.XmlUpdateContext;
    import com.sleepycat.dbxml.XmlValue;
    public class TestEnvironment
        private XmlManager i_xmlManager = null;
        private XmlContainer i_container = null;
        private XmlContainerConfig i_xmlContainerConfig = null;
        private XmlDocumentConfig i_docCfg = null;
        public TestEnvironment(File dataDir, File dbErr, File dbOut)
        throws DatabaseException, FileNotFoundException
            final EnvironmentConfig cfg = new EnvironmentConfig();
            cfg.setErrorStream(new FileOutputStream(dbErr));
            cfg.setMessageStream(new FileOutputStream(dbOut));
            cfg.setAllowCreate(true);
            cfg.setInitializeLocking(true);
            cfg.setInitializeLogging(true);
            cfg.setInitializeCache(true);
            cfg.setTransactional(true);
            cfg.setRunRecovery(false);
            cfg.setTxnNoSync(true);
            cfg.setTxnNotDurable(false);
            cfg.setTxnTimeout(60000000L);
            cfg.setCacheSize(1073741824L);
            cfg.setThreaded(true);
            cfg.setInitializeReplication(false);
            cfg.setReplicationLimit(1048576L);
            cfg.setVerboseReplication(true);
            cfg.setReplicationManagerAckPolicy(ReplicationManagerAckPolicy.NONE);
            cfg.setMaxLockers(100000);
            cfg.setMaxLockObjects(100000);
            cfg.setMaxLocks(100000);
            cfg.setLockDown(false);
            cfg.setSystemMemory(false);
            cfg.setInitializeCDB(false);
            final Environment env = new Environment(dataDir, cfg);
            env.setReplicationTimeout(ReplicationTimeoutType.ACK_TIMEOUT,  100000);
            env.setReplicationTimeout(ReplicationTimeoutType.CONNECTION_RETRY, 100000);
            env.setReplicationTimeout(ReplicationTimeoutType.ELECTION_RETRY, 100000);
            env.setReplicationTimeout(ReplicationTimeoutType.ELECTION_TIMEOUT, 90000);
            final XmlManagerConfig mgrCfg = new XmlManagerConfig();
            mgrCfg.setAdoptEnvironment(true);
            mgrCfg.setAllowAutoOpen(true);
            mgrCfg.setAllowExternalAccess(false);
            XmlManager.setLogCategory(XmlManager.CATEGORY_ALL, true);
            XmlManager.setLogLevel(XmlManager.LEVEL_ALL, true);
            i_xmlManager = new XmlManager(env, mgrCfg);
            i_xmlManager.setDefaultContainerType(XmlContainer.NodeContainer);
            i_xmlContainerConfig = new XmlContainerConfig();
            i_xmlContainerConfig.setAllowValidation(false);
            i_xmlContainerConfig.setIndexNodes(true);
            i_xmlContainerConfig.setNodeContainer(true);
            i_xmlContainerConfig.setTransactional(true);  
            if (i_xmlManager.existsContainer("container.dbxml") != 0)
                i_container = i_xmlManager.openContainer("container.dbxml", i_xmlContainerConfig);
            else
                i_container = i_xmlManager.createContainer("container.dbxml", i_xmlContainerConfig);
            i_docCfg = new XmlDocumentConfig();
            i_docCfg.setGenerateName(true);
            final TestEnvironment thisRef = this;
            Runtime.getRuntime().addShutdownHook(new Thread()
                public void run()
                    try
                        thisRef.close();
                        System.out.println("Shutting down the TestEnvironment.");
                    catch (Exception e)
                        e.printStackTrace();
        public void close() throws DatabaseException
            if (i_container != null)
                i_container.close();
                i_container = null;
            if (i_xmlManager != null)
                i_xmlManager.close();
                i_xmlManager = null;
        public void insert(String doc) throws DatabaseException
            System.out.println('[' + Thread.currentThread().getName() +
            "] insert received document to be inserted");
            final long beforeT = System.currentTimeMillis();
            final XmlUpdateContext ctxt = i_xmlManager.createUpdateContext();
            i_container.putDocument(null, doc, ctxt, i_docCfg);
            final long afterT = System.currentTimeMillis();
            System.out.println('[' + Thread.currentThread().getName() +
                "] insert  took " + (afterT - beforeT) + " ms. ");
        public String[] query(String xquery) throws DatabaseException
            System.out.println('[' + Thread.currentThread().getName() +
                "] query \"" + xquery + "\" received.");
            String[] retVal = {};
            final long beforeT = System.currentTimeMillis();
            XmlQueryContext qctxt = null;
            XmlResults rs = null;
            XmlValue nextValue = null;
            try
                qctxt = i_xmlManager.createQueryContext();
                qctxt.setQueryTimeoutSeconds(10);
                rs = i_xmlManager.query(xquery, qctxt);
                if (rs != null)
                    retVal = new String[rs.size()];
                    for  (int i = 0; i < retVal.length && rs.hasNext(); i++)
                        nextValue = rs.next();
                        retVal[i] = nextValue.asString();
                        nextValue.delete();
                        nextValue = null;
            finally
                if (nextValue != null)
                    nextValue.delete();
                if (qctxt != null)
                    qctxt.delete();
                if (rs != null)
                    rs.delete();
            final long afterT = System.currentTimeMillis();
            System.out.println('[' + Thread.currentThread().getName() +
                "] query \"" + xquery + "\" took " + (afterT - beforeT) + " ms. ");
            return retVal;
    }If I call the insert and the query methods in parallel from two different threads, they will both be stuck, the former in the method com.sleepycat.dbxml.dbxml_javaJNI.XmlContainer_putDocument__SWIG_0(Native Method) and the latter in the method com.sleepycat.dbxml.dbxml_javaJNI.XmlManager_query__SWIG_2(Native Method). I would really appreciate help with this issue, I've looked through all compilation flags for db and dbxml, and all runtime configuration parameters, and I can not figure out why this is not working. Thank you!
    Edited by: gmfeinberg on Mar 26, 2009 10:41 AM for formatting

    Upon your suggestion, I added explicit transactions to my code, and now it looks like this:
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.Environment;
    import com.sleepycat.db.EnvironmentConfig;
    import com.sleepycat.db.LockDetectMode;
    import com.sleepycat.dbxml.XmlContainer;
    import com.sleepycat.dbxml.XmlContainerConfig;
    import com.sleepycat.dbxml.XmlDocumentConfig;
    import com.sleepycat.dbxml.XmlException;
    import com.sleepycat.dbxml.XmlManager;
    import com.sleepycat.dbxml.XmlManagerConfig;
    import com.sleepycat.dbxml.XmlQueryContext;
    import com.sleepycat.dbxml.XmlResults;
    import com.sleepycat.dbxml.XmlTransaction;
    import com.sleepycat.dbxml.XmlValue;
    public class TestEnvironment
        private static final int DEADLOCK_DETECTOR_INTERVAL = 5000;
        private XmlManager i_xmlManager = null;
        private XmlContainer i_container = null;
        private XmlContainerConfig i_xmlContainerConfig = null;
        private XmlDocumentConfig i_docCfg = null;
        private boolean i_shuttingDown = false;
        public TestEnvironment(File dataDir, File dbErr, File dbOut)
        throws XmlException, DatabaseException, FileNotFoundException
            final EnvironmentConfig cfg = new EnvironmentConfig();
            cfg.setErrorStream(new FileOutputStream(dbErr));
            cfg.setMessageStream(new FileOutputStream(dbOut));
            cfg.setAllowCreate(true);
            cfg.setInitializeLocking(true);
            cfg.setInitializeLogging(true);
            cfg.setInitializeCache(true);
            cfg.setTransactional(true);
            cfg.setRunRecovery(false);
            cfg.setTxnNoSync(true);
            cfg.setTxnNotDurable(false);
            //cfg.setTxnTimeout(500000L);
            cfg.setCacheSize(1073741824L);
            cfg.setThreaded(true);
            cfg.setInitializeReplication(false);
            cfg.setMaxLockers(100000);
            cfg.setMaxLockObjects(100000);
            cfg.setMaxLocks(100000);
            cfg.setLockDown(false);
            cfg.setSystemMemory(false);
            cfg.setInitializeCDB(false);
            final Environment env = new Environment(dataDir, cfg);
            final XmlManagerConfig mgrCfg = new XmlManagerConfig();
            mgrCfg.setAdoptEnvironment(true);
            mgrCfg.setAllowAutoOpen(true);
            mgrCfg.setAllowExternalAccess(false);
            XmlManager.setLogCategory(XmlManager.CATEGORY_ALL, true);
            XmlManager.setLogLevel(XmlManager.LEVEL_ALL, true);
            i_xmlManager = new XmlManager(env, mgrCfg);
            i_xmlManager.setDefaultContainerType(XmlContainer.NodeContainer);
            i_xmlContainerConfig = new XmlContainerConfig();
            i_xmlContainerConfig.setAllowValidation(false);
            i_xmlContainerConfig.setIndexNodes(true);
            i_xmlContainerConfig.setNodeContainer(true);
            i_xmlContainerConfig.setTransactional(true);  
            i_xmlContainerConfig.setStatisticsEnabled(false);
            if (i_xmlManager.existsContainer("container.dbxml") != 0)
                i_container = i_xmlManager.openContainer("container.dbxml", i_xmlContainerConfig);
            else
                i_container = i_xmlManager.createContainer("container.dbxml", i_xmlContainerConfig);
            i_docCfg = new XmlDocumentConfig();
            i_docCfg.setGenerateName(true);
            final TestEnvironment thisRef = this;
            Runtime.getRuntime().addShutdownHook(new Thread()
                public void run()
                    try
                        thisRef.close();
                        System.out.println("Shutting down the TestEnvironment.");
                    catch (Exception e)
                        e.printStackTrace();
            final Thread deadLockDetector = new Thread("deadLockDetector") {
                @Override
                public void run()
                    while (!i_shuttingDown)
                        try
                            i_xmlManager.getEnvironment().detectDeadlocks(LockDetectMode.YOUNGEST);
                            System.out.println('[' + Thread.currentThread().getName() +
                                "] ran deadlock detector.");
                            Thread.sleep(DEADLOCK_DETECTOR_INTERVAL);
                        catch (XmlException e)
                            e.printStackTrace();
                        catch (DatabaseException e)
                            e.printStackTrace();
                        catch (InterruptedException e)
                            e.printStackTrace();
            deadLockDetector.start();
        public void close() throws XmlException
            i_shuttingDown = true;
            if (i_container != null)
                i_container.close();
                i_container = null;
            if (i_xmlManager != null)
                i_xmlManager.close();
                i_xmlManager = null;
        public void insert(String doc) throws XmlException
            System.out.println('[' + Thread.currentThread().getName() +
                "] insert received document to be inserted");
            final long beforeT = System.currentTimeMillis();
            final XmlTransaction txn = i_xmlManager.createTransaction();
            try
                i_container.putDocument(txn, null, doc, i_docCfg);
                txn.commit();
            catch (XmlException e)
                txn.abort();
                throw e;
            finally
                txn.delete();
            final long afterT = System.currentTimeMillis();
            System.out.println('[' + Thread.currentThread().getName() +
                "] insert  took " + (afterT - beforeT) + " ms. ");
        public String[] query(String xquery) throws XmlException
            System.out.println('[' + Thread.currentThread().getName() +
                "] query \"" + xquery + "\" received.");
            String[] retVal = {};
            final long beforeT = System.currentTimeMillis();
            XmlQueryContext qctxt = null;
            XmlResults rs = null;
            XmlValue nextValue = null;
            final XmlTransaction txn = i_xmlManager.createTransaction();
            try
                qctxt = i_xmlManager.createQueryContext();
                qctxt.setQueryTimeoutSeconds(10);
                rs = i_xmlManager.query(txn, xquery, qctxt);
                if (rs != null)
                    retVal = new String[rs.size()];
                    for  (int i = 0; i < retVal.length && rs.hasNext(); i++)
                        nextValue = rs.next();
                        retVal[i] = nextValue.asString();
                        nextValue.delete();
                        nextValue = null;
                txn.commit();
            catch (XmlException e)
                txn.abort();
                throw e;
            finally
                txn.delete();
                if (nextValue != null)
                    nextValue.delete();
                if (qctxt != null)
                    qctxt.delete();
                if (rs != null)
                    rs.delete();
            final long afterT = System.currentTimeMillis();
            System.out.println('[' + Thread.currentThread().getName() +
                "] query \"" + xquery + "\" took " + (afterT - beforeT) + " ms. ");
            return retVal;
    }For the purpose of brevity I omitted the main method, but it merely runs two parallel threads -- one inserting a collection of different XML documents, the other -- querying. Each thread runs a semi-tight loop with a 10 millisecond sleep after each iteration. The documents being inserted are all fairly similar, and well-formed. Here is what happens: if I do not set a maximum transaction timeout, every SINGLE concurrent pair of inserts/queries results in a deadlock, that is only broken when the deadlock detector thread runs every five seconds. Our application does require massive inserts/quieries run in parallel sometimes. If I do set a maximum transaction timeout that expires before the deadlock detector thread runs, I get the following exception:
    com.sleepycat.dbxml.XmlException: Error: DB_LOCK_NOTGRANTED: Lock not granted, errcode = DATABASE_ERROR
            at com.sleepycat.dbxml.dbxml_javaJNI.XmlContainer_putDocument__SWIG_3(Native Method)
            at com.sleepycat.dbxml.XmlContainer.putDocument(XmlContainer.java:736)
            at com.sleepycat.dbxml.XmlContainer.putDocument(XmlContainer.java:232)
            at com.sleepycat.dbxml.XmlContainer.putDocument(XmlContainer.java:218)
            at TestEnvironment.insert(TestEnvironment.java:178)
            at TestEnvironment$3.run(TestEnvironment.java:327)which does not seem to be a deadlock.
    Now I understand that deadlocks are a fact of life, but I thought they were statistically rare, and in this scenario every single insert/query pair results in a deadlock. The same code works without any deadlocks in the Berkeley DB XML 2.3/Berkeley DB 4.5 combination
    Could there be a patch or a bugfix that I missed? This seems very very suspicious. I also tried the same code on both Linux and Windows with the same result
    Thank you,
    Alexander.

  • "No service implementation available" with adhoc template in 1.3

    Hello
    I'm trying to use the adhoc template available since 1.3, using "X" global variables for connection name, system, query name and query type ...
    And I systematically get the error message :
    "No service implementation available"
    query could not be loaded
    I know that some have faced this issue and that it's known from many specialists here...
    - I've checked that everything is OK when I don't use the variables and execute the adhoc template app as a standard one (incl. the DSource, everything works well).
    - I've also checked that the olap connection language was not saved (it solved most of the cases described in the community)
    But I still have it.
    Any idea?
    Thanks a lot in advance
    Best Regards

    Hello Karol
    Thanks a lot for your answer.
    In fact it all has to do with events order : datasource manually assigned in designer will be initialized before X parameters evaluation, so if this datasource is an inexisting one, I'll get an error message before X parameters evaluation.
    Understood!
    It's not a problem to manually assign the datasource in designer.
    By the way, if you refer to Michael Howles "making-adhoc-analysis-template-images-and-css-work" document, you have to manually set at least the datasource connection, whether or not it is replaced at run time by XSYSTEM parameter, to make the template work on BI platform.
    So it works with a manually assigned query, as soon as this query exists : OK it's useless in case of X parameters usage, as this query will be initialized and immediately replaced by the one defined in the XQUERY parameter, but it works. It was not working for me (no effect from X parameters) because the manually assigned query was wrong and execution was some kinda stopped after the error message.
    Question)
    Finally, this template doesn't work for me (same error message : no service implementation available) if I use the system alias in the XSYSTEM parameter (for example "B73"). It works only if I use the cuid of the OLAP connection defined in the CMC (...&XSYSTEM=cuid:AUoUxgljSKNFkFeselrOJ1Q&XQUERY=DSTUDIO_DASH_4&XTYPE=BW). When I look at the adhoc template start up script :
    DS_1.assignDataSource(XSYSTEM, DataSourceType.QUERY, XQUERY);
    the assigndatasource method first parameter is supposed to be set with that kind of cuid : even if the contextual help describes a "Q99" parameter as an example - i.e. the connection name - in fact it doesn't accept this "name" format ; furthermore, using the wizard leads to a cuid anyway!
    DS_1.assignDataSource("cuid:AUoUxgljSKNFkFeselrOJ1Q", DataSourceType.QUERY, "DSTUDIO_DASH_4");
    I guess it's not normal, because both contextual help, documentation and tutorial (where "HBW" is used as XSYSTEM parameter) would then be wrong, and because this template would not be user friendly at all, if cuid were mandatory, as no one knows them by heart.
    So where did I go wrong? Do you have any idea why I can't use connection alias ?
    Thanks in advance,
    Regards
    Rémi
    DS 1.3 SP0, BI Platform

  • SSMS 2012:XQuery-doing "Retriving Job Candidates with the query Method" in AdventuresWorks 2012. Unclosed quotation mark after string '//*:Name.First?

    Hi all,
    From Page 354 of the the Book "Pro T-SQL 2008 Programmer's Guide" written by Michael Coles (published by apress), I copied the following code (Listing 12-9 Retrieving Job Candidates with the query Method):
    --Coles12_9.sql // saved in C:/Documemnts/SQL Server Management Studio
    -- Coles Listing 12-9 Retrieving Job Candidates with the query Method
    -- Doing XQuery and the xml Data Type in AdvantureWorks
    -- 17 March 2015 1105 AM
    USE AdventureWorks;
    GO
    SELECT Resume.query
    N'//*:Name.First,
    //*:Name.Middle,
    //*:Name.Last,
    //*:Edu.Level
    FROM HumanResources.JobCandidate;
    I executed this set of Listing 12-9 code in my SQL Server 2012 Management Studio and I got the following error messages:
    Msg 105, Level 15, State 1, Line 4
    Unclosed quotation mark after the character string '//*:Name.First,
    //*:Name.Middle,
    //*:Name.Last,
    //*:Edu.Level
    FROM HumanResources.JobCandidate;
    Msg 102, Level 15, State 1, Line 4
    Incorrect syntax near '//*:Name.First,
    //*:Name.Middle,
    //*:Name.Last,
    //*:Edu.Level
    FROM HumanResources.JobCandidate;
    I am not able to figure out why I got the error messages.  Please kindly help and advise me how to correct this set of sql codes.
    Thanks in advance,
    Scott Chang

    Hi Scott,
    I don't have that book at hand, but your problem is the "Unclosed quotationmark after the character string",as the error message shows. You have to enclose the 'XQUERY' string quotation in the
    query().
    SELECT jobcandidateid, Resume.query
    N'//*:resume,
    //*:Name.Middle,
    //*:Name.Last,
    //*:Edu.Level' --enclose the quotation here
    FROM HumanResources.JobCandidate;
    For XQUERY learning, here is a good
    link.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • SQL Server 2012 Management Studio: XML XQuery-query the XML Blob using CTE: How to specify the coorelation name in bulk rowset?

    Hi all,
    I just started doing the XML Xquery programming in my SQL Server 2012 Management Studio. I executed the following code:
    --query the XML Blob using a CTE (pulling from the XML file each time) Products
    WITH XmlFile (Contents) AS (
    SELECT CONVERT (XML, BulkColumn)
    FROM OPENROWSET (BULK 'H:\Products.xml', SINGLE_BLOB) ) AS XmlData
    SELECT *
    FROM XmlFile
    GO
    I got the the following Msg:
    Msg 491, Level 16, State 1, Line 4
    A correlation name must be specified for the bulk rowset in the from clause.
    How can I specify the correction name for the bulk rowset in my project?
    Please kindly help, advise and respond.
    Thanks in advance,
    Scott Chang

    Hello Scott,
    You have to assign a table alias for the OPENROWSET =>
    --query the XML Blob using a CTE (pulling from the XML file each time) Products
    WITH XmlFile (Contents) AS (
    SELECT CONVERT (XML, BulkColumn)
    FROM OPENROWSET (BULK 'H:\Products.xml', SINGLE_BLOB) AS MyXML ) AS XmlData
    SELECT *
    FROM XmlFile
    GO
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Querying RESOURCE_VIEW using XQuery

    Hi all:
    Anybody knows the best way to query RESOURCE_VIEW using XQuery to show directory listing information as an example.
    For example, I want to produce an XML Document with something like this using XQuery:
    <directoryListing>
    <dir anyPath="/public/JURRICULUM/cms/en">
    <DisplayName xmlns="http://xmlns.oracle.com/xdb/XDBResource.xsd">en</DisplayName>
    </dir>
    <dir anyPath="/public/JURRICULUM/cms/en/live">
    <DisplayName xmlns="http://xmlns.oracle.com/xdb/XDBResource.xsd">live</DisplayName>
    </dir>
    <dir anyPath="/public/JURRICULUM/cms/es">
    <DisplayName xmlns="http://xmlns.oracle.com/xdb/XDBResource.xsd">es</DisplayName>
    </dir>
    <dir anyPath="/public/JURRICULUM/cms/es/live">
    <DisplayName xmlns="http://xmlns.oracle.com/xdb/XDBResource.xsd">live</DisplayName>
    </dir>
    </directoryListing>
    I made this result by executing this query:
    SELECT XMLQuery('declare namespace res = "http://xmlns.oracle.com/xdb/XDBResource.xsd";
    <directoryListing>
    {for $i in $directoryListing/dir
    where $i/res:Resource/@Container="true"
    return
    <dir anyPath="{$i/@ANY_PATH}">
    {$i/res:Resource/res:DisplayName}
    </dir>}
    </directoryListing>'
    PASSING (
    select XMLAgg(XMLElement("dir",XMLATTRIBUTES(any_path,resid),res))
    from resource_view where
    under_path(res,'/public/JURRICULUM/cms')=1
    ) as "directoryListing" RETURNING CONTENT).getStringVal()
    FROM dual
    I had injected resource_view's content as an argument.
    Another way is to use ora:view() extension function, but I can't use under_path functionality for example.
    Is there some extension funcion like doc() or collection() but instead of returning the content of the document, returning the information of resource_view asociated to the URI?
    Is the above query optimal in term of execution plan?
    I tested it with JDeveloper and shows an execution plan similar to the query on resource_view alone.
    Best regards, Marcelo.

    Hi all:
    I had implemented an XQuery extension library ready to run inside the Oracle JVM, but it can run outside as well.
    The code is on the XQuery forums:
    How to write an XQuery Extension library
    I tested outside the database and the result is:
    /usr/java/jdk1.5.0_04/bin/java -hotspot -classpath ... com.prism.cms.xquery.Application1 /public/PCT_ADMIN/cms/es/3-AcercaParque/ 7934
    testXQL elapsed time: 3094
    testXQ elapsed time: 2164
    Running as Java Stored Procedure, it looks like this:
    SQL> exec testXQ('/public/PCT_ADMIN/cms/es/3-AcercaParque/','7934')
    testXQL elapsed time: 943
    testXQ elapsed time: 854
    PL/SQL procedure successfully completed.
    Obviously running as Java Stored procedure its around 3.5 faster than a regular application.
    Injecting the resource_view content as an argument instead of using an XQuery extension library seem to be equals (943 ~ 854), so I'll use the extension library mechanish for clearlying on the code.
    Best regards, Marcelo

  • XQuery query over just one single xml file returns data but query over lots of XML didn't return any data.

    Hello,
    Please, help me.
    I am depending on this query working fine to complete a academic task.
    On the Oracle xml database Express version 11.2.0.2.0 I used data from wikipedia to populate my table of XML files and W3C use case as a query model (XQuery and XPath Full Text 1.0 Use Cases).
    I have a table with 26.416 split xml files into some xml columns, it is about 512 MB.
    CREATE TABLE tb_wikipedia_inex (DOC VARCHAR(30) NOT NULL,
                                    XML XMLTYPE,
                                    PRIMARY KEY (DOC)
    I want to perform a query (full text) on all those files but when I execute a xquery it retuns nothing or warnings. Unfortunatelly I understand nothing from trace file.
    SQLPLUS:
    XQUERY  fn:collection("oradb:/HR/TB_INEX2009")//article//language  [ora:contains(., "java") > 0]
    TRACE FILE:
    System altered.
    Elapsed: 00:00:42.08
    Session altered.
    Elapsed: 00:00:00.00
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00
    Elapsed: 00:00:00.05
    Execution Plan
    Plan hash value: 1500681423                                                                      
    | Id  | Operation                           | Name                   | Rows  | Bytes | Cost (%CPU)|
    Time     |                                                                                       
    |   0 | SELECT STATEMENT                    |                        |  8168 | 16336 |    29   (0)|
    00:00:01 |                                                                                       
    |   1 |  COLLECTION ITERATOR XMLSEQ FETCH   | XMLSEQUENCEFROMXMLTYPE |  8168 | 16336 |    29   (0)|
    00:00:01 |                                                                                       
    |   2 |   SORT AGGREGATE                    |                        |     1 |     2 |            |
             |                                                                                       
    |*  3 |    COLLECTION ITERATOR PICKLER FETCH| XMLSEQUENCEFROMXMLTYPE |   408 |   816 |    66  (57)|
    00:00:01 |                                                                                       
    Predicate Information (identified by operation id):                                              
       3 - filter(SYS_XMLCONTAINS(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(SYS_XQEXTRACT(SYS_XQCON2SEQ(VALUE(KOKBF$
                  ,'/language/text()'),1,50),50,1,0),'java')>0)                                      
    Note                                                                                             
       - Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)       
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00
    How can I execute xquery over a bunch of xml files to obtain xml data?
    Regards,
    Daiane

    Hello,
    I was trying to find what is the problem, but without success.
    The most simple test don't work.
    So, I created a new table with few xml files to reproduce the query.
    Below are my scripts:
    XML COLUMN  SQLPLUS
    CREATE TABLE HR.tb_xml (DOC VARCHAR(30) NOT NULL,
                                               XML XMLTYPE,PRIMARY KEY (DOC))
    CREATE INDEX HR.Ixml_tb_xml ON HR.tb_xml (XML)  INDEXTYPE IS XDB.XMLINDEX  PARAMETERS ('PATHS (INCLUDE(//article
                                                                                                                       //article/physical_entity/communicator/person/compiler/causal_agent/language))')
    CREATE INDEX Itxt_tb_xml1  ON HR.tb_xml (XML)  INDEXTYPE IS CTXSYS.CONTEXT;
    Shell:
    nohup sqlldr daiane/daiane DIRECT=false PARALLEL=false control = load_xml.ctl;
    XML TABLE SQLPLUS:
    create table livros of XMLTYPE;
    Shell:
    nohup sqlldr daiane/daiane DIRECT=false PARALLEL=false control = load_xmltb.ctl;
    XML Files:
    https://www.dropbox.com/sh/sn26jq6fjoi4635/0wjJI6tT4h
    Queries:
    for XQUERY  fn:collection("oradb:/HR/TB_XML")//article/physical_entity/communicator/person/compiler/causal_agent/language/writer/header/categories/category [ora:contains(., "PHP") > 0]
    XQUERY  fn:collection("oradb:/HR/TB_XML")//article/physical_entity/communicator/person/compiler/causal_agent/language/writer/header/title [ora:contains(text(), "PHP") > 0]
    for XQUERY  fn:collection("oradb:/HR/LIVROS")//article/physical_entity/communicator/person/compiler/causal_agent/language/writer/header/categories/category [ora:contains(., "PHP") > 0]
    XQUERY  fn:collection("oradb:/HR/LIVROS")//article/physical_entity/communicator/person/compiler/causal_agent/language/writer/header/title [ora:contains(text(), "PHP") > 0]
    What is wrong with these queries?
    Regards,
    Daiane

  • Query in using = operator in xquery

    I am using the >= operator in one of the where condition as:
    declare function tns:getFactDlyOrdersTimePerdEndInRange(
    $timePerdEndDateFrom as xs:dateTime, $timePerdEndDateTo as xs:dateTime)
    as element(ns19:SymphOrdersDly)* {
    fn-bea:fence(
    for $SymphOrdersDly in ns20:SymphOrdersDly()
    where $timePerdEndDateFrom < $SymphOrdersDly/TIME_PERD_END_DATE
    and $timePerdEndDateTo >= $SymphOrdersDly/TIME_PERD_END_DATE
    Here i am getin the query plan fine but when i am using this function in one of the other dataservice the query plan generated is not proper.
    for $SymphOrdersDly in ns7:getFactDlyOrdersTimePerdEndInRange($lastDayCurrMthOrders, $lastDayNextMthOrders)

    1) Never use fn-bea:fence unless you have opened a case with customer support and they have explicitly told you to use it. If they have, only use it where they have told you.
    2) You have not provided any information on what you mean by "the query plan generated is not proper"
    3) You have not provided your DSP project/dataspace, so I have no idea what getFactDlyOrdersTimePerdEndInRange does.
    You might look at http://forums.bea.com/thread.jspa?threadID=300003921

  • Need help with Querying XML - XQuery

    Hey guys, im new to this stuff so  I gained some knowledge from internet but I'm running is some problem that I'll explain below. I have XML like:  
    <?xml version="1.0" encoding="iso-8859-1"?>
    <star:ShowLaborOperations xmlns:star="http://www.starstandard.org/STAR/5" releaseID="5.4.4">
    <star:ApplicationArea>
    <star:Sender>
    <star:CreatorNameCode>AD</star:CreatorNameCode>
    <star:SenderNameCode>DDDD</star:SenderNameCode>
    <star:SystemVersion>AD2.0</star:SystemVersion>
    </star:Sender>
    <star:CreationDateTime>2011-05-06T12:51:33Z</star:CreationDateTime>
    <star:BODID>A29BF24F-F68E-5CE5-E040-35A54242A0C</star:BODID>
    <star:Destination>
    <star:DestinationNameCode>AD</star:DestinationNameCode>
    </star:Destination>
    </star:ApplicationArea>
    <star:ShowLaborOperationsDataArea>
    <star:Show>
    <oagis:ResponseCriteria xmlns:oagis="http://www.openapplications.org/oagis/9">
    <oagis:ChangeStatus>
    <oagis:Description>Changes</oagis:Description>
    </oagis:ChangeStatus>
    </oagis:ResponseCriteria>
    </star:Show>
    <star:LaborOperations>
    <star:LaborOperationsHeader>
    <star:RequestCode>Changes</star:RequestCode>
    <star:LaborOperationsHeaderBase>
    <star:DocumentIdentificationGroup>
    <star:DocumentIdentification>
    <star:DocumentID>ShowOperationCode20110506050532TY</star:DocumentID>
    </star:DocumentIdentification>
    </star:DocumentIdentificationGroup>
    </star:LaborOperationsHeaderBase>
    <star:LaborOperationCodes/>
    </star:LaborOperationsHeader>
    <star:LaborOperationsDetail>
    <star:LaborOperationID>001020</star:LaborOperationID>
    <star:MajorGroupID>00</star:MajorGroupID>
    <star:ComponentGroupID>01</star:ComponentGroupID>
    <star:LaborOperationDescription>GAS TANK FILL</star:LaborOperationDescription>
    <star:LaborActionCode>OTH</star:LaborActionCode>
    <star:LaborOperationsChangeStatus>U</star:LaborOperationsChangeStatus>
    <star:Combinations>
    <star:VehicleGroupLaborAllowance>
    <star:VehicleIdentificationGroup>
    <star:VehicleGroupID>JTN</star:VehicleGroupID>
    <star:VehicleID>JJXB0</star:VehicleID>
    </star:VehicleIdentificationGroup>
    <star:ChangeStatus>A</star:ChangeStatus>
    <star:LaborAllowanceMeasure unitCode="hour">0.0</star:LaborAllowanceMeasure>
    <star:ChargeHoursIndicator>false</star:ChargeHoursIndicator>
    </star:VehicleGroupLaborAllowance>
    <star:VehicleGroupLaborAllowance>
    <star:VehicleIdentificationGroup>
    <star:VehicleGroupID>JTM</star:VehicleGroupID>
    <star:VehicleID>ZF32V</star:VehicleID>
    </star:VehicleIdentificationGroup>
    <star:ChangeStatus>U</star:ChangeStatus>
    <star:LaborAllowanceMeasure unitCode="hour">0.6</star:LaborAllowanceMeasure>
    <star:ChargeHoursIndicator>true</star:ChargeHoursIndicator>
    </star:VehicleGroupLaborAllowance>
    </star:Combinations>
    </star:LaborOperationsDetail>
    </star:LaborOperations>
    </star:ShowLaborOperationsDataArea>
    </star:ShowLaborOperations>
    and I wanna be able to see the following result: 
    <LaborOperationsDetail xmlns="http://www.starstandard.org/STAR/5">
    <LaborOperationID>001020</LaborOperationID>
    <MajorGroupID>00</MajorGroupID>
    <ComponentGroupID>01</ComponentGroupID>
    <LaborOperationDescription>GAS TANK FILL</LaborOperationDescription>
    <LaborActionCode>OTH</LaborActionCode>
    <LaborOperationsChangeStatus>U</LaborOperationsChangeStatus>
    <Combinations>
    <VehicleGroupLaborAllowance>
    <VehicleIdentificationGroup>
    <VehicleGroupID>JTN</VehicleGroupID>
    <VehicleID>JJXB0</VehicleID>
    </VehicleIdentificationGroup>
    <ChangeStatus>A</ChangeStatus>
    <LaborAllowanceMeasure unitCode="hour">0.0</LaborAllowanceMeasure>
    <ChargeHoursIndicator>false</ChargeHoursIndicator>
    </VehicleGroupLaborAllowance>
    </Combinations>
    </LaborOperationsDetail>
    for which I'm writing the following query 
    SELECT OpCodeXMLCol.query('
    declare default element namespace "http://www.starstandard.org/STAR/5";
    /ShowLaborOperations/ShowLaborOperationsDataArea/LaborOperations/LaborOperationsDetail[Combinations/VehicleGroupLaborAllowance/VehicleIdentificationGroup/VehicleGroupID="JTN"][LaborOperationID="001020"]
    -- specified [LaborOperationID="001020"] because there are multiple <LabrOperationDetial> ') as x
    FROM XMLData.dbo.OpCodeData
    where [ID] = 3 -- primary key for that row containing XML in first snippet
    but I'm getting both nodes for <VehicleIdentificatonGroup> whereas I expect to see one containing <VehicleGroupID>JTN</VehicleGroupID> as per filter in query. Please help

    The closest thing which makes sense:
    DECLARE @Data XML = N'
    <star:ShowLaborOperations xmlns:star="http://www.starstandard.org/STAR/5" releaseID="5.4.4">
    <star:ApplicationArea>
    <star:Sender>
    <star:CreatorNameCode>AD</star:CreatorNameCode>
    <star:SenderNameCode>DDDD</star:SenderNameCode>
    <star:SystemVersion>AD2.0</star:SystemVersion>
    </star:Sender>
    <star:CreationDateTime>2011-05-06T12:51:33Z</star:CreationDateTime>
    <star:BODID>A29BF24F-F68E-5CE5-E040-35A54242A0C</star:BODID>
    <star:Destination>
    <star:DestinationNameCode>AD</star:DestinationNameCode>
    </star:Destination>
    </star:ApplicationArea>
    <star:ShowLaborOperationsDataArea>
    <star:Show>
    <oagis:ResponseCriteria xmlns:oagis="http://www.openapplications.org/oagis/9">
    <oagis:ChangeStatus>
    <oagis:Description>Changes</oagis:Description>
    </oagis:ChangeStatus>
    </oagis:ResponseCriteria>
    </star:Show>
    <star:LaborOperations>
    <star:LaborOperationsHeader>
    <star:RequestCode>Changes</star:RequestCode>
    <star:LaborOperationsHeaderBase>
    <star:DocumentIdentificationGroup>
    <star:DocumentIdentification>
    <star:DocumentID>ShowOperationCode20110506050532TY</star:DocumentID>
    </star:DocumentIdentification>
    </star:DocumentIdentificationGroup>
    </star:LaborOperationsHeaderBase>
    <star:LaborOperationCodes/>
    </star:LaborOperationsHeader>
    <star:LaborOperationsDetail>
    <star:LaborOperationID>001020</star:LaborOperationID>
    <star:MajorGroupID>00</star:MajorGroupID>
    <star:ComponentGroupID>01</star:ComponentGroupID>
    <star:LaborOperationDescription>GAS TANK FILL</star:LaborOperationDescription>
    <star:LaborActionCode>OTH</star:LaborActionCode>
    <star:LaborOperationsChangeStatus>U</star:LaborOperationsChangeStatus>
    <star:Combinations>
    <star:VehicleGroupLaborAllowance>
    <star:VehicleIdentificationGroup>
    <star:VehicleGroupID>JTN</star:VehicleGroupID>
    <star:VehicleID>JJXB0</star:VehicleID>
    </star:VehicleIdentificationGroup>
    <star:ChangeStatus>A</star:ChangeStatus>
    <star:LaborAllowanceMeasure unitCode="hour">0.0</star:LaborAllowanceMeasure>
    <star:ChargeHoursIndicator>false</star:ChargeHoursIndicator>
    </star:VehicleGroupLaborAllowance>
    <star:VehicleGroupLaborAllowance>
    <star:VehicleIdentificationGroup>
    <star:VehicleGroupID>JTM</star:VehicleGroupID>
    <star:VehicleID>ZF32V</star:VehicleID>
    </star:VehicleIdentificationGroup>
    <star:ChangeStatus>U</star:ChangeStatus>
    <star:LaborAllowanceMeasure unitCode="hour">0.6</star:LaborAllowanceMeasure>
    <star:ChargeHoursIndicator>true</star:ChargeHoursIndicator>
    </star:VehicleGroupLaborAllowance>
    </star:Combinations>
    </star:LaborOperationsDetail>
    </star:LaborOperations>
    </star:ShowLaborOperationsDataArea>
    </star:ShowLaborOperations>
    WITH XMLNAMESPACES ( DEFAULT 'http://www.starstandard.org/STAR/5' )
    SELECT LaborOperationsDetail.query('.'),
    VehicleGroupLaborAllowance.query('.')
    FROM @Data.nodes('/ShowLaborOperations/ShowLaborOperationsDataArea/LaborOperations/LaborOperationsDetail') A ( LaborOperationsDetail )
    CROSS APPLY LaborOperationsDetail.nodes('Combinations/VehicleGroupLaborAllowance[VehicleIdentificationGroup/VehicleGroupID="JTN"]') B ( VehicleGroupLaborAllowance );
    Otherwise we need to destruct and rebuild the XML. This in this case imho better done with XSLT.

  • XQuery select query is not working in proper speed

    In our project we have large no. data (its a property listing site) and I'm storing that data to Barkeley DB (XML DB). The problem is when I am searching for a property it will list the first 10 property quickly(100% speed). Then I'm going to 2dn, 3rd page its working in the same speed. But if I'm going to 10th(30% speed) or 100th or 1500th(15%speed) page is working very slowly.
    Following are my query:
    let $property_ids:=
    for $property in collection('bdb/properties.dbxml')/properties/property
    order by $property/sale_price/number() descending
    return $property/@property_id,
    for $property in collection('bdb/properties.dbxml')/properties/property
    order by $property/sale_price/number() descending
    return $property/@property_id,
    for $property in collection('bdb/properties.dbxml')/properties/property
    order by $property/sale_price/number() descending
    return $property/@property_id
    return <properties>{
    for $id in subsequence($property_ids, 1, 10) return
    collection('bdb/properties.dbxml')/properties/property@property_id = $id
    }</properties>
    And some times query will change like the following way based on the filter option in my page(means sort by only sale_price field):
    let $property_ids:=
    for $property in collection('bdb/properties.dbxml')/properties/property
    order by $property/sale_price/number() descending
    return $property/@property_id
    return <properties>{
    for $id in subsequence($property_ids, 1, 10) return
    collection('bdb/properties.dbxml')/properties/property@property_id = $id
    }</properties>
    then from the first page its self its performance is very slow(15%).
    Could you please check my query and help me to solve the issue...
    Thank you,
    Vijesh

    If you use your
    Loop at I_DATA.
      select matnr mtart from mara into table itab
        where matnr = I_DATA-matnr.
    endloop.
    At end of loop, itab will only contain the result of the last select, so use a
    Loop at I_DATA.
      select matnr mtart from mara APPENDING table itab
        where matnr = I_DATA-matnr.
    endloop.
    better
    if I_DATA[] is not initial.
      select matnr mtart from mara into table itab
        FOR ALL ENTRIES IN i_data where matnr = i_data-matnr.
    endif.
    Some Remarks
    - If actually required (where does I_DATA come from, is it an external format, you need the internal value to use in SELECT statement), check via SE11 the correct [conversion exit|http://help.sap.com/saphelp_nw04/helpdata/en/35/26b217afab52b9e10000009b38f974/content.htm] associated with domain MATNR (Is it truly ALPHA, and not something like MATN1, so [CONVERSION_EXIT_MATN1_INPUT|http://www.sdn.sap.com/irj/scn/advancedsearch?query=conversion_exit_matn1_input])
    - You could try to use BAPI like [BAPI_MATERIAL_SAVEDATA|http://www.sdn.sap.com/irj/scn/advancedsearch?query=bapi_material_savedata] and not BDC
    Regards,
    Raymond

  • Convert path query to xquery

    Hello
    I need to convert this path regions/africa/item[[[NOT[/location="United States"]] AND /quantity="1" AND /payment="Creditcard"] OR shipping="Will ship only within country"]
    to xquery, where the data stored in standard.xml
    Thank you

    I found the solution if someone is interested
    <result>
    for $i in doc("standard.xml")//item
    where not(($i/location="United States" and $i/quantity="1" and $i/payment="Creditcard") or $i/shipping="Will ship only within country")
    return count($i)
    </result>
    Thanks all

  • Query For Xquery Implementation of Date Function

    Hi All,
    Objective: In array Item, I have to check for device entry Dates.
    First device entry date would be the date corresponding to device seq no =0
    Latest entry date would be the date corresponding to max device seq no.
    Diff date should be differnce between first entry date and latest entry dates in days.
    Output should be like
    <FirstEntrydate></FirstEntrydate>
    <LatestEntryDate></LatestEntryDate>
    <Diffdate></Diffdate>
    <Maxdevice Seq no></MaxdeviceSeqno>
    the XML to transform is :
    <?xml version="1.0"?>
    <ns0:contractDeviceHistory xmlns:ns0="http://www.lhsgroup.com/ws_v3">
    <ns0:item>
    *<ns0:deviceEntryDate>*
    *<ns0:date>2015-01-09T09:30:22</ns0:date>*
    *</ns0:deviceEntryDate>*
    <ns0:deviceId>3</ns0:deviceId>
    <ns0:deviceModDate>
    <ns0:date>2013-01-21T09:30:22</ns0:date>
    </ns0:deviceModDate>
    <ns0:devicePort>devicePort_1</ns0:devicePort>
    *<ns0:deviceSeqno>2</ns0:deviceSeqno>*
    <ns0:deviceSmNum>deviceSmNum_1</ns0:deviceSmNum>
    <ns0:deviceStatus>deviceStatus_1</ns0:deviceStatus>
    <ns0:deviceUserLastMod>deviceUserLastMod_1</ns0:deviceUserLastMod>
    <ns0:deviceValidFrom>
    <ns0:date>2013-01-06T09:30:22</ns0:date>
    </ns0:deviceValidFrom>
    <ns0:hlcode>32</ns0:hlcode>
    <ns0:hlcodePub>hlcodePub_1</ns0:hlcodePub>
    <ns0:reason>64</ns0:reason>
    </ns0:item>
    <ns0:item>
    *<ns0:deviceEntryDate>*
    *<ns0:date>2014-01-09T09:30:22</ns0:date>*
    *</ns0:deviceEntryDate>*
    <ns0:deviceId>3</ns0:deviceId>
    <ns0:deviceModDate>
    <ns0:date>2013-01-21T09:30:22</ns0:date>
    </ns0:deviceModDate>
    <ns0:devicePort>devicePort_1</ns0:devicePort>
    *<ns0:deviceSeqno>1</ns0:deviceSeqno>*
    <ns0:deviceSmNum>deviceSmNum_1</ns0:deviceSmNum>
    <ns0:deviceStatus>deviceStatus_1</ns0:deviceStatus>
    <ns0:deviceUserLastMod>deviceUserLastMod_1</ns0:deviceUserLastMod>
    <ns0:deviceValidFrom>
    <ns0:date>2013-01-06T09:30:22</ns0:date>
    </ns0:deviceValidFrom>
    <ns0:hlcode>32</ns0:hlcode>
    <ns0:hlcodePub>hlcodePub_1</ns0:hlcodePub>
    <ns0:reason>64</ns0:reason>
    </ns0:item>
    <ns0:item>
    *<ns0:deviceEntryDate>*
    *<ns0:date>2012-01-09T09:30:22</ns0:date>*
    *</ns0:deviceEntryDate>*
    <ns0:deviceId>3</ns0:deviceId>
    <ns0:deviceModDate>
    <ns0:date>2012-01-21T09:30:22</ns0:date>
    </ns0:deviceModDate>
    <ns0:devicePort>devicePort_1</ns0:devicePort>
    *<ns0:deviceSeqno>0.0</ns0:deviceSeqno>*
    <ns0:deviceSmNum>deviceSmNum_1</ns0:deviceSmNum>
    <ns0:deviceStatus>deviceStatus_1</ns0:deviceStatus>
    <ns0:deviceUserLastMod>deviceUserLastMod_1</ns0:deviceUserLastMod>
    <ns0:deviceValidFrom>
    <ns0:date>2013-01-06T09:30:22</ns0:date>
    </ns0:deviceValidFrom>
    <ns0:hlcode>32</ns0:hlcode>
    <ns0:hlcodePub>hlcodePub_1</ns0:hlcodePub>
    <ns0:reason>64</ns0:reason>
    </ns0:item>
    </ns0:contractDeviceHistory>
    The Incomplete Xquery i wrote is this, which is not working. Plz suggest
    declare function xf:SIMReplacementInfoResBSCSToSiebel($contractDeviceHistory1 as element())
    as element(ns0:SIMReplacementResponse) {
    <ns0:SIMReplacementResponse>
    <ns0:SIMReplacement>
    for $item in $contractDeviceHistory1/ns1:item
    group $item as $group by
                   $item/ns1:deviceSeqno as $key1,
                        $item/ns1:deviceEntryDate/ns1:date as $key2
                   order by $key1 descending
    return
    <ns0:SIMReplacement
    MaxDeviceSeqNo= "{ fn:max($key1) }"
    FirstEntry_date = "{if(($key1) = '0.0')then($key2) else (0)}"
    LatestEntry_date="{if(($key1)= fn:max($key1))then($key2) else ($key2)}"
    /> }
    <ns0:Status>Success</ns0:Status>
    </ns0:SIMReplacement>
    </ns0:SIMReplacementResponse>
    declare variable $contractDeviceHistory1 as element() external;
    xf:SIMReplacementInfoResBSCSToSiebel($contractDeviceHistory1)
    Regards
    Manu
    India.

    Post Author: jsiegmund
    CA Forum: Data Connectivity and SQL
    Not really, that function is a start, but to calculate the true ammount of work days there are a lot more variables to take into account. For instance, easter depends on the easter sunday which isn't a fixed date. In one year it may be in may, in the next it's in april. So defining a list of holidays (as done in the function in your example) isn't going to cut it. Therefore I mentioned implementing the function in Crystal Reports is a hard job which I wouldn't gladly take on. In the meantime, I've come upon an other solution using SQL Server 2005. It's possible to use assembly's in SQL Server, so I compiled the function as an assembly and loaded that into SQL Server. I needed information from the database for my reports anyway, so now I'm able to do the calculations in the views in the database, instead of leaving that to Crystal. Somewhat of a different solution, but it works for now. It would be great if future versions of Crystal would support the loading of assembly files though

  • Creating a new document using XQuery

    Hello everyone,
    I wondered if there was a way to create a new document using XQuery. What I am trying to do is to run a query on XML file and try to print the results in HTML for viewing purpose.
    The HTML is spitted out on DOS prompt. Instead I wanted to write that HTML to a file on disk. Is this possible with the XQuery tools provided by Oracle?
    Thanks in advance for all the help
    K

    Folks,
    Kinda answering to my question. Just send the DOS output to some file. Pretty Simple huh!
    Thankyou anyways
    K

  • How can I fix a xquery resulting error ORA-19279: XPTY0004 - XQuery dynamic type mismatch: expected singleton sequence  - got multi-item sequence

    Hello,
    How can I improve the XQuery below in order to obtain a minimised return to escape from both errors ORA-19279 and ORA-01706?
    XQUERY for $book in  fn:collection("oradb:/HR/TB_XML")//article let $cont := $book/bdy  where  $cont   [ora:contains(text(), "(near((The,power,Love),10, TRUE))") > 0] return $book
    ERROR:
    ORA-19279: XPTY0004 - XQuery dynamic type mismatch: expected singleton sequence
    - got multi-item sequence
    XQUERY for $book in  fn:collection("oradb:/HR/TB_XML")//article let $cont := $book/bdy  where  $cont   [ora:contains(., "(near((The,power,Love),10, TRUE))") > 0] return $book//bdy
    /*ERROR:
    ORA-01706: user function result value was too large
    Regards,
    Daiane

    below query works for 1 iteration . but for multiple sets i am getting following error .
    When you want to present repeating groups in relational format, you have to extract the sequence of items in the main XQuery expression.
    Each item is then passed to the COLUMNS clause to be further shredded into columns.
    This should work as expected :
    select x.*
    from abc t
       , xmltable(
           xmlnamespaces(
             default 'urn:swift:xsd:fin.970.2011'
           , 'urn:swift:xsd:mtmsg.2011' as "ns0"
         , '/ns0:FinMessage/ns0:Block4/Document/MT970/F61a/F61'
           passing t.col1
           columns F61ValueDate                Varchar(40) Path 'ValueDate'
                 , DebitCreditMark             Varchar(40) Path 'DebitCreditMark'
                 , Amount                      Varchar(40) Path 'Amount'
                 , TransactionType             Varchar(40) Path 'TransactionType'
                 , IdentificationCode          Varchar(40) Path 'IdentificationCode'                 
                 , ReferenceForTheAccountOwner Varchar(40) Path 'ReferenceForTheAccountOwner'
                 , SupplementaryDetails        Varchar(40) Path 'SupplementaryDetails'       
         ) x ;

  • Query time lengthened after additional indexes added

    I had been frequently getting results from my query in about .5 - 1.5 seconds. However, I added additional indexes to my container on fields that I am not even using in my query at the moment. When I did this, my query went to about 35 seconds. Can anyone tell me how to fix this problem
    Here is my query:
    for $record in collection("Catalog.dbxml")
    /*[T245[contains(.,"augustine") or contains(.,"Augustine") or contains(.,"AUGUSTINE")]] return $record
    Here are my indexes:
    Index: node-element-substring-string for node {}:T050
    Index: node-element-substring-string for node {}:T090
    Index: node-element-substring-string for node {}:T100
    Index: node-element-substring-string for node {}:T110
    Index: node-element-substring-string for node {}:T111
    Index: node-element-substring-string for node {}:T245
    Index: node-element-substring-string for node {}:T246
    Index: node-element-substring-string for node {}:T700
    Index: node-element-substring-string for node {}:T710
    Index: node-element-substring-string for node {}:T711
    Here is my queryplan:
    <XQuery>
    <Navigation>
    <QueryPlanFunction result="collection" container="Catalog5.dbxml">
    <OQPlan>n(V(node-element-substring-string,T245,=,'ine'),V(node-element-substring-string,T245,=,'tin'),V(node-element-substring-string,T245,=,'sti'),V(node-element-substring-string,T245,=,'ust'),V(node-element-substring-string,T245,=,'gus'),V(node-element-substring-string,T245,=,'aug'),V(node-element-substring-string,T245,=,'ugu'))</OQPlan>
    </QueryPlanFunction>
    <Step axis="child" uri="*" name="*" nodeType="element"/>
    <DbXmlFilter>
    <Navigation>
    <Step axis="child" name="T245" nodeType="element">
    <Predicates>
    <Operator name="or">
    <Navigation>
    <DbXmlContains>
    <OQPlan>n(V(node-element-substring-string,T245,=,'ugu'),V(node-element-substring-string,T245,=,'gus'),V(node-element-substring-string,T245,=,'ine'),V(node-element-substring-string,T245,=,'sti'),V(node-element-substring-string,T245,=,'tin'),V(node-element-substring-string,T245,=,'ust'),V(node-element-substring-string,T245,=,'aug'))</OQPlan>
    <Sequence>
    <AnyAtomicTypeConstructor value="augustine" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
    </Sequence>
    </DbXmlContains>
    </Navigation>
    <Navigation>
    <DbXmlContains>
    <OQPlan>n(V(node-element-substring-string,T245,=,'ine'),V(node-element-substring-string,T245,=,'tin'),V(node-element-substring-string,T245,=,'ust'),V(node-element-substring-string,T245,=,'sti'),V(node-element-substring-string,T245,=,'gus'),V(node-element-substring-string,T245,=,'ugu'),V(node-element-substring-string,T245,=,'aug'))</OQPlan>
    <Sequence>
    <AnyAtomicTypeConstructor value="Augustine" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
    </Sequence>
    </DbXmlContains>
    </Navigation>
    <Navigation>
    <DbXmlContains>
    <OQPlan>n(V(node-element-substring-string,T245,=,'ust'),V(node-element-substring-string,T245,=,'aug'),V(node-element-substring-string,T245,=,'ugu'),V(node-element-substring-string,T245,=,'gus'),V(node-element-substring-string,T245,=,'tin'),V(node-element-substring-string,T245,=,'sti'),V(node-element-substring-string,T245,=,'ine'))</OQPlan>
    <Sequence>
    <AnyAtomicTypeConstructor value="AUGUSTINE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
    </Sequence>
    </DbXmlContains>
    </Navigation>
    </Operator>
    </Predicates>
    </Step>
    </Navigation>
    </DbXmlFilter>
    </Navigation>
    </XQuery>

    Hi Andrew,
    You experience surprises me a little - I'd like to look into reproducing what you are seeing.
    Can you tell me which indexes you had to start with and which indexes you then added to cause the slow down? Is it possible for you to send me some sample data that exhibits this behavior - either the XML, or your container? If so, can you upload it to ftp.sleepycat.com/incoming and let me know what you've named the file.
    Thanks,
    John

Maybe you are looking for