ORA-02256: number of referencing columns must match referenced columns

Hi,
I have the following script;:
But when I execute the script, TOAD gives me in line "create table recipiente", (I have put in bold the line), the following error: ORA-02256: number of referencing columns must match referenced columns. But I don´t know where is the error.
create table bodega
( nombrebodega varchar2(50) primary key,
localidad varchar2(50),
nombredueño varchar2(50),
telefono varchar2(50),
museo char(1),
logo blob
create table vino
( tipovino varchar2(50),
categoriavino varchar2(50),
anovendimia number(4),
nombrebodega varchar2(50),
denominacionorigen varchar2(50),
precio_lproduc number(5),
litrosproduc number(10),
precio_lpublico number(5),
primary key (tipovino,categoriavino,anovendimia,nombrebodega),
foreign key (nombrebodega) references bodega on delete cascade
create table recipiente <-- Here gives me the error
( idrecipiente number(2) primary key,
capacidad number(10),
clase varchar2(50),
tipovino varchar2(50) not null,
categoriavino varchar2(50) not null,
anovendimia number(4) not null,
nombrebodega varchar2(50) not null,
foreign key (tipovino) references vino on delete cascade,
foreign key (categoriavino) references vino on delete cascade,
foreign key (anovendimia) references vino on delete cascade,
foreign key (nombrebodega) references vino on delete cascade
Anybody could help me?
Thanks. Regards

check:
SQL> create table bodega
  2  ( nombrebodega varchar2(50) primary key,
  3  localidad varchar2(50),
  4  nombredueo varchar2(50),
  5  telefono varchar2(50),
  6  museo char(1),
  7  logo blob
  8  );
Table created.
SQL> create table vino
  2  ( tipovino varchar2(50),
  3  categoriavino varchar2(50),
  4  anovendimia number(4),
  5  nombrebodega varchar2(50),
  6  denominacionorigen varchar2(50),
  7  precio_lproduc number(5),
  8  litrosproduc number(10),
  9  precio_lpublico number(5),
10  primary key (tipovino,categoriavino,anovendimia,nombrebodega),
11  foreign key (nombrebodega) references bodega on delete cascade
12  );
Table created.
SQL> create table recipiente
  2  ( idrecipiente number(2) primary key,
  3  capacidad number(10),
  4  clase varchar2(50),
  5  tipovino varchar2(50) not null,
  6  categoriavino varchar2(50) not null,
  7  anovendimia number(4) not null,
  8  nombrebodega varchar2(50) not null,
  9  foreign key (tipovino) references vino(tipovino) on delete cascade,
10  foreign key (categoriavino) references vino(categoriavino) on delete cascad
e,
11  foreign key (anovendimia) references vino(anovendimia) on delete cascade,
12  foreign key (nombrebodega) references vino(nombrebodega) on delete cascade
13  );
foreign key (tipovino) references vino(tipovino) on delete cascade,
ERROR at line 9:
ORA-02270: no matching unique or primary key for this column-list
SQL> alter table vino add constraint vino_uk unique (tipovino);
Table altered.
SQL> alter table vino add constraint categoriavino_uk unique (categoriavino);
Table altered.
SQL> alter table vino add constraint anovendimia_uk unique (anovendimia);
Table altered.
SQL> alter table vino add constraint nombrebodega_uk unique (nombrebodega);
Table altered.
SQL> create table recipiente
  2  ( idrecipiente number(2) primary key,
  3  capacidad number(10),
  4  clase varchar2(50),
  5  tipovino varchar2(50) not null,
  6  categoriavino varchar2(50) not null,
  7  anovendimia number(4) not null,
  8  nombrebodega varchar2(50) not null,
  9  foreign key (tipovino) references vino(tipovino) on delete cascade,
10  foreign key (categoriavino) references vino(categoriavino) on delete cascad
e,
11  foreign key (anovendimia) references vino(anovendimia) on delete cascade,
12  foreign key (nombrebodega) references vino(nombrebodega) on delete cascade
13  );
Table created.Amiel

Similar Messages

  • ORA-06562: type of out argument must match type of column or bind variab

    Hi everybody
    I have this -6562 oracle error when running a procedure where ther's the dbms_sql package
    here is the code :
    PROCEDURE PROC_CREATE_CAT_FILES (
    v_period in varchar2,
    v_cat_files_dir in varchar2
    as
    v_detail varchar2(2000);
    cursor_name INTEGER;
    rows_processed INTEGER;
    s_PATHNAME VARCHAR2(300) ;
    s_FILENAME VARCHAR(300) ;
    bFile_handle UTL_FILE.FILE_TYPE ;
    sselect varchar2(2000 ) ;
    begin
    cursor_name := dbms_sql.open_cursor;
    sselect :='select '
    || 'bd.contrno||'';''||'
    || 'bi_ref||'';''||'
    || 'substr(area,2)||'';''||'
    || 'subno||'';''||'
    || 'billtext_4||'';''||'
    || 'to_char(transdatetime,''DD.MM.YYYY'')||'';''||'
    || 'to_char(transdatetime,''HH:MI:SS'')||'';''||''\"''||'
    || 'substr(zode_lang.pr_text,1,14)||''\"''||'';''||''\"''||'
    || 'substr(ctg_lang.pr_text,1,14)||''\"''||'';''||'
    || 'substr(billtext_2,1,20)||'';''||'
    || 'to_char((substr(to_char(bi_quantity,''00000000''),4,2))*60*60+'
    || '(substr(to_char(bi_quantity,''00000000''),6,2))*60+'
    || '(substr(to_char(bi_quantity,''00000000''),8,2)),''FM999999'')||'';''||'
    || 'to_char(nvl(billamount,0),''FM0000.0000'')||'';''||'
    || 'to_char(nvl(vol_discount,0)+nvl(flat_discount,0),''FM0000.0000'')||'';''||'
    || 'to_char(ar_invdate,''DD.MM.YYYY'')||'';''||'
    || 'debamount_cur '
    || 'from '
    || v_bi_dump
    || ' bd,'
    || 'q_arinv_head arh,'
    || 'pr_text_rows ctg_lang,'
    || 'pr_text_rows zode_lang '
    || 'where '
    || 'bd.bi_ref = arh.ar_ref '
    || 'and ''CTG_''||chargetype||''_''||chargetype_group = ctg_lang.pr_field_id '
    || 'and bd.billtext_1 = zode_lang.pr_field_id '
    || 'and ctg_lang.pgm_name = ''Q30INV'' '
    || 'and ctg_lang.language = ''EN'' '
    || 'and zode_lang.pgm_name = ''Q30INV'' '
    || 'and zode_lang.language = ''EN'' '
    || 'and bd.contrno = '
    || v_contrno
    || ' and bd.bi_ref = '
    || v_invoice_no
    dbms_sql.parse(cursor_name,sselect,dbms_sql.v7);
    dbms_sql.define_column_char(cursor_name,1,v_detail,2000);
    rows_processed := dbms_sql.execute(cursor_name);
    loop
    if dbms_sql.fetch_rows(cursor_name) > 0 then
    dbms_sql.column_value(cursor_name,1,v_detail);
    the problem is the last line, the variable v_detail is varchar2, but seems to not match the result of the query where there's the big string.
    thanks for your help
    Alain

    I guess that the ORA itself is giving some clues why you failed to do what you intended.
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96525/e12700.htm#1006284
    So it seems like [exchanging partitions|http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/partiti.htm#sthref2762] between composit partitioned table and noncomposit partitioned table will not work.
    See 198120.1 , you are propably trying to do exchange between unsuported combination of partitioning types.

  • Reg: PLS-00418: array bind type must match PL/SQL table row type error

    I am trying to access a table of records through JDBC OracleCallableStatement. I am able to do it fine for all mappings except for the ones below
    TYPE CAT_CD_TYPE IS TABLE OF A.B %TYPE INDEX BY BINARY_INTEGER;
    TYPE ORG_CD_TYPE IS TABLE OF C.D %TYPE INDEX BY BINARY_INTEGER;
    Column B is CHAR(1) and Column D is CHAR(2). I am trying to register the out parameters of Oraclecallablestatement as
    cstmt.registerIndexTableOutParameter(2, 2000, OracleTypes.CHAR, 0);
    cstmt.registerIndexTableOutParameter(3, 2000, OracleTypes.CHAR, 0);
    All the other mappings work fine. These two fail with the error
    SQLException in invokeDBPackage() : ORA-06550: line 1, column 32:
    PLS-00418: array bind type must match PL/SQL table row type
    ORA-06550: line 1, column 35:
    PLS-00418: array bind type must match PL/SQL table row type
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    I tried other OracleTypes mappings too but no luck so far.
    Any advice on this would be greatly appreciated.

    Hi,
    I'm not sure it's reasonable to expect someone to sift through that much stuff.
    Which parameter is it having a problem with?
    Can you modify the following to reproduce the behavior?
    Thanks
    Greg
    create package mypack5 as
    TYPE v2array is table of emp.ename%type index by BINARY_INTEGER;
    PROCEDURE test_it(thearray IN v2array, numrecs out number);
    END;
    CREATE or replace PACKAGE BODY MYPACK5 AS
    PROCEDURE test_it(thearray IN v2array, numrecs out number)
    IS
    begin
    numrecs := thearray.count;
    END;
    END;
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    public class indexby
    public static void Main()
    OracleConnection con = new OracleConnection("data source=orcl;user id=scott;password=tiger;");
    con.Open();
    OracleCommand cmd = new OracleCommand("mypack5.test_it", con);
    cmd.CommandType = CommandType.StoredProcedure;
    OracleParameter Param1 = cmd.Parameters.Add("param1", OracleDbType.Varchar2);
    Param1.Direction = ParameterDirection.Input;
    Param1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    Param1.Size = 3;
    string[] vals = { "foo", "bar", "baz" };
    Param1.Value = vals;
    OracleParameter Param2 = cmd.Parameters.Add("param2", OracleDbType.Int32, DBNull.Value, ParameterDirection.Output);
    cmd.ExecuteNonQuery();
    Console.WriteLine("{0} records passed in", Param2.Value);
    con.Close();
    }

  • PLS-00418: array bind type must match PL/SQL table row type

    If a PL/SQL table is indexed by CHAR and is a parameter
    in a Stored Program, we are not able to call the stored
    program from the Java code.
    We get the following error code.
    java.sql.SQLException: ORA-06550: line 1, column 62:
    PLS-00418: array bind type must match PL/SQL table row type
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    But if we change the CHAR into VARCHAR2 then it works.
    We are using Oracle9i Enterprise Edition Release 9.2.0.5.0 -64bit Production ,
    JServer Release 9.2.0.5.0 - Production
    and JDK1.4.
    Thanks
    Push..

    Hi,
    I'm not sure it's reasonable to expect someone to sift through that much stuff.
    Which parameter is it having a problem with?
    Can you modify the following to reproduce the behavior?
    Thanks
    Greg
    create package mypack5 as
    TYPE v2array is table of emp.ename%type index by BINARY_INTEGER;
    PROCEDURE test_it(thearray IN v2array, numrecs out number);
    END;
    CREATE or replace PACKAGE BODY MYPACK5 AS
    PROCEDURE test_it(thearray IN v2array, numrecs out number)
    IS
    begin
    numrecs := thearray.count;
    END;
    END;
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    public class indexby
    public static void Main()
    OracleConnection con = new OracleConnection("data source=orcl;user id=scott;password=tiger;");
    con.Open();
    OracleCommand cmd = new OracleCommand("mypack5.test_it", con);
    cmd.CommandType = CommandType.StoredProcedure;
    OracleParameter Param1 = cmd.Parameters.Add("param1", OracleDbType.Varchar2);
    Param1.Direction = ParameterDirection.Input;
    Param1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    Param1.Size = 3;
    string[] vals = { "foo", "bar", "baz" };
    Param1.Value = vals;
    OracleParameter Param2 = cmd.Parameters.Add("param2", OracleDbType.Int32, DBNull.Value, ParameterDirection.Output);
    cmd.ExecuteNonQuery();
    Console.WriteLine("{0} records passed in", Param2.Value);
    con.Close();
    }

  • ORA-19007: Schema and element do not match

    I've registered a schema with my DB provided in the Oracle 9i XML DataBase Developer's Guide. I've created a table that has one field of type XMLType and is associated with the registered schema. Now I am trying to insert an xml string - also directly from the Oracle's developer's guide site and am getting 'ORA-19007: Schema and element do not match'.
    These are the steps I took:
    1.begin dbms_xmlschema.registerSchema( 'http://www.oracle.com/po.xsd', getClobDocument ('po.xsd','XSDDIR'), TRUE, TRUE, FALSE, FALSE); end;
    2.create table po_tab(id number,po sys.XMLType ) xmltype column po XMLSCHEMA "http://www.oracle.com/po.xsd"element "PurchaseOrder";
    3.INSERT INTO PurchaseOrder VALUES (xmltype.createxml('<PurchaseOrder xmlns="http://www.oracle.com/po.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.oracle.com/po.xsd"><PONum>1001</PONum><Company>Oracle Corp</Company><Item><Part>9i Doc Set</Part><Price>2550</Price></Item></PurchaseOrder>'));
    this is the po.xsd used:
    <schema targetNamespace="http://www.oracle.com/PO.xsd"
    xmlns:po="http://www.oracle.com/PO.xsd"
    xmlns="http://www.w3.org/2001/XMLSchema">
    <complexType name="PurchaseOrderType">
    <sequence>
    <element name="PONum" type="decimal"/>
    <element name="Company">
    <simpleType>
    <restriction base="string">
    <maxLength value="100"/>
    </restriction>
    </simpleType>
    </element>
    <element name="Item" maxOccurs="1000">
    <complexType>
    <sequence>
    <element name="Part">
    <simpleType>
    <restriction base="string">
    <maxLength value="1000"/>
    </restriction>
    </simpleType>
    </element>
    <element name="Price" type="float"/>
    </sequence>
    </complexType>
    </element>
    </sequence>
    </complexType>
    <element name="PurchaseOrder" type="po:PurchaseOrderType"/>
    </schema>
    thanks in advance

    Minor correction to the previous message, sorry: I've registered a schema with my DB provided in the
    Oracle 9i XML DataBase Developer's Guide. I've
    created a table that has one field of type XMLType
    and is associated with the registered schema. Now I
    am trying to insert an xml string - also directly
    from the Oracle's developer's guide site and am
    getting 'ORA-19007: Schema and element do not
    match'.
    These are the steps I took:
    1.begin dbms_xmlschema.registerSchema(
    'http://www.oracle.com/po.xsd', getClobDocument
    ('po.xsd','XSDDIR'), TRUE, TRUE, FALSE, FALSE); end;
    2.create table po_tab(id number,po sys.XMLType )
    xmltype column po XMLSCHEMA
    "http://www.oracle.com/po.xsd"element
    "PurchaseOrder";
    3.INSERT INTO PurchaseOrder VALUES
    (xmltype.createxml(1,'<PurchaseOrder
    xmlns="http://www.oracle.com/po.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.oracle.com/po.xsd"><PON
    m>1001</PONum><Company>Oracle
    Corp</Company><Item><Part>9i Doc
    Set</Part><Price>2550</Price></Item></PurchaseOrder>')
    this is the po.xsd used:
    <schema
    targetNamespace="http://www.oracle.com/PO.xsd"
    xmlns:po="http://www.oracle.com/PO.xsd"
    xmlns="http://www.w3.org/2001/XMLSchema">
    <complexType name="PurchaseOrderType">
    <sequence>
    <element name="PONum" type="decimal"/>
    <element name="Company">
    <simpleType>
    <restriction base="string">
    <maxLength value="100"/>
    </restriction>
    </simpleType>
    </element>
    <element name="Item" maxOccurs="1000">
    <complexType>
    <sequence>
    <element name="Part">
    <simpleType>
    <restriction base="string">
    <maxLength value="1000"/>
    </restriction>
    </simpleType>
    </element>
    <element name="Price" type="float"/>
    </sequence>
    </complexType>
    </element>
    </sequence>
    </complexType>
    <element name="PurchaseOrder"
    type="po:PurchaseOrderType"/>
    </schema>
    thanks in advance

  • Still ORA-19007: Schema and element do not match Error

    Hi all,
    I'm new to XML and dealing with lots of information but I'm stuck with this error ORA-19007: Schema and element do not match. Read some forums and tried some possibitlities but none has solved this issue. I think this is related with some malformed headers definitions but I'm not sure, so any help will be much appreciated.
    Here's what I've done so far:
    This is the xml file - emp.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!--Sample XML file generated by XMLSpy v2006 rel. 3 sp2 (http://www.altova.com)-->
    <employees xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/xdb/emp.xsd">
         <employee team="Team Test">
              <id>1</id>
              <name>Nelson Branco</name>
              <comment>No Comments</comment>
         </employee>
    </employees>
    ...and this is the XSD file: emp.xsd:
    <?xml version="1.0" encoding="ISO-8859-15"?>
    <!-- edited with XMLSpy v2006 rel. 3 sp2 (http://www.altova.com) by Nelson Branco (Oracle Corp) -->
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" elementFormDefault="qualified" xdb:storeVarrayAsTable="true">
         <xs:element name="comment" type="xs:string"/>
         <xs:element name="id" type="xs:string"/>
         <xs:element name="name" type="xs:string"/>
         <xs:complexType name="employeeType">
              <xs:sequence>
                   <xs:element ref="id"/>
                   <xs:element ref="name"/>
                   <xs:element ref="comment" minOccurs="0"/>
              </xs:sequence>
              <xs:attribute name="team" type="xs:string" use="optional"/>
         </xs:complexType>
         <xs:element name="employee" type="employeeType"/>
         <xs:element name="employees" xdb:defaultTable="EMPLOYEES">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="employee" maxOccurs="unbounded"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
    </xs:schema>
    1) Created folders
    declare
    ignore boolean;
    begin
    ignore := dbms_xdb.createFolder('/public/Emp');
    ignore := dbms_xdb.createFolder('/public/Emp/xsd');
    ignore := dbms_xdb.createFolder('/public/Emp/xml');
    commit ;
    end;
    2) Copied emp.xsd to /public/Emp/xsd in Win Explorer (via WebDAV connection)
    3) Registered the schema
    begin
    dbms_xmlschema.registerURI(schemaURL => 'http://xmlns.oracle.com/xdb/emp.xsd'
    ,schemaDocURI => '/public/Emp/xsd/emp.xsd'
    ,genTables => true
    commit ;
    end ;
    4) Copied the xml file to /public/Emp/xml. At this point I was expecting that the xml file was automatically uploaded to corresponding tables based on is content but it didn't happen. I didn't got any error also. When I issue:
    Select count(*) from employees
    ...or
    select y."name", y."team" from employees x, table(x.xmldata."employee") y
    ...got 0 rows returned
    5) So then created the table:
    create table emp_tab(
    id number,
    emp sys.XMLType
    xmltype column emp
    XMLSCHEMA "http://xmlns.oracle.com/xdb/emp.xsd"
    element "employee";
    6) And tried to insert one record based on the emp.xml:
    insert into emp_tab values (1,
    xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <!--Sample XML file generated by XMLSpy v2006 rel. 3 sp2 (http://www.altova.com)-->
    <employees xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/xdb/emp.xsd">
         <employee team="Team Test">
              <id>1</id>
              <name>Nelson Branco</name>
              <comment>No Comments</comment>
         </employee>
    </employees>'));
    ...and that when I get ORA-19007: Schema and element do not match.
    Any help on this will be appreciated. Thx.

    SQL> set echo on
    SQL> spool testcase.log
    SQL> --
    SQL> connect sys/ as sysdba
    Enter password:
    Connected.
    SQL> set define on
    SQL> --
    SQL> define USERNAME = OTNTEST
    SQL> --
    SQL> def PASSWORD = OTNTEST
    SQL> --
    SQL> def USER_TABLESPACE = USERS
    SQL> --
    SQL> def TEMP_TABLESPACE = TEMP
    SQL> --
    SQL> drop user &USERNAME cascade
      2  /
    old   1: drop user &USERNAME cascade
    new   1: drop user OTNTEST cascade
    User dropped.
    SQL> grant connect, resource to &USERNAME identified by &PASSWORD
      2  /
    old   1: grant connect, resource to &USERNAME identified by &PASSWORD
    new   1: grant connect, resource to OTNTEST identified by OTNTEST
    Grant succeeded.
    SQL> grant create any directory, drop any directory to &USERNAME
      2  /
    old   1: grant create any directory, drop any directory to &USERNAME
    new   1: grant create any directory, drop any directory to OTNTEST
    Grant succeeded.
    SQL> grant alter session, create view to &USERNAME
      2  /
    old   1: grant alter session, create view to &USERNAME
    new   1: grant alter session, create view to OTNTEST
    Grant succeeded.
    SQL> alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
      2  /
    old   1: alter user &USERNAME default tablespace &USER_TABLESPACE temporary tablespace &TEMP_TABLESPACE
    new   1: alter user OTNTEST default tablespace USERS temporary tablespace TEMP
    User altered.
    SQL> connect &USERNAME/&PASSWORD
    Connected.
    SQL> --
    SQL> alter session set events ='19027 trace name context forever, level 0x800'
      2  /
    Session altered.
    SQL> var schemaURL varchar2(256)
    SQL> var schemaPath varchar2(256)
    SQL> --
    SQL> begin
      2    :schemaURL := 'http://xmlns.oracle.com/xdb/emp.xsd';
      3    :schemaPath := '/public/testcase.xsd';
      4  end;
      5  /
    PL/SQL procedure successfully completed.
    SQL> create or replace directory XMLDIR as 'c:\xdb\otn'
      2  /
    Directory created.
    SQL> declare
      2    res boolean;
      3    xmlSchema xmlType := xmlType(
      4  '<?xml version="1.0" encoding="ISO-8859-15"?>
      5  <!-- edited with XMLSpy v2006 rel. 3 sp2 (http://www.altova.com) by Nelson Branco (Oracle Corp) -->
      6  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" elementFormDefault="qualified" xdb:store
    VarrayAsTable="true">
      7  <xs:element name="comment" type="xs:string"/>
      8  <xs:element name="id" type="xs:string"/>
      9  <xs:element name="name" type="xs:string"/>
    10  <xs:complexType name="employeeType">
    11  <xs:sequence>
    12  <xs:element ref="id"/>
    13  <xs:element ref="name"/>
    14  <xs:element ref="comment" minOccurs="0"/>
    15  </xs:sequence>
    16  <xs:attribute name="team" type="xs:string" use="optional"/>
    17  </xs:complexType>
    18  <xs:element name="employee" type="employeeType"/>
    19  <xs:element name="employees" xdb:defaultTable="EMPLOYEES">
    20  <xs:complexType>
    21  <xs:sequence>
    22  <xs:element ref="employee" maxOccurs="unbounded"/>
    23  </xs:sequence>
    24  </xs:complexType>
    25  </xs:element>
    26  </xs:schema>');
    27  begin
    28    if (dbms_xdb.existsResource(:schemaPath)) then
    29      dbms_xdb.deleteResource(:schemaPath);
    30    end if;
    31    res := dbms_xdb.createResource(:schemaPath,xmlSchema);
    32  end;
    33  /
    PL/SQL procedure successfully completed.
    SQL> begin
      2    dbms_xmlschema.registerSchema
      3    (
      4      :schemaURL,
      5      xdbURIType(:schemaPath).getClob(),
      6      TRUE,TRUE,FALSE,TRUE
      7    );
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    SQL> var xmltext varchar2(4000)
    SQL> --
    SQL> begin
      2    :xmltext :=
      3  '<?xml version="1.0" encoding="UTF-8"?>
      4  <!--Sample XML file generated by XMLSpy v2006 rel. 3 sp2 (http://www.altova.com)-->
      5  <employees xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation=
    "http://xmlns.oracle.com/xdb/emp.xsd">
      6  <employee team="Team Test">
      7  <id>1</id>
      8  <name>Nelson Branco</name>
      9  <comment>No Comments</comment>
    10  </employee>
    11  </employees>';
    12  end;
    13  /
    PL/SQL procedure successfully completed.
    SQL> insert into EMPLOYEES values ( xmltype(:xmltext));
    1 row created.
    SQL> /
    1 row created.
    SQL> create table emp_tab
      2  (
      3     id number,
      4     emp sys.XMLType
      5  )
      6  xmltype column emp
      7  XMLSCHEMA "http://xmlns.oracle.com/xdb/emp.xsd"
      8  element "employee"
      9  /
    Table created.
    SQL> insert into EMP_TAB values ( 1, xmltype(:xmltext))
      2  /
    insert into EMP_TAB values ( 1, xmltype(:xmltext))
    ERROR at line 1:
    ORA-19040: Element employees does not match expected employee.
    SQL> drop table emp_tab
      2  /
    Table dropped.
    SQL> create table emp_tab
      2  (
      3     id number,
      4     emp sys.XMLType
      5  )
      6  xmltype column emp
      7  XMLSCHEMA "http://xmlns.oracle.com/xdb/emp.xsd"
      8  element "employees"
      9  /
    Table created.
    SQL> insert into EMP_TAB values ( 1, xmltype(:xmltext))
      2  /
    1 row created.
    SQL>

  • How to update the null values to some number on the NUMBER type of column

    Hello All,
    I have one NUMBER type of column in DB table. It has some (null) values. I want to update with value 1. I tried to run the Update statement , It gives 0 rows updated.
    SELECT objectid,attr20 FROM table;
    object id attr20
    ====== ====
    fff70b67-8d54-4ad7-bc57-7b40a0d8b219     (null)
    cac5264a-b363-487b-bfe6-6b84d60064e9     (null)
    2fc2a626-51d8-401c-9495-18aacd4c35c8     (null)
    1b60bfa4-ff68-4488-adf6-2a83528c0e20     (null)
    1c662829-24c1-4b3c-9289-0128e170c043     5
    74f11331-545b-435f-bf4b-f57c7a6b4500     2
    c941c1ac-a18e-47ec-843c-dbe2a5b51001     0
    d7eba203-93c0-48ea-a109-9b06015ef387     0
    eba72fa3-21d8-4489-bb93-917ebbd67de2     0
    I ran following query but no success.
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 = NULL
    0 rows updated
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 = null
    0 rows updated
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 = ''
    0 rows updated
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 =' '
    Error starting at line 1 in command:
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 =' '
    Error report:
    SQL Error: ORA-01722: invalid number
    01722. 00000 - "invalid number"
    *Cause:   
    *Action:
    can some one help me out to update such values ????

    Hi,
    "=" will not work for NULL values. Please remeber two NULL values are NOT same. Try IS operator.
    UPDATE eb_tcsservfnadoc SET attr20 = 1 WHERE attr20 IS NULLRegards,
    Avinash

  • I cannot sort my songs using the "plays" column (also known as the number of plays column). The number of "plays" is not increasing as a song finishes.

    The "plays" column (also known as the number of plays column) is not saving not saving the number of plays (v 11.0).

    My number of 'Plays' was not increasing anymore at some point after updating to Version 11.  I had iTunes rev 11.0.1.12.  Today I updated to the latest rev 11.0.2.26, and now the numer of plays is increasing, so they must have fixed the bug!

  • ?Problem of :: "web-app" must match, help me?

    hi,Experts,
    Please do me a big favor, Does anybody know what is the exatly problem with my web.xml.
    My tomcat version is Apache Tomcat/4.1.18.
    here is the web.xml:
    <!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <display-name>newGUI</display-name>
    <description>The Database</description>
    <!--Filter Definitions-->
    <filter>
    <filter-name>theFilter</filter-name>
    <filter-class>org.gui.myFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>theFilter</filter-name>
    <url-pattern>/fetch.jsp</url-pattern>
    </filter-mapping>
    <filter>
    <filter-name>theFilter</filter-name>
    <filter-class>org.gui.myFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>theFilter</filter-name>
    <url-pattern>/query.jsp</url-pattern>
    </filter-mapping>
    <!-- Taglib Definitions-->
    <taglib>
    <taglib-uri>
    http://jsptags.com/tags/navigation/pager
    </taglib-uri>
    <taglib-location>
    /WEB-INF/jsp/pager-taglib.tld
    </taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/jstl-c</taglib-uri>
    <taglib-location>/WEB-INF/c.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/jstl-x</taglib-uri>
    <taglib-location>/WEB-INF/x.tld</taglib-location>
    </taglib>
    </web-app>
    The error message is :
    SEVERE: Parse Error at line 66 column 11: The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,
    servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,
    resource-env-ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,
    ejb-local-ref*)".

    It is telling you either you have elements out of order, or elements that do not belong.
    Try to do:
    <filter>
      <filter-name>theFilter</filter-name>
      <filter-class>org.gui.myFilter</filter-class>
    </filter>
    <filter>
      <filter-name>theFilter</filter-name>
      <filter-class>org.gui.myFilter</filter-class>
    </filter>
    <filter-mapping>
      <filter-name>theFilter</filter-name>
      <url-pattern>/fetch.jsp</url-pattern>
    </filter-mapping>
    <filter-mapping>
      <filter-name>theFilter</filter-name>
      <url-pattern>/query.jsp</url-pattern>
    </filter-mapping>Then double check spelling and such.

  • ORA-14402: updating partition key column would cause a partition change

    Hi,
    When I am trying to execute an update statement where i am tring to update date values emp_det from 11-oct-2010 to 12-nov-2010.
    Oracle throws an error :
    ORA-14402
    updating partition key column would cause a partition change
    I think that this is because emp_det is a partitioning key of a partitioned table.
    Oracle documentation says that
    "UPDATE will fail if you change a value in the column that would move the
    row to a different partition or subpartition, unless you enable row
    movement" .
    alter table t enable row movement;
    I did not understand what is meant by "enable row movement".
    I cannot drop the partitions and recreate it after updating the table and also i don't have proper priviliges for enale row movement syntax
    because of the lack of privileges. How to solve this is issues with out row movement and recreate partition.
    Can this be done by a developer or is there any other way to execute update in this case? its urgent.. pls help..
    thanks in advance..
    By
    Sivaraman
    Edited by: kn_sivaraman on Nov 1, 2010 2:32 AM

    kn_sivaraman wrote:
    I did not understand what is meant by "enable row movement". Each partition in partitioned table is physically separate segment. Assume you have a row that belongs to partition A stored in segment A and you change row's partitioning column to value that belongs to partition B - you have an issue since updated row can't be now stored in segment A anymore. By default such update is not allowed and you get an error. You can enable row movement and Oracle will move row to target partition:
    SQL> CREATE TABLE SALES_LIST(
      2                          SALESMAN_ID NUMBER(5,0),
      3                          SALESMAN_NAME VARCHAR2(30),
      4                          SALES_STATE VARCHAR2(20),
      5                          SALES_AMOUNT NUMBER(10,0),
      6                          SALES_DATE DATE
      7                         )
      8    PARTITION BY LIST(SALES_STATE)
      9    (
    10     PARTITION SALES_WEST     VALUES('California', 'Hawaii'),
    11     PARTITION SALES_EAST     VALUES('New York', 'Virginia', 'Florida'),
    12     PARTITION SALES_CENTRAL  VALUES('Texas', 'Illinois'),
    13     PARTITION SALES_OTHER    VALUES(DEFAULT)
    14    )
    15  /
    Table created.
    SQL> insert
      2    into sales_list
      3    values(
      4           1,
      5           'Sam',
      6           'Texas',
      7           1000,
      8           sysdate
      9          )
    10  /
    1 row created.
    SQL> update sales_list
      2    set  sales_state = 'New York'
      3    where sales_state = 'Texas'
      4  /
    update sales_list
    ERROR at line 1:
    ORA-14402: updating partition key column would cause a partition change
    SQL> alter table sales_list enable row movement
      2  /
    Table altered.
    SQL> update sales_list
      2    set  sales_state = 'New York'
      3    where sales_state = 'Texas'
      4  /
    1 row updated.
    SQL> SY.

  • Netbeans WVP/Tomcat, "faces-config", must match DOCTYPE root "null"

    With Netbeans 5.5 I suddenly (worked yesterday) get an error when
    starting Tomcat 5.5.17:
    org.apache.commons.digester.Digester - Parse Error at line 9 column 116: Document root element "faces-config", must match DOCTYPE root "null".
    org.xml.sax.SAXParseException: Document root element "faces-config", must match DOCTYPE root "null".
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
    The XML parser is complaining about a corrupt schema reference in faces-config.xml inside of web-ui.jar.
    First attempt at a solution: uninstalled WVP and re-installed, hoping for a jar with a valid xml file--no such luck, it's corrupt on install.
    Worst, it looks like JSF 1.2 stuff that's being called--my project is imported from JSC 2 and, presumably, should be using JSF 1.1.
    Second attempt at a solution: download latest JSF1.1 files and copy into netbeans module/ext and project's WEB-INF/lib.
    No luck, same error.

    The following piece of code should work:
         public static final String JAXP_SCHEMA_LANGUAGE="http://java.sun.com/xml/jaxp/properties/schemaLanguage";
         public static final String W3C_XML_SCHEMA="http://www.w3.org/2001/XMLSchema";
         public static final String SCHEMA_SOURCE_XSD = "C:/eclipse/workspace/XSDValidation/config/Providers-def.xsd";
         public static final String JAXP_SCHEMA_SOURCE ="http://java.sun.com/xml/jaxp/properties/schemaSource";
                        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   factory.setNamespaceAware(true);
                   factory.setValidating(true);     
                   try
                        factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
                        factory.setAttribute(JAXP_SCHEMA_SOURCE ,new File(SCHEMA_SOURCE_XSD));
    /*                    factory.setAttribute(VALID_SCHEM ,Boolean.valueOf(true));
                        factory.setAttribute(VALID_SCHEM_FULL ,Boolean.valueOf(true));
                   catch (IllegalArgumentException x)
                        // Happens if the parser does not support JAXP 1.2
                        System.err.println("Could not register the providers as the underlying parser" +
                                  "does not support JAXP 1.2");
                   // get the xml document builder
                   DocumentBuilder builder = factory.newDocumentBuilder();
                   Validator handler = new Validator();
                   builder.setErrorHandler(handler);                    
         private class Validator extends DefaultHandler
              public boolean validationError = false;
              public SAXParseException saxParseException = null;
              public void error(SAXParseException exception)
              throws SAXException{
              validationError = true;
              saxParseException = exception;     
              throw new SAXException("failed validation");
              public void fatalError(SAXParseException exception)
              throws SAXException {
              validationError = true;     
              saxParseException=exception;     
              public void warning(SAXParseException exception)
              throws SAXException { }     
    ########################################################

  • ORA-01779: cannot modify a column which maps to a non key-preserved table

    define cusname='GEORGE';
    INSERT INTO (select s.prd_id, s.cus_id, s.qty_sold, s.price from sales s, customers c where s.cus_id=c.cus_id)
    VALUES (102,(select cus_id from customers where upper(c_name) like '%GEORGE%'),14,(select price from product where prd_id = 102)*14)
    I am getting the following error when I am trying to run the above query.
    SQL Error: ORA-01779: cannot modify a column which maps to a non key-preserved table
    01779. 00000 -  "cannot modify a column which maps to a non key-preserved table"
    *Cause:    An attempt was made to insert or update columns of a join view which map to a non-key-preserved table.
    *Action:   Modify the underlying base tables directly.
    CUSTOMERS TABLE
    Name   
    Null   
    Type        
    CUS_ID 
    NOT NULL
    NUMBER      
    C_NAME         
    VARCHAR2(50)
    C_LIMIT         
    NUMBER      
    CITY           
    VARCHAR2(20)
    PRODUCT TABLE
    Name 
    Null   
    Type        
    PRD_ID
    NOT NULL
    NUMBER      
    PRICE         
    NUMBER      
    COST           
    NUMBER      
    SALES TABLE
    Name   
    Null   
    Type  
    PRD_ID 
    NOT NULL
    NUMBER
    CUS_ID 
    NOT NULL
    NUMBER
    QTY_SOLD         
    NUMBER
    PRICE             
    NUMBER

    Hi,
    As the error message sugggested, INSERT directly into the sales table.  You can get the values from a sub-query that joins whatever tables are needed, including sales itself.  MERGE might be simpler and more efficient than INSERT.
    I hope this answers your question.
    If not, post  a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    If you're asking about a DML statement, such as INSERT, the sample data will be the contents of the table(s) before the DML, and the results will be state of the changed table(s) when everything is finished.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Query block has incorrect number of result columns

    can anyone edit my query to eliminate below error ??
    SELECT FLROOPENHEAD.RONBR RepairOrder,FLROOPENHEAD.DATEOPENED DateOpened,NULL DateClosed,
    (SELECT FLREPAIRSTAT.DESCRIPTION  FROM FLREPAIRSTAT
    WHERE FLREPAIRSTAT.REPAIRSTATID = FLROOPENHEAD.REPAIRSTATID) RepairOrderStatus,
      (SELECT flrt.DESCRIPTION FROM FLREPAIRTYPE flrt
      WHERE flrt.REPAIRTYPEID = FLROOPENHEAD.REPAIRTYPEID) RepairType,  FLROOPENHEAD.REPAIRCENTER  RepairCenter,
    FLROOPENHEAD.FLVEHICLEID , FLROOPENHEAD.FLATTACHID,'O'
    FROM FLROOPENHEAD   WHERE FLROOPENHEAD.LDEVNBR =2334
    AND ((extract(DAY FROM SYSTIMESTAMP - TIMEOPENED)*24)+(extract(HOUR FROM SYSTIMESTAMP - TIMEOPENED)) <= 72)
    UNION
    SELECT FLROHISTHEAD.RONBR RepairOrder,FLROHISTHEAD.DATEOPENED DateOpened, null, FLROHISTHEAD.DATECLOSED DateClosed,
    (SELECT FLREPAIRSTAT.DESCRIPTION  FROM FLREPAIRSTAT
    WHERE FLREPAIRSTAT.REPAIRSTATID =FLROHISTHEAD.REPAIRSTATID) RepairOrderStatus,
    (SELECT flrt.DESCRIPTION FROM FLREPAIRTYPE flrt
    WHERE flrt.REPAIRTYPEID = FLROHISTHEAD.REPAIRTYPEID) RepairType, FLROHISTHEAD.REPAIRCENTER  RepairCenter
    from FLROHISTHEAD WHERE FLROHISTHEAD.LDEVNBR =2334
    AND ((extract(DAY FROM SYSTIMESTAMP - FLROHISTHEAD.TIMECLOSED)*24) + (extract(HOUR FROM SYSTIMESTAMP - FLROHISTHEAD.TIMECLOSED)) <= 72)
    ORDER BY DateOpened, RepairOrder
    i think error was at second Where condition.
    Error at Command Line:1 Column:0
    Error report:
    SQL Error: ORA-01789: query block has incorrect number of result columns
    01789. 00000 -  "query block has incorrect number of result columns"
    *Cause:   
    *Action:

    Hi,
    On comparison with 1st query and 2nd query,it can be easily noticed that ,1st query is returning 4 columns and 2nd query returns 5 columns in select clause.
    In order to work union ,both of your queries should select equal no of columns.
    Hence replace your query
    Original query(1st ) :
    SELECT FLROOPENHEAD.RONBR RepairOrder,FLROOPENHEAD.DATEOPENED DateOpened,NULL DateClosed,
    (SELECT FLREPAIRSTAT.DESCRIPTION  FROM FLREPAIRSTAT
    WHERE FLREPAIRSTAT.REPAIRSTATID = FLROOPENHEAD.REPAIRSTATID) RepairOrderStatus,
    ....Relplace with :
    SELECT FLROOPENHEAD.RONBR RepairOrder,FLROOPENHEAD.DATEOPENED DateOpened,NULL,/*Here you need missed the comma */
    DateClosed,
    (SELECT FLREPAIRSTAT.DESCRIPTION  FROM FLREPAIRSTAT
    WHERE FLREPAIRSTAT.REPAIRSTATID = FLROOPENHEAD.REPAIRSTATID) RepairOrderStatus,
    ....Hope this helps
    Regards,
    Achyut

  • ORA-14314: resulting List partition(s) must contain atleast 1 value

    Hi,
    Using: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production, Windows 7 Platform.
    I'm trying to understand Exchange Partition and Split (List) partitioning. Below is the code I'm trying to work on:
      CREATE TABLE big_table (
      id            NUMBER(10),
      created_date  DATE,
      lookup_id     NUMBER(10),
      data          VARCHAR2(50)
    declare
      l_lookup_id big_table.lookup_id%type;
      l_create_date date;
    begin
      for i in 1 .. 1000000 loop
        if mod(i,3) = 0 then
           l_create_date := to_date('19-mar-2011','dd-mon-yyyy');
           l_lookup_id := 2;
        elsif mod(i,2) = 0 then
           l_create_date := to_date('19-mar-2012','dd-mon-yyyy');
           l_lookup_id := 1;
        else
           l_create_date := to_date('19-mar-2013','dd-mon-yyyy');
           l_lookup_id := 3;
        end if;
        insert into big_table(id, created_date, lookup_id, data)
           values (i, l_create_date, l_lookup_id, 'This is some data for '||i);
      end loop;
      commit;
    end;
    alter table big_table add (
    constraint big_table_pk primary key (id));
    exec dbms_stats.gather_table_stats(user, 'BIG_TABLE', cascade => true);
    create table big_table2 (
    id number(10),
    created_date date,
    lookup_id number(10),
    data varchar2(50)
    partition by list (created_date)
    (partition p20991231 values (TO_DATE(' 2099-12-31 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')));
    alter table big_table2 add (
    constraint big_table_pk2 primary key(id));
    alter table big_table2 exchange partition p20991231
    with table big_table
    without validation
    update global indexes;
    drop table big_table;
    rename big_table2 to big_table;
    alter table big_table rename constraint big_table_pk2 to big_table_pk;
    alter index big_table_pk2 rename to big_table_pk;
    exec dbms_stats.gather_table_stats(USER, 'BIG_TABLE', cascade => TRUE);
    I'm trying to split the data by moving created_date=19-mar-2013 to new partition p20130319. I tried to run the below query but failed with error. Where am I doing it wrong?
    Thanks.
    alter table big_table
    split partition p20991231 values (to_date('19-mar-2013','dd-mon-yyyy'))
    into (partition p20130319
         ,partition p20991231
    Error report:
    SQL Error: ORA-14314: resulting List partition(s) must contain atleast 1 value
    14314. 00000 -  "resulting List partition(s) must contain atleast 1 value"
    *Cause:    After a SPLIT/DROP VALUE of a list partition, each resulting
               partition(as applicable) must contain at least 1 value
    *Action:   Ensure that each of the resulting partitions contains atleast
               1 value

    I stand corrected.
    Below are the steps I have gone through to understand:
    1. How to partition a table with data in it.
    2. Exchange partition.
    3. Split partition (List).
    4. Split data to more than 2 partitions.
    Please correct me if I'm missing anything.
    CREATE TABLE big_table
        id           NUMBER(10),
        created_date DATE,
        lookup_id    NUMBER(10),
        data         VARCHAR2(50)
    DECLARE
      l_lookup_id big_table.lookup_id%type;
      l_create_date DATE;
    BEGIN
      FOR i IN 1 .. 1000000
      LOOP
        IF mod(i,3)= 0 THEN
          l_create_date := to_date('19-mar-2011','dd-mon-yyyy');
          l_lookup_id   := 2;
        elsif mod(i,2)   = 0 THEN
          l_create_date := to_date('19-mar-2012','dd-mon-yyyy');
          l_lookup_id   := 1;
        ELSE
          l_create_date := to_date('19-mar-2013','dd-mon-yyyy');
          l_lookup_id   := 3;
        END IF;
        INSERT INTO big_table(id, created_date, lookup_id, data)
          VALUES(i, l_create_date, l_lookup_id, 'This is some data for '||i);
      END LOOP;
      COMMIT;
    END;
    ALTER TABLE big_table ADD
    (CONSTRAINT big_table_pk PRIMARY KEY (id));
    EXEC dbms_stats.gather_table_stats(USER, 'BIG_TABLE', CASCADE => true);
    CREATE TABLE big_table2
      ( id           NUMBER(10),
        created_date DATE,
        lookup_id    NUMBER(10),
        data         VARCHAR2(50)
      partition BY list(created_date)
      (partition p0319 VALUES
        (TO_DATE(' 2013-03-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') ,TO_DATE(' 2012-03-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') ,TO_DATE(' 2011-03-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    ALTER TABLE big_table2 ADD
    (CONSTRAINT big_table_pk2 PRIMARY KEY(id));
    ALTER TABLE big_table2 exchange partition p0319
    WITH TABLE big_table without validation
    UPDATE global indexes;
    DROP TABLE big_table;
    RENAME big_table2 TO big_table;
    ALTER TABLE big_table RENAME CONSTRAINT big_table_pk2 TO big_table_pk;
    ALTER INDEX big_table_pk2 RENAME TO big_table_pk;
    EXEC dbms_stats.gather_table_stats(USER, 'BIG_TABLE', CASCADE => TRUE);
    SELECT p.partition_name, p.num_rows
    FROM user_tab_partitions p
    WHERE p.table_name = 'BIG_TABLE';
    ALTER TABLE big_table split partition p0319 VALUES
    (TO_DATE(' 2013-03-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    INTO (partition p20130319, partition p0319);
    ALTER INDEX big_table_pk rebuild;
    EXEC dbms_stats.gather_table_stats(USER, 'BIG_TABLE', CASCADE => TRUE);
    SELECT p.partition_name, p.num_rows
    FROM user_tab_partitions p
    WHERE table_name = 'BIG_TABLE';
    SELECT DISTINCT created_date FROM big_table partition(p20130319);
    SELECT DISTINCT created_date FROM big_table partition(p0319);
    ALTER TABLE big_table split partition p0319 VALUES
    (TO_DATE(' 2012-03-19 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    INTO (partition p20120319, partition p20110319);
    ALTER INDEX big_table_pk rebuild;
    EXEC dbms_stats.gather_table_stats(USER, 'BIG_TABLE', CASCADE => TRUE);
    SELECT p.partition_name, p.num_rows
    FROM user_tab_partitions p
    WHERE table_name = 'BIG_TABLE';
    SELECT DISTINCT created_date FROM big_table partition(p20130319);
    SELECT DISTINCT created_date FROM big_table partition(p20120319);
    SELECT DISTINCT created_date FROM big_table partition(p20110319);

  • Use the last number in a column

    Don't use spread sheets much and wondered if anybody could help with this problem. I am monitoring my weight and each day put the new weight value in the next cell. ie
    201
    198
    197
    I have another cell in the sheet which contains my target weight from which I want to subtract the latest weight record this of course moves to the next cell down each day. Is there a formula to pick the last number in a column of data? ie in the above example takes 198 on day 2 but 197 on day 3.
    Thanks
    Jonathan

    Ok. The formula didn't have to be that fancy after all. We can use COUNT to count the number of entries, then use INDEX to return the corresponding entry.
    If the actual weights are in column B and goal weight in E2, then in D2 enter this formula:
    =E2-INDEX(B,COUNT(B),1)
    So, a couple caveats:
    1) Must start entering the weights in the top body cell (whether table has header or not, see below).
    2) Column B cannot have any extraneous numbers (this will throw the count of entries off).
    Free Image Hosting
    If you are actually using Numbers '09 and the table has headers, then for some reason the formula is slightly different depending on how many header cells are in column B. E.g. if one header, then enter =INDEX(B,COUNT(B)+1,1); if two headers, then enter =INDEX(B,COUNT(B)+2,1); Or, simply enter =INDEX(B,COUNT(B)+ROW(B)-1,1), which adjusts to whatever number of header cells.
    Robin
    Message was edited by: sharknca

Maybe you are looking for