MERGE statement is increment the sequence. It problem?


Hi all

I use a merge statement to update thousands of data in a table. If the criteria does not match (WHEN NOT MATCHED) I wrote an insert statement that contains a reference to the sequence. And it works very well.

My question is, will this increment also sequence even though it won't insert the statement in the script of fusion. I think it will be. Right?

Say, I update 20K record will be the sequence also increment by 20 times k. If his past all work around.

Thanks in advance.

Here is a less effective solution to your problem that creates a function to get the value of the following sequence, but I agree with Justin cave that because of the cache you must lose the values.

SQL > CREATE SEQUENCE s_emp;

Order of creation.

SQL > CREATE or REPLACE FUNCTION s_emp_nextval

2 RETURN NUMBER

3 AS

4 v_nextval NUMBER;

5 BEGIN

6. SELECT s_emp.nextval

7 INTO v_nextval

8 DOUBLE;

9 v_nextval of RETURN;

10 END;

11.

The function is created.

SQL > MERGE IN emp t (USING)

2. SELECT empno, ename

3 FROM emp) s

4. WE (t.empno = s.empno)

5. WHEN MATCHED THEN

UPDATE 6

7 SET t.ename = s.ename

8 WHEN NOT MATCHED THEN

9 INSERT (empno, ename)

10 VALUES (s_emp_nextval, 'SMITH');

14 lines merged.

SQL > SELECT s_emp. NEXTVAL

2 FROM dual;

NEXTVAL

----------

1

Tags: Database

