External Table to Internal table Data update query

Hi all ,
I have Follwoing 2 tables one is external oracle and 2nd is internal and both table have the same data as following this is sample data while actual table contains millions of record.
External Table name SE2_EXT
        GL_REF_NO     GL_CUST_ID     GL_TRAN_AMT_LCY     GL_REVERSAL_MARKER     GL_GL_ID     GL_LOCAL
1     5          513557               100               136340003678088.020001     
2     5          513557               -100          R     136340003678088.020002     
3     1          26               -685.12               136340003674772.030001     
4     1          26               685.12          R     136340003674772.030002     
5     4          500539               100               136340003477900.000001     
6     4          500539               -100          R     136340003477900.000002     
7     23          604612               182.15               136340003578165.170001     
8     23          604612               -182.15          R     136340003578165.170002     
9     76          232033               -230.7               136340003576922.100001     
10     76          232033               235.7          R     136340003576957.010001     I want to update GL_LOCAL column with 'R' with conditions that if
WHERE GL2.GL_GL_ID=GL2_EXT.GL_GL_ID
  AND GL2.GL_REF_NO=GL2_EXT.GL_REF_NO
  AND GL2.GL_CUST_ID=GL2_EXT.GL_CUST_ID
  AND GL2.GL_REVERSAL_MARKER IN ('R',NULL)
  AND GL2.GL_TRAN_AMT_LCY=GL2_EXT.GL_TRAN_AMT_LCYbut the tricky thing is GL_TRAN_AMT is one time - (minus) and one time +(plus). I only want to update those record who have same TRAN_AMT_LCY with same other condition mentioned above.
I tried merj statement but it did'nt work.If any body help me i would be appriciated.
MERGE INTO SE2 A
USING ( SELECT GL_REF_NO,GL_CUST_ID,GL_TRAN_AMT_LCY,GL_REVERSAL_MARKER,GL_GL_ID FROM GL2_EXT) B
ON (A.GL_GL_ID=B.GL_GL_ID AND A.GL_CUST_ID=B.GL_CUST_ID)
WHEN MATCHED THEN
UPDATE
SET A.GL_LOCAL_A1=B.SE_LOCAL

Why is it tricky? You did not say.
Making a guess as to the problem why not use TO_NUMBER to cast the string?

