Help me to update table with condition's

this table is an alert table which will update when the sql server down , not pinging and drive space low.
Every 15 mins the monitoring system run. if the any issue came then it will update the information in this table. if  the issue not solved by 15 mins the table will update again with the same details.. 
I would like update tickeraised = Y  only on first time and  if i got same issue less then 30 min the it should not change to Y..  based on server name , type and message. 
min >10 and <20 min if any value is there then the table should not update with same value. can any one help me with tsql query...

In future please post DDL and DML. For now I have created a scenario which will help you understand solution to your own requirement.
CREATE TABLE Tickets_Log(
Ticked_ID SMALLINT IDENTITY(1,1) PRIMARY KEY,
Ticket_Type VARCHAR(20) NOT NULL,
Log_Date DATETIME2 NOT NULL DEFAULT DATEADD(MINUTE,-15,GETDATE()),
Machine_Name VARCHAR(50) NOT NULL,
Message VARCHAR(100) NOT NULL,
Ticket_Status CHAR(2) NOT NULL DEFAULT 'N',
Update_Status SMALLINT DEFAULT 0)
INSERT Tickets_Log(Ticket_Type,Machine_Name,Message)
SELECT 'Pinging','HOD-400-651','Server Not Pinging' UNION
SELECT 'Low Drive Space','HOD-400-652','Drive Space Low' UNION
SELECT 'Connection','HOD-400-653','Unable to Connect to Server'
UPDATE TL
SET Log_Date=NewTickets.Log_Date,
Update_Status=1
FROM( SELECT 'Pinging' Ticket_Type,'HOD-400-651' Machine_Name,'Server Not Pinging' Message,GETDATE() Log_Date UNION
SELECT 'Pinging','HOD-400-653','Server Not Pinging',GETDATE() Log_Date) NewTickets
LEFT JOIN Tickets_Log TL ON NewTickets.Machine_Name=TL.Machine_Name AND NewTickets.Ticket_Type=TL.Ticket_Type
WHERE TL.Ticket_Type IS NOT NULL AND TL.Machine_Name IS NOT NULL AND DATEDIFF(MINUTE,TL.Log_Date,NewTickets.Log_Date)>=15 AND Update_Status=0
INSERT Tickets_Log(Ticket_Type,Machine_Name,Message,Log_Date)
SELECT NewTickets.*
FROM( SELECT 'Pinging' Ticket_Type,'HOD-400-651' Machine_Name,'Server Not Pinging' Message,GETDATE() Log_Date UNION
SELECT 'Pinging','HOD-400-653','Server Not Pinging',GETDATE() Log_Date) NewTickets
LEFT JOIN Tickets_Log TL ON NewTickets.Machine_Name=TL.Machine_Name AND NewTickets.Ticket_Type=TL.Ticket_Type
WHERE TL.Ticket_Type IS NULL AND TL.Machine_Name IS NULL
Chaos isn’t a pit. Chaos is a ladder. Many who try to climb it fail and never get to try again. The fall breaks them. And some are given a chance to climb, but they refuse. They cling to the realm, or the gods, or love. Illusions. Only the ladder is real.
The climb is all there is.