Similar Questions

  • Insert/update of the XML help merge and to generate the sequence number

    Hello

    I'm working on Oracle 11 g.

    I have a doubt with loading XML.
    I get an xml and I need to insert or update data in a table. What I can accomplish by using the MERGE statement.
    But there is a column in A table, I need to fill with a sequence number, based on the data sent in the xml file.
    The XML does not send the data in this column.
    And I have to make sure that sequence is created according to the order in which the records are present in xml.
    For example the MERGER is insert five rows and update two lines and insert again 3 rows of xml in table A. The sequence number must be created in the same order for the column in the table.
    Also for every new XML, the sequence starts with 1 and ends with the number of records in the xml file. I can't create a sequence and use the seq.nextval.

    Please let me know, there is a way to achieve this.

    Thank you!

    Published by: 934451 on 8 August 2012 06:33

    Published by: 934451 on 8 August 2012 06:50

    Hello

    As a result of your previous thread: {: identifier of the thread = 2403469}

    You can use the clause for ORDINALITE in XMLTable to generate the necessary sequence:

    MERGE INTO target_table t
    USING (
      SELECT x.seq_num, x.pk_id, x.col1, x.col2, ...
      FROM XMLTable(
             '/root/record'
             passing my_xml_doc
             columns seq_num FOR ORDINALITY
                   , pk_id   number       path 'ID'
                   , col1    varchar2(30) path 'COL1'
                   , col2    varchar2(30) path 'COL2'
                   , ...
           ) x
    ) src
    ON ( t.pk_id = src.pk_id )
    WHEN MATCHED THEN UPDATE
     SET t.seq_num = src.seq_num
       , t.col1 = src.col1
       , t.col2 = src.col2
       , ...
    WHEN NOT MATCHED THEN INSERT
     (seq_num, pk_id, col1, col2, ...)
     VALUES (src.seq_num, src.pk_id, src.col1, src.col2, ...)
    ;
    
  • Using the sequence @inlines - problems!

    Hello
    I'm having a problem with a paragraph that is wrapped in an "if" statement and that contains an inserted field.

    My paragraph begins:

    <? If@inlines:num=1? > blah blah blah... [DATE_OF_WITHDRAWL]... blah blah blah <? end if? >

    In fact, it looks like:

    <? If@inlines:num=1? > blah blah blah...
    01.03.2010
    .. .bla bla bla..? end if? >

    I tried the inlines sequence according to the thread: Re: how to avoid the line break in the loop if BI model publisher and have traversed the chapter:
    http://download.Oracle.com/docs/CD/E12844_01/doc/BIP.1013/e12187/T421739T481157.htm#con_freeform but still could not get my paragraph appear 'normal '.

    I would be very grateful for any advice on how to address this issue. Thank you
    Sue
    PS. I can now get the <? If@inlines:num=1? > work if I just want to add another piece of text in my paragraph according to the http://download.oracle.com/docs/cd/E12844_01/doc/bip.1013/e12187/T421739T481157.htm#con_freeform, but not when you insert a field.
    Thanks again!

    Published by: smp245 on March 8, 2010 12:11

    Hi Sue,

    I've corrected the template and sent you the pdf output as well. the error was that you had not updated the property formfield with the changes suggested by Charlotte. I've highlighted the formfield in grey content in the model (it will show the output correctly) this way you can easily see what had gone wrong.

    Good day

  • Merge statement: update only when a difference

    Hello

    I have two tables have almost the same columns, how can I use the merge statement to update the table target only when there is difference between the source and target table. Is there an easier way to do not compare every column one by one? I use Oracle 11.2.


    Here's the MERGE statement:

    Merge into trgt tb_trgt using tb_src src
    on (src.id = trgt.id)
    When not matched then values of insertion (trgt.id, trgt.nm, trgt.addr) (src.id, src.nm, src.nm)
    when matched, then update set trgt.nm = src.nm, trgt.addr = src.addr
    where trgt.nm <>src.nm or trgt.addr <>src.addr
    ;

    Is there an easier way to clarify the clause in the NO MATCHED? I don't want to compare every column in the tables. Because I might have a lot of columns in tables.

    Thank you

    939569 wrote:
    I have two tables have almost the same columns, how can I use the merge statement to update the table target only when there is difference between the source and target table. Is there an easier way to do not compare every column one by one? I use Oracle 11.2.
    Is there an easier way to clarify the clause in the NO MATCHED? I don't want to compare every column in the tables. Because I might have a lot of columns in tables.

    I use the method of Tom Kyte to compare tables; It gives me the differences between the source and the target using GROUP BY, who manages the value NULL comparisons. Can I use this result in the MERGER. Here is a step by step illustration. First, set up test data:

    define num_rows = 10
    /
    define pct = 20
    /
    define value_length = 50
    /
    define num_mods = round((&num_rows/3)*(&pct/100),0)
    /
    DROP TABLE T_TARGET;
    /
    DROP TABLE T_SOURCE;
    /
    create table t_target(key1 number, value1 varchar2(&value_length), constraint pk_target primary key(key1));
    insert /*+ append */ into t_target
    select level+&num_mods*3, rpad('DO NOTHING - same in source and target ',&value_length, '*')
    from dual
    where level <= &num_rows-&num_mods*2 connect by level <= &num_rows-&num_mods*2;
    /
    create table t_source as select * from t_target;
    /
    insert into t_source
    select level, rpad('INSERT - in source, not in target ',&value_length, '*')
    from dual where level <= &num_mods connect by level <= &num_mods;
    /
    insert into t_target
    select level+&num_mods, rpad('DELETE (after update) - not in source, in target ',&value_length, '*')
    from dual where level <= &num_mods connect by level <= &num_mods;
    /
    insert into t_source
    select level+&num_mods*2, rpad('UPDATE - put this in target ',&value_length, '*')
    from dual where level <= &num_mods connect by level <= &num_mods;
    /
    insert into t_target
    select level+&num_mods*2, rpad('UPDATE - update this from source ',&value_length, '*')
    from dual where level <= &num_mods connect by level <= &num_mods;
    /
    commit;
    /
    select 't_target', count(*), value1 from t_target group by 't_target', value1
    union all
    select 't_source', count(*), value1 from t_source group by 't_source', value1;
    /
    'T_TARGET'   COUNT(*) VALUE1
    ---------- ---------- --------------------------------------------------
    t_target            1 UPDATE - update this from source *****************
    t_target            8 DO NOTHING - same in source and target ***********
    t_target            1 DELETE (after update) - not in source, in target *
    t_source            1 UPDATE - put this in target **********************
    t_source            8 DO NOTHING - same in source and target ***********
    t_source            1 INSERT - in source, not in target ****************
    

    So, I need to do an insert, update, and a delete.

    Now I'll build code comparison step by step. I don't show the results every time, but if you run each query yourself can see what is happening.

    -- Step by step build of "refresh by merge" USING ROWIDs
    -- Result: with cardinality hint, can use "BY USER ROWID" and avoid 3d full scan
    -- 1) Full scan of both tables to get data,
    -- identify old / new records and get old ROWID
    select KEY1,VALUE1,
    1 old_cnt, 0 new_cnt, rowid rid from T_TARGET o
    UNION ALL
    SELECT KEY1,VALUE1,
    0 old_cnt, 1 new_cnt, NULL FROM T_SOURCE n
    /
    -- 2) GROUP BY compares records, identical records have old_cnt = new_cnt
    select KEY1,VALUE1,
    sum(old_cnt) old_cnt, sum(new_cnt) new_cnt, max(rid) rid
    FROM (
      select KEY1,VALUE1,
      1 old_cnt, 0 new_cnt, rowid rid from T_TARGET o
      UNION ALL
      SELECT KEY1,VALUE1,
      0 old_cnt, 1 new_cnt, NULL FROM T_SOURCE n
    )
    group by KEY1,VALUE1
    /
    -- 3) Filter out identical records
    select KEY1,VALUE1,
    sum(old_cnt) old_cnt, sum(new_cnt) new_cnt, max(rid) rid
    FROM (
      select KEY1,VALUE1,
      1 old_cnt, 0 new_cnt, rowid rid from T_TARGET o
      UNION ALL
      SELECT KEY1,VALUE1,
      0 old_cnt, 1 new_cnt, NULL FROM T_SOURCE n
    )
    group by KEY1,VALUE1
    having sum(old_cnt) <> sum(new_cnt)
    /
    -- 4) for INSERT, keep NEW; for DELETE, keep OLD;
    -- for UPDATE, keep NEW values and OLD rid
    SELECT /*+ cardinality(1) */ KEY1,VALUE1,
    old_cnt, new_cnt, row_number() OVER(PARTITION BY KEY1 ORDER BY old_cnt) rn
    , max(rid) over(partition by key1) rid
    from (
      select KEY1,VALUE1,
      sum(old_cnt) old_cnt, sum(new_cnt) new_cnt, max(rid) rid
      FROM (
        select KEY1,VALUE1,
        1 old_cnt, 0 new_cnt, rowid rid from T_TARGET o
        UNION ALL
        SELECT KEY1,VALUE1,
        0 old_cnt, 1 new_cnt, NULL FROM T_SOURCE n
      )
      group by KEY1,VALUE1
      having sum(old_cnt) <> sum(new_cnt)
    )
    /
    -- 5) Filter out OLD UPDATE record, not needed
    SELECT KEY1,VALUE1,
    new_cnt, rid
    FROM (
      SELECT /*+ cardinality(1) */ KEY1,VALUE1,
      old_cnt, new_cnt, row_number() OVER(PARTITION BY KEY1 ORDER BY old_cnt) rn
      , max(rid) over(partition by key1) rid
      from (
        select KEY1,VALUE1,
        sum(old_cnt) old_cnt, sum(new_cnt) new_cnt, max(rid) rid
        FROM (
          select KEY1,VALUE1,
          1 old_cnt, 0 new_cnt, rowid rid from T_TARGET o
          UNION ALL
          SELECT KEY1,VALUE1,
          0 old_cnt, 1 new_cnt, NULL FROM T_SOURCE n
        )
        group by KEY1,VALUE1
        having sum(old_cnt) <> sum(new_cnt)
      )
    ) where rn = 1
    /
    
    KEY1     VALUE1                                   NEW_CNT     RID
    1     INSERT - in source, not in target ****************     1
    2     DELETE (after update) - not in source, in target *     0     AAAcDHAAMAAAACtAAA
    3     UPDATE - put this in target **********************     1     AAAcDHAAMAAAACtAAB
    

    Now, here's the real MERGER:

    merge into T_TARGET o
    USING (
      SELECT KEY1,VALUE1,
      new_cnt, rid
      FROM (
        SELECT /*+ cardinality(1) */ KEY1,VALUE1,
        old_cnt, new_cnt, row_number() OVER(PARTITION BY KEY1 ORDER BY old_cnt) rn
        , max(rid) over(partition by key1) rid
        from (
          select KEY1,VALUE1,
          sum(old_cnt) old_cnt, sum(new_cnt) new_cnt, max(rid) rid
          FROM (
            select KEY1,VALUE1,
            1 old_cnt, 0 new_cnt, rowid rid from T_TARGET o
            UNION ALL
            SELECT KEY1,VALUE1,
            0 old_cnt, 1 new_cnt, NULL FROM T_SOURCE n
          )
          group by KEY1,VALUE1
          having sum(old_cnt) <> sum(new_cnt)
        )
      ) where rn = 1
    ) n
    on (o.rowid = n.rid)
    when matched then update set
    VALUE1=n.VALUE1
    DELETE WHERE (n.new_cnt = 0)
    WHEN NOT MATCHED THEN INSERT (
      KEY1,VALUE1
    ) VALUES (
      n.KEY1,n.VALUE1
    )
    /
    

    Published by: stew Ashton on February 7, 2013 20:42

  • video does not go on the chronology of the sequence

    I want to drag a piece of video from my source monitor and/or control panel of my project and I get an icon of the hand with a circle that has a strike through it (the can not surround). Audio will slide in the sequence without problem. The video will not be. I use the new Premier Pro CC 2014. Help!

    Thank you

    Danielle

    You source patched the track.

    Adobe Premiere Pro help. Source patch and the targeting of the track

    If that's not all: what kind of video is it and what codec inside.

  • Problem in the Merge statement

    Hi all

    I use the merge updated statement 30000 records of tables having 55 records of Lakes.
    But it takes a lot of time as I kill the session after 12 hours, as it was still ongoing.

    So, the same day I m using cursors, it will end in less than 3 hours.

    I used merge is: -.

    MERGE IN Table1 a
    USING (SELECT MAX (TO_DATE (TO_CHAR (contact_date, "dd/mm/yyyy")
    || contact_time,
    "jj/mm/aaaa HH24:Mi:SS".
    )
    ) m_condate,.
    appl_id
    FROM Table2 b,.
    (SELECT DISTINCT acc_no acc_no
    IN table 3, Table1
    WHERE acc_no = appl_id AND delinquent_flag = 'Y '.
    AND financier_id = 'NEWACLOS') d
    WHERE d.acc_no = b.appl_id
    AND (contacted_by IS NOT NULL
    OR followup_branch_code IS NOT NULL
    )
    GROUP BY appl_id) c
    WE (a.appl_id = c.appl_id AND a.delinquent_flag = 'Y')
    WHEN MATCHED THEN
    UPDATE
    SET last_contact_date = c.m_condate;

    In this query, table 1 has 30000 documents and table 2 and table 3 have records 3670955 and 555674 respectively.

    Please suggest, what I'm doing wrong with merger, because according to my understanding merge statement is much better than the updates or updates using cursors.

    Required info is as follows:

    SQL > show the user_dump_dest parameter

    VALUE OF TYPE NAME
    ------------------------------------ ----------- ------------------------------
    user_dump_dest string/opt/oracle/admin/FINCLUAT/udu
    MP
    SQL > show parameter optimizer

    VALUE OF TYPE NAME
    ------------------------------------ ----------- ------------------------------
    optimizer_dynamic_sampling integer 2
    optimizer_features_enable string 10.2.0.4
    optimizer_index_caching integer 0
    OPTIMIZER_INDEX_COST_ADJ integer 100
    the string ALL_ROWS optimizer_mode
    optimizer_secure_view_merging Boolean TRUE
    SQL > show parameter db_file_multi

    VALUE OF TYPE NAME
    ------------------------------------ ----------- ------------------------------
    db_file_multiblock_read_count integer 16
    SQL > show parameter db_block_size

    VALUE OF TYPE NAME
    ------------------------------------ ----------- ------------------------------
    Whole DB_BLOCK_SIZE 8192
    SQL > column sname format a20
    SQL > column pname format a20
    SQL > column pval2 format a20
    SQL > select
    2 sname,
    3 pname,
    pval1 4,.
    5 pval2
    6 of
    7 sys.aux_stats$;
    sys.aux_stats$
    *
    ERROR on line 7:
    ORA-00942: table or view does not exist


    Elapsed time: 00:00:00.05
    SQL > explain the plan for
    2 - Put your statement here
    3 MERGE IN one cs_case_info
    4 USE (SELECT MAX (TO_DATE (TO_CHAR (contact_date, "dd/mm/yyyy")
    5                          || contact_time,
    6 'dd/mm/yyyy HH24:Mi:SS.
    7                          )
    (8) m_condate,
    9 appl_id
    CS_CASE_DETAILS_ACLOS 10 b,
    11 (SELECT DISTINCT acc_no acc_no
    12 OF NEWACLOS_RESEARCH_HIST_AYLA, cs_case_info
    13 WHERE acc_no = appl_id AND delinquent_flag = 'Y '.
    14 AND financier_id = "NEWACLOS") d
    15 WHERE d.acc_no = b.appl_id
    16 AND (contacted_by IS NOT NULL
    17 GOLD followup_branch_code IS NOT NULL
    18                )
    C 19 GROUP BY appl_id)
    20. WE (a.appl_id = c.appl_id AND a.delinquent_flag = 'Y')
    21. WHEN MATCHED THEN
    UPDATE 22
    23 SET last_contact_date = c.m_condate
    24;

    He explained.

    Elapsed time: 00:00:00.08
    SQL > select * from table (dbms_xplan.display);

    PLAN_TABLE_OUTPUT
    ----------------------------------------------------------------------------------------------------------------------------------

    --------------------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | TempSpc | Cost (% CPU).
    --------------------------------------------------------------------------------------------------
    | 2 > MERGE STATEMENT | 47156 | 874K | 128K (1) |
    | 1. MERGE | CS_CASE_INFO |
    | 2. VIEW |
    | 3. HASH JOIN | 47156 | 36 M | 5672K | 128K (1) |
    | 4. VIEW | 47156 | 5111K | 82339 (1) |
    | 5. GROUP SORT BY | 47156 | 4236K | 298 M | 82339 (1) |
    | 6. HASH JOIN | 2820K | 247 M | 10 M | 60621 (1) |
    | 7. HASH JOIN | 216K | 7830K | 6985 (1) |
    | 8. VIEW | the index $ _join$ _012 | 11033. 258K | 1583 (1) |
    | 9. HASH JOIN |
    | 10. INDEX RANGE SCAN | IDX_CCI_DEL | 11033. 258K | 768 (1) |
    | 11. INDEX RANGE SCAN | CS_CASE_INFO_UK | 11033. 258K | 821 (1) |
    | 12. FULL RESTRICTED INDEX SCAN FAST | IDX_NACL_RSH_ACC_NO | 5539K | 68 M | 5382 (1) |
    | 13. TABLE ACCESS FULL | CS_CASE_DETAILS_ACLOS | 3670K | 192 M | 41477 (1) |
    | 14. TABLE ACCESS FULL | CS_CASE_INFO | 304K | 205 M | 35975 (1) |
    --------------------------------------------------------------------------------------------------

    Note
    -----
    -"PLAN_TABLE' is old version

    24 selected lines.

    Elapsed time: 00:00:01.04
    SQL > rollback;

    Complete restoration.

    Elapsed time: 00:00:00.03
    SQL > set autotrace traceonly arraysize 100
    SQL > alter session set events 10046 name context forever, trace level 8';
    ERROR:
    ORA-01031: insufficient privileges


    Elapsed time: 00:00:00.04
    SQL > disconnect
    Disconnected from the database to Oracle 10 g Enterprise Edition Release 10.2.0.4.0 - Production 64-bit
    With partitioning, OLAP, Data Mining and Real Application Testing options
    SQL > spool off

    Published by: user4528984 on May 5, 2009 22:37

    Create indexes for tables. CS_CASE_DETAILS_ACLOS, CS_CASE_INFO

    also try to use the underside of suspicion

    (SELECT / * + no_merge * / SEPARATE acc_no acc_no)
    IN table 3, Table1

    HTH

  • Different result by using the MERGE statement

    I have 2 SQL statements:

    MERGE INTO PT_CQS_AGGR APC

    With the HELP of PT_CQS_AGGR_TEMP Lady

    WE (concat (concat(pca.from_city_id,pca.to_city_id), pca.query_timestamp_hh) = concat (concat(pcah.from_city_id,pcah.to_city_id), pcah.query_timestamp_hh))

    WHEN MATCHED THEN

    Setting a DAY SET pca.search_count = pca.search_count + pcah.search_count

    WHEN NOT MATCHED THEN

    VALUES of INSERTION (to_city_id, query_timestamp_hh, from_city_id, search_count) (pcah.from_city_id, pcah.to_city_id, pcah.query_timestamp_hh, pcah.search_count);

    AND

    MERGE INTO PT_CQS_AGGR APC

    With the HELP of PT_CQS_AGGR_TEMP Lady

    WE (pca.from_city_id = pcah.from_city_id AND pca.to_city_id = pcah.to_city_id AND pca.query_timestamp_hh = pcah.query_timestamp_hh)

    WHEN MATCHED THEN

    Setting a DAY SET pca.search_count = pca.search_count + pcah.search_count

    WHEN NOT MATCHED THEN

    VALUES of INSERTION (to_city_id, query_timestamp_hh, from_city_id, search_count) (pcah.from_city_id, pcah.to_city_id, pcah.query_timestamp_hh, pcah.search_count);

    First statement correctly the merged data, but use FULL TABLE SCANS, so it's rather slow. Second statement using a UNIQUE INDEX on the columns from_city_id, to_city_id, and query_timestamp_hh on the MAP of EXPLAIN, but during the execution of I've got ORA-00001: unique constraint (PODOWNER. IDX_CQS_AGGR_3COL) violated. What is the problem with the second statement - especially with this line:

    WE (pca.from_city_id = pcah.from_city_id AND pca.to_city_id = pcah.to_city_id AND pca.query_timestamp_hh = pcah.query_timestamp_hh)

    Can I use a more complex condition in the MERGE statement? Because it seems that not all the conditions have been taken...

    ???

    Select pcah.from_city_id, pcah.to_city_id, PT_CQS_AGGR_TEMP Lady pcah.query_timestamp_hh

    less

    Select pca.from_city_id, pca.to_city_id, pca.query_timestamp_hh PT_CQS_AGGR pca

    somewhere the conditions limiting the time.

    (or whatever the columns make up the stress of failing)

    In addition, select for each column in the constraint of failure where the column is null.  If one of these columns is null, equality fails, even if both are null, because null <> null.  So you will get a "no match" if all values are the same and it is set to null.

    Edit: Oh, slap forehead, that is why one works and the complete analysis.  As SomeoneElse said, it normalizes the type of data and concatenates, comparison null to no effect and refusing all usual index.

  • Error in the Merge statement using dblink

    Hello

    I am facing the following error when you use the merge statement using the dblink.

    ORA-02069: global_names must be set to true for this operation parameter.

    I can use the same dblink in my select insert and update statements but when I try to use merge then he invites the error said, is also not any syntax error as same statement can be used on the same tables of database instead of dblink.

    Please suggest any help will be much appreciated.

    Thanks in advance

    Hi Aqeel

    If insert and update statements work well through links db, then it should not be a problem with the merge statement. But if you are faced with the question, so please check the entire sql statement with tnsnames on both sides. Please share the tnsnames for the two dbs with dblink ddl.

    Concerning

    Jihane Narain Sylca

  • problem compiling with MERGE statement

    What is the problem with this merge statement?

    When I compile I get the message
    met symbol IN when one of the following expected
    *:= . (@ %; < a SQL > *)

    MERGE INTO PF_REP_TEMP HAS
    WITH THE HELP OF PF_REP_SKS B
    WE (a. pf_userid = "FINP' AND B.pfbatch = 'F99' and B.pfstfno = A.pf_staffno
    and B.pfcc = "7" and B.pftransmy = A.mmyy and B.slno = A.s_no)
    When matched then
    game update
    a.pfwdrlm = b.pfwdrlm,
    a.PFRC = b.PFRC;

    Help, please

    (version of the form is 10g, 11g database version)

    How to perform a merge into forms button pressed trigger command

  • Problem updating my state machine, using the emg signal

    Hello

    I have problems with my code. My entry is an EMG signal that I gather from three different electrodes using usb 6008. In the program, I divide the signals and display them in a chart that is unique. What I want now is to read the signal, and if a signal passes a threshold I want an LED lights. This must remain lit until there is another signal that passes the threshold.

    To put it simply: "large enough signal--> lamp on--> stay informed--> enough large signal--> lamp--> stay off the coast and then start again."

    I tried a few different approaches, but I decided using a state machine. Now, the problem is that when the signal to enter the state machine the program crashes. I think it's because the table that I use to convert the signals does not update when I get my state machine, so the signal stops to come. But how to get around this problem? It is even possible to code what I want?

    I have attached the code. All the tips are welcome, I have been struggling with this for some time now.

    Thank you

    jenmich

    The problem is internal while the loop is run until the stop condition is true, but he never does a new Boolean entry. So that it remains for always in the same State. Remove the inner loop and put the shift register on the outer loop instead.

    You must also use a daqmx configures the element, and then set the properties of daq. The read.vi can be set to read a number of samples of each iteration.

    Also: you can expand the table to index for several items of output. If you want that element number 0, 1, and 2, you have yet to wire the index entries

  • Get error in the merge statement

    Version of Oracle, Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    Hi gurus

    I am trying to perform the merge statement using the clause, but I get the error message, see below my sample data:

    Examples of data

    DROP TABLE OF BILLING;

    DROP TABLE GROUP_MST;

    DROP TABLE age_max;

    CREATE ARRAY OF BILLING

    (

    BILLING_ID NUMBER (5),

    RATE NUMBER (5),

    MAXIMUM_AGE NUMBER (5),

    package_id NUMBER (5)

    );

    INSERT

    IN BILLING

    (SELECT 11,1,10,100 FROM DUAL

    UNION ALL

    SELECT 12,2,15,100 FROM DUAL

    UNION ALL

    SELECT 13,3,20,100 FROM DUAL

    );

    CREATE TABLE GROUP_MST

    (group_number NUMBER (5), package_id NUMBER (5))

    );

    INSERT INTO GROUP_MST

    (SELECT DOUBLE 5 000 100

    );

    -------

    CREATE TABLE AGE_MAX

    (group_number NUMBER (5), max_age NUMBER (5))

    );

    INSERT

    IN AGE_MAX

    (SELECT 5000,60 FROM DUAL

    );

    Merge statement

    MERGE INTO DRC USING billing

    (WITH datum1 AS

    (SELECT A.group_number,

    b.billing_id,

    b.rate,

    b.maximum_age,

    b.package_id

    OF group_mst A,.

    b billing

    WHERE A.package_id = b.package_id

    ),

    datum2 AS

    (SELECT max_age, group_number FROM age_max

    )

    SELECT * FROM A, b WHERE A.group_number = b.group_number datum2 datum1

    )

    CBC ON (drc.billing_id = src.billing_id)

    WHEN MATCHED THEN

    UPDATE SET drc.maximum_age = src.max_age - 1;

    Error

    Error from the 33 in the command line:

    MERGE INTO DRC USING billing

    (WITH datum1 AS

    (SELECT A.group_number,

    b.billing_id,

    b.rate,

    b.maximum_age,

    b.package_id

    OF group_mst A,.

    b billing

    WHERE A.package_id = b.package_id

    ),

    datum2 AS

    (SELECT max_age, group_number FROM age_max

    )

    SELECT * FROM A, b WHERE A.group_number = b.group_number datum2 datum1

    )

    CBC ON (drc.billing_id = src.billing_id)

    WHEN MATCHED THEN

    UPDATE SET drc.maximum_age = src.max_age - 1

    Error in the command line: 50 column: 1

    Error report:

    SQL error: ORA-00918: column ambiguously defined

    00918 00000 - "ambiguously defined column.

    * Cause:

    * Action:

    Thanks in advance

    Concerning

    Shu

    WITH datum1 AS (SELECT A.group_number,

    b.billing_id,

    b.rate,

    b.maximum_age,

    b.package_id

    OF group_mst A, b billing

    WHERE A.package_id = b.package_id),

    datum2 AS (SELECT max_age, group_number FROM age_max)

    SELECT A.*, b.max_age, b.group_number as group_number_b - ERROR HERE

    OF datum1 A, b datum2

    WHERE A.group_number = b.group_number

  • Problem audio clip in the sequence

    Hi, Im new to the forum. I'm using Adobe premiere CC on macbook pro. I have a problem with my sound clip. I import them and they work well in the source monitor. I try with the first and it appears in the sequence with the audio. any fine. But when I try to place on the other, it lets me just load image not the sound, I do not understand why? Can someone help me? Thank you very much!

    The first thing to check is that source patch is selected for an audio track. In the screenshot below, blue background behind "V1" means that the source patch is enabled; the default dark gray background for A1 means source patch is disabled.

    If you find that source patch is indeed enabled, then please post a screenshot of your mounting Panel to help us diagnose the problem.

    BTW, you posted this question in the first Clip forum. Clip is a separate application for mobile devices. I will move the thread to the Premiere Pro forum.

  • Return in the MERGE statement clause

    Hello

    I use Oracle 10 g Version

    I tried the code using UPDATE with return Clause & MERGER with return below Clause.

    I have not found ANY error while working with the UPDATE statement. Here is the code with the UPDATE statement

    DECLARE
       TYPE empno_list IS TABLE OF emp.empno%TYPE;
       vempno_list   empno_list;
    BEGIN
          UPDATE emp
             SET comm = 11
           WHERE deptno IN (SELECT deptno FROM dept)
       RETURNING empno
            BULK COLLECT INTO vempno_list;
       FOR i IN vempno_list.FIRST .. vempno_list.LAST
       LOOP
          DBMS_OUTPUT.put_line ('Values of EMP ' || vempno_list (i));
       END LOOP;
    END;   
    

    But PL/SQL error: ORA-00933: SQL not correctly completed command when you work with the MERGE statement

    declare 
     type empno_list  is  table of emp.empno%type;
     vempno_list empno_list;
    begin                
       merge into emp tgt 
          using dept src
            on (src.deptno =tgt.deptno)
            when matched then 
             update set tgt.comm=12
           returning tgt.empno bulk collect into vempno_list ;
           
            for i in vempno_list.first .. vempno_list.last loop
                    dbms_output.put_line('Values of EMP '||vempno_list(i) ) ;
            end loop;
    end;  
    

    Please suggest me

    Probably because BACK IN clause does not belong to the MERGE statement. It is available only for INSERT, UPDATE, and DELETE. Here's the quote from Oracle Documentation:

    The static method RETURNING INTO article belongs to a DELETE , INSERT , or UPDATE statement. The dynamic RETURNING INTO article belongs to a EXECUTE IMMEDIATE statement.

    And here is the link.

    Back IN the Clause

    It will be useful.

    Ishan

  • Question about the transition from string values to the Partition clause in a merge statement

    Hi all

    I use the code to update the data of specific secondary partition using oracle merge statements below.

    I'm getting the name of the secondary partition and pass this string to the secondary partition clause.

    The Merge statement is a failure, indicating that the specified secondary partition does not exist. But the partition under do exists for the table.

    We use a server Oracle 11 GR 2.

    Here is the code I use to fill in the data.

    declare
    ln_min_batchkey PLS_INTEGER;
    ln_max_batchkey PLS_INTEGER;
    lv_partition_name VARCHAR2 (32767).
    lv_subpartition_name VARCHAR2 (32767).
    Start

    FOR m1 IN (SELECT (year_val + 1) AS year_val, year_val AS orig_year_val)
    FROM (SELECT DISTINCT
    To_char (batch_create_dt, 'YYYY') year_val
    OF stores_comm_mob_sub_temp
    ORDER BY 1)
    ORDER BY year_val)
    LOOP
    lv_partition_name: =.
    () scmsa_handset_mobility_data_build.fn_get_partition_name
    nom_table_p = > 'STORES_COMM_MOB_SUB_INFO ',.
    p_search_string = > m1.year_val);

    FOR m2
    IN (SELECT DISTINCT
    'M' || To_char (batch_create_dt, 'MM') AS month_val
    OF stores_comm_mob_sub_temp
    WHERE TO_CHAR (batch_create_dt, 'YYYY') = m1.orig_year_val)
    LOOP
    lv_subpartition_name: =.
    () scmsa_handset_mobility_data_build.fn_get_subpartition_name
    nom_table_p = > 'STORES_COMM_MOB_SUB_INFO ',.
    p_partition_name = > lv_partition_name,
    p_search_string = > m2.month_val);

    DBMS_OUTPUT. Put_line (' lv_subpartition_name = > ' | lv_subpartition_name |' and lv_partition_name = > ' | lv_partition_name);

    IF lv_subpartition_name IS NULL
    THEN
    DBMS_OUTPUT. Put_line ("to the INTERIOR of FI = > ' |") M2.month_val);
    INSERT INTO STORES_COMM_MOB_SUB_INFO (T1)
    T1.ntlogin,
    T1.first_name,
    T1.last_name,
    T1.job_title,
    T1.store_id,
    T1.batch_create_dt)
    SELECT t2.ntlogin,
    T2.first_name,
    T2.last_name,
    T2.job_title,
    T2.store_id,
    T2.batch_create_dt
    OF stores_comm_mob_sub_temp t2
    WHERE TO_CHAR (batch_create_dt, 'YYYY') = m1.orig_year_val
    AND'M '. To_char (batch_create_dt, 'MM') =
    M2.month_val;
    ELSIF lv_subpartition_name IS NOT NULL
    THEN
    DBMS_OUTPUT. Put_line (' INSIDE ELSIF = > ' | m2.month_val);
    MERGE (SELECT *)
    OF stores_comm_mob_sub_info
    SUBPARTITION (lv_subpartition_name)) T1
    USING (SELECT *)
    OF stores_comm_mob_sub_temp
    WHERE TO_CHAR (batch_create_dt, 'YYYY') =
    M1.orig_year_val
    AND'M '. To_char (batch_create_dt, 'MM') =
    M2.month_val) T2
    WE (T1.store_id = T2.store_id
    AND T1.ntlogin = T2.ntlogin)
    WHEN MATCHED
    THEN
    GAME UPDATE
    T1.postpaid_totalqty =
    (NVL (t1.postpaid_totalqty, 0))
    (+ NVL (t2.postpaid_totalqty, 0));
    T1.sales_transaction_dt =
    LARGEST)
    NVL (t1.sales_transaction_dt,
    T2.sales_transaction_dt),
    NVL (t2.sales_transaction_dt,
    T1.sales_transaction_dt)),
    T1.batch_create_dt =
    LARGEST)
    NVL (t1.batch_create_dt, t2.batch_create_dt),
    NVL (t2.batch_create_dt, t1.batch_create_dt))
    WHEN NOT MATCHED
    THEN
    INSERT (t1.ntlogin,
    T1.first_name,
    T1.last_name,
    T1.job_title,
    T1.store_id,
    T1.batch_create_dt)
    VALUES (t2.ntlogin,
    T2.first_name,
    T2.last_name,
    T2.job_title,
    T2.store_id,
    T2.batch_create_dt);
    END IF;
    END LOOP;
    END LOOP;

    COMMIT;

    end;
    /



    Really appreciate your input here.

    Thank you
    MK.

    Hello

    You can use "immediate execution" what works.

    Thank you

  • Question about the MERGE statement

    Hi all

    I have a small question... I can post code, table creation, etc... but I think this question can be able to be simply answered, if I explain it. If you want me to zip codes, etc... then just ask and I'll do it.

    Here it goes:

    I have a set up merge statement, and I have two columns. One is named ADD_DT, and the other is called LST_UPD_DT.

    Update in the merge statement, the LST_UPD_DT column is updated with the SYSDATE.
    When it is inserted in the merge statement, the ADD_DT column is updated with the SYSDATE.

    So, here is my question:

    Regardless of whether or not the information is updated, the LST_UPD_DT updates the SYSDATE every time. Any advice on how to update the LST_UPD_DT column only if information is changed/updated, so that the information is not changed would be not updated by the SYSDATE? I hope that this question was not too complicated.

    Thank you all and if you want to see the code or examples of table... Please ask and I'll post one. I just thought that this may be able to meet without it.

    Hello

    991769 wrote:
    OK, here's what the table looks like:

    Thank you.

    CREATE TABLE TBL_SUPPLIERS
    (
    SUPP_CD                 VARCHAR2(40 CHAR),
    SUPP_NM                 VARCHAR2(255 CHAR),
    ADD_DT                  VARCHAR2(50 CHAR),
    LST_UPD_DT              VARCHAR2(50 CHAR))
    

    Do not use a VARCHAR2 column for date information. Use a DATE column.

    CREATE TABLE D_SUPPLIERS
    (
    SUPP_CD                 VARCHAR2(40 CHAR),
    SUPP_NM                 VARCHAR2(255 CHAR))
    
    INSERT INTO TBL_SUPPLIERS VALUES (1234, MINING, '03-26-2013 3:33:49 PM', '04-02-2013 9:04:52 AM');
    INSERT INTO TBL_SUPPLIERS VALUES (2345, ELECTRIC, '03-26-2013 3:33:49 PM', '04-02-2013 9:04:52 AM');
    INSERT INTO TBL_SUPPLIERS VALUES (3456, COAL, '03-26-2013 3:33:49 PM', '04-02-2013 9:04:52 AM');
    

    You want people to view the solutions that actually work? Please make sure that your own instructions will actually work. Test and fix your code before posting.
    All INSERT statements you posted fail; You seem to be missing single quotes around string literals. I think you meant:

    INSERT INTO TBL_SUPPLIERS VALUES (1234, 'MINING', '03-26-2013 3:33:49 PM', '04-02-2013 9:04:52 AM');
    ...
    

    Here's one way:

    MERGE INTO  tbl_suppliers     sm
    USING  (
               SELECT  d.*
            FROM              d_suppliers        d
            LEFT OUTER JOIN  tbl_suppliers  t  ON  t.supp_cd  = d.supp_cd
            WHERE   t.supp_cd                            IS NULL
            OR        DECODE (t.supp_nm, d.supp_nm, 0, 1) = 1
           )                       ds
    ON     (sm.supp_cd = ds.supp_cd)
        WHEN MATCHED THEN
            UPDATE SET
                sm.supp_nm = ds.supp_nm,
                sm.lst_upd_dt = SYSDATE
        WHEN NOT MATCHED THEN
            INSERT (sm.supp_cd, sm.supp_nm, sm.add_dt)
            VALUES
            (ds.supp_cd, ds.supp_nm, SYSDATE);
    
    SELECT     *
    FROM     tbl_suppliers
    ORDER BY     SUPP_CD;
    

    This can be more efficient, because it does not generate redo, or triggers, when two tables have exactly the same line.

Maybe you are looking for