Lag with partition by.

Hi,
I have a question on LAG analytical function. Here is my test scenario.
SCOTT@CRP1 > CREATE TABLE test1 AS 
SELECT 123 document_id, 0 bill_id, 12.40 prev_balance
  FROM DUAL
UNION ALL
SELECT 123, 1, 13.2
  FROM DUAL
UNION ALL
SELECT 123, 2, 1.2
  FROM DUAL
UNION ALL
SELECT 122, 1, 15.5
  FROM DUAL
Table created.
Elapsed: 00:00:00.09
SCOTT@CRP1 > select * from test1;
DOCUMENT_ID    BILL_ID PREV_BALANCE
        123          0         12.4
        123          1         13.2
        123          2          1.2
        122          1         15.5
Elapsed: 00:00:00.02
SCOTT@CRP1 > select t.*,
lag(t.prev_balance) over (partition by document_id order by document_id, bill_id) prev_bal1 from test1 t;
DOCUMENT_ID    BILL_ID PREV_BALANCE  PREV_BAL1
        122          1         15.5
        123          0         12.4
        123          1         13.2       12.4
        123          2          1.2       13.2
Elapsed: 00:00:00.01
  1* select * from
(select t.*,
lag(t.prev_balance) over (partition by document_id order by document_id, bill_id) prev_bal1 from test1 t)
where bill_id<>0
SCOTT@CRP1 > /
DOCUMENT_ID    BILL_ID PREV_BALANCE  PREV_BAL1
        122          1         15.5
        123          1         13.2       12.4
        123          2          1.2       13.2
Elapsed: 00:00:00.00Now, my problem is, for scenario where document_id = 122, I need prev_bal1 to be 15.5 instead of zero (since there is no value to be carried over from bill_id = 0 for that document_id).
Everything else should remain the same.
Is this even possible with 'LAG' function? or am I gonna have to look something exotic like 'MODEL' clause?
Thank you,
Rahul.
Message was edited by:
RPuttagunta
Message was edited by:
RPuttagunta

Did you try?
SQL> CREATE TABLE test1 AS  SELECT 123 document_id, 0 bill_id, 12.40 prev_balance
  2    FROM DUAL
  3  UNION ALL
  4  SELECT 123, 1, 13.2
  5    FROM DUAL
  6  UNION ALL
  7  SELECT 123, 2, 1.2
  8    FROM DUAL
  9  UNION ALL
10  SELECT 122, 1, 15.5
11    FROM DUAL
12  ;
Table created.
SQL> select *
  2    from (select t.*
  3               , lag(t.prev_balance, 1, t.prev_balance)
  4                  over (partition by document_id order by document_id, bill_id) new_prev_bal1
  5           from test1 t
  6         )
  7   where bill_id<>0
  8  /
DOCUMENT_ID    BILL_ID PREV_BALANCE NEW_PREV_BAL1
        122          1         15.5          15.5
        123          1         13.2          12.4
        123          2          1.2          13.2
SQL>