Similar Messages

  • Update table with data from dialog

    Hello,
    I need the problem.
    I'm not update table with inputtext field where data change from dialog.
    This metod is update table.
    public void returnHandlerGoods(ReturnEvent returnEvent) {
    // Add event code here...
    ArrayList<PricatGoods> data = (ArrayList<PricatGoods>) returnEvent.getReturnValue();
    BindingContainer bc = getBindings();
    DCIteratorBinding dcIterBinding;
    // сохранить изменения detail
    dcIterBinding = (DCIteratorBinding) bindings.get("findVMIOrderDetailsIter");
    RowSetIterator s = dcIterBinding.getRowSetIterator();
    System.out.println("Получено товаров " + data.size());
    for (int i =0; i < data.size(); i++){
    Row detailRow = (RowImpl)s.createRow();
    detailRow.setNewRowState(Row.STATUS_INITIALIZED);
    s.insertRow(detailRow);
    s.setCurrentRow(detailRow);
    // detailRow.setAttribute("lineNum",createLineNum(i));
    detailRow.setAttribute("gtin",((PricatGoods)data.get(i)).getGtin());
    detailRow.setAttribute("goodId",((PricatGoods)data.get(i)).getGoodId());
    detailRow.setAttribute("goodName",((PricatGoods)data.get(i)).getGoodName());
    detailRow.setAttribute("sellerarticle",((PricatGoods)data.get(i)).getGoodCode());
    detailRow.setAttribute("buyerarticle",((PricatGoods)data.get(i)).getBuyerArticle());
    detailRow.setAttribute("unit",((PricatGoods)data.get(i)).getUnit());
    detailRow.setAttribute("totalQuantity",0);
    detailRow.setAttribute("acceptedQuantity",0);
    detailRow.setAttribute("taxRate",((PricatGoods)data.get(i)).getVatPercent());
    detailRow.setAttribute("price",((PricatGoods)data.get(i)).getCost());
    detailRow.setAttribute("priceWithoutTax",((PricatGoods)data.get(i)).getCostWithoutVat());
    detailRow.setAttribute("sumWithoutTax",0.0);
    detailRow.setAttribute("totalSum",0.0);
    detailRow.setAttribute("currency",((PricatGoods)data.get(i)).getCurrency());
    System.out.println("Добавление товара \" "+((PricatGoods)data.get(i)).getGoodName()+ "\" с goodCode " +((PricatGoods)data.get(i)).getGoodCode());
    s.closeRowSetIterator();
    AdfFacesContext.getCurrentInstance().addPartialTarget(table2);
    Fields are update good where inputText.readOnly = true.
    Fields are not update good where inputText.readOnly = false. Old data duplicate in new row.
    I have found some posts, but in them is not told accurately as I can solve the given problem.
    How to update a adf table??
    Re: ADF Dialog FrameWork-Table Update Problem
    Whether it is possible to solve the given problem?
    Thx,
    Dema

    If I use outputText that all job's a good. But I don't change these fields. I should have field with change for users.
    Code jspx page for table ===>
    <af:table value="#{bindings.findVMIOrderDetails1.collectionModel}"
    var="row"
    rows="#{bindings.findVMIOrderDetails1.rangeSize}"
    first="#{bindings.findVMIOrderDetails1.rangeStart}"
    emptyText="#{bindings.findVMIOrderDetails1.viewable ? 'Товаров пока нет.' : 'Access Denied.'}"
    selectionState="#{bindings.findVMIOrderDetails1.collectionModel.selectedRow}"
    selectionListener="#{bindings.findVMIOrderDetails1.collectionModel.makeCurrent}"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.table2}"
    id="table2" styleClass="baseTable">
    <af:column sortProperty="lineNum" sortable="false"
    headerText="№"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column19}"
    id="column19">
    <af:inputText value="#{row.lineNum}" simple="false"
    required="true"
    columns="4"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.inputText4}"
    id="inputText4" readOnly="false"
    requiredMessageDetail='Поле "№" обязательно для заполнения'/>
    </af:column>
    <af:column sortProperty="gtin" sortable="false"
    headerText="GTIN"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column20}"
    id="column20">
    <af:inputText value="#{row.gtin}" simple="true"
    required="#{bindings.findVMIOrderDetails1.attrDefs.gtin.mandatory}"
    columns="#{bindings.findVMIOrderDetails1.attrHints.gtin.displayWidth}"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.inputText26}"
    id="inputText26" readOnly="true"/>
    </af:column>
    <af:column sortProperty="sellerarticle" sortable="false"
    headerText="Код товара у поставщика"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column21}"
    id="column21">
    <af:inputText value="#{row.sellerarticle}" simple="true"
    required="#{bindings.findVMIOrderDetails1.attrDefs.sellerarticle.mandatory}"
    columns="#{bindings.findVMIOrderDetails1.attrHints.sellerarticle.displayWidth}"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.inputText27}"
    id="inputText27" readOnly="true"/>
    </af:column>
    <af:column sortProperty="buyerarticle" sortable="false"
    headerText="Код товара у покупателя"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column22}"
    id="column22">
    <af:inputText value="#{row.buyerarticle}" simple="true"
    required="#{bindings.findVMIOrderDetails1.attrDefs.buyerarticle.mandatory}"
    columns="10"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.inputText28}"
    id="inputText28" readOnly="true"
    disabled="false"/>
    </af:column>
    <af:column sortProperty="goodName" sortable="false"
    headerText="Наименование"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column23}"
    id="column23">
    <af:inputText value="#{row.goodName}" simple="true"
    required="true"
    columns="11"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.inputText29}"
    id="inputText29"
    requiredMessageDetail="Поле обязательно для заполнения"
    readOnly="true"/>
    </af:column>
    <af:column sortProperty="itemDesc" sortable="false"
    headerText="Описание"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column24}"
    id="column24" rendered="false">
    <af:inputText value="#{row.itemDesc}" simple="true"
    required="#{bindings.findVMIOrderDetails1.attrDefs.itemDesc.mandatory}"
    columns="#{bindings.findVMIOrderDetails1.attrHints.itemDesc.displayWidth}"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.inputText30}"
    id="inputText30"/>
    </af:column>
    <af:column sortProperty="unit" sortable="false"
    headerText="Ед. изм."
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column25}"
    id="column25">
    <af:inputText value="#{row.unit}" simple="true"
    required="#{bindings.findVMIOrderDetails1.attrDefs.unit.mandatory}"
    columns="#{bindings.findVMIOrderDetails1.attrHints.unit.displayWidth}"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.inputText31}"
    id="inputText31" readOnly="true"/>
    </af:column>
    <af:column sortProperty="currency" sortable="false"
    headerText="Валюта"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column26}"
    id="column26" rendered="false">
    <af:inputText value="#{row.currency}" simple="true"
    required="#{bindings.findVMIOrderDetails1.attrDefs.currency.mandatory}"
    columns="#{bindings.findVMIOrderDetails1.attrHints.currency.displayWidth}"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.inputText32}"
    id="inputText32"/>
    </af:column>
    <af:column sortProperty="totalQuantity" sortable="false"
    headerText="Общее кол-во"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column27}"
    id="column27">
    <af:inputText value="#{row.totalQuantity}"
    required="#{bindings.findVMIOrderDetails1.attrDefs.totalQuantity.mandatory}"
    columns="#{bindings.findVMIOrderDetails1.attrHints.totalQuantity.displayWidth}"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.inputText36}"
    id="inputText36" readOnly="true">
    <f:convertNumber groupingUsed="false"
    pattern="#{bindings.findVMIOrderDetails1.formats.totalQuantity}"/>
    </af:inputText>
    </af:column>
    <af:column sortProperty="acceptedQuantity" sortable="false"
    headerText="Кол-во поставки"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column28}"
    id="column28">
    <af:inputText value="#{row.acceptedQuantity}"
    required="true"
    columns="7"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.inputText37}"
    id="inputText37"
    requiredMessageDetail='Поле "Подтвержденное количество "обязательно для заполнения'
    validator="#{backing_documents_outcoming_unprocessing_type_15_edit_01.validatorQuantity}"
    readOnly="false">
    <f:convertNumber groupingUsed="false"
    pattern="#{bindings.findVMIOrderDetails1.formats.acceptedQuantity}"/>
    </af:inputText>
    </af:column>
    <af:column sortProperty="taxRate" sortable="false"
    headerText="НДС, %"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column29}"
    id="column29">
    <af:inputText value="#{row.taxRate}"
    required="true"
    columns="4"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.inputText38}"
    id="inputText38"
    requiredMessageDetail='Поле "НДС" обязательно для заполнения'
    validator="#{backing_documents_outcoming_unprocessing_type_15_edit_01.unitValidatorNDS}"
    readOnly="false">
    <f:convertNumber groupingUsed="false"
    pattern="#{bindings.findVMIOrderDetails1.formats.taxRate}"/>
    </af:inputText>
    </af:column>
    <af:column sortable="false" headerText="Цена"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column34}"
    id="column34">
    <af:column sortProperty="priceWithoutTax" sortable="false"
    headerText="Без НДС"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column31}"
    id="column31">
    <af:inputText value="#{row.priceWithoutTax}"
    required="true"
    columns="6"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.inputText40}"
    id="inputText40"
    requiredMessageDetail='Поле "Цена без НДС" обязательно для заполнения'
    validator="#{backing_documents_outcoming_unprocessing_type_15_edit_01.unitValidatorPriceWithoutTax}"
    readOnly="false">
    <f:convertNumber groupingUsed="false"
    pattern="#{bindings.findVMIOrderDetails1.formats.priceWithoutTax}"/>
    </af:inputText>
    </af:column>
    <af:column sortProperty="price" sortable="false"
    headerText="С НДС"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column30}"
    id="column30">
    <af:inputText value="#{row.price}"
    required="true"
    columns="6"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.inputText39}"
    id="inputText39"
    requiredMessageDetail='Поле "Цена с НДС" обязательно для заполнения'
    validator="#{backing_documents_outcoming_unprocessing_type_15_edit_01.unitValidatorPrice}"
    readOnly="false">
    <f:convertNumber groupingUsed="false"
    pattern="#{bindings.findVMIOrderDetails1.formats.price}"/>
    </af:inputText>
    </af:column>
    </af:column>
    <af:column sortable="false" headerText="Сумма"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column35}"
    id="column35">
    <af:column sortProperty="sumWithoutTax" sortable="false"
    headerText="Без НДС"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column32}"
    id="column32">
    <af:inputText value="#{row.sumWithoutTax}"
    required="true" columns="6"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.inputText41}"
    id="inputText41"
    requiredMessageDetail='Поле "Сумма без НДС" обязательно для заполнения'
    autoSubmit="true"
    valueChangeListener="#{backing_documents_outcoming_unprocessing_type_15_edit_01.changeSum}"
    readOnly="false">
    <f:convertNumber groupingUsed="false"
    pattern="#{bindings.findVMIOrderDetails1.formats.sumWithoutTax}"/>
    </af:inputText>
    </af:column>
    <af:column sortProperty="totalSum" sortable="false"
    headerText="С НДС"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.column33}"
    id="column33">
    <af:inputText value="#{row.totalSum}" required="true"
    columns="6"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.inputText42}"
    id="inputText42"
    requiredMessageDetail='Поле "Сумма с НДС" обязательно для заполнения'
    autoSubmit="true"
    valueChangeListener="#{backing_documents_outcoming_unprocessing_type_15_edit_01.changeSum}"
    validator="#{backing_documents_outcoming_unprocessing_type_15_edit_01.unitValidatorTotalSum}"
    readOnly="false">
    <f:convertNumber groupingUsed="false"
    pattern="#{bindings.findVMIOrderDetails1.formats.totalSum}"/>
    </af:inputText>
    </af:column>
    </af:column>
    <f:facet name="selection">
    <af:tableSelectOne text="Select and"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.tableSelectOne2}"
    id="tableSelectOne2">
    <af:commandLink text="Удалить"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.commandLink5}"
    id="commandLink5"
    action="#{backing_documents_outcoming_unprocessing_type_15_edit_01.deleteRow}"
    styleClass="tableControlButton"
    immediate="false"/>
    </af:tableSelectOne>
    </f:facet>
    <f:facet name="actions">
    <h:panelGroup binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.panelGroup2}"
    id="panelGroup2">
    <af:commandLink text="Добавить"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.commandLink6}"
    id="commandLink6"
    styleClass="tableControlButton"
    immediate="false"
    action="#{backing_documents_outcoming_unprocessing_type_15_edit_01.addRows}"
    useWindow="true" windowHeight="500"
    windowWidth="600"
    returnListener="#{backing_documents_outcoming_unprocessing_type_15_edit_01.returnHandlerGoods}"
    rendered="#{bindings.JdDoctype02rspType.inputValue == 9&amp;&amp;bindings.JdDoctype02orderrspId.inputValue==null}"/>
    <af:commandLink text="Пересчитать" id="commandLink31"
    styleClass="tableControlButton"
    binding="#{backing_documents_outcoming_unprocessing_type_15_edit_01.commandLink31}"
    action="#{backing_documents_outcoming_unprocessing_type_15_edit_01.calc}"
    useWindow="true" immediate="false">
    <af:setActionListener from="#{row.rowKeyStr}"
    to="#{processScope.mainRowKeyStr}"/>
    </af:commandLink>
    </h:panelGroup>
    </f:facet>
    </af:table>

  • After update trigger with condition

    Dear members,
    I have a table with multiple columns on each update on these columns I have to update another table columns.
    for one column the following trigger is working fine, but there are about more than 10 columns which I have to check for.
    I want to create only one after update trigger on this table and check which column is updated and update the same column in 2nd table.
    here is the trigger:
    CREATE OR REPLACE TRIGGER ABC_RATE_UPD
    AFTER UPDATE
       OF RATE
       ON ABC_PCD 
       REFERENCING NEW AS New OLD AS Old
       FOR EACH ROW
    DECLARE
      BEGIN
        UPDATE RM_TRAN_IN
        SET RATE = :NEW.RATE
        WHERE RM_PCD_ID = :NEW.RM_PCD_ID;
       EXCEPTION
         WHEN OTHERS THEN
           -- Consider logging the error and then re-raise
           RAISE;
    END ABC_RATE_UPD; here is my if condition, (edited)
    if :NEW.RATE != :OLD.RATE then
            UPDATE ABC_TRAN_IN
            SET RATE = :NEW.RATE
            WHERE ABC_PCD_ID = :NEW.ABC_PCD_ID;
        ELSIF :NEW.PACK_UNIT_ID != :OLD.PACK_UNIT_ID then
            UPDATE ABC_TRAN_IN
            SET PACK_UNIT_ID = :NEW.PACK_UNIT_ID
            WHERE ABC_PCD_ID = :NEW.ABC_PCD_ID;
    END IF;
        Its working good, is this a good approach, to the solution?
    regards:
    Edited by: user2040934 on Dec 29, 2012 3:22 PM

    In your trigger if you update more than one column at a time will it update all the updated columns in the other table properly?
    Can't you code something like this
    CREATE OR REPLACE TRIGGER ABC_RATE_UPD
    AFTER UPDATE
       OF col1,col2 , col3
       ON ABC_PCD 
       REFERENCING NEW AS New OLD AS Old
       FOR EACH ROW
    DECLARE
      BEGIN
    if updating ('col1') then
        UPDATE RM_TRAN_IN
        SET col1 = :NEW.col1
        WHERE :old.id = :NEW.id;
      end if;
      if updating ('col2') then
        UPDATE RM_TRAN_IN
        SET col2 = :NEW.col2
        WHERE :old.id = :NEW.id;
      end if;
       if updating ('col3') then
        UPDATE RM_TRAN_IN
        SET col3 = :NEW.col3
        WHERE :old.id = :NEW.id;
      end if;
       EXCEPTION
         WHEN OTHERS THEN
           -- Consider logging the error and then re-raise
           RAISE;
    END ABC_RATE_UPD;

  • 29875; error updating table with geometry but without index

    hi,
    I've a table with next description
    AGGREGATEDUNIT_ID NOT NULL NUMBER(38)
    DATASET_ID NUMBER(38)
    GEOMETRY MDSYS.SDO_GEOMETRY
    REDEFINEDMETADATA SYS.XMLTYPE
    I dont need a spatial index in column GEOMETRY, but when I try an update operation:
    INSERT INTO AGGREGATEDUNIT (AGGREGATEDUNIT_ID, DATASET_ID) VALUES (389, 893)
    I get next error:
    INSERT INTO AGGREGATEDUNIT
    ERROR en lmnea 1:
    ORA-29875: fallo al ejecutar la rutina ODCIINDEXINSERT
    ORA-13203: fallo al leer la tabla USER_SDO_GEOM_METADATA
    ORA-13203: fallo al leer la tabla USER_SDO_GEOM_METADATA
    ORA-06512: en "MDSYS.SDO_INDEX_METHOD_9I", lmnea 183
    ORA-06512: en lmnea 1
    anybody knows?
    thanx

    Hi,
    Whether you need the index or not, someone has created a spatial index on the table.
    You can drop the index, or you can add the metadata for the table into user_sdo_geom_metadata (it was there at the time the index was created).
    Hope this helps,
    Dan

  • Updating table with invalid identifiers

    Hi!
    I use a third-party plug in and that comparisons of chemical structures. I would like to update one table with values from another when the plug-in matches two rows. However, I am getting an invalid identifier problem.
    Two tables:
    PLATES: has VARCHAR2 columns of PLATE_SMILES, IN_DB
    INVEST: has VARCHAR2 columns of SMILES
    The operator is a binary one: jc_compare(PLATE_SMILES, SMILES)=1 (or 0 if they don't match)
    I want my query to say: "If comparison of PLATE_SMILES, SMILES = 1, set IN_DB=1 for that row" - effectively asking if PLATE_SMILES exists in the INVEST table.
    I've tried a number of renditions, all giving invalid identifiers. Here's an example:
    update (select plate.PLATE_SMILES, plate.IN_DB, invest.SMILES
    from PLATES plate
    INVEST invest
    WHERE jc_compare(PLATE_SMILES, SMILES)=1)
    set plate.IN_DB = 1;
    ORA-00904: "PLATE"."IN_DB": invalid identifier
    I'm hoping this should be an easy fix, and any help is greatly appreciated!

    Hi,
    You have
    UPDATE (SELECT plate.plate_smiles,
                   plate.in_db,
                   invest.smiles
            FROM   plates plate, invest invest
            WHERE  jc_compare ( plate_smiles, smiles) = 1)
    SET    plate.in_db = 1;   -- Error herePLATE is not known outside the inline view. Just remove it.
    Regards
    Peter

  • Update Table with xml data

    Hi,
    I have to update Table by reading Xml data.
    I have written a procedure which is given below.
    PROCEDURE Sp_Set_File_Permission
    p_i_v_xml_data  IN VARCHAR2,
    Cur_Out_Col_Nm    OUT Typ_Icon_Out
    IS 
    XmlDataset   XMLTYPE;
      BEGIN
    /* This is my xml
    <xmldata>
    <newdataset>
    <fileid>99</fileid>
    <add>TRUE</add>
    <edit>TRUE</edit>
    <del>FALSE</del>
    <ex>FALSE</ex>
    <im>TRUE</im>
    </newdataset>
    <newdataset>
    <fileid>100</fileid>
    <add>FALSE</add>
    <edit>TRUE</edit>
    <del>FALSE</del>
    <ex>FALSE</ex>
    <im>TRUE</im>
    </newdataset>
    </xmldata>*/
    xmldataset := Xmltype.Createxml(p_i_v_Xml_Data);
    --error occured on this line while executing procedure
    FOR i IN (SELECT
                   Dt.Extract('//newdataset/fileid/text()').Getstringval() AS Fileid,
                   Dt.Extract('//newdataset/add/text()').Getstringval() AS Add,
                   Dt.Extract('//newdataset/edit/text()').Getstringval() AS Edit,
                   Dt.Extract('//newdataset/del/text()').Getstringval() AS d,
                   Dt.Extract('//newdataset/ex/text()').Getstringval() AS e,
                   Dt.Extract('//newdataset/im/text()').Getstringval() AS I
                    FROM TABLE(Xmlsequence( xmldataset.Extract('//xmldata/newdataset'))) Dt)
        LOOP
        UPDATE t_object_master
      SET add_view=i.Add
      ,edit_view=i.Edit,
      delete_view=i.D,
      export_view=i.E,
      import_view=i.I
      WHERE objct_id=i.Fileid;
      COMMIT;
      END LOOP;
      END Sp_Set_File_Permission;
    When I am trying to exceute this procedure with the above mentioned xml ,getting error ORA-00923 ,FROM keyword not found where expected.
    Please help me out in this.
    Thanks,

    Something like this (no commit inside loop, no row per row)
    create table t_object_master as
    with myxml as (
    select xmltype(
    '<xmldata>
    <newdataset>
    <fileid>99</fileid>
    <add>TRUE</add>
    <edit>TRUE</edit>
    <del>FALSE</del>
    <ex>FALSE</ex>
    <im>TRUE</im>
    </newdataset>
    <newdataset>
    <fileid>100</fileid>
    <add>FALSE</add>
    <edit>TRUE</edit>
    <del>FALSE</del>
    <ex>FALSE</ex>
    <im>TRUE</im>
    </newdataset>
    </xmldata>') doc from dual
    select
    fileid
    ,add_view
    from
    myxml
    ,xmltable('//newdataset'
    passing myxml.doc
    columns
    Fileid number      path 'fileid'
    ,add_view varchar2(5) path 'add'
    table created
    select
    from t_object_master
    FILEID
    ADD_VIEW
    99
    TRUE
    100
    FALSE
    update t_object_master t
    set add_view = (
    with myxml as (
    select xmltype(
    '<xmldata>
    <newdataset>
    <fileid>99</fileid>
    <add>FALSE</add>
    <edit>TRUE</edit>
    <del>FALSE</del>
    <ex>FALSE</ex>
    <im>TRUE</im>
    </newdataset>
    <newdataset>
    <fileid>100</fileid>
    <add>TRUE</add>
    <edit>TRUE</edit>
    <del>FALSE</del>
    <ex>FALSE</ex>
    <im>TRUE</im>
    </newdataset>
    </xmldata>') doc from dual
    , myextract as (
    select
    fileid
    ,add_view
    from
    myxml
    ,xmltable('//newdataset'
    passing myxml.doc
    columns
    Fileid number      path 'fileid'
    ,add_view varchar2(5) path 'add'
    select
    add_view
    from myextract
    where
    fileid = t.fileid
    select *
    from  t_object_master
    FILEID
    ADD_VIEW
    99
    FALSE
    100
    TRUE

  • Help to read a table with data source and convert time stamp

    Hi Gurus,
      I have a req and need to write a ABAP prog. As soon as i excute ABAP program it should ask me enter a data source name, then my ABAP prog has excute teh code, in ABAP code i have to read a table with this data source as key, sort time stamp from table and should display the data source and time stamp as output.
    As follows:
    Enter Data Source Name: 
    Then user enters : 2lis_11_vahdr
    Then out put should be "Data source  :"  10-15-2008.
    The time stamp format in table is 20,050,126,031,520 (YYYYMMDDhhmmss). I have to display as 05-26-2005. Any help would be apprciated.
    Thanks,
    Ram

    Hi Jayanthi Babu Peruri,
    I tried to extract YEAR, MONTH, DAY separately and using
    EDIT MASK written it.
    Definitely there will be some STANDARD CONVERSION ROUTINE will be there. But no idea about it.
    DATA : V_TS      TYPE TIMESTAMP,
           V_TS_T    TYPE CHAR16,
           V_YYYY    TYPE CHAR04,
           V_MM      TYPE CHAR02,
           V_DD      TYPE CHAR02.
    START-OF-SELECTION.
      GET TIME STAMP FIELD V_TS.
      V_TS_T = V_TS.
      CONDENSE V_TS_T.
      V_YYYY = V_TS_T.
      V_MM   = V_TS_T+4(2).
      V_DD   = V_TS_T+6(2).
      V_TS_T(2) = V_MM.
      V_TS_T+2(2) = V_DD.
      V_TS_T+4(4) = V_YYYY.
      SKIP 10.
      WRITE : /10 V_TS," USING EDIT MASK '____-__-________'.
              /10 V_YYYY,
              /10 V_MM,
              /10 V_DD,
              /10 V_TS_T USING EDIT MASK '__-__-__________'.
    If you want DATE alone, just declare the length of V_TS_T as 10.
    Regards,
    R.Nagarajan.
    We can -

  • Get records number from internal table with condition.

    Internal table itab got more than 1000 records,now i need to get the number of records with condition that itab-field1 = 'XXXX'.
    actully, i got an inefficient logic to count the number in a loop statement. is there better way to implement it?

    hello,
    Every time assigning data into temp table and delete may that may not be much efficient. You can check in loop logic how much time is taken. You can check the below code. here I am trying to check the numbers of plant for for one material.
    In this logic material is the first field. So if there is option to make the required field in to the 1 st position then it will be nice.
    TYPES: BEGIN OF x_count,
            matnr TYPE matnr,
            count TYPE i,
           BEGIN OF x_count.
    DATA: i_marc  TYPE STANDARD TABLE OF marc,
          i_count TYPE STANDARD TABLE OF x_count,
          wa_count TYPE x_count.
    FIELD-SYMBOLS: <wa_marc> TYPE marc.
    SELECT * UP TO 1000 ROWS
      FROM marc
      INTO TABLE i_marc.
    IF sy-subrc = 0.
      SORT i_marc BY matnr.
      LOOP AT i_marc ASSIGNING <wa_marc>.
        wa_count-count = wa_count-count + 1.
        AT END OF matnr.
          wa_count-matnr = <wa_marc>-matnr.
          APPEND wa_count TO i_count.
        ENDAT.
      ENDLOOP.
    ENDIF.
    Thanks
    Subhanakr

  • How to reduce time when updating table with join of anther table

    Hi all,
    I am update table Policy1 using another table from other scheme
    Policy1 is in schema "TEST".
    TRN_POLICY_RISK_GIS is in Schema "TEST2".
    Now i am executing my query which is taking lot of time to update and make cpu utilization upto 45%.
    update policy1 set total_si = (select total_is from (select pol_sys_id,
    avg(nvl(pol_cvr_si,0)) total_si from TEST2.TRN_POLICY_COVER_GIS tpcg
    group by pol_sys_id ) b where p.pol_sys_id = b.pol_sys_id)
    Help to optimize to given query.

    update policy1    A
        set total_si =
           (select avg(nvl(pol_cvr_si,0))
               from TEST2.TRN_POLICY_COVER_GIS    B
              where B.pol_sys_id = A.pol_sys_id
    ;hopefully there is an index on TEST2.TRN_POLICY_COVER_GIS (POL_SYS_ID)

  • Updating table with seq

    Hi,
    Need some help..........Theres this history table with composite primary key having a record version number which is incremented everytime theres a modification on its parent table and records are inserted for the same instrument id. (one id = multiple version record number) and these two forms the composite key.......now we have to drop this key, add new column, which will be populated using a sequence....this sequence should be mapped to the instrument id so that there is no data modification for the existing data; later a primary key be applied to this new column with seq numbers. Please help.........
    Thanks in adv.....

    What is the problem in question?
    null

  • Updating table with column NUMBER(6,2) causing concurrency exception in .NE

    For info,
    I try to update a table with a column defined as a NUMBER(6,2). I receive a concurrency exception.
    If I resize this column as a NUMBER(8,2), every thing works well.
    Bye

    I get the same problem. Changing from anything less than number(8,2) changes the vb datatype from single to double.
    Apparently ODP.NET cannot handle the single datatype.
    /Bj�

  • Update table with select from another table

    Hallo,
    I'd like to update table b with codes from a mapping table a.
    a has:
    town_id, town_code, town_name
    b has town_code, town_id, town_population, town_zip_code,...
    Table a has all the details - town_id, town_code and town_name and acts as the mapping between town_id and town_code
    In table b, town_code is null. I want to update the column b.town_code with town_code from table a where a.town_id = b.town_id.
    How will the update query look like?
    I tried
    UPDATE B SET town_code = (SELECT A.town_code FROM A,B WHERE A.town_id=B.town_id)
    and I get the error 'single-row subquery returns more than one row'
    Will appreciate your assistance

    This is what I did.
    First, I created and populated the TOWN_INFO table:
    CREATE TABLE "TOWN_INFO"
    (     "TOWN_ID" NUMBER,
         "TOWN_CODE" NUMBER,
         "E_MAIL" CHAR(15 BYTE)
    Table Created.
    insert all
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3024,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3040,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3052,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3065,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3066,'[email protected]')
    select * from dual
    5 rows created.
    The following creates and populates the mapping table:
    CREATE TABLE "TOWN_MAPP"
    (     "TOWN_CODE" NUMBER,
         "TOWN_ID" VARCHAR2(255 BYTE),
         "TOWN_NAME" CHAR(6 BYTE)
    insert all
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3024,'1001','TOWN_1')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3040,'1003','TOWN_3')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3052,'1002','TOWN_2')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3065,'1004','TOWN_4')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3066,'1006','TOWN_6')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3088,'1007','TOWN_7')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3020,'1009','TOWN_9')
    select * from dual
    7 rows created.
    And now the update query:
    UPDATE TOWN_INFO
    SET TOWN_CODE=(SELECT B.TOWN_CODE FROM TOWN_MAPP B, TOWN_INFO C
    WHERE B.TOWN_ID=B.TOWN_ID)
    SET TOWN_CODE=(SELECT B.TOWN_CODE FROM TOWN_MAPP B, TOWN_INFO C
    ERROR at line 2:
    ORA-01427: single-row subquery returns more than one row
    Thanx in advance
    Edited by: user9954260 on Apr 13, 2010 7:40 AM
    Edited by: user9954260 on Apr 13, 2010 7:44 AM

  • Help in joining nested table with regular table

    Im creating a nested table codelist as object prtcnpt_info. In a anonymous block im declaring t_code as nested table type codelist.
    Now when i try to join the nested table with the regular oracle DB table and i get error: PL/SQL: ORA-00904: "COLUMN_VALUE": invalid identifier.
    Please help me on this and provide tutorial link pertaining to this concepts..Below is the code i wrote
    --Code Start;
    create or replace type prtcnpt_info as object ( id number
    ,name varchar2(200)
    ,code varchar2(30));
    create type codelist is table of prtcnpt_info;
    declare
    t_code codelist;
    begin
    select prtcnpt_info(b.pid ,b.name ,pt.code) bulk collect into t_code
    from part pt
    ,mc_code b
    where pt.cd in ('AAA','BBB')
    and pt.ptype_id=b.pt_type_id;
    INSERT INTO table ( ID
    ,RUN_ID
    ,DATA
    ,P_ID
    SELECT id
         ,run_id
         ,data
         ,prtct.id ----> 1
    FROM table_2 t2
    ,(select column_value from table(t_code)) prtct
    WHERE prtct.id=t2.P_ID; ------> 2
    end;
    --Code End;
    also from the anonymous block
    1 => is this correct way to get value of id (b.pid) from the nested tablet_code aliased as prtct ?
    2 => is this correct way to join the nested table with regular table? i want to join the column id's in both the tables.
    Edited by: 914912 on Apr 30, 2012 2:11 AM

    When you create a table type without an object, i.e. a single column type like this you will get the column name as COLUMN_VALUE.
    SQL*Plus: Release 10.2.0.5.0 - Production on Mon Apr 30 07:38:32 2012
    Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> create or replace type mytbl as table of varchar2(10)
      2  /
    Type created.
    SQL> var rc refcursor
    "afiedt.buf" 11 lines, 162 characters
      1  declare
      2     ltbl mytbl;
      3  begin
      4     select to_char(level) bulk collect into ltbl
      5       from dual
      6    connect by level <= 10;
      7     open :rc for
      8     select * from table(ltbl);
      9* end;
    10  /
    PL/SQL procedure successfully completed.
    SQL> print rc
    COLUMN_VAL
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    10 rows selected.And when you create a table type with object you will get the object column name.
    SQL> drop type mytbl
      2  /
    Type dropped.
    SQL> create type myobj as object (id varchar2(10))
      2  /
    Type created.
    SQL> create type mytbl as table of myobj
      2  /
    Type created.
    SQL> declare
      2     ltbl mytbl;
      3  begin
      4     select myobj(to_char(level)) bulk collect into ltbl
      5       from dual
      6    connect by level <= 10;
      7     open :rc for
      8     select * from table(ltbl);
      9  end;
    10  /
    PL/SQL procedure successfully completed.
    SQL> print rc
    ID
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    10 rows selected.
    SQL>

  • Error Updating Table with "Get Active UnitOfWork" Checked

    Hi everyone.
    I call invoke the a DB Adapter twice to update table in one BPEL, and so I have checked "Get Active UnitOfWork" so that each update can be persisted. I am seeing inconsistent results. What could be causing this?

    Hi, Have you checked the .jca source to make sure this value is indeed checked? Sometimes even when you check this option in the wizard it doesn't reflect in the source when you also perform a select operation: http://docs.oracle.com/cd/E12839_01/relnotes.1111/e10133/adapter.htm. Also are you using the xADataSource driver in the data source and the xADataSourceName ConnectionFactory property?
    21.1.5.1 The Value Of the Active Unit Of Work Property Is Not Saved for Outbound SELECT Operation
    While configuring an outbound Oracle Database Adapter to perform a SELECT operation, if you select Get Active Unit of Work in the Adapter Configuration Wizard - Advanced Option page, then the value of the GetActiveUnitofWork property is not saved in the .jca file.
    The workaround for this issue is to manually add this property in the .jca file of the Oracle Database Adapter, as shown in the following example:
    <property name="GetActiveUnitOfWork" value="true"/>

  • Creation of SAP Query in SQ02 with Single Table With Condition

    Hi All,
    I want to Create SAP Query in SQ02 using single Table MCHA.
    ii) I dont want all entries of MCHA Table I mean , I have to apply some Condition on this Table.
    i.e  Suppose I am having actual data in MCHA table is like this for Material M1.
    Plant    Material   Batch   BatchCreationdate
    P1          M1         B1       20.06.2007
    P2          M1         B1       04.05.2009
    P3          M1         B1       04.05.2009
    But I want the Output of SAP Query is like this:
       Material   Batch   BatchCreationdate
          M1         B1       20.06.2007
    That is irrespective of Plant if Material & Batch are equal ---> 1st record with Lowest date shoud get at the output.
    Please help me How write the code on single table in the SAP Query.
    Thanks,
    Kiran Manyam

    Hi,
    Your query should be like this:
    Select MATNR CHARG HSDAT
    from MCHA
    into table t_mcha
    where matnr = Materlal number from selection screen.
    The structure of t_mcha should contain the fields that you select.
    Then sort the table by date ascending
    Sort t_mcha by HSDAT.
    Hope this solves your problem.
    Thanks,
    Sowmya

Maybe you are looking for