Using PARTITION FOR/SUBPARTITION FOR syntax to insert

We are trying to use PARTITION FOR syntax (or, better, SUBPARTITION FOR syntax) to insert into a subpartitioned table.
http://docs.oracle.com/cd/E11882_01/server.112/e26088/sql_elements009.htm#i165979
08:26:46 GM_CS_CDR@oradev02> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE    11.2.0.3.0      Production
TNS for Solaris: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
5 rows selected.This table is has interval partitions on DATA_ORIGIN_ID and list subpartitions on TABLE_NAME.
First, a basic insert without specifying partitions:
08:10:05 GM_CS_CDR@oradev02> insert into key_ids2 (
08:11:51   2  DATA_ORIGIN_ID         ,
08:11:51   3  TABLE_NAME             ,
08:11:51   4  DUR_UK                 ,
08:11:51   5  DUR_UK_ID              )
08:11:51   6  select
08:11:51   7  12         ,
08:11:51   8  TABLE_NAME             ,
08:11:51   9  DUR_UK                 ,
08:11:51  10  DUR_UK_ID             
08:11:51  11  from key_ids where table_name = 'PART'
08:11:51  12  and rownum <= 10;
10 rows created.Verifying SUBPARTITION FOR syntax on a SELECT:
08:19:43 GM_CS_CDR@oradev02>
08:26:45 GM_CS_CDR@oradev02>
08:26:45 GM_CS_CDR@oradev02>
08:26:45 GM_CS_CDR@oradev02>
08:26:45 GM_CS_CDR@oradev02> select count(*) from key_ids2
08:26:45   2  subpartition for(12,'PART');
  COUNT(*)
        10