Similar Messages

  • Dynamically Update External Table Data

    I loaded a data table from an external csv file. But the csv file is an output from a program that appends a new line to the csv file every couple days.
    I made a Report with the loaded data, but in a couple days when a few new lines of data appear in the csv file, I want my report to update as well.
    Is there a way to create a "Refresh Button" in my application that will load the data from the csv when pressed?
    I have oracle database 11g express with APEX 4.1.1

    Hi,
    what you describe could certainly be achieved, but it would have to be designed and built, it is not going to be provided "out of the box". I would probably go with an external table based on your file and a process that you would build would be callable from the button and this would do some sort of a merge of the external table data into your database table. Apart from being callable on demand, the process could also be made to be a scheduled process that loads the data on a regular basis, say once a day or once an hour, depending on your requirements. To use an external table it is assumed that the file will be available on the database server. If not and the file is available on only a client machine, then doing an on demand load process would still be possible, but a little more difficult.
    Andre

  • External Tables Date Error

    I get error while loading data into Oracle 11g R2 with EXTERNAL TABLES.
    error processing column DATE_M in row 1 for datafile C:\app\S\admin\orcl\dpdump\TABLE_EXT.txt
    ORA-01847: day of month must be between 1 and last day of month
    error processing column DATE_M in row 2 for datafile C:\app\S\admin\orcl\dpdump\TABLE_EXT.txt
    ORA-01843: not a valid month
    error processing column DATE_M in row 3 for datafile C:\app\S\admin\orcl\dpdump\TABLE_EXT.txt
    ORA-01843: not a valid month
    error processing column DATE_M in row 4 for datafile C:\app\S\admin\orcl\dpdump\TABLE_EXT.txt
    ORA-01847: day of month must be between 1 and last day of month
    error processing column DATE_M in row 5 for datafile C:\app\S\admin\orcl\dpdump\TABLE_EXT.txt
    ORA-01843: not a valid month
    error processing column DATE_M in row 6 for datafile C:\app\S\admin\orcl\dpdump\TABLE_EXT.txt
    ORA-01843: not a valid month
    error processing column DATE_M in row 7 for datafile C:\app\S\admin\orcl\dpdump\TABLE_EXT.txt
    ORA-01843: not a valid month
    error processing column DATE_M in row 8 for datafile C:\app\S\admin\orcl\dpdump\TABLE_EXT.txt
    ORA-01843: not a valid month
    error processing column DATE_M in row 9 for datafile C:\app\S\admin\orcl\dpdump\TABLE_EXT.txt
    ORA-01843: not a valid month
    error processing column DATE_M in row 10 for datafile C:\app\S\admin\orcl\dpdump\TABLE_EXT.txt
    ORA-01843: not a valid month-----
    CREATE TABLE TABLE_EXT
       (  "COMPANY" VARCHAR2(101),
      "COMPANY_VN" VARCHAR2(15),
      "IL" VARCHAR2(17),
      "TERMINAL" VARCHAR2(8),
      "T_NO" VARCHAR2(15),
      "NAME" VARCHAR2(108),
      "SNAME" VARCHAR2(50),
      "REF_NO" VARCHAR2(23),
      "AMOUNT" NUMBER(15,2),
      "DATE_M" DATE,
      "TIME" VARCHAR2(11),
      "TEL_NO" VARCHAR2(25),
      "ADDRESS" VARCHAR2(50)
       ORGANIZATION EXTERNAL (
      TYPE ORACLE_LOADER
      DEFAULT DIRECTORY data_pump_dir
      ACCESS PARAMETERS (
        RECORDS DELIMITED BY NEWLINE
        FIELDS TERMINATED BY '|'
        MISSING FIELD VALUES ARE NULL
    COMPANY,
    COMPANY_VN,
    IL,
    TERMINAL,
    T_NO,
    NAME,
    SNAME,
    REF_NO,
    AMOUNT decimal  ,
    DATE_M CHAR  date_format DATE mask "dd.mm.yyyy" ,
    TIME,
    TEL_NO,
    ADDRESS
      LOCATION ('TABLE_EXT.txt')
    REJECT LIMIT 10------
    Sample Data:
    CITY HOSPITAL|04680072124|CITY|00614860|47746244218|JOHN|WHITE|172871|420,12|21.08.2011|14:26|0806422627784|06
    CITY HOSPITAL|04680072124|CITY|00614847|14274017676|BRAD|BROWN|448127|810,00|22.08.2011|11:04|0806427488476|06
    CITY HOSPITAL|04680072124|CITY|00614842|16218778886|PETER|BALSON|862626|12,00|24.08.2011|14:16|0806062177008|06
    CITY HOSPITAL|04680072124|CITY|00614846|14607666866|GEORGE|LOUIS|688811|40,10|24.08.2011|08:48|0806424172468|06
    CITY HOSPITAL|04680072124|CITY|00614846|14607666866|GEORGE|LOUIS|460481|42,64|24.08.2011|08:47|0806424172468|06
    CITY HOSPITAL|04680072124|CITY|00614860|18460662462|JR|TEPE|404622|44,16|22.04.2011|20:08|0806446446866|06
    CITY HOSPITAL|04680072124|CITY|00614840|47207688618|BARRY|HRAN|402886|42,40|27.08.2011|11:12|0806478768007|06
    CITY HOSPITAL|04680072124|CITY|00614847|42161048612|TOM|HIGGS|148640|12,00|06.06.2011|08:18|0806068076700|06
    CITY HOSPITAL|04680072124|CITY|00614846|42161048612|TOM|HIGGS|208847|12,00|06.06.2011|08:46|0806068076700|06-----
    NLS_DATE_FORMAT : DD/MM/RRRR-----
    NOTE:
    I tried :
    TARIH CHAR date_format DATE mask "DD/MM/RRRR" , same error.
    Edited by: 904386 on Jan 24, 2012 6:42 AM

    I have no experience with external tables but my understanding is that they are described the same was as you would describe a file to be loaded by SQL Loader. When ever I create a sql loader control file to load a date column I use syntax like this:
    DATE_M                                             "TO_DATE(:DATE_M,'dd.mm.yyyy')",Not sure if that will work for external tables or not.

  • External table data edit

    Hi Experts...
    I am trying to export data from main frame system files(.csv) by using the external tables,
    my question is can I edit before loading into the external tables? if yes how/
    or else wat is the best process to edit while loading from external tables to main tables?
    sample code will be appreciated...

    It depends on what you mean by "edit". You can do anything in a sql statment against an external table that you can against a real table. So, if by "edit" you mean things like make a column upper case, do some basic formatting etc., or even ignore some lines/columns in the file, then it should be done is the select statment from the external table.
    John

  • Large Table Data Updation

    Hi,
    I have a large table about 8 GB i need to add a new column to this table and update new column values of all the present records.
    Please let me know any good methods for the same. while doing i same i also intend to partition the table.
    Thanks in advance.

    Check this
    SQL> CREATE TABLE tb1(c1 NUMBER);
    Table created.
    SQL> ALTER TABLE tb1 ADD CONSTRAINT tb1_pk PRIMARY KEY(c1);
    Table altered.
    SQL> INSERT INTO tb1 VALUES(1);
    1 row created.
    SQL> CREATE TABLE tb2(c1 NUMBER, c2 NUMBER);
    Table created.
    SQL> exec dbms_redefinition.can_redef_table(USER, 'TB1');
    PL/SQL procedure successfully completed.
    SQL>  exec dbms_redefinition.start_redef_table(USER, 'TB1', 'TB2', 'C1 C1, 34 C2');
    PL/SQL procedure successfully completed.
    SQL> exec dbms_redefinition.finish_redef_table(USER, 'TB1', 'TB2')
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM tb1;
         C1        C2
          1        34
    SQL> Lukasz

  • Effects of Updating GRPO table from Update Query..

    Hi all,
    Wanted to know what are the repercussions of updating GRPO table with Update statement, Basically the client is not selected Project field in the GRPO rows in some of the documents during the Posting. Now the same is to be updated, as Invoices are created for most of them and payments also made document is un-editable.
    If i can update using UPDATE statement how will the system react? I know as per SAP guidelines, we cannot update the SAP Tables directly using INSERT or UPDATE statements but wanted to know what is the further effect on postings and SAP as a whole.
    Regards
    Rohan

    Hi,
    The using of update, insert or delete are not allowed in SAP B1. If you use it in B1 db, the maintenance contract with you will be stopped and your money will not be returned. The consequence of using the statements is the database inconsistency.
    Just an info, SAP AG support will use insert, update and delete statement only if the statements are needed and fix the db inconsistency. E.g., if your user is trying to add sales order and after add, the sales order row is empty and header is not empty. SAP will use  the statement to fix the database only if the cause of the error is explained to them. E.g. the server is suddenly shutdown because  the power supply is stopped and it made the sales order like that
    JimM

  • Filter Table data on Query Result

    Dear All
    When I execute the following query (in Query Generator) I got 6411 records. But when I want to filer this table, in the drop down list in 'ITEM' column I found only 500 records (i.e. up to the recods starting with 'K' though there are records starting with 'W' in 'ITEM' field).
    I am using SAP B1, PL 14.
    Can any one suggest how to get all the records in the drop down list of filter window?
    My query is as follows:
    SELECT     distinct D.ITEMCODE + ' - ' + D.DSCRIPTION 'ITEM',
              DATENAME(M,H.DOCDATE) + ' - ' + DATENAME(YYYY,H.DOCDATE) 'MONTH',
              D.PRICE
    FROM     PCH1 D INNER JOIN OPCH H ON H.DOCENTRY= D.DOCENTRY
    WHERE     H.DOCTYPE='I' AND D.ITEMCODE + ' - ' + D.DSCRIPTION IS NOT NULL
    ORDER BY     1, 2
    Thnaks & with regards
    Aloke
    Edited by: ALOKE BANDYOPADHYAY on Jul 15, 2011 4:51 PM

    Dear Gordon
    I have placed the following problem also in forum since one month without receiving any positive answer. So I am requesting you personally can you help me to solve the problem:
    Following is the code I am using for revaluation of items which is giveing "Internal Error 5002':
    Dim lMaterialRevaluation As SAPbobsCOM.MaterialRevaluation
    lMaterialRevaluation = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oMaterialRevaluation)
    For li As Integer = 0 To ls_Lines.Length - 1
    If ls_Lines(li).Split(vbTab).Length 5 Then
    My.Computer.FileSystem.WriteAllText(ls_OutFileName, lnl_SrlNo & "--> Can't Read in the data in Line " & li + 1, True)
    My.Computer.FileSystem.WriteAllText(ls_OutFileName, vbNewLine, True)
    lnl_SrlNo += 1
    Continue For
    End If
    ls_ItemCode = ls_Lines(li).Split(vbTab)(0).Trim
    ls_WareHouseCode = ls_Lines(li).Split(vbTab)(1).Trim
    ld_Price = ls_Lines(li).Split(vbTab)(2).Trim
    li_IncAccount = ls_Lines(li).Split(vbTab)(3).Trim
    li_DecAccount = ls_Lines(li).Split(vbTab)(4).Trim
    lMaterialRevaluation.Lines.SetCurrentLine(li)
    lMaterialRevaluation.Lines.ItemCode = ls_ItemCode
    lMaterialRevaluation.Lines.WarehouseCode = ls_WareHouseCode
    lMaterialRevaluation.Lines.Price = ld_Price
    lMaterialRevaluation.Lines.RevaluationIncrementAccount = li_IncAccount
    lMaterialRevaluation.Lines.RevaluationDecrementAccount = li_DecAccount
    lMaterialRevaluation.Lines.Add()
    Next
    Dim li_Ret As Integer
    li_Ret = lMaterialRevaluation.Add
    If li_Ret = 0 Then
    MsgBox("Material Revaluation Completed")
    System.Runtime.InteropServices.Marshal.ReleaseComObject(lMaterialRevaluation)
    Else
    oCompany.GetLastError(lErrCode, sErrMsg)
    MsgBox(sErrMsg & ", Material Revaluation failed")
    End If
    Thanks & with regards
    Aloke

  • Asking for transport request whie table data updation

    Hi All,
    I am trying to update a table TCJ04 using transaction OPS6. When ever I am adding a new entry or edit the existing entry and click SAVE, the table is asking for Transport request number.
    This table carries a master data and should not be asking for transport request. Rather its access has to be controlled by user authorisation.
    Please tell me as to what is the reason of asking for transport request.
    regards,
    Gaurav.

    Hi Gourav,
    If you go table maintanance generater of the table TCJ04 in SE11, you will find that Standard recording routine radio button is selected. That is the reason you are asked to provide transport request while updating data.

  • Problem: Z table data updates using SM30

    Hi,
    I have a requirement, while updating records in a Z table
    using SM30 Transaction.
    The Structure of the table is below:
    APMOD    Primary Key   Char(3)
    KONST    Primary Key   Char(20)
    ENDDA    Primary Key   DATS
    BEGDA    Non Key       DATS   
    and some other non key fields....
    Problem:  This table should act something like Infotype in HR.  I mean Delimition of Records while creating or changeing the existing record.
    Say there is a record
    APMOD = OGMT
    KONST = Organization Management
    BEGDA = 01/01/2004
    ENDDA = 12/31/9999
    Whenever i am Inserting a new record with key
    APMOD = OGMT and KONST = 'Organization Management'
    and BEGDA = '01/01/2006'.
    First it should update the old record with
    BEGDA = 01/01/2004 and ENDDA = 12/31/2005
    Then the new record needs to be inserted with
    BEGDA = 01/01/2006 and ENDDA = 12/31/9999.
    How can I achieve this using SM30? Can we write our own code somewhere? If yes Where and How?  Or is there any settings available for this requirement?
    I can write a Z program to update this Table, but i should achieve this using SM30 only.
    Let me know if you need any additional info. 
    Regards,
    Sudhakar.

    Hi Sudhakar,
    1. I tried the same at my end. It works fantastic !
       In  SM30 it shows
       'Delimit' Button
       'Expand <--> Collapse' Button.
        and accordingly delmits the records.
    2. in SE11,
       Use the menu
       Utilities ---> Table Maintenance Generator
       and finally build a table maintenance
       to use in SM30.
    3. When u use in SM30,
       u will achieve what u want.
    4. Just make sure your field
       ENDDA has the data element ENDDA
       in table definition.
      It should also be key.
    5. After this ENDDA column,
       there should be no other key column
      ( not even BEGDA)
    I Hope it helps.
    Regards,
    Amit M.

  • How to join four tables in Update query??

    Please how to join four tables in a single query to update one table row??

    You can use this syntax to update. Here updation of 1 column to a constant value (50) in multiple rows in Table A based on an associated 'SOURCE' value in table B
    Table A joins to Table B based on the TableA.definition_id = TableB.Att_Def_id
    like..
    update TableA
    set value =50
    where
    TableA.definition_id = TableB.Att_Def_id
    and TABLEB.Source = 'NEWPRODUCT'

  • Asking for transport request while table data updation

    Hi All,
    I am trying to update a table TCJ04 using transaction OPS6. When ever I am adding a new entry or edit the existing entry and click SAVE, the table is asking for Transport request number.
    This table carries a master data and should not be asking for transport request. Rather its access has to be controlled by user authorisation.
    Please tell me as to what is the reason of asking for transport request.
    regards,
    Gaurav.

    Hi There,
    It is asking for the transport request for each new entry in the table since the Delivery class in the attributes is set to C( Customizing table, maintenance only by cust., not SAP import ), If it is set to "A" it will not ask for the transport request..
    Try creating a custom table and play around with the Delivery class, A and C, you will come to know the difference.
    Let me know if you need further help in this regard.
    don't 4get to rward pionts if found helpful.
    Thanks-

  • BADI   ME_GUI_PO_CUST  Data Updation Query

    Hi
    I am adding Subscreen in PO at item level by using BADI ME_GUI_PO_CUST , subscreen is successfully implemented and
    visible at item level and the table which i have made for collecting the customer data but Z table is not populated.
    I have made changes to following interfaces
    SUBSCRIBE
    MAP_DYNPRO_FIELDS
    TRANSPORT_FROM_MODEL
    TRANSPORT_TO_DYNP
    TRANSPORT_FROM_DYNP
    TRANSPORT_TO_MODEL
    EXECUTE
    So what steps i will follow to update the data in Z table.
    Ankesh Jindal
    Edited by: Ankesh Jindal on Aug 20, 2009 12:28 PM
    Edited by: Ankesh Jindal on Aug 20, 2009 12:29 PM

    HI,
    Use the perform
    perform set_header_data(saplmepo) using ekko.
    Thanks,
    Shailaja Ainala.

  • Accessing The External Table using UIAPI and DIAPI

    Hi  Every One,
    can any one tell me about , can we access the external table data  that is created by using sql query externally using UIApi and DIAPI
    Regards
    Srinivas

    Hi,
    technically is it possible, but all inserts and updates have to be through query.
    Note, that when you create tables from sdk, you can set more informations about fields than in sql query manager (for example subtype) - so you may have problem in binding data to matrix for example. So if you have table externally, you may work with, but this isn`t allowed by SAP (and I think that this case may be dangerous if you acces it in sdk). If you need to acces it on sql server side (own numbering, some stored procedure, ..) it will works safer, but it is not allowed as well.
    Petr

  • External tables in Oracle 11g database is not loading null value records

    We have upgraded our DB from Oracle 9i to 11g...
    It was noticed that data load to external tables in 9i is rejecting the records with null columns..However upgrading it to 11g,it allows the records with null values.
    Is there are way to restrict loading the records that has few coulmns that are null..
    Can you please share if this is the expected behaviour in Oracle 11g...
    Thanks.

    Data isn't really loaded to an External Table. Rather, the external table lets you query an external data source as if it were a regular database table. To not see the rows with the NULL value, simply filter those rows out with your SQL statement:
    SELECT * FROM my_external_table WHERE colX IS NOT NULL;
    HTH,
    Brian

  • External Table log file

    I am using external table in my query and it works fine, just I want to create log file or bad file if any in different folder currently it create in same folder where data file (CSV) exists.
    create or replace directory data_dir as 'c:\temp\'

    You can specify one or many of the following options:
    NOBADFILE NODISCARDFILE NOLOGFILEIn the ACCESS PARAMETERS portion of your table definition.
    Hope this helps!

Maybe you are looking for