Similar Messages

  • LEAD with Partition

    Hi,
    I am stuck on a problem to implement LEAD/LAG with partition.
    Below is the example and expected Result
    create table trd(
         key number,
         book number,
         prd_key number,
         direction varchar2(2),
         trdtime date,
         price number)
    insert into trd values(1234,115,133864,'B','17-07-2013 18:18:00',108.859375);
    insert into trd values(1235,115,133864,'S','17-07-2013 18:18:00',108.859375);
    insert into trd values(1245,115,133864,'S','17-07-2013 18:18:00',108.859375);
    insert into trd values(1236,115,133864,'B','15-07-2013 18:18:00',108.872261598);
    insert into trd values(1237,115,133864,'S','15-07-2013 18:18:00',108.866752398);
    insert into trd values(1247,115,133864,'S','15-07-2013 18:18:00',108.866752398);
    insert into trd values(1238,115,133864,'S','14-07-2013 18:18:00',107.86);
    insert into trd values(1239,115,133864,'S','14-07-2013 18:17:00',108.86);
    insert into trd values(1240,115,133864,'B','14-07-2013 18:12:00',109.86);
    insert into trd values(1241,115,133864,'B','14-07-2013 18:17:00',110.86);
    I need to return the value something like this:
    Key
    Book
    Prd_Key
    Direction
    TrdTime
    Price
    NextPrice
    1234
    115
    133864
    B
    7/17/2013 6:18:00 PM
    108.859375
    108.866752398
    1235
    115
    133864
    S
    7/17/2013 6:18:00 PM
    108.859375
    108.872261598
    1245
    115
    133864
    S
    7/17/2013 6:18:00 PM
    108.859375
    108.872261598
    1236
    115
    133864
    B
    7/15/2013 6:18:00 PM
    108.872261598
    108.86
    1237
    115
    133864
    S
    7/15/2013 6:18:00 PM
    108.866752398
    110.86
    1247
    115
    133864
    S
    7/15/2013 6:18:00 PM
    108.866752398
    110.86
    1238
    115
    133864
    S
    7/14/2013 6:18:00 PM
    107.86
    110.86
    1239
    115
    133864
    S
    7/14/2013 6:17:00 PM
    108.86
    109.86
    1240
    115
    133864
    B
    7/14/2013 6:12:00 PM
    109.86
    NULL
    1241
    115
    133864
    B
    7/14/2013 6:17:00 PM
    110.86
    NULL
    The logic to embed is :
    For each record, Need to get the OPPOSITE direction's and Existing TrdTime > Other records TrdTime.
    For example: for key 1237, the Direction is S and TrdTime is 7/15/2013 6:18:00 PM.
    There are following records returned for this record:
    1240 and 1241 both having opposite side ; 'B' and existing record TrdTime > these two records.
    But the TrdTime of 1241 is selected since it is ordered by nearest and highest TrdTime.
    How Can I implement this functionality.
    I was thinking of doing it using LEAD function and partition.
    I cannot use Cursors since tables are not indexed and there are over 5 mil records.
    Any suggestions please.

    Hi,
    Here's a way to do it using the analytic LAST_VALUE function.
    Let me know how this compares to the previous solution on your real data.
    SELECT    t.*
    ,         CASE
                  WHEN  direction = 'B'
                  THEN  LAST_VALUE ( CASE
                                         WHEN  direction = 'S'
                                         THEN  price
                                    END
                                    IGNORE NULLS
                                   ) OVER ( PARTITION BY  book
                                            ,             prd_key
                                            ORDER BY      trdtime
                                            RANGE BETWEEN UNBOUNDED PRECEDING
                                                  AND      1E-6 PRECEDING
                  WHEN  direction = 'S'
                  THEN  LAST_VALUE ( CASE
                                         WHEN  direction = 'B'
                                         THEN  price
                                     END
                                     IGNORE NULLS
                                   ) OVER ( PARTITION BY  book
                                            ,             prd_key
                                            ORDER BY      trdtime
                                            RANGE BETWEEN UNBOUNDED PRECEDING
                                                  AND      1E-6 PRECEDING
              END AS nextprice
    FROM      trd  t
    --WHERE   ... -- If you want any filtering, put it here
    ORDER BY  trdtime  DESC
    ,        direction
    ,        key
    The magic number 1E-6 is an arbitrary number, less than the granularity of trdtime.  That is, we want to look at trdtimes up to and including 1 second (roughly .000012 days) in the past.  1E-6 is clearly less than that.

  • Can I use LEAD or LAG with Groups?

    Can I use LEAD or LAG with Groups?
    I want to compare two records of each group.
    Is it possible?
    Thanks in advance

    Xavi wrote:
    I have this query:
    SELECT a.cod_riesgo_txpk           as num_poliza,
    a.cod_suplementor_txpk      as suplemento,
    a.movimiento_nmpk           as movimiento,
    a.cod_tipo_operacion_txfk   as tipo_operacion,
    rc.fecha_vcto_cobertura_txd as fecha_vto,
    rc.capital_asegurado_nm     as capital,
    rc.prima_total_nm           as prima
    FROM REGU_RIESGOS_COBERTURAS rc, REGU_MOVIMIENTOS_POLIZAS a
    WHERE rc.cod_cobertura_txpkfk ='005'
    AND rc.cod_riesgo_txpkfk = a.cod_riesgo_txpk
    AND rc.cod_suplementor_txpkfk = a.cod_suplementor_txpk
    AND rc.movimiento_nmpkfk = a.movimiento_nmpk
    order by num_poliza, movimiento;
    The results:
    NUM_POLIZA     SUPLEMENTO     MOVIMIENTO     TIPO_OPERACION     FECHA_VTO     CAPITAL     PRIMA
    0640080109141     0640080109141/014     1     02     01/05/2010     15025302,61     3,19
    0640180096274     0640180096274/006     1     02     01/05/2006     1652783     1387,8
    0640180365194     0640180365194/005     1     02     08/07/2006     150253     294,83
    0640180369821     0640180369821/009     1     02     31/12/2006     13460000     28483,08
    0640180369821     0640180369821/010     2     02     28/02/2007     13460000     29546,08
    0640180384185     0640180384185/010     1     02     30/12/2006     36085241,96     113951,53Can yo see NUM_POLIZA 0640180369821     I have two records, then I want to compare two rows in each grou.What do you mean by compare? What do you want to do?
    You can use the PARTITION BY clause if you want the analytic function to work within a specific group.

  • I have huge lag with Safari's Reading List using a rMBP. I have probably 80 articles saved, which is likely the cause of the lag. Is there any way to export that list of articles so as to be able to delete them from Reading List but still have a record?

    I have huge lag with Safari's Reading List using a rMBP. I have probably 80 articles saved, which is likely the cause of the lag. Is there any way to export that list of articles so as to be able to delete them from Reading List but still have a record of the articles I intend to read?

    I'm currently dealing with this issue myself, except that my rMBP has NO articles in the reading list.  It's a brand new rMBP too, purchased just this week, with the 2.6 Ghz Processor & 16GB of RAM.
    Let's see what we can find.  I may just take it back to the Apple Store.

  • Table creation with partition

    following is the table creation script with partition
    CREATE TABLE customer_entity_temp (
    BRANCH_ID NUMBER (4),
    ACTIVE_FROM_YEAR VARCHAR2 (4),
    ACTIVE_FROM_MONTH VARCHAR2 (3),
    partition by range (ACTIVE_FROM_YEAR,ACTIVE_FROM_MONTH)
    (partition yr7_1999 values less than ('1999',TO_DATE('Jul','Mon')),
    partition yr12_1999 values less than ('1999',TO_DATE('Dec','Mon')),
    it gives an error
    ORA-14036: partition bound value too large for column
    but if I increase the size of the ACTIVE_FROM_MONTH column to 9 , the script works and creates the table. Why is it so ?
    Also, by creating a table in this way and populating the table data in their respective partitions, all rows with month less than "JULY" will go in yr7_1999 partition and all rows with month value between "JUL" and "DEC" will go in the second partition yr12_1999 , where will the data with month value equal to "DEC" go?
    Plz help me in solving this problem
    thanks n regards
    Moloy

    Hi,
    You declared ACTIVE_FROM_MONTH VARCHAR2 (3) and you try to check it against a date in your partitionning clause:TO_DATE('Jul','Mon')so you should first check your data model and what you are trying to achieve exactly.
    With such a partition decl, you will not be able to insert dates from december 1998 included and onward. The values are stricly less than (<) not less or equal(<=) hence such lines can't be inserted. I'd advise you to check the MAXVALUE value jocker and the ENABLE ROW MOVEMENT partitionning clause.
    Regards,
    Yoann.

  • Does anyone get the mouse lag with an external display connected via the display port?

    does anyone get the mouse lag with an external display connected via the display port?

    You don't describe the problem in great detail.  Is this the issue you are describing?
    https://discussions.apple.com/thread/4398076?start=0&tstart=0
    If so, then, "Yes."  I have the same problem.  Note that this isn't a tracking speed problem for me, it's a lag between my hand moving and the pointer moving on the external display.
    Andrew

  • LCD TV 55HT1U lags with game systems

    I'm am having an issue with my LCD TV 55HT1U. It has about a 1 or 2 second lag with my PS3 and xbox 360. Is there any way I can fix this issue? I am running both with HDMI if that helps. I've also noticed that regular cable TV has a delay.

    I have the same problem. The lag is not between the sound and video.. the lag is from the HDMI port to the display itself. For instance, I plugged my HDMI cable from my PS3 to the HDMI port on the side of the TV and then when I navigated through the PS3 main menu, I would click on the PS3 button to go from one menu to the other and it would take a good second for the video to update on the screen. I did the same test with a CRT TV and the response is immediate.
    I thought it might be the PS3 lagging so I plugged my laptop and then tried a DVD player. Both did the same thing.. I would click an icon on the PC or navigated the menus on the DVD and it seems like the image and sound would be delayed "inside" the TV. Maybe the video takes some time to rasterize and the sound is synchronized with the video so both will "wait" until the video is ready?
    If you have a fix for this, please let me know.  I'm thinking of returning the TV entirely just because of this. The PS3 is unplayable and you know, if I had a choice of which one should go...

  • ORA-00604 ORA-00904 When query partitioned table with partitioned indexes

    Got ORA-00604 ORA-00904 When query partitioned table with partitioned indexes in the data warehouse environment.
    Query runs fine when query the partitioned table without partitioned indexes.
    Here is the query.
    SELECT al2.vdc_name, al7.model_series_name, COUNT (DISTINCT (al1.vin)),
    al27.accessory_code
    FROM vlc.veh_vdc_accessorization_fact al1,
    vlc.vdc_dim al2,
    vlc.model_attribute_dim al7,
    vlc.ppo_list_dim al18,
    vlc.ppo_list_indiv_type_dim al23,
    vlc.accy_type_dim al27
    WHERE ( al2.vdc_id = al1.vdc_location_id
    AND al7.model_attribute_id = al1.model_attribute_id
    AND al18.mydppolist_id = al1.ppo_list_id
    AND al23.mydppolist_id = al18.mydppolist_id
    AND al23.mydaccytyp_id = al27.mydaccytyp_id
    AND ( al7.model_series_name IN ('SCION TC', 'SCION XA', 'SCION XB')
    AND al2.vdc_name IN
    ('PORT OF BALTIMORE',
    'PORT OF JACKSONVILLE - LEXUS',
    'PORT OF LONG BEACH',
    'PORT OF NEWARK',
    'PORT OF PORTLAND'
    AND al27.accessory_code IN ('42', '43', '44', '45')
    GROUP BY al2.vdc_name, al7.model_series_name, al27.accessory_code

    I would recommend that you post this at the following OTN forum:
    Database - General
    General Database Discussions
    and perhaps at:
    Oracle Warehouse Builder
    Warehouse Builder
    The Oracle OLAP forum typically does not cover general data warehousing topics.

  • Using AGO function with partitions

    I have a situation where we have logical sources with the same repository folder that are partitioned. We would like to use the AGO function but are getting the following error:
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 22042] AGO function may not be used on '# Applied Invoices' because its source is horizontally partitioned. (HY000)
    Has anyone had success using the AGO function with partitions? If not, do you have an alternate solution to the problem?

    AGO doesn't work with partitions - it's documented on metalink....there's an enhancement request , but that's it - no work-around provided....I'd suggest creating a common view for that particular report

  • I have a macbook pro and two monitors connected via matrox dualhead2go. The display is fine, but there is a lag with the mouse cursor. Matrox technical do not seem to have the answer, anyone else?

    As in the question, everything works fine, but there is a lag with the mouse pointer, latency issue. I have seen on other forums this has been an issue, but with different solutions, and some with no solutions. Matrox technical team have no solutions for me unfortunately, so any similar user experiences would be good.

    I have the same issue....
    Is there any solution ?
    iMac 2010 27" 2.93GHz , OSX 10.6.8 Snow Leopard, Matrox DualHead2Go ME

  • DATACOPY with partitioned data source

    Hello,
    I am actually working on the Hyperion Essbase EPM 11.1.2
    I am trying to perform a Datacopy command in a HBR.
    Data source are partitioned with a transparent partition.
    This datacopy do not work. The HBR is really fast but when I retrieve data no data are copied.
    I am wondering if this is possible to perform a datacopy command, in a HBR with partitioned data source.
    I have managed to perform this datacopy throw a HBR using the command:
    SET CREATEBLOCKONEQ
    Target = Source;
    But this method is really long.
    Thanks for your answer,
    Arthur.

    Hi
    Make sure that you have relevant Role & Authorization at Quality/PRS.
    You have to Transport the Source Cube first and then Create a Generate Export Data Source in QAS. Then, replicate data sources for BW QAS Soruce System. Make sure this replicated Data Source in QAS. Only then can transport new update rules for second cube.
    Hope it helps and clear

  • Troubles editing tables with partitions

    I'm running SQL Developer 1.5.3 against Oracle 10/11 databases and SQL Developer has trouble with my partitioned tables. Both the schema owner and sys users experience the same problems.
    The first time I try to edit a table, I get an "Error Loading Objects" dialog with a NullPointException message. If I immediately turn around and try to edit the table again, I get the Edit Table dialog. That's annoying but there's at least a work-around.
    Next, if I select the Indexes pane, I can view the first index but selecting another one results in an "Index Error on <table>" error dialog. The message is "There are no table partitions on which to define local index partitions". At this point, selecting any of the other panes (Columns, Primary Key, etc.) results in the same dialog. While the main Partitions tab shows my partitions, I cannot see them in the Edit Table dialog. In fact, the Partition Definitions and Subpartition Templates panes are blank.
    Does anyone else see this behavior? Version 1.5.1 behaved the same way so it's not new.
    Of course I've figured out how to do everything I need through SQL but it would be handy if I could just use the tool.
    Thank you.

    Most of my tables are generated from a script so this morning I decided to just create a very basic partitioned table. It contained a NUMBER primary key and a TIMESTAMP(6) column to use with partitioning. That table worked just fine in SQL Developer.
    At that point I tried to figure out what is different about my tables and I finally found the difference... Oracle Spatial. If I add an MDSYS.SDO_GEOMETRY column to my partitioned table, SQL Developer starts having issues.
    I also have the GeoRaptor plugin installed so I had to wonder if it was interfering with SQL Developer. I couldn't find an option to uninstall an extension so I went into the sqldeveloper/extensions directory and removed GeoRaptorLibs and org.GeoRaptor.jar. GeoRaptor doesn't appear to be installed in SQL Developer anymore but I still see the same behavior.
    It appears that there is an issue in SQL Developer with Oracle Spatial and partitioning. Can someone confirm this?

  • Insert performance issue with Partitioned Table.....

    Hi All,
    I have a performance issue during with a table which is partitioned. without table being partitioned
    it ran in less time but after partition it took more than double.
    1) The table was created initially without any partition and the below insert took only 27 minuts.
    Total Rec Inserted :- 2424233
    PL/SQL procedure successfully completed.
    Elapsed: 00:27:35.20
    2) Now I re-created the table with partition(range yearly - below) and the same insert took 59 minuts.
    Is there anyway i can achive the better performance during insert on this partitioned table?
    [ similerly, I have another table with 50 Million records and the insert took 10 hrs without partition.
    with partitioning the table, it took 18 hours... ]
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 4195045590
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 643K| 34M| | 12917 (3)| 00:02:36 |
    |* 1 | HASH JOIN | | 643K| 34M| 2112K| 12917 (3)| 00:02:36 |
    | 2 | VIEW | index$_join$_001 | 69534 | 1290K| | 529 (3)| 00:00:07 |
    |* 3 | HASH JOIN | | | | | | |
    | 4 | INDEX FAST FULL SCAN| PK_ACCOUNT_MASTER_BASE | 69534 | 1290K| | 181 (3)| 00:00
    | 5 | INDEX FAST FULL SCAN| ACCOUNT_MASTER_BASE_IDX2 | 69534 | 1290K| | 474 (2)| 00:00
    PLAN_TABLE_OUTPUT
    | 6 | TABLE ACCESS FULL | TB_SISADMIN_BALANCE | 2424K| 87M| | 6413 (4)| 00:01:17 |
    Predicate Information (identified by operation id):
    1 - access("A"."VENDOR_ACCT_NBR"=SUBSTR("B"."ACCOUNT_NO",1,8) AND
    "A"."VENDOR_CD"="B"."COMPANY_NO")
    3 - access(ROWID=ROWID)
    Open C1;
    Loop
    Fetch C1 Bulk Collect Into C_Rectype Limit 10000;
    Forall I In 1..C_Rectype.Count
    Insert test
         col1,col2,col3)
    Values
         val1, val2,val3);
    V_Rec := V_Rec + Nvl(C_Rectype.Count,0);
    Commit;
    Exit When C_Rectype.Count = 0;
    C_Rectype.delete;
    End Loop;
    End;
    Total Rec Inserted :- 2424233
    PL/SQL procedure successfully completed.
    Elapsed: 00:51:01.22
    Edited by: user520824 on Jul 16, 2010 9:16 AM

    I'm concerned about the view in step 2 and the index join in step 3. A composite index with both columns might eliminate the index join and result in fewer read operations.
    If you know which partition the data is going into beforehand you can save a little bit of processing by specifying the partition (which may not be a scalable long-term solution) in the insert - I'm not 100% sure you can do this on inserts but I know you can on selects.
    The APPEND hint won't help the way you are using it - the VALUES clause in an insert makes it be ignored. Where it is effective and should help you is if you can do the insert in one query - insert into/select from. If you are using the loop to avoid filling up undo/rollback you can use a bulk collect to batch the selects and commit accordingly - but don't commit more often than you have to because more frequent commits slow transactions down.
    I don't think there is a nologging hint :)
    So, try something like
    insert /*+ hints */ into ...
    Select
         A.Ing_Acct_Nbr, currency_Symbol,
         Balance_Date,     Company_No,
         Substr(Account_No,1,8) Account_No,
         Substr(Account_No,9,1) Typ_Cd ,
         Substr(Account_No,10,1) Chk_Cd,
         Td_Balance,     Sd_Balance,
         Sysdate,     'Sisadmin'
    From Ideaal_Cons.Tb_Account_Master_Base A,
         Ideaal_Staging.Tb_Sisadmin_Balance B
    Where A.Vendor_Acct_Nbr = Substr(B.Account_No,1,8)
       And A.Vendor_Cd = b.company_no
          ;Edited by: riedelme on Jul 16, 2010 7:42 AM

  • Problems with partition tables

    Hi all,
    I've got some problems with partition tables. The script at the bottom run but when I wanna insert some values it returns me an error
    (ORA-06550: line 1, column 30: PL/SQL: ORA-06552: PL/SQL: Compilation unit analysis terminated
    ORA-06553: PLS-320: the declaration of the type of this expression is incomplete or malformed
    ORA-06550: line 1, column 7: PL/SQL: SQL Statement ignored)
    and I can't understand why!
    There's something incorrect in the script or not?
    Please help me
    Thanks in advance
    Steve
    CREATE TABLE TW_E_CUSTOMER_UNIFIED
    ID_CUSTOMER_UNIFIED VARCHAR2 (27) NOT NULL ,
    START_VALIDITY_DATE DATE NOT NULL ,
    END_VALIDITY_DATE DATE ,
    CUSTOMER_STATUS VARCHAR2 (255)
    PARTITION BY RANGE (START_VALIDITY_DATE)
    SUBPARTITION BY LIST (END_VALIDITY_DATE)
    PARTITION M200909 VALUES LESS THAN (TO_DATE('20091001','YYYYMMDD'))
    (SUBPARTITION M200909_N VALUES (NULL), SUBPARTITION M200909_NN VALUES (DEFAULT)),
    PARTITION M200910 VALUES LESS THAN (TO_DATE('20091101','YYYYMMDD'))
    (SUBPARTITION M200910_N VALUES (NULL), SUBPARTITION M200910_NN VALUES (DEFAULT)),
    PARTITION M200911 VALUES LESS THAN (TO_DATE('20091201','YYYYMMDD'))
    (SUBPARTITION M200911_N VALUES (NULL), SUBPARTITION M200911_NN VALUES (DEFAULT)),
    PARTITION M200912 VALUES LESS THAN (TO_DATE('20100101','YYYYMMDD'))
    (SUBPARTITION M200912_N VALUES (NULL), SUBPARTITION M200912_NN VALUES (DEFAULT)),
    PARTITION M201001 VALUES LESS THAN (TO_DATE('20100201','YYYYMMDD'))
    (SUBPARTITION M201001_N VALUES (NULL), SUBPARTITION M201001_NN VALUES (DEFAULT)),
    PARTITION M201002 VALUES LESS THAN (TO_DATE('20100301','YYYYMMDD'))
    (SUBPARTITION M201002_N VALUES (NULL), SUBPARTITION M201002_NN VALUES (DEFAULT)),
    PARTITION M210001 VALUES LESS THAN (MAXVALUE))
    (SUBPARTITION M210001_N VALUES (NULL), SUBPARTITION M210001_NN VALUES (DEFAULT))
    ;

    Hi Hoek,
    the DB version is 10.2 (italian version, then SET is correct).
    ...there's something strange: now I can INSERT rows but I can't update them!
    I'm using this command string:
    UPDATE TW_E_CUSTOMER_UNIFIED SET END_VALIDITY_DATE = TO_DATE('09-SET-09', 'DD-MON-RR') WHERE
    id_customer_unified = '123' and start_validity_date = TO_DATE('09-SET-09', 'DD-MON-RR');
    And this is the error:
    Error SQL: ORA-14402: updating partition key column would cause a partition change
    14402. 00000 - "updating partition key column would cause a partition change"
    *Cause:    An UPDATE statement attempted to change the value of a partition
    key column causing migration of the row to another partition
    *Action:   Do not attempt to update a partition key column or make sure that
    the new partition key is within the range containing the old
    partition key.
    I think that is impossible to use a PARTITION/SUBPARTITION like that: in fact the update of "END_VALIDITY_DATE" cause a partition change.
    Do u agree or it's possible an update on a field that implies a partition change?
    Regards Steve

  • Problems Faced with Partitions in Oracle 9i.

    I have a doubt regarding the partitions in Oracle 9i can you please help me regarding this?
    Create table t1
    ( x number,
    y number,
    z number);
    insert into t1 values (1,1,1);
    insert into t1 values (2,2,2);
    insert into t1 values (3,3,3);
    Create table t2
    x number,
    y number,
    z number
    partition by range(x)
    partition p1 values less than(2),
    partition p2 values less than(3),
    partition p3 values less than(4),
    partition p4 values less than(maxvalue)
    alter table t2 exchange partition p1 with table t1;
    SQL> alter table t2 exchange partition p1 with table t1;
    alter table t2 exchange partition p1 with table t1
    ERROR at line 1:
    ORA-14099: all rows in table do not qualify for specified partition
    WHAT DOES THIS ERROR MESSAGE MEAN? I AM NOT ABLE TO UNDERSTAND THIS? WHAT NEED's TO BE DONE TO RESOLVE THIS?
    alter table t2 exchange partition p1 with table t1 WITHOUT VALIDATION;
    SQL> SELECT * FROM T2;
    X Y Z
    1 1 1
    2 2 2
    3 3 3
    SQL> SELECT * FROM T2 PARTITION(P1);
    X Y Z
    1 1 1
    2 2 2
    3 3 3
    SQL> SELECT * FROM T2 PARTITION(P2);
    no rows selected
    SQL> SELECT * FROM T2 PARTITION(P3);
    no rows selected
    (i) Why i am facing this error ORA-14099: while partitioning? Can you please brief me about this ?
    (ii) why there is not data's in the PARTITIONS p2 &p3 after the partitions is exchanged WITHOUT VALIDATION options?
    what is going with this method?
    (iii) Also can you please explain me with an example how to partitions a table having milliion of records with EXCHANGE PARTITION Options with MULITPLE partition segment's (say partition based on status id column with 6 differnt values i am thinking to use list partitions using status_id as partition key) ?
    Also i have tried the below approch is this a right approch? please correct me if i am wrong.
    Create table t1
    ( x number,
    y number,
    z number);
    insert into t1 values (1,1,1);
    insert into t1 values (2,2,2);
    insert into t1 values (3,3,3);
    commit;
    Create table t2
    x number,
    y number,
    z number
    partition by range(x)
    partition p1 values less than(2),
    partition p2 values less than(3),
    partition p3 values less than(4),
    partition p4 values less than(maxvalue)
    SQL> insert into t2 select * from t1;
    3 rows created.
    SQL> commit;
    Commit complete.
    SQL> SELECT * FROM T2 PARTITION(P1);
    X Y Z
    1 1 1
    SQL> SELECT * FROM T2 PARTITION(P2);
    X Y Z
    2 2 2
    SQL> SELECT * FROM T2 PARTITION(P3);
    X Y Z
    3 3 3
    SQL> SELECT * FROM T2 PARTITION(P4);
    no rows selected
    EXPLAIN PLAN
    FOR SELECT * FROM T2 WHERE X = 1
    | Id | Operation | Name | Rows | Bytes | Cost | Pstart| Pstop |
    | 0 | SELECT STATEMENT | | 1 | 9 | 2 | | |
    | 1 | TABLE ACCESS FULL | T2 | 1 | 9 | 2 | 1 | 1 |
    Now my question is what is problem instead of using EXCHANGE PARTITION why caun't we follow this above approch?
    to partition a non-partitioned table?
    Thanks,
    Rajesh.

    The value of 3 should obviously should go into the partition P3.Then why are you putting it into p1?
    Your command,
    <tt>    alter table t2 exchange partition <b>p1</b> with table t1;</tt>
    will swap partition p1 with the contents of table t1, leaving you with partition p1 containing the three values that were in t1. At first it told you there were rows in t1 that did not belong in that partition, but you used FORCE so it put them in anyway.
    btw there are notes in the FAQ about how to use ** tags to format your posts.
    ~Edited by: William Robertson on Oct 15, 2008 6:49 AM~                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • Job to schedule every 8 hours daily...

    Hello In our loads we need to load daily and every 8 hourly once. I have created the process chains in the following way. 1) on start variant of the process chain under "Date/Time" i had given the start date and time. 2) Under periodic values window

  • Balance Sheet Adjustment F.5D computation

    Hello All, How do F.5D compute the balance sheet adjustment as per profit center. Ex. PK     Account     Amount     Profit Ctr 40     A1     2,000.00     PCDUMMY 40     A2     1,000.00     P1 40     A2            1,000.00     P2 50     A2     -1,000.

  • Getting manager hierarchy using LDAP

    I have a set of oracle email ids. I would like to get their manager hierarchy as well as Job title. Is this possible using LDAP. If so can someone please explain with a code snippet. Thanks.

  • WCS 7.x & Multiple Accounts

    New to Cisco WCS, i.e. fresh install.  We have a new install of v7.x WCS, with three admins.  Didn't find any reference to this issue in the Cisco docs/search.  Question/Statement is: If two users are logged in and making modifications to the same ca

  • Monthview calendar control

    Hi, I'm using the monthview calendar control in my application. It works fine on win98/XP system based, but something does not go with win 2000pro OS. I've tried to install the MSCOMCT2.OCX file in system32 folder, but nothing is changed, the control