MERGE or PL/SQL statement? (and ORA-30926: failed to get a stable set of rows in the source tables)

Hi SQL & PL/SQL gurus...

A bit of advice please...

IM loading documents in the system... In this context, I have a routine that check the progress of loading (upload_records) against an existing table (supplier_records).  If the details differ so it updates, and if the folder does not exist, it inserts a new record...

About 90% of the time, recording will be unchanged and the statement will do nothing...

The challenge I have is that I get the error above fairly regularly, because (I think) there are simultaneous users, loading documents in the system... so, both tables change regularly...  The merge statement is below... but my question is: I would achieve anything by converting the merge statement into a PL/SQL loop that checks if the recordset contains a record that needs to either update or insertion? Would be the first simple quick check that reduction of 90% of the files works better, (with further processing if the folder must insert or update) and this would remove the error above, or the merge statement made the same thing anyway, and I should leave it as what? or is my incorrect merge statement and which contribute to the error?  The merge statement, if it finds a match, updates the record anyway, even if she didn't need to...  (which is not very effective)... However a pl/SQL loop will have to check if the record exists. check if it needs to be changed, change it if she does... Insert if the folder does not exist.

MERGE statement is:

MERGE INTO s suppliers

USING (select distinct (sup_provision_id),

provider,

sup_acc_holder,

sup_bank_acc,

sup_bank_name,

payments_upload sup_bank_branch

where csv_id =: P20_CSV_ID) could

WE (pu.sup_provision_id = s.supplier_id)

WHEN MATCHED THEN

GAME UPDATE

s.SUPPLIER = pu.supplier,

s.SUP_ACC_HOLDER = pu.sup_acc_holder,

s.BANK_ACC_NO = pu.sup_bank_acc,

s.BANK_NAME = pu.sup_bank_name,

s.BRANCH_NO = pu.sup_bank_branch

WHEN NOT MATCHED THEN

INSERT (s.SUPPLIER_ID,

s.SUPPLIER,

s.SUP_ACC_HOLDER,

s.BANK_ACC_NO,

s.BANK_NAME,

s.BRANCH_NO,

s.CAT)

VALUES (pu.sup_provision_id,

able. Beg,

Pu.sup_acc_holder,

Pu.sup_bank_acc,

Pu.sup_bank_name,

Pu.sup_bank_branch,

'S' );

Thank you very much

Richard

Hi, Richard,.

Richard Legge wrote:

Hello.. Thanks for the reply...... The reason for the 'distinct' to ensure that the query retrieves only one line (based on the extraction of the full line, as you point out)... (so why he would never get more than one?) Well Yes... know that the media are not quite relevant...

The reasoning is that out or 5000 records. 4000 will have the same provider... so want to retrieve a single record for what it (or other unique visitors who may be similar but have different criteria) and simply update the corresponding record, insert if there is no trace...

Rgds

Richard

SELECT DISTINCT guarantees that no 2 rows will be exactly alike.  In other words, if you compare the 2 rows in the result set, either sup_provision_id supplier of GOLD supp_acc_holder for GOLD OR one of the other columns (or maybe 2 or more columns) will be different.  It does not guarantee that any 1 column will be unique.

FUSION requires that, when a match is found, it should only be 1 line in the result set generated by the USING clause.  Given that the matching condition is

WE (pu.sup_provision_id = s.supplier_id)

This means that pu_sup_provision must be unique.  The ORA_30926 error occurs if it is not unique.  SELECT DISTINCT to ensure that complete lines in pu are unique, but it does not guarantee that any single column will be unique.

Depending on your data and your needs, you may need to change the USING clause, so that sup_provision_id is unique.  You may need to add more conditions to the WHERE clause, or do a GROUP BY or use an analytic function such as ROW_NUMBER.

If you need help, post a small example of data (that is, CREATE TABLE and INSERT statements for all the tables involved, as they are before the MERGER) and the exact results you want (that is, indicate which suppliers should contain after the MERGER).

Check out the Forum FAQ: Re: 2. How can I ask a question on the forums?

Tags: Database

