Update temp table with alias

I have query like this:
SELECT o1.q_sum, c.q_sum FROM CTE1 c INNER JOIN #order o1 ON o1.col1=c1.col1
It works. I get c.q_sum different from null for every row, while o1.q_sum is null.
But if I write like this:
UPDATE o1 SET o1.q_sum=c.q_sum FROM CTE1 c INNER JOIN #order o1 ON o1.col1=c1.col1
id doesn't work. The all columns q_sum from temp table are still null. How is that possible?

Do not need alias for columns
create table #t (c int)
insert into #t values (1)
update o set c =2 from #t o  ---works just fine
create table #t1 (c int)
insert into #t1 values (2)
update o set c =#t1.c from #t o join #t1 on o.c=#t1.c  ---works just fine
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence

Similar Messages

  • URGENT  update a table with a text that has a single quote in it

    Hello, I am trying to update a table with a text that has a single quote in it. I believe I need to use two singles quotes but I am not sure how.
    For example:
    UPDATE TEST
    SET DESCRLONG='Aux fins d'exportations'
    WHERE etc...
    Should I put 2 singles quotes before the quote in the text?
    UPDATE TEST
    SET DESCRLONG='Aux fins d'''exportations'
    WHERE etc...
    Thank you very much :)

    The best way depends on the version of Oracle.
    But, the quick and universal answer is to use two single quotes
    SQL> connect test/test
    Connected.
    SQL> create table test (descrlong varchar2(128));
    Table created.
    SQL> insert into test values ('This is a string with a '' single quote');
    1 row created.
    SQL> select * from test;
    DESCRLONG
    This is a string with a ' single quote
    SQL> update test set descrlong='Aux fins d''exportations'
      2  where descrlong like 'T%';
    1 row updated.
    SQL> select * from test;
    DESCRLONG
    Aux fins d'exportations
    SQL>                                             

  • Is it possible to update multiple tables with a dynamic form?

    I have columns from two tables populating a dynamic form. I am trying to have the form update both tables on submit. I have tried both a linked transaction and a custom transaction but I am not making progress. Only the master table is being updated. Is it possible with ADDT to update two tables with a dynamic form?

    I meant
    SXMSMSTAT
    SXMSSYERR
    Thanks.

  • How can I update the table with a single query for...

    I have a table with columns C1 and C2.
    C1 C2
    A1 null
    A1 null
    A1 null
    A1 null
    A2 null
    A2 null
    A2 null
    A3 null
    A4 null
    A4 null
    I want to update my table with a single query so that I would have data like
    C1 C2
    A1 1
    A1 2
    A1 3
    A1 4
    A2 1
    A2 2
    A2 3
    A3 1
    A4 1
    A4 2
    The updated column C2 has the values like serial no grouped on the column C1.

    SQL> create table mytable
      2  ( c1 varchar2(2)
      3  , c2 number(2)
      4  )
      5  /
    Tabel is aangemaakt.
    SQL> insert into mytable (c1)
      2  select 'A1' from dual union all
      3  select 'A1' from dual union all
      4  select 'A1' from dual union all
      5  select 'A1' from dual union all
      6  select 'A2' from dual union all
      7  select 'A2' from dual union all
      8  select 'A2' from dual union all
      9  select 'A3' from dual union all
    10  select 'A4' from dual union all
    11  select 'A4' from dual
    12  /
    10 rijen zijn aangemaakt.
    SQL> select * from mytable
      2  /
    C1                                     C2
    A1
    A1
    A1
    A1
    A2
    A2
    A2
    A3
    A4
    A4
    10 rijen zijn geselecteerd.
    SQL> merge into mytable t1
      2  using (select c1
      3              , row_number() over (partition by c1 order by null) rn
      4              , rowid rid
      5           from mytable
      6        ) t2
      7     on (t1.rowid = t2.rid)
      8   when matched then
      9        update set c2 = rn
    10   when not matched then
    11        insert values (null,null)
    12  /
    10 rijen zijn samengevoegd.
    SQL> select * from mytable
      2  /
    C1                                     C2
    A1                                      1
    A1                                      2
    A1                                      3
    A1                                      4
    A2                                      1
    A2                                      2
    A2                                      3
    A3                                      1
    A4                                      1
    A4                                      2
    10 rijen zijn geselecteerd.Regards,
    Rob.

  • Updating base table with Materialized View's data

    Hi,
    In order to update base table with MVs data, I am trying real time data transfer between two databases. One is Oracle 8i and other is Oracle 9i. I have created an updatable MV in 9i on a base table using database link. The base table is in 8i. Materialized View log is created in 8i on base table. MV has to be associated to some replication group, but I am not able to create replication group in 9i to which MV has to be associated. The required packages are not installed.
    Replication packages are to be used to create replication group are :
    /*Create Materialized View replication group*/
    BEGIN
    DBMS_REPCAT.CREATE_MVIEW_REPGROUP (
    gname => 'TEST_MV_GRP',
    master => 'TEST_DATA_LINK',
    propagation_mode => 'ASYNCHRONOUS');
    END;
    But above block is giving error.
    Can anyone suggest how to resolve this, or are there any other approaches (by not using replication packages) to update base table with MVs data ?
    Thanks,
    Shailesh

    Yes, I created link between two databases and was able to update tables on 8i from 9i database using that link.
    The error I am getting while creating replication group is :
    ORA-06550
    PLS-00201 : identifier 'SYS.DBMS_REPCAT_UTL2@'TEST_DATA_LINK' must be declared
    ORA-06550
    PLS-00201 : identifier 'SYS.DBMS_REPCAT_UNTRUSTED@'TEST_DATA_LINK' must be declared
    ORA-06512 : at "SYS.DBMS_REPCAT_UTL", line 2394
    ORA-06512 : at "SYS.DBMS_REPCAT_SNA_UTL", line 1699
    ORA-06512 : at "SYS.DBMS_REPCAT_SNA", line 64
    ORA-06512 : at "SYS.DBMS_REPCAT", line 1262
    Is there any other approach which can be used to update base table with MVs data instead of using replication packages ?
    Thanks,
    Shailesh

  • Best way to update a table with disinct values

    Hi, i would really appreciate some advise:
    I need to reguarly perform a task where i update 1 table with all the new data that has been entered from another table. I cant perform a complete insert as this will create duplicate data every time it runs so the only way i can think of is using cursors as per the script below:
    CREATE OR REPLACE PROCEDURE update_new_mem IS
    tmpVar NUMBER;
    CURSOR c_mem IS
    SELECT member_name,member_id
    FROM gym.members;
    crec c_mem%ROWTYPE;
    BEGIN
    OPEN c_mem;
    LOOP
    FETCH c_mem INTO crec;
    EXIT WHEN c_mem%NOTFOUND;
    BEGIN
    UPDATE gym.lifts
    SET name = crec.member_name
    WHERE member_id = crec.member_id;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN NULL;
    END;
    IF SQL%NOTFOUND THEN
    BEGIN
    INSERT INTO gym.lifts
    (name,member_id)
    VALUES (crec.member_name,crec.member_id);
    END;
    END IF;
    END LOOP;
    CLOSE c_mem;
    END update_new_mem;
    This method works but is there an easier (faster) way to update another table with new data only?
    Many thanks

    >
    This method works but is there an easier (faster) way to update another table with new data only?
    >
    Almost anything would be better than that slow-by-slow loop processing.
    You don't need a procedure you should just use MERGE for that. See the examples in the MERGE section of the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm
    MERGE INTO bonuses D
       USING (SELECT employee_id, salary, department_id FROM employees
       WHERE department_id = 80) S
       ON (D.employee_id = S.employee_id)
       WHEN MATCHED THEN UPDATE SET D.bonus = D.bonus + S.salary*.01
         DELETE WHERE (S.salary > 8000)
       WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus)
         VALUES (S.employee_id, S.salary*.01)
         WHERE (S.salary <= 8000);

  • Populating a temp table with multiple records.

    I want to populate a temp table with a a set of recs. This table will be used for
    crossing/joining with my other tables to pull out data.
    ie:
    Main table (loc)contains these fields -> county,permit,utme,utmn
    Temp table ( tmpid) contains these fields -> countytemp, permittemp
    So I will be doing a statement like this once my temp table is populated.
    Select l.county,l.permit,l.utme,l.utmn from loc l,tmpid t where l.county=t.countytemp and l.permit=t.permittemp;
    So this temp table will basically be a list of ids that can range from a few recs to several hundred.
    I want to know is there is way I can poplulate/repopulate it easily using sqlPlus/other by reading in a Ascii file
    from client PCs. (besides SQL loader).

    HI
    let me explain my requirement first,
    i need to populate my block with the results from the following sql
    SELECT * from contactdet where
    (Month=12 and TrType='MTM' and FinYr='04-05' and Userid='SA009' and Clcode='SB001')
    UNION
    SELECT * from contactdetSUM where (Clcode='SB001' AND CSCODE='AB001')
    Pease note. the where clauses i have put are different in each table and my requirement is
    the constants values i have put in where clause should be variable (ie. i should be able to put variables like :clcode or so)
    I tried us using Query data source type as 'FROM clause query' but it does not allow me to put variables in where clause.
    Is there any way out i can do this ? Please help me
    Regards
    Uday

  • Updating a table with billion rows

    It was an interview question, what's the best way to update a table with 10 billion rows. Give me your suggestions. Thanks in advance.
    svk

    The best way to answer questions such as this is NOT with a absolute and specific answer.  Instead, discuss your strategy for approaching the problem.  The first step is to understand your exact requirement.  It is surprising how often people
    write update statements with an under-qualified where clause. NEVER update a row that does not need to be updated.  For example, a statement like:
    update mytable set cola = 'ABC' where id in (1, 45, 212);
    Assuming id is unique for the table and the specified values exist in the table, we know 3 rows will be updated.  Do all of those rows need to be updated?  Think about it.  If cola is already set to 'ABC' for any of those rows, we could ignore
    those rows and make the update more efficient.  To do that, you need to add "and cola <> 'ABC' " to the where clause.   That is just one example of understanding exactly what you need to do - and doing only that which needs to be done.
    Once you understand exactly what you need to do, you need to analyze the impact of the update and identify any potential issues.  Updating a lot of rows can take a lot of time and consume large amounts of log and disk space.  What else is using
    the table?  Can you afford to lock the table for the duration of the update?  Are there concurrency issues, regardless of whether you update in batches or in one single statement?  When using a batch approach, is there an issue if someone runs
    a query against the table (i.e., the result is different from that of the same query run after all updates have been completed)?  Are you changing something which is included in an index?  Are you changing part of the clustered index? 
    Ultimately, every question you are asked is (or should be) designed to test your problem-solving skills and your skillset. IMO, it is relatively easy to improve your skillset of any particular tool, language, or environment.  The other - not so much
    and that is why they are more valuable IMO.

  • UPDATING A TABLE WITH SAME INFO FROM ANOTHER TABLE ON THE SAME DB

    0down votefavorite
    I am trying to update a table with info from another table on the same db with same table name. I just want the info to be the same , no primary key or constraint involve just a straight replacement of records and I keep getting errors WITH THE TABLE not
    being recignize. below is my query:
    UPDATE
    VNDFIL
    SET EOBTYP
    =  VNDFIL.EOBTYP, 
    EDI_X12_835_VERSION =  VNDFIL.EDI_X12_835_VERSION
    FROM
    AGERECOVERY
    WHERE
    VNDFIL.EOBTYP
    = VNDFIL.EOBTYP
    AND
    VNDFIL
    .EDI_X12_835_VERSION
    = VNDFIL.EDI_X12_835_VERSION

    Hi rotary,
    If those two same named tables are in the same database then they have to be in different schemas. If you mean they are in the same server instance, then they may be in different databases, besides the "table not being recognized" error,
    anyway you should use the fully qualified table names, that is database.Schema.Table(If across instances, ServerName should be prefixed) to avoid the table unrecognized error.
    Using Identifiers As Object Names
    With the fully qualified names, your update statement can be like below.
    UPDATE
    db1.schema1.VNDFIL
    SET EOBTYP = srcTbl.EOBTYP, EDI_X12_835_VERSION = srcTbl.EDI_X12_835_VERSION
    FROM
    db1.schema2.VNDFIL srcTbl
    WHERE
    db1.schema1.VNDFIL.EOBTYP = srcTbl.VNDFIL.EOBTYP AND
    db1.schema1.VNDFIL.EDI_X12_835_VERSION = srcTbl.VNDFIL.EDI_X12_835_VERSION
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • How to update two tables with trigger

    Hi:
    how to update two tables with trigger ?
    I have two tables :
    (1)ASIA
    MI number;
    (2)ASIA_P
    ID number;
    When I insert a new value into the asia.MI ,I also can
    insert the same value into the asia_p.id field.
    I have write a trigger as follows but it does't work.
    create or replace trigger MI_TRG
    before insert on asia
    for each row
    declare
    seq number;
    begin
    select MI_SEQ.Nextval into seq from dual;
    :new.MI:=seq;
    insert into ASIA_PRO(MI_ID)
    values
    (seq);
    end MI_TRG;
    How to realize it ?
    thanks
    zzm

    Why do you say it does not work?

  • Recordset - updating 2 tables with 1 recordset using application object update record

    I have a recordset that uses a field from 2 different tables
    with a select statement where clause that joins a userid. I can
    display the field’s data just fine. Now I want to use the
    Application object “update record” so I can modify
    either of the fields. The problem is the Application object
    “update record” only allows you to update one table.
    How does Dreamweaver mx 2004 allow me to update 2 tables with one
    recordset and 1 submit button? Currently using php.
    Example of where:
    Where member.userid = member_detail.userid
    I tried creating the one form with the field from the first
    table and that works just fine. I added the other field from the
    other table into the form but ofcourse there isn’t any code
    that will update the second table so it won’t work.
    My application requires me to update alot of fields between 2
    tables at the same time.
    Does anyone know a way using Dreamweaver mx 2004 to do this?
    I don’t have much php experience.

    jon-rookie wrote:
    > DreamerJim,
    >
    > I am sorry but I don't think you are correct. I just
    can't believe that with
    > all the powers to be at Macromedia and now Adobe can't
    figure out how to update
    > two tables at once. There are millions of db's out there
    that require this. I
    > spent several hours today perusing lots of posts on the
    internet. It seems I
    > am not the only one out there that has asked this
    question. Unfortunately
    > there are no good answers yet to my surprise.
    >
    > I did find a Dreamweaver extension that does exactly
    what I myself and many
    > others want. The problem is it is no longer available
    unless you purchase a
    > bundle of software from Adobe.
    >
    > I have not looked into it in detail so I am not 100%
    sure that is accurate!
    >
    > Still, alot of php programmers do this all the time
    without much trouble. I
    > just want to know if Dreamweaver mx 2004 has the
    capability if a person knows
    > the right steps.
    >
    > Hopefully a Dreamweaver expert will post something to
    let us know for sure.
    > Until then I am stuck.
    >
    Not even CS3 has this built in, you will either have to code
    it yourself
    or buy the extension you have found. Dreamweaver gives you
    basic
    features to help you develop applications, but if you want to
    do
    anything really clever you have to do it yourself.
    One thing to consider is maybe creating an SQL view that is
    can be
    updated. I am pretty sure it exists, then you use the view
    instead of
    the table in the update behaviour. I have never done it
    myself, but I am
    sure it can be done.
    Steve

  • Global Temp table with BLOB causing session crash

    Hi,
    i have a table as follows:
    create global temporary table spg_file_import (
    name varchar2 (128) constraint sfi_nam_ck not null,
    mime_type varchar2 (128),
    doc_size number,
    dad_charset varchar2 (128),
    last_updated date,
    content_type varchar2 (128),
    content long raw,
    blob_content blob
    on commit delete rows
    this is my 9ias 'document' table thats used to receive uploaded files which i modified to be global temporary.
    what i want to do is:
    a)upload a text file (xml)
    b) convert that file to clob
    c) store that file in new permanent table as clob
    d) commit (hence delete temp table rows as they are no longer necessary)
    to test it i have:
    CREATE OR REPLACE procedure daz_html
    as
    begin
    htp.p(' <FORM enctype="multipart/form-data" action="daz_fu" method="POST">');
    htp.p(' <p>');
    htp.p(' File to upload: <INPUT type="file" name="p_file_in"><br>');
    htp.p(' <p><INPUT type="submit">');
    htp.p(' </form>');
    htp.p('</body>');
    htp.p('</html>');
    end;
    CREATE OR REPLACE procedure daz_fu (
    p_file_in varchar2
    as
    -- BLOB Stream locator
    v_raw blob;
    v_clob clob;
    v_blob_length number;
    v_length number;
    v_buffer varchar2(32767);
    v_pos number := 1;
    begin
    -- Get xml document from transient 9iAs data store.
    select blob_content
    into v_raw
    from spg_file_import
    where name = p_file_in;
    -- create temp LOB
    dbms_lob.createtemporary(v_clob, false);
    -- get BLOB length
    v_blob_length := dbms_lob.getlength(v_raw);
    loop
    -- get length to read. this is set as a max length of 32767
    v_length := least((v_blob_length - (v_pos-1)),32767);
    -- assign BLOB to a varchar2 buffer in preparation to convert to CLOB
    v_buffer := utl_raw.cast_to_varchar2(dbms_lob.substr(v_raw, v_length, v_pos));
    -- now write out to the CLOB
    dbms_lob.writeappend(v_clob, v_length, v_buffer);
    -- increment our position.
    v_pos := v_pos + v_length;
    -- exit when we are done.
    exit when v_pos >= v_blob_length;
    end loop;
    commit;
    htp.p('commit done!');
    end;
    now if i upload a small text file (about 5kb) it works with no problem.
    however if I upload a large text file (say about 1Mb) it crashes oracle with:
    Fri, 26 Jul 2002 11:49:24 GMT
    ORA-03113: end-of-file on communication channel
    DAD name: spgd1
    PROCEDURE : daz_fu
    USER : spg
    URL : http://www.bracknell.bt.co.uk/pls/spgd1/daz_fu
    PARAMETERS :
    ============
    p_file_in:
    F22210/Document.txt
    this produces a large trc file.. the trace file indicates the crash occured on the commit; line
    Current RBA:[0x4eb0.117.10]
    *** 2002-07-26 12:35:11.857
    ksedmp: internal or fatal error
    ORA-00600: internal error code, arguments: [kcblibr_user_found], [4294967295], [2], [12583564], [65], [], [], []
    Current SQL statement for this session:
    declare
    rc__ number;
    begin
    owa.init_cgi_env(:n__,:nm__,:v__);
    htp.HTBUF_LEN := 255;
    null;
    daz_fu(p_ref_in=>:p_ref_in,p_type_in=>:p_type_in,p_file_in=>:p_file_in);
    if (wpg_docload.is_file_download) then
    rc__ := 1;
    wpg_docload.get_download_file(:doc_info);
    null;
    commit;
    else
    rc__ := 0; null;
    commit;
    owa.get_page(:data__,:ndata__);
    end if;
    :rc__ := rc__;
    end;
    ----- PL/SQL Call Stack -----
    object line object
    handle number name
    812b1998 42 procedure SPG.DAZ_FU
    819dff90 7 anonymous block
    ----- Call Stack Trace -----
    If i reaplce the temporary table with a non-temp table of the same structure i get no problems what-so-ever. Am I doing something that I shouldnt be with global temporary tables?
    Thanks.

    This is on Oracle 8.1.7.2

  • Progammatic update a table with a database view  in the page

    Hi All,
    I am using JDev 11g. With FOD database schema, I have one database view Products which comes from two tables Products_Base and Product_Transactions. I created three EOs (ProductEO, ProductsBaseEO, ProductTransactionsEO) and three VOs (ProductVO, ProductsBaseVO, ProductTransactionsVO) based on their EOs respectively.
    Here is my scenario. I have an ADF form which is based on the database view Products and is dragged and dropped from Data Controls->ProductVO. When an existing record is submitted, a backing bean method will be called to update the data against the table Products_Base (and the table Product_Transactions at the same time) programmatically. An update method updateProductPrice() is added into the Application Module and published it to UI Client. The submit button in the page is created by directly dragging and dropping Data Controls->updateProductPrice into the page. When I run it, I got the following error message,
    Failed to post data to database during "Update": SQL Statement "UPDATE PRODUCTS ProductEO SET COST_PRICE=:1 WHERE PRODUCT_ID=:2".
    What I don't understand here is that, in my update method updateProductPrice(), it supposes to update the table Products_Base. But from the error, it appears that it is trying to update the view Products. Can anyone give me a help on what I did wrong here? When I try to debug it, it throws an exception to this line in the method updateProductPrice(),
    getDBTransaction().commit();
    Here are my codes,
    The method which got called in the backing bean
    public String cb6_action() {
    DCBindingContainer bc = (DCBindingContainer)getBindings();
    FacesCtrlAttrsBinding ProductId = (FacesCtrlAttrsBinding)bc.get("ProductId");
    FacesCtrlAttrsBinding CostPrice = (FacesCtrlAttrsBinding)bc.get("CostPrice");
    JUCtrlActionBinding action =
    (JUCtrlActionBinding)bc.findCtrlBinding("updateProductPrice");
    DCDataControl dc = action.getDataControl();
    ApplicationModule am = (ApplicationModule)dc.getDataProvider();
    AppModule service = (AppModule)am;
    service.updateProductPrice(new Long(ProductId.toString()), CostPrice.toString());
    return null;
    public BindingContainer getBindings() {
    return BindingContext.getCurrent().getCurrentBindingsEntry();
    The update method defined in the Application module (AppModuleImpl.java)
    public void updateProductPrice(long productId, String costPrice) {
    ProductsBaseEOImpl product = retrieveProductById(productId);
    if (product != null) {
    try {
    product.setCostPrice(new Number(costPrice));
    getDBTransaction().commit();
    catch (JboException ex) {
    getDBTransaction().rollback();
    throw ex;
    catch (SQLException ex1) {
    getDBTransaction().rollback();
    private ProductsBaseEOImpl retrieveProductById(long productId) {
    EntityDefImpl productDef = ProductsBaseEOImpl.getDefinitionObject();
    Key productKey = ProductsBaseEOImpl.createPrimaryKey(new DBSequence(productId));
    return (ProductsBaseEOImpl)productDef.findByPrimaryKey(getDBTransaction(),productKey);
    Edited by: john wang on Oct 27, 2009 7:14 AM

    or
    merge into test
    using (select rowid rid
                , id
                , sub_id
                , startdate
                , lead (startdate) over (order by id, sub_id) - 1 ed
           from test) x
    on (x.rid = test.rowid)
    when matched then
       update set end_date = x.ed
    ;

  • Update DB table with logic

    HI All ,
    I have table with records in DB which i need to modify from internal table via job.
    if we start from scratch (fill the db table in the first time ) all the records should be valid
    (column valid mark as abap_true)
    in the next run if new data will come to the table the records should be valid automatically
    and if some records are not occur in the second run the record in the table should be not valid
    what is the best way to do that .
    i give an example
    in the first run i have users in the itab ( that update the db)
    users    roles   valid_flag
    user1    rol1      X
    user1    rol2      X
    user1    rol3      X
    user2    rol1      X
    user2    rol2      X
    user2    rol3      X
    This what i have in the internal table and what should be in the db table also .
    in the next run i have in the itab
    user1    rol1      X
    user1    rol2      X
    user1    rol4      X
    user2    rol1      X
    user2    rol5      X
    user2    rol6      X
    user3    rol1      X
    user3    rol5      X
    user3    rol3      X
    so after the following run the table should look like .
    users    roles   valid_flag
    user1    rol1      X
    user1    rol2      X
    user1    rol3     
    user1    rol4      X
    user2    rol1      X
    user2    rol2    
    user2    rol3     
    user2    rol5      X
    user2    rol6      X
    user3    rol1      X
    user3    rol5      X
    user3    rol3      X
    The old records are not deleted there are just mark as not valid and if we have new records
    they are inserted to the table with valid flag .
    What is the best way to do that .
    Regards
    Chris

    HI Anmol
    its not that simple ...
    I have table with records in DB which i need to modify from internal table via job.
    if we start from scratch (fill the DB table in the first time ) all the records should be valid
    (column valid mark as abap_true)
    in the next run if new data will come to the table (it_new_usrs_data)  the new records should be valid automatically
    and if some records are not occur (in it_new_usrs_data ) in the second run the record in the DB  table should be not valid .
    You can see the the example in my first post .
    What i want to avoid the select single in loop because of performance  the DB table can store more than 100000 records ...
    Do you have diff idea ?
    in the first run i have users in the itab ( that update the DB)
    Assume that after the first run i this is the DB table that i read in the second run with the select to lt_copy_db
    users roles valid_flag
    user1 rol1 X
    user1 rol2 X
    user1 rol3 X
    user2 rol1 X
    user2 rol2 X
    user2 rol3 X
    In the next run of the job  i have in the internal table it_new_usrs_data
    user1 rol1 X
    user1 rol2 X
    user1 rol4 X
    user2 rol1 X
    user2 rol5 X
    user2 rol6 X
    user3 rol1 X
    user3 rol5 X
    user3 rol3 X
    so after the following run the DB  table should look like .
    The o_ld records are not deleted_ there are just mark as not valid and if we have new records
    they are inserted to the table with valid flag .
    users roles valid_flag
    user1 rol1 X
    user1 rol2 X
    user1 rol3
    user1 rol4 X
    user2 rol1 X
    user2 rol2
    user2 rol3
    user2 rol5 X
    user2 rol6 X
    user3 rol1 X
    user3 rol5 X
    user3 rol3 X
    Thanks
    Chris
    Edited by: Chris Teb on Jan 6, 2010 10:58 PM

  • Updating a table with no Primary key

    What I am trying to find out is if you can uniquely update a single record in a table that has no primary key. I see no way to reference the record I want, other than specifying all the field values in a where clause. This is a problem though, because if I have another record with the same field values, that will get updated too. (I know its a bad database design, but some people do it and I need to work around it!!!), there are some situations where you would have identical records as far as a where clause is concerned, for example, you cant use a blob in a where clause so that might be where your records differ...
    In SQLServer 2000, Enterprise manager throws an error if you have a table with no primary key and duplicate records that you try to update through the GUI. EM uses stored procedures to execute updates, and it rolls back ones which result in more than one update result.
    Im not too familiar with Cursors in SQL, only that they are quite slow and not implemented on all DB products. But I think that they might be able to solve the problem (but I dont logically see how).
    Can anybody explain this to me?

    another record with the same field valuesIf you have two records and all the field values are the same then the records are logically the same anyways, so it shouldn't matter if you update both (one would question why there are two records in the first place.) In other words there is no way, either computationally or manually to tell them apart.
    I suspect that that is rather rare. Instead what is more likely is that you are only using some of the fields. So just keep adding fields until it is unique.

Maybe you are looking for

  • Will this API eventually support Office 365 and other hosted Lync Services?

    I just noticed in the intro forum post that this SDK only supports on-prem Skype installations. I was hoping to use the SDK against an Office 365 install. Is it in the roadmap for this SDK to support hosted Skype? Are there any estimate timeframes yo

  • What happens if two iPhones with different versions of ios share an identical ID and password?

    I activated my new iPhone 6 as a replacement of  my old iPhone 4, using the same apple ID and phone name. Everything the old iPhone 4 had is now on the new phone. What happens if I connect my old phone, which I believe is still registered as before,

  • Error when calling add method of UDO object

    Hi all i've created a UDO object. when i invoke the method "add" i get the following error message: "Ref count for this object is higher then 0" anyone can tell me how to fix this? appreciate the help Yoav

  • N95-can't remove .sis from SD

    Hi all, my beauty, N95, gives me pure and real satisfaction but also plays me hard (pretty much like all the beauties I know...) First issue: have installed to SD two .sis files (games) and after upgrating to 12, I can't REMOVE nor RUN them. Should I

  • Design View - Everything Highlights

    In Design view of CS5 Dreamweaver (OS Windows 7), when I click to make a minor revision, everything highlights.  I read a post to right click in the design view & go to Element View > Full because I have the following style in my wrap div in my CSS f