Create XML file from SQL trigger

I have to create a XML file of a record when a certain column of table Absences is updated. I have the following bcp command in the (after update) trigger :
    bcp "select absences.HID, absences.Amount,absences.Itemcode,absences.Itemcount, absences.[Description],absences.PRocessnumber, Cicmpy.ID from absences inner join cicmpy on cicmpy.cmp_wwn = absences.HID where absences.Type = 110  for
XML RAW (''Order''), ROOT (''Orders''), ELEMENTS XSINIL" QUERYOUT "c:\filename.xml" -T -SJR8512\sql2008 -c -d100'
When the trigger is fired, the table get's a lock, so the file isn't created. What am I missing?

As Russ says: Service Broker is exactly what you want. The trigger would put a message on the Service Broker queue. (And the message would be the XML document created from the inserted/deleted tables.) In the other application you would have an activation
procedure that processes the message.
If you have never worked with Service Broker, this book is an excellent start:
http://www.amazon.com/Rational-Server-Service-Broker-Guides/dp/1932577270/ref=sr_1_1?ie=UTF8&qid=1399411944&sr=8-1&keywords=wolter+service+broker
Also, bookmark Remus Rusanu's blog:
http://rusanu.com/blog/
Lot's of tips there.
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • XML File from SQL Query

    I have created XML File from Query using below function:-
    select dbms_xmlgen.getxml('
    select * from tblreports where rownum<=1') from dual;
    "(CLOB) <?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <REPORTID>preRES0011</REPORTID>
    <ALIAS>Date wise Summary of pins Report</ALIAS>
    <ACTIVE>Y</ACTIVE>
    <TITLE>Date wise Summary of pins Report</TITLE>
    <QUERY>select tsb.month1,
    count(SIDNUMBER)GENERATED,
    sum(case WHEN SERIALSTATUSID=&apos;SRS01&apos; THEN 1 ELSE 0 END)NotAllocated,
    SUM(CASE WHEN SERIALSTATUSID=&apos;SRS02&apos; or SERIALSTATUSID=&apos;SRS03&apos; or SERIALSTATUSID=&apos;SRS05&apos; THEN 1 ELSE 0 END)ALLOCATED,
    SUM(CASE WHEN SERIALSTATUSID=&apos;SRS02&apos; or SERIALSTATUSID=&apos;SRS01&apos; THEN 1 ELSE 0 END)NOTASSIGNEDTORESELLER,
    SUM(CASE WHEN SERIALSTATUSID=&apos;SRS03&apos; THEN 1 ELSE 0 END)READYTOACTIVATE,
    sum(CASE WHEN SERIALSTATUSID=&apos;SRS05&apos; THEN 1 ELSE 0 END)ACTIVATED,
    sum(CASE WHEN SERIALSTATUSID=&apos;SRS06&apos; THEN 1 ELSE 0 END)Terminated,
    sum(CASE WHEN SCRAPSTATUSID=&apos;CST01&apos; THEN 1 ELSE 0 END)scraped,
    sum(CASE WHEN LOCKSTATUSID=&apos;CST01&apos; THEN 1 ELSE 0 END)locked,
    NULL,
         NULL,
         NULL,
         NULL,
         NULL,
    NULL,
    NULL     
    from (SELECT TO_CHAR(CREATEDATE,&apos;DD-MON-YYYY&apos;)MONTH1 ,PINUSAGEMODEID,SERIALBATCHID,SERIALIDCOUNT,CREATEDATE FROM TBLMSERIALBATCH )TSB,
    tblmserial ts
    where TSB.SERIALBATCHID=ts.SERIALBATCHID
    and to_char(TSB.CREATEDATE,&apos;MON-YYYY&apos;)=&apos;$1&apos;
    GROUP BY TSB.MONTH1
    order by TO_DATE(MONTH1,&apos;dd-mon-yyyy&apos;) DESC</QUERY>
    <CONNECTIVITYID>C0001</CONNECTIVITYID>
    <INPUTREQUIRED>Y</INPUTREQUIRED>
    <INPUTNAME>Month</INPUTNAME>
    <CREATEDATE>30-JAN-10</CREATEDATE>
    <LASTMODIFIEDDATE>22-FEB-10</LASTMODIFIEDDATE>
    <CREATEDBY>reportadmin</CREATEDBY>
    <LASTMODIFIEDBY>reportadmin</LASTMODIFIEDBY>
    <TITLEPARAM>Y</TITLEPARAM>
    <SUBTITLE>Date wise Summary of pins Report For &amp;1</SUBTITLE>
    <ELEMENTTYPEID>AET002</ELEMENTTYPEID>
    <REPORTTYPEID>RTP01</REPORTTYPEID>
    <SORTFIELD>Disable</SORTFIELD>
    </ROW>
    </ROWSET>
    But in that it is taking '&apos;' for ' ' instead of '$1' it is taking &apos;$1&apos;
    how to keep ' ' in XML file instead of &apos?

    You can use bcp with query out option
    use your above query as the source query and use queryout option after specifying destination as your required local file path (specify extension as .xml)
    see
    http://visakhm.blogspot.com/2013/10/bcp-out-custom-format-data-to-flat-file.html
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Creating XML file from Java Bean

    Hi
    Are there any standard methods in Java 1.5 to create XML file from java bean,
    i can use JAXB or castor to do so,
    But i would like to know if there is any thing in java core classes,
    I have seen XMLEncoder, but this is not what i want.
    Any ideas
    Ashish

    Marshall JavaBean to an XML document with JAXB or XMLBeans.

  • How to create xml file from Oracle and sending the same xml file to an url

    How to create xml file from Oracle and sending the same xml file to an url

    SQL/XML (XMLElement, XMLForest, XMLAgg, etc) and UTL_HTTP.
    Whether that works for you with the version of Oracle you have, your requirements, and needs is another story. A little detail goes a long way.

  • How to generate XML file from SQL file !

    I am new to XML publisher. I known one way to generate XML file is register one report file in concurrent manager.
    But I want to generate XML file from sql file.
    Could someone show me how to code in sql file, how to register is in concurrent manager.
    Thanks !

    Hi
    Phew ... not sure we have the space here. So I can point you in the right direction:
    1. XML data generation - there are two packages in the db you can use with a plsql procedure, XMLGEN and SQL XML. You can also use java APIs too. Try checking the db documentation and search for the above methods.
    2. Registering the report - the system administrators guide will provide this info. Hooking the program up with XMLP is covered here - http://www.oracle.com/technology/products/applications/publishing/resource/CM%20Whitepaper5.0.pdf
    Regards, Tim

  • Create XML file from table data

    Dear All,
    with dataservice 4.0, I want to create an XML file from a table data.
    Table have a single column but more record, for example:
    0001000488;100;EUR;
    0001000489;200;EUR;
    0001000450;300;EUR;
    My desired XML output:
    <Data>
      0001000488;100;GBP;
      0001000489;200;EUR;
      0001000450;300;EUR;
    </Data>
    I try with a sample query but the sistem write only the last record in XML file:
    <Data>
      0001000450;300;EUR;
    </Data>
    Can everyone help me?
    Thank in advance.
    Simone

    Hello
    That is a very simple (also odd) XML document structure, and as such doesn't require use of the XML target.  It can be easily acheived by writing a normal file with a header and footer, which is acheived using a row_generation and a query to generate the hard coded open and close tags.
    Michael

  • Create XML file from ABAP with SOAP Details

    Hi,
    I am new to XML and I am not familiar with JAVA or Web Service. I have searched in SDN and googled for a sample program for creating XML document from ABAP with SOAP details. Unfortunately I couldn't find anything.
    I have a requirement for creating an XML file from ABAP with SOAP details. I have the data in the internal table. There is a Schema which the client provided and the file generated from SAP should be validating against that Schema. Schema contains SOAP details like Envelope, Header & Body.
    My question is can I generate the XML file using CALL TRANSFORMATION in SAP with the SOAP details?
    I have tried to create Transformation (Transaction XSLT_TOOL) in SAP with below code. Also in CALL transformation I am not able to change the encoding to UTF-8. It's always show UTF-16.
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
      <xsl:template match="/">
        <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
          <SOAP:Header>
            <CUNS:HeaderInfo>
              <CUNS:InterfaceTypeId>10006</InterfaceTypeId>
              <CUNS:BusinessPartnerID>11223344</BusinessPartnerID>
              <CUNS:SchemaVersion>1.0</SchemaVersion>
              <CUNS:DateTime>sy-datum</DateTime>
            </CUNS:HeaderInfo>
          </SOAP:Header>
          <SOAP:Body>
            <xsl:copy-of select="*"/>
          </SOAP:Body>
        </SOAP:Envelope>
      </xsl:template>
    </xsl:transform>
    In ABAP program, I have written below code for calling above Transformation.
      call transformation ('Z_ID')
           source tab = im_t_output[]
           result xml xml_out.
      call function 'SCMS_STRING_TO_FTEXT'
        exporting
          text      = xml_out
        tables
          ftext_tab = ex_t_xml_data.
    Please help me how to generate XML file with SOAP details from ABAP. If anybody have a sample program, please share with me.
    Is there any easy way to create the XML file in CALL Transformation. Please help.
    Thanks

    Try ABAP forum, as it seems not to be PI related.

  • How to create xml file from original

    I have this complicated xml and I want to search through it and make a new xml with only element I find that match. what is the best way to do this? the file
    is about 6mb and I want to read the whole file easily..should i load to database table and create a file from table? I have found issues reading the file..
    - <ArrayOfJobClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    - <JobClass>
    - <Triggers>
    - <TriggerClass>
    <ExpireActionType>Delete</ExpireActionType>
    <ExpireType>DateTime</ExpireType>
    <TriggerType>TimeType</TriggerType>
    - <TTime>
    <TimeTriggerType>Custom</TimeTriggerType>
    <IntervalType>Daily</IntervalType>
    <SpecificType>Days</SpecificType>
    <FirstLastType>First</FirstLastType>
    <IntervalValue>1</IntervalValue>
    <FirstLastWeekDay>Monday</FirstLastWeekDay>
    <InitDate>2009-05-04T14:17:05.40625-07:00</InitDate>
    - <IntervalDays>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>

    You can load it in the database in an XMLType table (Object-Relational or Binary XML storage), use XQuery on the XML content and then write back the result to a file.
    Or, you might just use an external processor (XSLT or XQuery).
    If you want to stay in the Oracle world, you can use :
    - For XSLT : $ORACLE_HOME/bin/oraxsl (it's a wrapper for the java XSLT engine)
    - For XQuery : the java XQuery API
    Personally, I sometimes use the Saxon XSLT and XQuery processor, quite efficient.
    Here's a simplistic example with oraxsl utility :
    emp.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <emps>
      <emp id="7369">
        <name>SMITH</name>
        <job>CLERK</job>
        <salary>800</salary>
      </emp>
      <emp id="7499">
        <name>ALLEN</name>
        <job>SALESMAN</job>
        <salary>1600</salary>
      </emp>
      <emp id="7521">
        <name>WARD</name>
        <job>SALESMAN</job>
        <salary>1250</salary>
      </emp>
      <emp id="7566">
        <name>JONES</name>
        <job>MANAGER</job>
        <salary>2975</salary>
      </emp>
      <emp id="7654">
        <name>MARTIN</name>
        <job>SALESMAN</job>
        <salary>1250</salary>
      </emp>
    </emps>
    emp.xsl
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml"/>
    <xsl:template match="text()"/>
    <xsl:template match="emps/emp[job='SALESMAN']">
      <xsl:copy-of select="."/>
    </xsl:template>
    </xsl:stylesheet>Applying the transformation to search and extract all "salesmen" :
    D:\ORACLE\test>%ORACLE_HOME%\bin\oraxsl emp.xml emp.xsl result.xml
    D:\ORACLE\test>type result.xml
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <emp id="7499">
        <name>ALLEN</name>
        <job>SALESMAN</job>
        <salary>1600</salary>
      </emp><emp id="7521">
        <name>WARD</name>
        <job>SALESMAN</job>
        <salary>1250</salary>
      </emp><emp id="7654">
        <name>MARTIN</name>
        <job>SALESMAN</job>
        <salary>1250</salary>
      </emp>

  • Create XML file from XSD

    Hello,
    can anybody help me with generating an empty tagged XML file from a XSD file. Any sample java code will be highly appreciated.
    Thanx in advance.
    A .

    Apache XML Beans presents a way to compile the XSD Schema and generate Java classes for each element defined in the schema. With these interface you can then create new XML instances from the schema. (http://xmlbeans.apache.org/)

  • How to create xml file from relational tables in 10gR2

    Hi,
    I am very new to XML and was wondering how to create an XML file from querying relational tables. Some child tables may contain multiple rows that need to be returned in certain instances. Other queries will just be single or multiple rows from one or more tables. I would like to use the latest feathers in 10gR2. Thanks for any help you can provide.
    Thanks,
    Lee

    Here is the first row of data created from our person table - it used the column names as the tag names:
    <?xml version="1.0"?>
    <ROWSET>
         <ROW>
              <MP_ID_SEQ>289</MP_ID_SEQ>
              <MP_NAME>LOBERG,JUDITH LEE</MP_NAME>
              <MP_SEX>F</MP_SEX>
              <MP_RACE>I</MP_RACE>
              <MP_DOB>19500709</MP_DOB>
              <MP_HT>504</MP_HT>
              <MP_WT>170</MP_WT>
              <MP_EYE_CLR>BLU</MP_EYE_CLR>
              <MP_HAIR_CLR>BRO</MP_HAIR_CLR>
              <MP_SKN>RUD</MP_SKN>
              <MP_SMT>POCKMARKS</MP_SMT>
              <MP_SOC>517607968</MP_SOC>
              <MP_OLN>517607968</MP_OLN>
              <MP_OLS>MT</MP_OLS>
              <MP_OLY>2007</MP_OLY>
              <MP_CAUT_MED>70</MP_CAUT_MED>
              <MP_VISION_SCRIPT>C0RRECTIVE LENSES</MP_VISION_SCRIPT>
              <MP_DNA_AVAIL>N</MP_DNA_AVAIL>
              <CREATED_BY>MMPS</CREATED_BY>
              <DTM_CREATED>31-AUG-06</DTM_CREATED>
              <MI_INC_ID_SEQ>288</MI_INC_ID_SEQ>
              <MP_ALERT>N</MP_ALERT>
         </ROW>

  • Create XML file from Oracle DB

    Hi,
    I'm working in a task to create electronic billing for Mexico Rules, to do this; I need to create a XML source that will contain all the information requested from Oracle DB.
    For this reason, I'm looking how to create this XML file from Oracle DB.
    All this is for the new legislations rules in Mexico to use electronic billing.
    Please, if you have any reference about this, let me know.
    Thanks and regards.

    you may want to check out commands like xmlforest and xmlelement
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions221.htm
    copied from documentation
    Purpose
    XMLForest converts each of its argument parameters to XML, and then returns an XML fragment that is the concatenation of these converted arguments.
    •If value_expr is a scalar expression, then you can omit the AS clause, and Oracle Database uses the column name as the element name.
    •If value_expr is an object type or collection, then the AS clause is mandatory, and Oracle uses the specified c_alias as the enclosing tag. The c_alias can be up to 4000 characters.
    •If value_expr is null, then no element is created for that value_expr.
    Examples
    The following example creates an Emp element for a subset of employees, with nested employee_id, last_name, and salary elements as the contents of Emp:
    SELECT XMLELEMENT("Emp",
    XMLFOREST(e.employee_id, e.last_name, e.salary))
    "Emp Element"
    FROM employees e WHERE employee_id = 204;
    Emp Element
    <Emp>
    <EMPLOYEE_ID>204</EMPLOYEE_ID>
    <LAST_NAME>Baer</LAST_NAME>
    <SALARY>10000</SALARY>
    </Emp>

  • Create XML File from a specified XSD file

    Hi,
    I'd like to create an XML document with java. BUT How can we "bind" this creation with a XSD file. Hence, the creation may fail if the XSD binded file is not respected.
    So I know how to create XML file but not bind to this creation my proper XSD file (XML schema). With which tool can I do this ?
    Thanks.

    Hi,
    I'd like to create an XML document with java. BUT How can we "bind" this creation with a XSD file. Hence, the creation may fail if the XSD binded file is not respected.
    So I know how to create XML file but not bind to this creation my proper XSD file (XML schema). With which tool can I do this ?
    Thanks.

  • Can not create XML file from MS Access 2003

    Hi,
    I am getting error as "Error loading in DLL" when I use msaccess_exporter to create XML file for migrations usind Access 2003 DB. Does anyone know about this? If yes, could you please let me know how to resolve it?
    Thanks,
    Kartik

    Hi Daniel,
    I believe you are seeing the message "Table'_OracletblDatabase' already exists" because you are attempting to export an MDB file that you previously attempted to export, but that initial export process may not have run to completion. I recommend opening your .MDB file, and delete any "_Oracletbl..." table objects that exist under the list of Table objects. Close the MDB file and carry out the export process again. You should now be able to use the 2000 mde file.
    I hope this helps.
    Regards,
    Hilary

  • Please Help. Trying to create XML file from 2 tables.

    Step1: Target XML format
    Created an XML
    <DEPART>
    <DEPARTMENT_ID>10</DEPARTMENT_ID>
    <DEPARTMENT_NAME>Administration</DEPARTMENT_NAME>
    <MANAGER_ID>200</MANAGER_ID>
    <LOCATION_ID>1700</LOCATION_ID>
    <EMP><EMPLOYEE_ID>100</EMPLOYEE_ID>
    <FIRST_NAME>Steven</FIRST_NAME>
    <LAST_NAME>King</LAST_NAME>
    <SALARY>24000</SALARY>
    </EMP>
    </DEPART>Step 2. Created a target data server from the above mentioned xml. Specified the logical and physical schema.
    Step3.Logged into Designer and reverse engineered from the the schema created in step2.
    step 4. Following Hierarchy is created
    DEPART
    --> EMP
    Step 5. Reverse engineered 2 tables from oraclexe (HR ) Schema
    Employees
    Departments
    Step 6. Created an interface and made DEPART from step 4 as target
    and Departments from step 5 as source.
    Step 7. Staging area is different to the target.
    step 8. modified the IKM SQL Control Append to write to a file
    create xmlfile #filename from schema DEPART
    Step 9. Changed the DEPART PK Column in the TARGET to 0
    Step 10. File is created.
    Problem:
    1. When i view the file it has all the departments but the employees are also displayed eventhough i haven't done the mapping.
    2. All the employees are listed under every department.
    Please help as i have tried everything. I know i am missing something somewhere.
    Thanks a lot for reading it.
    Alvinder
    Edited by: alvinder on Jun 30, 2010 5:29 PM

    Hi Alvindar,
    Thanks u posted good issue,
    Can u clarify this about how your issue got ressolved. I am also trying with same XML as you have pasted here. I have following doubts.
    While setting up XML data server the ro option i have deleted as defalut value is false which allows both read/write & its look like this
    jdbc:snps:xml?f=../demo/XML/EMPDEPT.xml&s=SCH_EMPDEPT.
    I have mapped and written create XML commands in commit section of IKM which looks like this :CREATE XMLFILE #ExportXMLFileLoc FROM SCHEMA SCH_FLDEPT
    created the interface and executed,it went through fine,4 rows data transformed into target xml data store,file is generated in the given path .
    But in the generated file is same as which have EMPDEPT.xml with data change,but in the target xml data store depart i am able to view newly inserted records.
    i want generate an output xml for each of the target of the XML data store, how we can do that please explain me.
    this is my xml
    <?xml version="1.0" encoding="UTF-8"?>
    <REQUEST>
    <DEPART>
    <DEPARTMENT_ID>10</DEPARTMENT_ID>
    <DEPARTMENT_NAME>Admin</DEPARTMENT_NAME>
    <MANAGER_ID>200</MANAGER_ID>
    <LOCATION_ID>1700</LOCATION_ID>
    </DEPART>
    </REQUEST>
    tried only with DEPART table.
    Waiting for ur repply,
    Thanks,
    MNK

  • Creating XML file from ABAP internal table data....

    Hello,
    I am fethcing data froma  custom table and I have to write data in XMl format. Following is the XML format in which I want data. Is there any function module iN SAP which will help me in writing data from internal table to XML file ?
    <batch>
      <invoice>
        <StatusCode>10</StatusCode>
        <paymentamount>122.00</paymentamount>
         <ReferenceNumber>70980934</ReferenceNumber>
      </invoice>
      <invoice>
         <StatusCode>90</StatusCode>
        <paymentamount>122.00</paymentamount>
         <ReferenceNumber>70980934</ReferenceNumber>
      </invoice>
      <control>
        <InvoiceCount>2</InvoiceCount>
      </control>
    </batch>
    Please help.
    Regards,
    Jainam.

    I suggest you look into "simple transformations". That's SAP's most recent technology for such purposes, as far as I know.
    http://help.sap.com/abapdocu_70/en/ABENABAP_ST.htm
    Thomas

Maybe you are looking for