Similar Questions

  • Using Merge in oracle 11g this error SQL Error: ORA-30926: failed to get a stable set of rows in the source tables

    whenever I run this code I get this error

    SQL Error: ORA-30926: failed to get a stable set of rows in the source tables

    30926 00000 - "impossible to get a stable set of rows in the source tables.

    * Cause: A stable set of rows could not be achieved due to the large dml

    activity or one not deterministic where clause.

    * Action: Remove any non deterministic of the clauses and reissue of the dml.

    Don't know wht goes wrong!


    SQL:

    MERGE IN VENDORS_ACTIVE_DATE s

    USING (nvl (d.VENDOR, s.VENDOR) selection of the SELLER,

    NVL (d.COMPANY_CODE, s.COMPANY_CODE) COMPANY_CODE.

    (case when ((d.VENDOR = s.VENDOR) and (d.COMPANY_CODE = s.COMPANY_CODE)))

    )

    then "MATCH".

    When d.COMPANY_CODE is null

    then 'DELETE '.

    When s.COMPANY_CODE is null

    then "INSERT."

    else 'UPDATE '.

    chck end)

    from (select * from VENDORS_ACTIVE_DATE where COMPANY_CODE = 2) s

    full outer join (select * provider where COMPANY_CODE = 2) d

    on (d.COMPANY_CODE = s.COMPANY_CODE AND s.COMPANY_CODE = 2)

    ) d

    WE (d.COMPANY_CODE = s.COMPANY_CODE AND d.chck in ('UPDATE', 'GAME', 'DELETE'))

    WHEN MATCHED THEN

    UPDATE SET s.VENDOR = d.VENDOR

    WHERE d.chck in ('UPDATE', 'DELETE')

    DELETE WHERE d.chck = 'DELETE '.

    WHEN NOT MATCHED THEN

    INSERT (SELLER, COMPANY_CODE)

    VALUES (d.VENDOR, d.COMPANY_CODE)

    Work request: (deleted the duplicate data in tables (source and target))

    MERGE IN VENDORS_ACTIVE_DATE s

    USING (nvl (d.VENDOR, s.VENDOR) selection of the SELLER,

    NVL (d.ACTIVEDATE, s.ACTIVEDATE) ACTIVEDATE.

    NVL (d.COMPANY_CODE, s.COMPANY_CODE) COMPANY_CODE.

    (case when ((d.VENDOR = s.VENDOR))

    - AND D.ACTIVEDATE = S.ACTIVEDATE

    and NVL (d.ACTIVEDATE, trunc (sysdate)) = NVL (s.ACTIVEDATE, trunc (sysdate))

    and (d.COMPANY_CODE = s.COMPANY_CODE)

    )

    then "MATCH".

    When d.COMPANY_CODE is null

    then 'DELETE '.

    When s.COMPANY_CODE is null

    then "INSERT."

    else 'UPDATE '.

    chck end)

    from (select * from suppliers where COMPANY_CODE = 2) d

    full outer join (select * from vendors_active_date where COMPANY_CODE = 2) s

    on (d.COMPANY_CODE = s.COMPANY_CODE and s.vendor = d.vendor)

    ) d

    WE (d.COMPANY_CODE = s.COMPANY_CODE AND d.VENDOR = s.VENDOR AND d.chck in ('UPDATE', 'GAME', 'DELETE'))

    WHEN MATCHED THEN

    S.ACTIVEDATE = UPDATE SET d.ACTIVEDATE

    WHERE d.chck in ('UPDATE', 'DELETE')

    DELETE WHERE d.chck = 'DELETE '.

    WHEN NOT MATCHED THEN

    INSERT (VENDOR, ACTIVEDATE, COMPANY_CODE)

    VALUES (d.VENDOR, d.ACTIVEDATE, d.COMPANY_CODE)

  • FUSION IN: ORA-30926: failed to get a stable set of rows in the source tables

    Hi all

    Database Oracle 12 c Enterprise Edition Release 12.1.0.1.0 - 64 bit Production 0

    PL/SQL Release 12.1.0.1.0 - Production 0

    CORE 12.1.0.1.0 Production 0

    AMT for 64-bit Windows: Version 12.1.0.1.0 - Production 0

    NLSRTL Version 12.1.0.1.0 - Production 0

    When you use the MERGE clause, if executed more than once, I get the below error

    ORA-30926: failed to get a stable set of rows in the source tables

    create table CBC (nums number, sname varchar2 (10))

    create tar (tnum number, tNom varchar2 (10)) table

    Insert in src values (1, 'a')

    Insert in src values (1, 'b')

    Insert in src values (2, "c")

    merge into tar

    using the CBC

    on (nums = tnum)

    when matched

    then

    update the value tNom = sname

    When not matched

    then

    Insert the values(snum,sname);

    What expect, it's that first time itself (when inserted), he must raise the error. But it's not.

    Select * from tar

    TNUM TNOM

    1 b

    1 a

    2 c

    But if we run for the second time it shows the error.

    I saw the document of the Oracle and he said

    MERGEis a deterministic statement. You cannot update the same row in the target table multiple times in the same MERGE statement.

    I've seen below cela son but failed to get the solution for this.

    MERGE STATEMENT ORA-30926: failed to get a stable set of lines in the source

    Nondeterministic fusion?

    Someone at - it make a clarification?

    I don't want to insert records into the first time itself. for example, to run the first time he must raise the error. can I do this using MERGE?

    Thank you

    Hello

    O - O wrote:

    Thanks knani, Frank.

    One more doubt.

    When you run the MERGE statement, the first time, there is no rows in the target table, so no rows in the target table is what it is.

    So we cannot perform below sqls using MERGE when the target table is empty?

    insert into tar values (1, 'a')

    updated tar tNom = 'b' set where tnum = 1

    insert into tar values (2, "c")

    Is - that means that the MERGER will be only works with validated data?

    Right; a MERGE statement will not update a line which has been previously inserted into the same MERGE statement.  All fact tables reference to the data in the tables by the time the MERGER began.

  • ORA-30926: failed to get a stable set of rows in the source table

    Dear all

    When I try to load my cube I get the error "ora-30926: failed to get a stable set of rows in the source table.
    Any idea? Googling for this error has not returned all the solutions.

    My env:

    Source: Oracle 10g (10.2.x)
    Target: Oracle 11g (11.1.0.7)

    I use the generator to warehouse 11.1.0.7 on Linux

    Thank you

    Hello

    Yes, I'm very sure. The error is revived by the MERGE statement.
    If the cube is empty, it is not a problem. All of the rows from the source Gets a surrogate key.
    If you run the cube for the second time, and you have two or more lines with exact in the attributes values as you use for correspondence, this error occurs.

    Kind regards
    Carsten.

  • ORA-30926: failed to get a stable set of rows in the source tables

    Hello

    Please suggest me I get the error message when running under code MERG. Please suggest

    Below the two tables are the same in the code not to structure no change that I just need to update the real table when data in the temporary table.

    MERGE WITH CEMLI_ASSESMENT CM

    USING (SELECT DISTINCT * FROM TEMP_CEMLI_ASSESMENT) TCM

    WE (CM.PRO_ID = TCM.PRO_ID AND)

    CM CEMLI_NAME THE GROUP TCM. CEMLI_NAME)

    WHEN MATCHED THEN

    GAME UPDATE

    CM CEMLI_TYPE THE GROUP TCM. CEMLI_TYPE,

    CM CEMLI_CODE_UNIT_EXEC THE GROUP TCM. CEMLI_CODE_UNIT_EXEC,

    CM LAST_USAGE_DT THE GROUP TCM. LAST_USAGE_DT,

    CM REQUIRED GROUP TCM. Mandatory

    CM.COMPLEXITY = TCM.COMPLEXITY,

    CM HIT THE GROUP TCM. AFFECTED,

    CM RE_DEVELOPMENT THE GROUP TCM. RE_DEVELOPMENT,

    CM IMPACT_DESC THE GROUP TCM. IMPACT_DESC,

    CM CEMLI_GROUP THE GROUP TCM. CEMLI_GROUP,

    CM REVISED_COMPLEXITY THE GROUP TCM. REVISED_COMPLEXITY,

    CM RETRO_PLANNED_START_DT THE GROUP TCM. RETRO_PLANNED_START_DT,

    CM RETRO_PLANNED_END_DT THE GROUP TCM. RETRO_PLANNED_END_DT,

    CM RETRO_ACTUAL_START_DT THE GROUP TCM. RETRO_ACTUAL_START_DT,

    CM RETRO_ACTUAL_END_DT THE GROUP TCM. RETRO_ACTUAL_END_DT,

    CM FUT_PLANNED_START_DT THE GROUP TCM. FUT_PLANNED_START_DT,

    CM FUT_PLANNED_END_DT THE GROUP TCM. FUT_PLANNED_END_DT,

    CM FUT_ACTUAL_START_DT THE GROUP TCM. FUT_ACTUAL_START_DT,

    CM FUT_ACTUAL_END_DT THE GROUP TCM. FUT_ACTUAL_END_DT,

    CM UPDATE_FLG THE GROUP TCM. UPDATE_FLG,

    CM.COMMENTS = TCM.COMMENTS

    WHEN NOT MATCHED THEN

    INSERT (CM.PRO_ID, CM. CEMLI_NAME, CM. CEMLI_TYPE, CM. CEMLI_CODE_UNIT_EXEC, CM. LAST_USAGE_DT, CM. IF NECESSARY, CM.COMPLEXITY, CM. HIT, CM. RE_DEVELOPMENT, CM. IMPACT_DESC, CM. CEMLI_GROUP, CM. REVISED_COMPLEXITY, CM. RETRO_PLANNED_START_DT, CM. RETRO_PLANNED_END_DT, CM. RETRO_ACTUAL_START_DT, CM. RETRO_ACTUAL_END_DT, CM. FUT_PLANNED_START_DT, CM. FUT_PLANNED_END_DT, CM. FUT_ACTUAL_START_DT, CM. FUT_ACTUAL_END_DT, CM. UPDATE_FLG, CM.COMMENTS)

    VALUES (TCM.PRO_ID, TCM. CEMLI_NAME, TCM. CEMLI_TYPE, TCM. CEMLI_CODE_UNIT_EXEC, TCM. LAST_USAGE_DT, TCM. IF NECESSARY, TCM.COMPLEXITY, TCM. HIT, TCM. RE_DEVELOPMENT, TCM. IMPACT_DESC, TCM. CEMLI_GROUP, TCM. REVISED_COMPLEXITY, TCM. RETRO_PLANNED_START_DT, TCM. RETRO_PLANNED_END_DT, TCM. RETRO_ACTUAL_START_DT, TCM. RETRO_ACTUAL_END_DT, TCM. FUT_PLANNED_START_DT, TCM. FUT_PLANNED_END_DT, TCM. FUT_ACTUAL_START_DT, TCM. FUT_ACTUAL_END_DT, TCM. UPDATE_FLG, TCM.COMMENTS);

    Thank you

    Shilpa

    This means that there are several lines in traditional Chinese with the same TCM.PRO_ID and TCM. CEMLI_NAME. And the MERGER cannot be updated same line several times. You must decide what to do in such cases. If you don't care which line of lines with the same TCM.PRO_ID and TCM. CEMLI_NAME to take, use:

    MERGE WITH CEMLI_ASSESMENT CM
    WITH THE HELP OF TCM (SELECT T.*, ROW_NUMER () OVER(PARTITION BY PRO_ID,CEMLI_NAME ORDER BY 1) RN TEMP_CEMLI_ASSESMENT T)
    WE (CM.PRO_ID = TCM.PRO_ID AND)
    CM CEMLI_NAME THE GROUP TCM. CEMLI_NAME AND
    TCM. RN = 1)
    WHEN MATCHED THEN
    GAME UPDATE
    CM CEMLI_TYPE THE GROUP TCM. CEMLI_TYPE,
    CM CEMLI_CODE_UNIT_EXEC THE GROUP TCM. CEMLI_CODE_UNIT_EXEC,
    CM LAST_USAGE_DT THE GROUP TCM. LAST_USAGE_DT,
    CM REQUIRED GROUP TCM. Mandatory
    CM.COMPLEXITY = TCM.COMPLEXITY,
    CM HIT THE GROUP TCM. AFFECTED,
    CM RE_DEVELOPMENT THE GROUP TCM. RE_DEVELOPMENT,
    CM IMPACT_DESC THE GROUP TCM. IMPACT_DESC,
    CM CEMLI_GROUP THE GROUP TCM. CEMLI_GROUP,
    CM REVISED_COMPLEXITY THE GROUP TCM. REVISED_COMPLEXITY,
    CM RETRO_PLANNED_START_DT THE GROUP TCM. RETRO_PLANNED_START_DT,
    CM RETRO_PLANNED_END_DT THE GROUP TCM. RETRO_PLANNED_END_DT,
    CM RETRO_ACTUAL_START_DT THE GROUP TCM. RETRO_ACTUAL_START_DT,
    CM RETRO_ACTUAL_END_DT THE GROUP TCM. RETRO_ACTUAL_END_DT,
    CM FUT_PLANNED_START_DT THE GROUP TCM. FUT_PLANNED_START_DT,
    CM FUT_PLANNED_END_DT THE GROUP TCM. FUT_PLANNED_END_DT,
    CM FUT_ACTUAL_START_DT THE GROUP TCM. FUT_ACTUAL_START_DT,
    CM FUT_ACTUAL_END_DT THE GROUP TCM. FUT_ACTUAL_END_DT,
    CM UPDATE_FLG THE GROUP TCM. UPDATE_FLG,
    CM.COMMENTS = TCM.COMMENTS

    SY.

  • [Error code: 904, SQL State: 42000] ORA-00904: "G". "' NAME ': invalid

    When I run the SQL below, I get the following:

    08:00:08 [SELECT - 0 row (s), dry 0.000] [error Code: 904, SQL State: 42000] ORA-00904: "G". "" NAME ": invalid identifier

    When I comment the lines "BOLD", it works fine. I tried to fully qualify the column without success. I'm sure it's a matter of formatting.

    ************************************************

    Select
    SR. SCHOOLID,
    SR. StudentID, sr.coursenumber,
    SR. REGISTREQ_ID,
    (select
    min (rr.ID |) » -'|| URI COURSEGROUP)
    Of
    REGISTREQ rr
    where
    RR.grade_level = (select s.sched_nextyeargrade from student s where s.id = sr.studentid)
    and rr.yearid = 2100
    and rr.id not in (6426,6415)
    and rr. COURSEGROUP in
    (select
    g.Name
    Of
    g GEN
    where
    g.CAT = "coursegroups".
    and instr (g.valuet, sr.coursenumber) > 0
    and g.schoolid = sr.schoolid)
    and ((g.name as 'ALT %' and sr. GLOBALALTERNATECOURSE = 1)
    or (g.name not as 'ALT %' and sr. GLOBALALTERNATECOURSE = 0))
    ) as New_RegID
    Of
    SCHEDULEREQUESTS sr
    where
    SR. SCHOOLID = 703
    and sr.yearid = 2100

    This is because the lines that you have Ringing are out of reach for the alias 'g', which is part of the inner query.

    Maybe you want to just 'name' without the prefix "g.".

  • When you try to install fix - it files, diagnostic and cleaning Center. I get a message that it is in the wrong format

    original title: format of the troubleshooting tool

    When you try to install fix - it files, diagnostic and cleaning Center. I get a message that it is in the wrong format. How can I fix it so I can clean or remove the unwanted [for example registry files]?

    Hi RandyHunter,

    1. what you trying to accomplish?

    2. What is the question you are facing on the computer?

    3. you try to install Microsoft fixit tool?

    4. did you of recent changes on the computer?

    If you try to install Microsoft fixit tool then I would suggest that you post your query in the Sub forum mentioned.

    http://social.Microsoft.com/forums/en-us/fixitcenter/threads

    Your question does contain all the required information necessary for us to help you. Please provide more relevant information to continue troubleshooting as a result.

  • Error: ORA-16757: failed to get the value of this property

    Hi all
    I have an error:
    DGMGRL > see the database dbname_stb LogXptStatus;
    Error: ORA-16757: failed to get the value of this property
    I check:
    DGMGRL > see the configuration;

    Configuration - dbname_dg

    Protection mode: MaxPerformance
    Databases:
    dbname_pr - primary database
    dbname_stb - physical of the standby database

    Fast-Start Failover: DISABLED

    The configuration status:
    SUCCESS

    drcdbname_stb.log:
    RSM0: Received the request the property Get: rid = 0 x 01010000, pid = 54
    2012-10-17 15:21:14.702 of database Resource: get the LogXptStatus property
    RSM 15:21:14.702 2012-10-17 error: trying to interview a 'LogXptStatus' primary type property on a standby database resource.
    2012 10-17 error 15:21:14.702 database resource GetProperty (16501,16757)

    I don't understand this error?
    Thank you all.

    Take a look on this

    Re: ORA-00254 | Trouble with dataguard

  • MV for replication. No PK in the source table and the LOB column

    I would like to replicate tables between 2 instances in 2 different hosts. Mixed 11 GR 1 material and Oracle 10 g 2. I have my doubts:

    1. some tables from the source is not PK, and I understand that MV with rowid is not supported. Is there no workaround known workaround on this case without changing the structure of the source table? Full/complete update is acceptable.

    2 one of the table has the CLOB data type. Can I just ignore this column in MV? A known issue with this kind of approach?

    #1. You must use WITH ROWID MV and I believe it is supported up to the latest version, unless you can find any document, please give me the code of Notes.
    #2. CLOB column is supported in MV, so no need to jump.

  • Interrupted SQL statement and start several times with several SQL_EXEC_ID

    Hi all

    We meet a strange phenomenon, maybe someone can help.

    We see that sometimes, when our client runs a single statement, implemented Oracle to process the statement with a special SQL_EXEC_ID, but after a while stops and starts processing the statement along with different SQL_EXEC_ID. Then, after a while, it happens again - stop Oracle processes the statement and start from the beginning with the new SQL_EXEC_ID. This happens again and again until we kill all of the other sessions on the database (then it ends).

    What we see exactly: Client executes the statement (sql_id = "2tp7pz6yv87qp"). Monitor us v $ SQL_MONITOR and get this:

    SELECT Sql_id, sql_exec_id, to_char (SQL_EXEC_START, "HH24:MI:SS MON-DD-YYYY) SQL_EXEC_START, status OF V$ SQL_MONITOR where sql_id = '2tp7pz6yv87qp' ORDER BY SQL_EXEC_START DESC;

    2tp7pz6yv87qp 16777216 28 may 2015 07:19:14 the EXECUTION

    After a while check us again and see this:

    2tp7pz6yv87qp 16777217 28 may 2015 07:36:17 the EXECUTION

    2tp7pz6yv87qp 16777216 28 may 2015 07:19:14 FACT

    After a while, we see this:

    2tp7pz6yv87qp 16777219 28 may 2015 08:09:58 the EXECUTION

    2tp7pz6yv87qp 16777218 28 may 2015 07:53:37 FACT

    2tp7pz6yv87qp 16777217 28 may 2015 07:36:17 FACT

    2tp7pz6yv87qp 16777216 28 may 2015 07:19:14 FACT

    and so on — will happen again and again until we kill all of the other sessions in the database.

    When comparing the follow-up of the different SQL_EXEC_IDs SQL reports, we see that each of them did exactly the same job: used the same execution plan, beginning treatment she even read/wrote the same amount of e/s and each of them stopped at the same point during execution. You can see that for each SQL_EXEC_ID execution 'stops' in the middle and never reach the end of the plan. She always stops in the JOIN by HASH and never continue to the next steps in the implementation plan.

    When you look more deeply, we see in V$ ACTIVE_SESSION_HISTORY always last thing that happens for every SQL_EXEC_ID is HASH JOIN RIGHT OUTER (SQL_PLAN_OPERATION = HASH and SQL_PLAN_OPTIONS = RIGHT OUTER JOIN). Then comes the new SQL_EXEC_ID and it starts to do the same thing as the previous SQL_EXEC_ID did when it was launched.

    Kill all other sessions, run finally ends. We see that the final (successful) SQL_EXEC_ID work and completes his plan to run to completion.

    When executing the same single statement (when it comes to the single session in the database), it ends with a single SQL_EXEC_ID. Its SQL monitoring report looks like the final execution when the phenomenon occurs after killing all other sessions.

    -We checked that the customer executing the query only once. AWR also only shows simple execution of the query.

    -We have reproduced in many different clients (plus SQL, JDBC thin client OIC and DBMS_SCHEDULER job).

    -It has no PARALLEL in the query or table.

    -In this case for different statements (different INSERT-SELECT and MERGE instructions).

    -Version: Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    Does anyone have an idea?

    Finally found the root cause of the problem.

    This phenomenon occurs when the cursor of the active query being invalidated. This can occur in several scenarios, in our case, what happens when we work on a single partition (read or write) and perform DDL operations on different partitions of the same or the tables.

    Steps to reproduce:

    1 launch long command DML that affect the single partition

    2. in the course of executing this SQL, do one of the following values in a session different all 1 minute:

    2.1 do the indexes to a different partition unusable: ALTER TABLE X EDIT PARTITION Y UNUSABLE LOCAL INDEX

    2.2 rebuild the unusable index of different partition: ALTER TABLE X EDIT PARTITION Y REBUILD UNUSABLE LOCAL INDEX

    2.3 a partition different truncate

    Support of Oracle we were told that this problem is known and there are several requests for bugs and improvements thereon, for example this one:

    Bug 12905327 : TRUNCATE to an INVALID PARTITION TABLE UNNECESSARILY IMMEDIATELY all THE SLIDERS

    In our case (ETL process), we used to perform all these operations DDL and DML operations long (we work on different partitions in parallel). In order to solve, we have separated these operations to the different phases in our process and don't be DDL and DML operations at the same time more. This solved the problem for us.

  • ORA-19573: failed to get exclusive enqueue for datafile 4

    Hello

    I have the database to Oracle 10 g on AIX.
    I take a full backup since the database isn't that big.
    The users.dbf has been deleted accidentally at the OS level.
    I'm trying to restore and recover the users tablespace. I'm rman documentation and that's what I tried to do.
    RMAN > run {}
    SQL 'alter tablespace offline users;
    Restore tablespace users;
    recover tablespace users;
    SQL 'alter tablespace users online ';
    }

    but I get the error below:
    using the control file of the target instead of recovery catalog database
    SQL statement: alter tablespace users offline
    RMAN-00571: ===========================================================
    RMAN-00569: = ERROR MESSAGE STACK FOLLOWS =.
    RMAN-00571: ===========================================================
    RMAN-03009: failure of the sql command to the default channel at 14/04/2010 18:04:38
    RMAN-11003: failure in parsing / execution of the SQL statement: alter tablespace users offline
    ORA-01116: error opening the database file 4
    ORA-01110: data file 4: ' / u01/app/oracle/oradata/BKUPDB/users01.dbf'
    ORA-27041: could not open the file
    IBM AIX RISC System/6000 error: 2: no such file or directory
    Additional information: 3


    I did some research and it looks like I need to close the database, bring it back to get State and then do the restore and recover.
    I thought since storage space is not SYSTEM, I should be able to make the tablespace recovery without putting the database in offline mode.

    Can someone help me understand.

    Thank you.

    "alter tablespace offline users" is a NORMAL offline trying to control point the data file.

    Make an "alter tablespace users offline immediate.

    Hemant K Collette

  • Formulation of condition CQL with the source table and Javabean event

    Hello

    I managed to create a State in CQL that compares 2 values of TIMESTAMP between a source table and a Java bean.

    I did this by complying with the standard DATETIME SimpleDateFormat in the docs.

    But the format does not include milliseconds. Is there another way I can do this, without losing the value of millisecond of the Javabean?

    The request is something like

    Select table.*
    table, beans
    where table.sometimestamp < bean.startdate
    and table.sometimestamp > bean.enddate


    where bean.startdate and bean.enddate is a java.util.Date? (or all)

    I tried all kinds of combinations like to_timestamp (bean.startdate.getTime ()) but it is not the correct timestamp.

    Also tried to use types of java.sql. * but came through different CQL syntax errors.


    Any tips?

    Thank you!
    Jarell

    Hello

    I think you have two options:

    (1) to use SimpleDateFormat the of ' pattern. For example: "' yyMMddHHmmssSS', where the last two are the number of milliseconds.

    2) keep as a long (e.g. System.currentTimeMillis)

    Best regards
    Alex

  • Add more than 2 lines for a select statement without inserting rows in the base table

    Hi all

    I have a below a simple select statement that is querying a table.

    Select * from STUDY_SCHED_INTERVAL_TEMP
    where STUDY_KEY = 1063;

    but here's the situation. As you can see its return 7 ranks. But I must add
    2 rows more... with everything else, default or what exist... except the adding more than 2 lines.
    I can't insert in the base table. I want my results to end incrementing by 2 days in
    measurement_date_Taken on 01-APR-09... so big measurement_date_taken expected to
    end at study_end_Date...



    IS IT STILL POSSIBLE WITHOUT INSERT ROWS IN THE TABLE AND PLAYIHY ALL AROUND WITH
    THE SELECT STATEMENT?

    Sorry if this is confusing... I'm on 10.2.0.3

    Published by: S2K on August 13, 2009 14:19

    Well, I don't know if this request is as beautiful as my lawn, but seems to work even when ;)
    I used the "simplified" version, but the principle should work for your table, S2K.
    As Frank has already pointed out (and I fell on it while clunging): simply select your already existing lines and union them with the 'missing documents', you calculate the number of days that you are "missing" based on the study_end_date:

    MHO%xe> alter session set nls_date_language='AMERICAN';
    
    Sessie is gewijzigd.
    
    Verstreken: 00:00:00.01
    MHO%xe> with t as ( -- generating your data here, simplified by me due to cat and lawn
      2  select 1063 study_key
      3  ,      to_date('01-MAR-09', 'dd-mon-rr') phase_start_date
      4  ,      to_date('02-MAR-09', 'dd-mon-rr') measurement_date_taken
      5  ,      to_date('01-APR-09', 'dd-mon-rr') study_end_date
      6  from dual union all
      7  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('04-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
      8  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('09-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
      9  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('14-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
     10  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('19-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
     11  select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('23-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
     12  select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('30-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual
     13  ) -- actual query:
     14  select study_key
     15  ,      phase_start_date
     16  ,      measurement_date_taken
     17  ,      study_end_date
     18  from   t
     19  union all
     20  select study_key
     21  ,      phase_start_date
     22  ,      measurement_date_taken + level -- or rownum
     23  ,      study_end_date
     24  from ( select study_key
     25         ,      phase_start_date
     26         ,      measurement_date_taken
     27         ,      study_end_date
     28         ,      add_up
     29         from (
     30                select study_key
     31                ,      phase_start_date
     32                ,      measurement_date_taken
     33                ,      study_end_date
     34                ,      study_end_date - max(measurement_date_taken) over (partition by study_key
     35                                                                          order by measurement_date_taken ) add_up
     36                ,      lead(measurement_date_taken) over (partition by study_key
     37                                                          order by measurement_date_taken ) last_rec
     38                from   t
     39              )
     40         where last_rec is null
     41       )
     42  where rownum <= add_up
     43  connect by level <= add_up;
    
     STUDY_KEY PHASE_START_DATE    MEASUREMENT_DATE_TA STUDY_END_DATE
    ---------- ------------------- ------------------- -------------------
          1063 01-03-2009 00:00:00 02-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 04-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 09-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 14-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 19-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 23-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 30-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 31-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 01-04-2009 00:00:00 01-04-2009 00:00:00
    
    9 rijen zijn geselecteerd.
    

    Is there a simpler way (in SQL), I hope that others join, and share their ideas/example/thoughts.
    I feel that it is using more resources there.
    But I have to cut the daisies before now, they interfere my 'grass-green-ess";)

  • COMPARING TWO ROWS IN THE SAME TABLE AND DELETE THEM USING DELETION BLOCK

    Hi all
    I have a problem. I have an Employee table

    employee

    Emp_name Emp_id Emp_status Emp_date

    John 1 P 11-27-2010

    Mike 2 26/11/2010 S

    Simon P 3 22 / 11 / 2010

    Dennis C 4 25/11/2010...


    I compare the rows in the table and their employee_status if 'P', should I remove the... Here, I should delete lines 1 and 3 as their Emp_status is 'P '. I only use BULK DELETE... I tried to use the join query internal and deletion, but it does not work... Can someone help me...

    Ooops, it should be:

    and e2.emp_status in ('P', 'C')

    not

    and e2.emp_status in ('P', 'A')

    Here it goes:

    SQL> select  *
      2    from  employees
      3  /
    
    E EMP_NAME      EMP_KEY          X
    - ---------- ---------- ----------
    C John              123          1
    P Mike              123          2
    P Paul              123          6
    C Harry             124          5
    A Gass              125          7
    C Gass              125          7
    
    6 rows selected.
    
    delete  employees e1
      where 2 = (
                 select  count(distinct e2.emp_status)
                      from  employees e2
                      where e2.emp_key = e1.emp_key
                        and e2.emp_status in ('P','C')
                   )
    /
    
    3 rows deleted.
    
    SQL>
    

    SY.

  • Sign up between 2 tables without correspondence with values and keep the number of rows in the first Table

    Hello Experts,

    I have a problem that is a little tricky. Requirement is if 2 columns (region and Code in the tables below) match exactly, then it is Best Fit, if one of the columns match while it is average in shape, if the two columns do not match then it's worse to adapt.

    Create Table Table1 (varchar2 (10), varchar2 (10) of the filter region, Code varchar2 (10), revenue Number (15), owner varchar2 (5));

    Table1:

    Insert into Table1 values ('Test1', 'Midwest', '0900', 3000286, 'P1')

    Insert into Table1 values ('Test1', 'Midwest', '0899', 36472323, 'P2')

    Insert into Table1 values ('Test1', 'Midwest', '0898', 22472742, "P3")

    Insert into Table1 values ('Test1', 'West', '0901', 375237423, 'P1')

    Insert into Table1 values ('Test1', 'West', '0700', 34737523, null)

    Insert into Table1 values ('Test1', 'West', '0701', 95862077, "P3")

    Insert into Table1 values ('Test1', 'South', '0703', 73438953, 'P4')

    Insert into Table1 values ('Test1', 'South', '0704', 87332089, 'P1')

    Insert into Table1 values ('Test1', 'South', '0705', 98735162, 'P4')

    Insert into Table1 values ('Test1', 'South', '0706', 173894762, "P9")

    Insert into Table1 values ('Test1', 'South', '0902', 72642511, 'P6')

    Create Table Table2 (filter varchar2 (10), region varchar2 (10), Code varchar2 (10), plafond1 Number (15), Limit2 Number (15));

    Table2

    Insert into Table2 Values ('Test1', 'ALL', ' 0902', 15000, 10000)

    Insert into Table2 Values ('Test1', 'ALL', 'ALL', 20000, 12000)

    Insert into Table2 Values ('Test1', 'Midwest' ' 0900', 10000, 5000)

    Insert into Table2 Values ('Test1', 'Midwest', 'ALL', 18000, 8000)

    Insert into Table2 Values ('Test1', 'West', 'ALL', 16000, 6000)

    Insert into Table2 Values ('Test1', 'West', '0901', 10000, 5000)

    Final output

    Filter the income Code region owner plafond1 Limit2

    Test1 0900 3000286 P1 10 000 5 000 - Best Midwest (region because both Code Matches)

    Test1 0899 36472323 P2 Midwest 18 000 8 000 - way (because the region corresponds to only), we consider 'ALL' for the Code

    Test1 0898 22472742 P3 Midwest 18 000 8 000 - way (because the region corresponds to only), we consider 'ALL' for the Code

    Test1 West 0901 375237423 10 000 5 000 - Best P1 (region because both Code Matches)

    Test1 West 0700 34737523 16 000 6 000 - medium (because the area corresponds to only), we consider 'ALL' for the Code

    Test1 West 0701 95862077 P3 16 000 6 000 - way (because the region corresponds to only), we consider 'ALL' for the Code

    Test1 South 0703 73438953 P4 20 000 12 000 - worse (because region both Code DON T Match ' "), we consider option as worst 'ALL', 'ALL '.

    Test1 South 0704 87332089 P1 20 000 12 000 - worse (because region both Code DON T Match ' "), we consider option as worst 'ALL', 'ALL '.

    Test1 South 0705 98735162 P4 20 000 12 000 - worse (because region both Code DON T Match ' "), we consider option as worst 'ALL', 'ALL '.

    Test1 South 0706 173894762 P9 20 000 12 000 - worse (because region both Code DON T Match ' "), we consider option as worst 'ALL', 'ALL '.

    Test1 South 0902 72642511 P6 15 000 10 000 - way (because the Code corresponds to only) we consider 'ALL' for the region

    In the final result, we should have row count equal to Table1, and as soon as there's game (best first, then middle, then the worst), then if is once again, that we should ignore.

    There are other columns in the tables as well.

    Thank you very much!

    As you wish...

    select filter, region, code, region2, code2,
    revenue, owner, limit1, limit2, match
    from (
      select filter, region, code, region2, code2,
      revenue, owner, limit1, limit2, match,
      row_number() over(
        partition by filter, region, code order by match
      ) priority
      from (
        select a.filter, a.region, a.code, a.revenue, a.owner,
        b.region region2, b.code code2, b.limit1, b.limit2,
        case
          when (a.region, a.code) = ((b.region, b.code)) then 'Best'
          when a.region = b.region or a.code = b.code then 'Medium'
          else 'Worst'
        end match
        from table1 a
        join table2 b
        on a.filter = b.filter
        and (b.region, b.code) in (
          (a.region, a.code),
          (a.region, 'ALL'),
          ('ALL', a.code),
          ('ALL', 'ALL')
        )
      )
    )
    where priority = 1
    order by region, code;
    

Maybe you are looking for