1 row selected.But when we add a subpartition specification (to limit the lock to a single subpartition), we get a syntax error:
08:14:57 GM_CS_CDR@oradev02> insert into key_ids2 subpartition for(12,'PART') (
08:14:57   2  DATA_ORIGIN_ID         ,
08:14:57   3  TABLE_NAME             ,
08:14:57   4  DUR_UK                 ,
08:14:57   5  DUR_UK_ID              )
08:14:57   6  select
08:14:57   7  14         ,
08:14:57   8  TABLE_NAME             ,
08:14:57   9  DUR_UK||'!'                 ,
08:14:57  10  DUR_UK_ID             
08:14:57  11  from key_ids
08:14:57  12  where table_name = 'PART'
08:14:57  13  and rownum <= 10;
insert into key_ids2 subpartition for(12,'PART') (
ERROR at line 1:
ORA-14173: illegal subpartition-extended table name syntaxSpecifying at the partition level did not work either:
08:14:58 GM_CS_CDR@oradev02> insert into key_ids2 partition for(14) (
08:15:23   2  DATA_ORIGIN_ID         ,
08:15:23   3  TABLE_NAME             ,
08:15:23   4  DUR_UK                 ,
08:15:23   5  DUR_UK_ID              )
08:15:23   6  select
08:15:23   7  14         ,
08:15:23   8  TABLE_NAME             ,
08:15:23   9  DUR_UK||'!'                 ,
08:15:23  10  DUR_UK_ID             
08:15:23  11  from key_ids
08:15:23  12  where table_name = 'PART'
08:15:23  13  and rownum <= 10;
insert into key_ids2 partition for(14) (
ERROR at line 1:
ORA-14108: illegal partition-extended table name syntaxBut specifying explicit partition and subpartition does work:
08:17:45 GM_CS_CDR@oradev02> insert into key_ids2 partition (SYS_P15127) (
08:18:23   2  DATA_ORIGIN_ID         ,
08:18:23   3  TABLE_NAME             ,
08:18:23   4  DUR_UK                 ,
08:18:23   5  DUR_UK_ID              )
08:18:23   6  select
08:18:23   7  12         ,
08:18:23   8  TABLE_NAME             ,
08:18:23   9  DUR_UK||'!'                 ,
08:18:23  10  DUR_UK_ID             
08:18:23  11  from key_ids
08:18:23  12  where table_name = 'PART'
08:18:23  13  and rownum <= 10;
10 rows created.
08:18:24 GM_CS_CDR@oradev02> insert into key_ids2 subpartition (SYS_SUBP15126) (
08:19:42   2  DATA_ORIGIN_ID         ,
08:19:42   3  TABLE_NAME             ,
08:19:42   4  DUR_UK                 ,
08:19:42   5  DUR_UK_ID              )
08:19:42   6  select
08:19:42   7  12         ,
08:19:42   8  TABLE_NAME             ,
08:19:42   9  DUR_UK||'!#'                 ,
08:19:42  10  DUR_UK_ID             
08:19:42  11  from key_ids
08:19:42  12  where table_name = 'PART'
08:19:42  13  and rownum <= 10;
10 rows created.We have been successful in using the PARTITION FOR syntax for tables that were partitioned but not subpartitioned.
Any ideas?
Thanks,
Mike

I've created a simplified script to reproduce our issue. The use of the syntax on an INSERT INTO using VALUES still produces the same error.
Thanks,
Andy
select * from v$version;
create table part_test_tbl
  data_origin_id NUMBER  not null,
  table_name VARCHAR2(30) not null,
  dur_uk     VARCHAR2(250) not null,
  dur_uk_id  NUMBER
partition by range (data_origin_id) INTERVAL (1)
subpartition by list (TABLE_NAME)
SUBPARTITION TEMPLATE(
  subpartition BLUE values ('BLUE'),
  subpartition RED values ('RED'),
  subpartition YELLOW values ('YELLOW'),
  subpartition GREEN values ('GREEN'),
  subpartition ORANGE values ('ORANGE')
(PARTITION DFLT_INTRVL VALUES LESS THAN (0)
  subpartition BLUE values ('BLUE'),
  subpartition RED values ('RED'),
  subpartition YELLOW values ('YELLOW'),
  subpartition GREEN values ('GREEN'),
  subpartition ORANGE values ('ORANGE')
-- Create/Recreate indexes
create index PART_TEST_TBL_PK on PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
  compress 2  local;
create unique index PART_TEST_TBL_UK on PART_TEST_TBL (TABLE_NAME, DUR_UK_ID)
  compress 1;
-- Create/Recreate primary, unique and foreign key constraints
alter table PART_TEST_TBL
  add constraint PART_TEST_TBL_PK primary key (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK) USING INDEX PART_TEST_TBL_PK;
alter table PART_TEST_TBL
  add constraint PART_TEST_TBL_UK unique (TABLE_NAME, DUR_UK_ID) USING INDEX PART_TEST_TBL_UK;
--Add test data
BEGIN
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (0, 'BLUE', '1', 1);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (0, 'BLUE', '2', 2);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (0, 'YELLOW', '3', 3);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (0, 'GREEN', '4', 4);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (0, 'ORANGE', '5', 5);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (1, 'BLUE', '6', 6);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (1, 'BLUE', '7', 7);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (1, 'YELLOW', '8', 8);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (1, 'GREEN', '9', 9);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (1, 'ORANGE', '10', 10);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (2, 'BLUE', '11', 11);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (2, 'BLUE', '12', 12);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (2, 'YELLOW', '13', 13);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (2, 'GREEN', '14', 14);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (2, 'ORANGE', '15', 15);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (10, 'BLUE', '16', 16);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (10, 'BLUE', '17', 17);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (10, 'YELLOW', '18', 18);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (10, 'GREEN', '19', 19);
   insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
   values (10, 'ORANGE', '20', 20);
   COMMIT;
END;
--Validate the subpartition_extended syntax
select count(*) from PART_TEST_TBL subpartition for(10,'BLUE');
--Show subpartition_extended syntax does not work on INSERT INTO
INSERT /*+APPEND */ INTO PART_TEST_TBL SUBPARTITION FOR (10,'BLUE')
(data_origin_id
,table_name
,dur_uk
,dur_uk_id)
VALUES
(10
,'BLUE'
,'16!'
,1016);
--Show subpartition_extended syntax does not work on INSERT INTO
INSERT /*+APPEND */ INTO PART_TEST_TBL SUBPARTITION FOR (10,'BLUE')
(data_origin_id
,table_name
,dur_uk
,dur_uk_id)
SELECT ptt.data_origin_id
      ,ptt.table_name
      ,ptt.dur_uk || '!' dur_uk
      ,ptt.dur_uk_id + 1000 dur_uk_id
  FROM PART_TEST_TBL ptt
WHERE ptt.table_name = 'BLUE'
   AND ptt.data_origin_id = 10;
DROP TABLE part_test_tbl PURGE;-----
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE  11.2.0.3.0  Production
TNS for Solaris: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> create table part_test_tbl
  2  (
  3    data_origin_id NUMBER  not null,
  4    table_name VARCHAR2(30) not null,
  5    dur_uk     VARCHAR2(250) not null,
  6    dur_uk_id  NUMBER
  7  )
  8  partition by range (data_origin_id) INTERVAL (1)
  9  subpartition by list (TABLE_NAME)
10  SUBPARTITION TEMPLATE(
11    subpartition BLUE values ('BLUE'),
12    subpartition RED values ('RED'),
13    subpartition YELLOW values ('YELLOW'),
14    subpartition GREEN values ('GREEN'),
15    subpartition ORANGE values ('ORANGE')
16  )
17  (PARTITION DFLT_INTRVL VALUES LESS THAN (0)
18    (
19    subpartition BLUE values ('BLUE'),
20    subpartition RED values ('RED'),
21    subpartition YELLOW values ('YELLOW'),
22    subpartition GREEN values ('GREEN'),
23    subpartition ORANGE values ('ORANGE')
24    )
25  );
Table created
SQL> -- Create/Recreate indexes
SQL> create index PART_TEST_TBL_PK on PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
  2    compress 2  local;
Index created
SQL> create unique index PART_TEST_TBL_UK on PART_TEST_TBL (TABLE_NAME, DUR_UK_ID)
  2    compress 1;
Index created
SQL> -- Create/Recreate primary, unique and foreign key constraints
SQL> alter table PART_TEST_TBL
  2    add constraint PART_TEST_TBL_PK primary key (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK) USING INDEX PART_TEST_TBL_PK;
Table altered
SQL> alter table PART_TEST_TBL
  2    add constraint PART_TEST_TBL_UK unique (TABLE_NAME, DUR_UK_ID) USING INDEX PART_TEST_TBL_UK;
Table altered
SQL> --Add test data
SQL> BEGIN
  2 
  3     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
  4     values (0, 'BLUE', '1', 1);
  5 
  6     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
  7     values (0, 'BLUE', '2', 2);
  8 
  9     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
10     values (0, 'YELLOW', '3', 3);
11 
12     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
13     values (0, 'GREEN', '4', 4);
14 
15     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
16     values (0, 'ORANGE', '5', 5);
17 
18     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
19     values (1, 'BLUE', '6', 6);
20 
21     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
22     values (1, 'BLUE', '7', 7);
23 
24     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
25     values (1, 'YELLOW', '8', 8);
26 
27     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
28     values (1, 'GREEN', '9', 9);
29 
30     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
31     values (1, 'ORANGE', '10', 10);
32 
33     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
34     values (2, 'BLUE', '11', 11);
35 
36     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
37     values (2, 'BLUE', '12', 12);
38 
39     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
40     values (2, 'YELLOW', '13', 13);
41 
42     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
43     values (2, 'GREEN', '14', 14);
44 
45     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
46     values (2, 'ORANGE', '15', 15);
47 
48     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
49     values (10, 'BLUE', '16', 16);
50 
51     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
52     values (10, 'BLUE', '17', 17);
53 
54     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
55     values (10, 'YELLOW', '18', 18);
56 
57     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
58     values (10, 'GREEN', '19', 19);
59 
60     insert into PART_TEST_TBL (DATA_ORIGIN_ID, TABLE_NAME, DUR_UK, DUR_UK_ID)
61     values (10, 'ORANGE', '20', 20);
62 
63     COMMIT;
64  END;
65  /
PL/SQL procedure successfully completed
SQL> --Validate the subpartition_extended syntax
SQL> select count(*) from PART_TEST_TBL subpartition for(10,'BLUE');
  COUNT(*)
         2
SQL> --Show subpartition_extended syntax does not work on INSERT INTO
SQL> INSERT /*+APPEND */ INTO PART_TEST_TBL SUBPARTITION FOR (10,'BLUE')
  2  (data_origin_id
  3  ,table_name
  4  ,dur_uk
  5  ,dur_uk_id)
  6  VALUES
  7  (10
  8  ,'BLUE'
  9  ,'16!'
10  ,1016);
INSERT /*+APPEND */ INTO PART_TEST_TBL SUBPARTITION FOR (10,'BLUE')
(data_origin_id
,table_name
,dur_uk
,dur_uk_id)
VALUES
(10
,'BLUE'
,'16!'
,1016)
ORA-14173: illegal subpartition-extended table name syntax
SQL> --Show subpartition_extended syntax does not work on INSERT INTO
SQL> INSERT /*+APPEND */ INTO PART_TEST_TBL SUBPARTITION FOR (10,'BLUE')
  2  (data_origin_id
  3  ,table_name
  4  ,dur_uk
  5  ,dur_uk_id)
  6  SELECT ptt.data_origin_id
  7        ,ptt.table_name
  8        ,ptt.dur_uk || '!' dur_uk
  9        ,ptt.dur_uk_id + 1000 dur_uk_id
10    FROM PART_TEST_TBL ptt
11   WHERE ptt.table_name = 'BLUE'
12     AND ptt.data_origin_id = 10;
INSERT /*+APPEND */ INTO PART_TEST_TBL SUBPARTITION FOR (10,'BLUE')
(data_origin_id
,table_name
,dur_uk
,dur_uk_id)
SELECT ptt.data_origin_id
      ,ptt.table_name
      ,ptt.dur_uk || '!' dur_uk
      ,ptt.dur_uk_id + 1000 dur_uk_id
  FROM PART_TEST_TBL ptt
WHERE ptt.table_name = 'BLUE'
   AND ptt.data_origin_id = 10
ORA-14173: illegal subpartition-extended table name syntax
SQL> DROP TABLE part_test_tbl PURGE;
Table dropped
SQL>

Similar Messages

  • Partition exchange loading for specific subpartitions

    Hi All,
    Looking at an archive strategy - where we have to archive a specific dataset.
    Rather than a insert/delete routine - I was thinking of using partition exchange.
    The to-be archived table is interval range partitioned on date, with a list subpartition on country.
    It is for specific countries that I want to partition exchange.
        create table
        test_table
        (tbl_id number,
        country varchar2(2),
        sales_dt date,
        volume number)
        partition by range (sales_dt) interval (NUMTOYMINTERVAL(1,'Month'))
        subpartition by list (country)
        Subpartition template
        (subpartition p_ireland values ('IR'),
        subpartition p_france values ('FR'),
        subpartition p_other values (DEFAULT))
        (partition before_2008 values less than (to_date('01-JAN-2008','DD-MON-YYYY'))); The data loaded falls into the partitions and subpartitions correctly. All the partitions names are system generated.
    When I come to partition exchange for all the 'FR' subpartitions- I can't determine the logic.
    Using
        Alter table test_table
        exchange subpartition system_generated_name
        with table TEST_TABLE_ARCH;I can swap out a specific 'known' subpartition.
    I know you can use the 'for' logic with Oracle 11g but can't get the syntax to work.
    Any ideas?

    The error means you are trying to swap a partition that still contains data in a configuration where OWB expects an empty partition. How did you set the "Replace existing data in Target Partition" configuration parameter?
    Also, for more details on PEL, review the 10.19 to 10.27 pages of the user manual.
    Regards:
    Igor

  • Can i use partition by for the following

    hi, i wanted to find out if i can use partition by or rank to the get the needed results below. If yes can anyone help me out with it.
    if there is an other way to get the results also please let me know.
    i'm using Oracle version 10.2.0.4.0
    create table script:
    CREATE TABLE DMM.QUES
      CASENAME        VARCHAR2(100 BYTE),
      CASENUMBER      VARCHAR2(20 BYTE),
      COVERAGE        VARCHAR2(10 BYTE),
      DIVISIONNUMBER  VARCHAR2(6 BYTE),
      CLASSNUMBER     number,
      TIER            VARCHAR2(2 BYTE),
      MONTHLYRATE     NUMBER
      )Insert statement scripts:
    insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
    values ('ABC','123J','health', '456J','987',null,.25)
    insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
    values ('ABC','123J','health', '456J','123',null,.25)
    insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
    values ('ABC','123J','health', '456J','453',null,.25)
    insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
    values ('ABC','123J','dental', '456J','453','ee',.29)
    insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
    values ('ABC','123J','dental', '456J','453','es',.23)
    insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
    values ('ABC','123J','dental', '456J','453','ec',.44)
    insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
    values ('ABC','123J','dental', '456J','453','fa',.33)
    insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
    values ('ABC','123J','dental', '456J','123','ee',.45)
    insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
    values ('ABC','123J','dental', '456J','123','es',.45)
    insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
    values ('ABC','123J','dental', '456J','123','ec',.46)
    insert into QUES (CASENAME,CASENUMBER,  COVERAGE,  DIVISIONNUMBER,  CLASSNUMBER,  TIER,MONTHLYRATE)
    values ('ABC','123J','dental', '456J','123','fa',.49)select * from ques:
    ABC     123J     health     456J     987          0.25
    ABC     123J     health     456J     453          0.25
    ABC     123J     health     456J     123          0.25
    ABC     123J     dental     456J     453     ee     0.29
    ABC     123J     dental     456J     453     es     0.23
    ABC     123J     dental     456J     453     ec     0.44
    ABC     123J     dental     456J     453     fa     0.33
    ABC     123J     dental     456J     123     ee     0.45
    ABC     123J     dental     456J     123     es     0.45
    ABC     123J     dental     456J     123     ec     0.46
    ABC     123J     dental     456J     123     fa     0.49i would like to get the following output
    ABC     123J     health     456J     123          0.25
    ABC     123J     dental     456J     123     ee     0.45
    ABC     123J     dental     456J     123     es     0.45
    ABC     123J     dental     456J     123     ec     0.46
    ABC     123J     dental     456J     123     fa     0.49i would like the code to take the minimum of classnumber for each divisonnumber/coverage combination and give me all the records for that classnumber.
    Thanks in advance.

    Hi,
    That's an example of a Top-N Query , and yes, analytic functions are a good way to do it:
    WITH     got_r_num     AS
         SELECT     ques.*
         ,     RANK () OVER ( PARTITION BY  coverage
                               ,          divisionnumber
                          ORDER BY          classnumber
                        ) AS r_num
         FROM    ques
    SELECT  casename, casenumber, coverage, divisionnumber, classnumber, tier, monthlyrate
    FROM     got_r_num
    WHERE     r_num     = 1
    ;Thanks for posting the CREATE TABLE and INSERT statements, that's very helpful!
    "PARTITION BY" is a clause often used with analytic functions. "PARTTIION" also means at least two other things in Oracle, so people will understand you better if you say "analytic functions", rather than "partition by".
    For more about the RANK function, see this thread:
    Re: A "double grouping" SQL query

  • Help needed. I have a 3TB external hard drive partitioned into 1TB's. I used one partition as backup for the main computer hard drive. But now it is greyed out as shown in the disk utility and its name changed, i dont know how that happened, i tried verif

    Help needed. I have a 3TB external hard drive partitioned into 1TB's. I used one partition as backup for the main computer hard drive. But now it is greyed out as shown in the disk utility and its name changed, i dont know how that happened, i tried verifying and repairing it but had no luck. I also tried mounting and unmounting it but still no solution. Anyone to help please?

    Looks bad. I would strongly advise backing up the stuff on the other two partitions as soon as possible in case the rest of the drive goes wrong.
    Beyond that, Disk Utility has limited abilities to repair disks, DiskWarrior uses a different approach and might, emphasis might be more successful. It has certainly done the job for me in the past when Disk Utility could not.
    See http://www.alsoft.com/diskwarrior/

  • How to partition my drive for  Mac and XP use?  from a novice

    I would like to use my MacBook Pro for both Mac ad PC programs (Office and others) and hear that I can partition the drive.  How is the best way to do that?  Also I have an external Seagate FreeAgent GoFlex external drive to set up that supposedly can back up both Mac and PC without formatting each time.  Do I have to partition the drive first?  Do I use Time Machine?

    Is it your intent to run Windows programs on your computer?  If so then this is more than simply a partitioning exercise.
    In order to use an external drive on both Macs and PCs there are two options.  Option One is to partition and format the drive MBP and FAT32, respectively.  OS X can read/write a FAT32 formatted drive.  However, due to filesystem differences some features of the OS X filesystem are not supported by FAT32, so FAT32 is not the best choice for transferring OS X documents, but would be fine for transferring Windows documents.
    Option Two is to partition the drive using GUID then creating two partitions.  One partition is formatted Mac OS Extended, Journaled and the other partition is formatted FAT32.  Each partition can be used for the data from the appropriate platform.
    TM is not a file transfer program, cannot be used for Windows documents, and does not work on Windows.
    If you wish to run Windows on your Mac then see the following:
    Windows on Intel Macs
    There are presently several alternatives for running Windows on Intel Macs.
    1. Install the Apple Boot Camp software.  Purchase Windows XP w/Service Pak2, Vista, or Windows 7.  Follow instructions in the Boot Camp documentation on installation of Boot Camp, creating Driver CD, and installing Windows.  Boot Camp enables you to boot the computer into OS X or Windows.
    2. Parallels Desktop for Mac and Windows XP, Vista Business, Vista Ultimate, or Windows 7.  Parallels is software virtualization that enables running Windows concurrently with OS X.
    3. VM Fusionand Windows XP, Vista Business, Vista Ultimate, or Windows 7.  VM Fusion is software virtualization that enables running Windows concurrently with OS X.
    4. CrossOver which enables running many Windows applications without having to install Windows.  The Windows applications can run concurrently with OS X.
    5. VirtualBox is a new Open Source freeware virtual machine such as VM Fusion and Parallels that was developed by Solaris.  It is not as fully developed for the Mac as Parallels and VM Fusion.
    Note that Parallels and VM Fusion can also run other operating systems such as Linux, Unix, OS/2, Solaris, etc.  There are performance differences between dual-boot systems and virtualization.  The latter tend to be a little slower (not much) and do not provide the video performance of the dual-boot system.
    See MacTech.com's Virtualization Benchmarking for comparisons of Boot Camp, Parallels, and VM Fusion. Boot Camp is only available with Leopard or Snow Leopard. Except for Crossover and a couple of similar alternatives like DarWine you must have a valid installer disc for Windows. You must also have an internal optical drive for installing Windows. Windows cannot be installed from an external optical drive.

  • I have a 1TB external hard drive (NTFS) that has all my files from my old PC, how do I create a partition on it for HFS  without formatting it so that I can use it for Time Machine and the like?

    I have a 1TB external hard drive (NTFS) that has all my files from my old PC, how do I create a partition on it for HFS  without formatting it so that I can use it for Time Machine and the like?

    There aren't any 3rd party apps or anything. I use PC's and Mac's at school and the only computer connected to a printer at my house is a PC so i need access to both

  • I use a yahoo account for my e-mail which worked fine until I changed my password a few weeks ago. I now keep getting a message up telling me to insert my password again. i know I'm putting in the right password but this driving me to distraction!

    I use a yahoo account for my e-mail which worked fine until I changed my password a few weeks ago. I now keep getting a message up telling me to insert my password again. I know I'm putting in the right password but this is driving me to distraction!
    I have now deleted the account and reinstalled it but now I can't get my e-mails through at all. Can anyone make any suggestions?

    Hello,
    Open Keychain Access in Utilities, use Keychain First Aid under the Keychain Menu item, then either check the Password under that item, change it, or delete it and start over.
    You may have multiple entries.
    Open Keychain Access in Utilities, enter the part after the @ sign in the search bar, hit enter

  • Non riesco a ricevere acquisti fatti su itunes, mi da questo errore :erreu : you have an error in your sql syntax; checkthe manual that corresponds to your mysql server version for the right syntax to use near from news order by id desc at line. cosa devo

    non riesco a ricevere acquisti fatti su itunes, mi da questo errore :erreu : you have an error in your sql syntax; checkthe manual that corresponds to your mysql server version for the right syntax to use near from news order by id desc at line. cosa devo fare?  grazie

    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]

  • How to use the Output clause for the updated statment

    How to use the output clause for the below update stament,
    DECLARE @MyTableVar table(
        sname int NOT NULL)
    update A set stat ='USED' 
    from (select top 1 * from #A 
    where stat='AVAILABLE' order by sno)A
    Output inserted.sname
    INTO @MyTableVar;
    SELECT sname
    FROM @MyTableVar;
    Here am getting one error incorrect syntax near Output
    i want to return the updated value from output clause

    see
    http://blogs.msdn.com/b/sqltips/archive/2005/06/13/output-clause.aspx
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Query to find out the time used by an user for an application

    Hello All,
    I want to know the query to find out the whole time used by the user for an application. Please view the below data
    Employee:
    SNO EMP_ID EMP_NAME EMP_DATE LOGIN_TIME LOGOUT_TIME
    1 10 Visu 21-Nov-2010 06:30:00 07:30:00
    2 10 Visu 21-Nov-2010 06:40:00 07:20:00
    3 10 Visu 21-Nov-2010 06:50:00 07:50:00
    4 10 Visu 21-Nov-2010 07:30:00 08:30:00
    5 10 Visu 21-Nov-2010 09:30:00 10:30:00
    By checking the above data we can say that the total time Visu used the application is
    8.30 - 6.30 (From 1,2,3,4 records) = 2hrs
    10.30 - 9.30 (Based on 5th rec) = 1hr
    So the total time Visu used the application would be 3 hrs = 180 mins.
    Could you please help me in getting the result from that data using a query?

    odie_63 wrote:
    I think it may be solved with analytics too.
    with t1 as (
                select 1 sno,10 emp_id,'Visu' emp_name,'21-Nov-2010' emp_date,'06:30:00' login_time,'07:30:00' logout_time from dual union all
                select 2,10,'Visu','21-Nov-2010','06:40:00','07:20:00' from dual union all
                select 3,10,'Visu','21-Nov-2010','06:50:00','07:50:00' from dual union all
                select 4,10,'Visu','21-Nov-2010','07:30:00','08:30:00' from dual union all
                select 5,10,'Visu','21-Nov-2010','09:30:00','10:30:00' from dual
         t2 as (
                select  emp_id,
                        emp_name,
                        emp_date,
                        to_date(emp_date || login_time,'DD-MON-YYYYHH24:MI:SS') login_time,
                        to_date(emp_date || logout_time,'DD-MON-YYYYHH24:MI:SS') logout_time
                  from  t1
         t3 as (
                select  t2.*,
                        case
                          when login_time < max(logout_time) over(
                                                                  partition by emp_id,emp_date
                                                                  order by login_time
                                                                  rows between unbounded preceding
                                                                           and 1 preceding
                            then 0
                          else 1
                        end start_of_group
                  from  t2
         t4 as (
                select  t3.*,
                        sum(start_of_group) over(partition by emp_id,emp_date order by login_time) grp
                  from  t3
         t5 as (
                select  emp_id,
                        emp_date,
                        min(login_time) login_time,
                        max(logout_time) logout_time
                  from  t4
                  group by emp_id,
                           emp_date,
                           grp
    select  emp_id,
            numtodsinterval(sum(logout_time - login_time),'day') time_spent
      from  t5
      group by emp_id
      order by emp_id
        EMP_ID TIME_SPENT
            10 +000000000 03:00:00.000000000
    SQL> SY.

  • How to update an existing item in a sharepoint list using the WSS adapter for Biztalk

    Is there a way that a record in SP list be updated using WSS adapter in biztalk ?
    BizTalk 2013 and SP 2013 ..
    Regards
    Ritu Raj
    When you see answers and helpful posts,
    please click Vote As Helpful, Propose As Answer, and/or Mark As Answer

    A ListItem has its own unique row id so in all likelihood, an insert with the same data will result in a new list entry. The Lists Web Service however, has an UpdateListItem method which will take an update request. [refer
    http://msdn.microsoft.com/en-us/library/office/websvclists.lists.updatelistitems(v=office.15).aspx ]
    There is another note in the conference (marked answered) to your List Item Update problem. Probably worth a try too. [refer
    http://social.msdn.microsoft.com/Forums/en-US/bee8f6c6-3259-4764-bafa-6689f5fd6ec9/how-to-update-an-existing-item-in-a-sharepoint-list-using-the-wss-adapter-for-biztalk?forum=biztalkgeneral ]
    Regards.

  • Can I use an external drive for Time Machine and storing other data?

    At the moment I have one external drive, a 500gb LaCie. My internal drive is 160gb. I don't think I'll be using all 500 of those gigabytes for a while, so I want to put them to good use. Can I make a partition on this drive and use that for Time Machine, leaving the rest of the drive for my documents and other files? If so, how would I partition the drive? I'm not fluent in Disk Utility and even though I'm pretty sure I know how to do it, I don't want to screw up. Also, how big a partition would you recommend?
    While we're here, I have a second question, somewhat relevant to the first. Could I move my Time Machine backups to a second drive if I wanted to? Also, if I used a big drive (say 1tb) could I use Time Machine to backup my current LaCie to a partition on that drive? Thanks in advance.

    videoCWK wrote:
    Does that also mean that I could back them both up on a very big drive?
    Yes. Time Machine will, by default, back up all of your external drives unless you specifically exclude them.
    Also, will Time Machine backups eat all my space after a lot of usage?
    It depends on what you do on your Mac. If you work often with very large files (video editing, heavy photo editing, big disk images, Microsoft Entourage data file, Parallels disk image file, etc) then your backup drive could fill up very quickly.
    I use my Mac mostly for e-mail, web browsing, iTunes, iPhoto, and the occasional iMovie project. I have 92 GB on my main hard drive (60 GB of which are my iTunes and iPhoto libraries, and one iMovie project.) My Time Machine backups consume 155GB on my backup drive, and that's after using Time Machine for a full year.

  • How do I use my original iphone for videos & apps only, not as phone

    I want to use my original iphone as a video and app player(not a phone) for my daughter, using my library of purchases on my account. I have an iphone 3G and my original iphone is not being used. How do I do this?

    After an iPhone is no longer activated, you can't install a firmware update or restore the iPhone with iTunes (which re-installs the firmware) since activation is required in order to do so.
    I'm not aware of a way to roll a restore back.
    If you have the SIM card that was used when this iPhone was activated, you can try inserting the SIM card and do another restore. Someone here reported that it is possible to install a firmware update or restore an iPhone with iTunes that is no longer activated as long as the SIM card that was used with the iPhone when activated is inserted.
    Message was edited by: Allan Sampson

  • Using an External Drive for Time Machine and Other Things

    I have a 2TB external drive which I use for Time Machine Backups on my 2 macs. The macs have HDs of 500GB and 160GB so the external drive has ample space for backups.
    Is it okay to use the external drive for other things that I don't care if they aren't backed up (like digital copies of DVDs)? i.e. Will Time Machine cause any issues if a drive is used for more than just Time Machine backups?

    rgraves wrote:
    I have a 2TB external drive which I use for Time Machine Backups on my 2 macs. The macs have HDs of 500GB and 160GB so the external drive has ample space for backups.
    Maybe. See #1 in [Time Machine - Frequently Asked Questions|http://web.me.com/pondini/Time_Machine/FAQ.html] (or use the link in *User Tips* at the top of this forum).
    Is it okay to use the external drive for other things that I don't care if they aren't backed up (like digital copies of DVDs)? i.e. Will Time Machine cause any issues if a drive is used for more than just Time Machine backups?
    It's best to put such things in their own partition. See #3 in the FAQ.
    You may also want to make separate partitions for each Mac's backups, if you're backing-up either one directly (ie, not over your network). See #4 in the FAQ.

  • Can I partition my HD for Time Machine?

    Hi all,
    I just bought a drive intended for use with Time Machine. However, I would like to know, if its possible to partition the drive first and use only one half for Time Machine?
    Another thing, do I have to format the drive to Mac OS Extended journaled first before I can use it? Its a Buffalo DriveStation Turbo USB External HD 500gb.
    Thanks

    Matt,
    I think it's possible that the entire drive might show up as FAT32, but the two partitions (volumes) can be formatted as Mac OS Extended (journaled)....I seem to recall this happening to me when I partitioned a WD 500Gb drive a couple of weeks ago. The Volume is the 'subset' shown just below the Hard Drive in Disk Utility.
    Go ahead and partition the drive into two sections. Give each section a name that will be useful to you (perhaps, "Time Machine" for one, and "Data" for the other).
    The two volumes should mount on your desktop. If, for some reason, they aren't Mac OS X Extended (Journaled), just use disk utility to erase/reformat them individually as you need.
    I'll be off line for about 24 hours. You can't hurt the drive by experimenting with partitioning/formatting it... Just be careful about putting data on it, and then trying to reformat it--you'll lose the data that was on the external HD.
    Bob

Maybe you are looking for

  • I accident emptied the photos out of my iPhotos is there a way i can get them back

    I accident emptied the photos out of my iPhotos is there a way i can get them back

  • Getting error in a cursor

    12/1 error :sql statement ignored 12/145 error: column not allowed here. 15/1 error: sql statement ignored 15/145 error: column not allowed here create or replace procedure pps is ccsal number; cursor comm is select salary+nvl(commission_pct,0)from e

  • Create new or use existing info object ? How to decide ?

    All; I have this question. I enhanced the data source with a field user ID, now I am mapping it in the transfer rules in bw. When I searched in the system (ctrl F in infobjects of RSA1) I could find related info objects but they are currently being u

  • WSDL parse error

    Flex builder 3 reports this error when trying to parse my WSDL: actionscript class name contains illegal characters I suspect it is the dots in the "name" attributes that it does not like: --> − <definitions name="GlobalLB.Pool" targetNamespace="urn:

  • MacBook Pro hangs in gray screen after security update

    I just allowed software update to download and install the latest Safari update and Security update 2009-6. During the restart my macbook just hung on the gray screen with the spinning gear. I've tried starting in target disc mode but the iMac doesn'