Inconsistent datatypes. Why?

DB version is 10.2.0.3
WITH t AS (
  SELECT 'one' as str FROM dual UNION ALL
  SELECT 'two' FROM dual UNION ALL
  SELECT 'three' FROM dual
SELECT COLLECT(CAST(str AS varchar2(10))) FROM t;What's wrong here?

Well, it's tool specific problem. In fact in PL/SQL Developer (allround automation) it's giving some error like
"ORA-04043 object HR:SYSTPZ... does not exists" if I execute it in SQL window, command window is not giving any error.
Whereas, SQL *PLUS is giving the result perfectly.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Why do I get this error? ORA-00932: inconsistent datatypes

    This is my stored procedure I've created to select only the exact amount of records per page for a GridView (for ASP.NET):
    CREATE OR REPLACE
    PROCEDURE SELECT_COMMAND
    (pTable IN VARCHAR2
    , pFields IN VARCHAR2
    , pSortField IN VARCHAR2
    , pPageIndex IN NUMBER
    , pTotalRecs IN NUMBER
    , pResultSet OUT SYS_REFCURSOR
    ) AS
    BEGIN 
      EXECUTE IMMEDIATE
      'SELECT ' || pFields || ' FROM '
      || '(SELECT '|| pFields ||', ROW_NUMBER() OVER(ORDER BY '|| pSortField ||') ROW_NUM '
      || 'FROM '|| pTable ||') WHERE ROW_NUM BETWEEN '|| to_char(pPageIndex*pTotalRecs) ||' AND '
      || to_char((pPageIndex+1)*pTotalRecs)   
      INTO pResultSet;
      -- Plus 1 to our index because GridView is a zeroth index collection
    END SELECT_COMMAND;I then do a test case with the following paremeters:
    declare
    p_test sys_refcursor;
    begin
    select_command('v_sig_devices', '"JOB", "LINE"', '"DEVICE_ID"', 0, 10, p_test);
    end;But I get the following error:
    >
    Error report: ORA-00932: inconsistent datatypes: expected - got -
    ORA-06512: at "SIM.SELECT_COMMAND", line 10
    ORA-06512: at line 4
    00932. 00000 - "inconsistent datatypes: expected %s got %s"
    >
    At first Oracle gave me an error because the numbers were not a string. Then I convert them into a string (with to_char) and Oracle is still not happy! Any ideas as to why this is happening?
    Thanks for any help that you can provide.

    You don't select into ref cursors, you open them:
    SQL> create table t(c varchar2(1));
    Table created.
    SQL> insert into t values ('a');
    1 row created.
    SQL> insert into t values ('b');
    1 row created.
    SQL> insert into t values ('c');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> create or replace
      2  procedure p (p_ref out sys_refcursor) as
      3  begin
      4     open p_ref for 'select c from t';
      5  end;
      6  /
    Procedure created.
    SQL> var results refcursor
    SQL> exec p(:results);
    PL/SQL procedure successfully completed.
    SQL> print results
    C
    a
    b
    c

  • [8i] Case statement generates ORA-00932: inconsistent datatypes

    Note: I am working with an 8i database (yes, it is quite old), and in this situation, I have to deal with the datatypes (i.e. CHAR), I am given to work with.
    I am attempting to calculate the amount of time product waits between manufacturing steps. As I've discovered though, sometimes I get a negative value when subtracting the date the previous step completes from the date the current step starts. As it is generally impossible to start a later step before an earlier step (imagine trying to screw a cap onto a bottle that doesn't have threads cut yet--it just can't happen), what I've found is that sometimes two steps are started on the same day and finished on the same day (though not necessarily the day they started). This situation CAN happen when one person did both steps and logged on to both steps at the same time, rather than logging on to one, then the other. So, what I need to do in these situations is replace the negative number with a zero (I'll treat the later step as having no wait time).
    Here is some sample data:
    (Note: the real data set is the result of a query, and has around 200K rows and more columns, but this should be representative enough to find a solution that works on my actual application.)
    CREATE TABLE     steps
    (     item_id          CHAR(25)
    ,     ord_nbr          CHAR(10)
    ,     sub_nbr          CHAR(3)
    ,     step_nbr     CHAR(4)
    ,     start_date     DATE
    ,     finish_date     DATE
    INSERT INTO steps
    VALUES ('A','0000000001','001','0010',TO_DATE('01/01/2011','mm/dd/yyyy'),TO_DATE('01/02/2011','mm/dd/yyyy'));
    INSERT INTO steps
    VALUES ('A','0000000001','001','0020',TO_DATE('01/01/2011','mm/dd/yyyy'),TO_DATE('01/02/2011','mm/dd/yyyy'));
    INSERT INTO steps
    VALUES ('A','0000000001','001','0030',TO_DATE('01/05/2011','mm/dd/yyyy'),TO_DATE('01/06/2011','mm/dd/yyyy'));
    INSERT INTO steps
    VALUES ('A','0000000001','002','0010',TO_DATE('01/01/2011','mm/dd/yyyy'),TO_DATE('01/02/2011','mm/dd/yyyy'));
    INSERT INTO steps
    VALUES ('A','0000000001','002','0020',TO_DATE('01/04/2011','mm/dd/yyyy'),TO_DATE('01/04/2011','mm/dd/yyyy'));
    INSERT INTO steps
    VALUES ('A','0000000001','002','0030',TO_DATE('01/06/2011','mm/dd/yyyy'),TO_DATE('01/07/2011','mm/dd/yyyy'));
    INSERT INTO steps
    VALUES ('B','0000000002','001','0005',TO_DATE('01/10/2011','mm/dd/yyyy'),TO_DATE('01/12/2011','mm/dd/yyyy'));
    INSERT INTO steps
    VALUES ('B','0000000002','001','0025',TO_DATE('01/10/2011','mm/dd/yyyy'),TO_DATE('01/12/2011','mm/dd/yyyy'));Here is the query I use that returns negative values sometimes:
    SELECT     item_id
    ,     ord_nbr
    ,     sub_nbr
    ,     step_nbr
    ,     start_date - last_step_finished
    FROM     (
         SELECT     s.*
         ,     LAG (s.finish_date)     OVER     (
                                  PARTITION BY     s.item_id
                                  ,          s.ord_nbr
                                  ,          s.sub_nbr
                                  ORDER BY     s.step_nbr
                                  )     AS last_step_finished
         FROM     steps s
    Returns:
    ITEM_ID                   ORD_NBR    SUB STEP START_DATE-LAST_STEP_FINISHED
    A                         0000000001 001 0010
    A                         0000000001 001 0020                        -1.000
    A                         0000000001 001 0030                         3.000
    A                         0000000001 002 0010
    A                         0000000001 002 0020                         2.000
    A                         0000000001 002 0030                         2.000
    B                         0000000002 001 0005
    B                         0000000002 001 0025                        -2.000These are the results I want to see:
    ITEM_ID                   ORD_NBR    SUB STEP START_DATE-LAST_STEP_FINISHED
    A                         0000000001 001 0010
    A                         0000000001 001 0020                         0.000
    A                         0000000001 001 0030                         3.000
    A                         0000000001 002 0010
    A                         0000000001 002 0020                         2.000
    A                         0000000001 002 0030                         2.000
    B                         0000000002 001 0005
    B                         0000000002 001 0025                         0.000And this is what I tried to do to get those results (comment notes what line generated the error):
    SELECT     item_id
    ,     ord_nbr
    ,     sub_nbr
    ,     step_nbr
    ,     CASE
              WHEN     start_dt - last_step_finished     < 0
              THEN     0
              ELSE     start_dt - last_step_finished  -- THIS LINE GENERATES THE ORA-00932 ERROR
         END                         AS days_in_queue
    FROM     (
         SELECT     s.*
         ,     LAG (s.finish_date)     OVER     ( PARTITION BY  s.item_id
                                    ,          s.ord_nbr
                                    ,          s.sub_nbr
                                    ORDER BY     s.step_nbr
                                  )     AS last_step_finished
         FROM     steps s
         );I know I've had inconsistent datatype errors before with case statements in this particular 8i database, but I can't seem to figure out why I'm getting one this time. I think it has something to do with the NULL values that can occur for last_step_finished. Also, if I change the case statement to:
    ,     CASE
              WHEN     start_dt - last_step_finished     < 0
              THEN     NULL
              ELSE     start_dt - last_step_finished  -- THIS LINE GENERATES THE ORA-00932 ERROR
         END     the query runs just fine. But, I don't want NULL, I want 0. In the next level of this query, I will be taking averages by item_id/step_nbr, and I want the 0's to be included in the average. (NULL values, as far as I can tell, would be excluded. AVG(NULL, 1, 2) =AVG (1,2) = 1.5 NOT AVG(0,1,2) = 1).
    Thanks in advance!

    Thanks, TO_NUMBER did the trick. Since you didn't state in your post where to use TO_NUMBER, here is my final solution, in case anyone in the future looks through this thread to find an answer to their question:
    SELECT     item_id
    ,     ord_nbr
    ,     sub_nbr
    ,     step_nbr
    ,     CASE
              WHEN     start_dt - last_step_finished     < 0
              THEN     0
              ELSE     TO_NUMBER(start_dt - last_step_finished)
         END                         AS days_in_queue
    FROM     (
         SELECT     s.*
         ,     LAG (s.finish_date)     OVER     ( PARTITION BY  s.item_id
                                    ,          s.ord_nbr
                                    ,          s.sub_nbr
                                    ORDER BY     s.step_nbr
                                  )     AS last_step_finished
         FROM     steps s
         );Edited by: user11033437 on Jun 27, 2011 11:17 AM
    I see you edited your post to add TO_NUMBER to it.

  • [Oracle 8i] ORA-00932 Inconsistent Datatypes

    Hopefully this is a quick question to answer. In running a query I get the 'inconsistent datatypes' error, and I've narrowed the error down to one part of my query:
    SELECT     CASE     
              WHEN     sopn.plan_start_dt < SYSDATE     THEN SYSDATE
              ELSE     sopn.plan_start_dt
         END                                             
    FROM     SOPN sopn(replacing SYSDATE with an actual hard-coded date doesn't work either)
    The field sopn.plan_start_dt is definitely a date datatype. If I do a simple query for just that field with a date parameter in my where statement, it works just fine, for example:
    SELECT     sopn.plan_start_dt
    FROM     SOPN sopn
    WHERE     sopn.plan_start_dt<SYSDATEdoes not give me any errors.
    I'm guessing there's something wrong with my case statement, or maybe case statements with date parameters are something Oracle 8i doesn't get along with...
    If anyone can tell me why my case statement is causing an 'inconsistent datatype' error, I'd appreciate it. Thanks!

    Well, this tells me column sopn.plan_start_dt datatype is not DATE. CASE requires all branches to return same type expressions. Most likely sopn.plan_start_dt is VARCHAR2 and it is very bad coding to rely on implicit comversions. Use TO_DATE with proper format. For example:
    SELECT     CASE     
              WHEN     TO_DATE(sopn.plan_start_dt,'DD-MON-YY') < SYSDATE     THEN SYSDATE
              ELSE     TO_DATE(sopn.plan_start_dt,'DD-MON-YY')
         END                                             
    FROM     SOPN sopnSY.

  • Error 'Inconsistent datatypes' with Java classes

    Hi,
    I have some Java classes loaded in Oracle 8.1.6, mapped as Object Types, so when I create one object from PL/SQL, JVM ought to create the matching Java object, communicating via the SQLData interface.
    Unfortunately, after the code:
    pippo:=OraMailer('mail.server.com','mymail');
    that creates the PL/SQL object, any code that use member procedures or function wrapping instance methods of the Java class fails with the error 932: Inconsistent datatypes.
    I looked for a mistake in my PL/SQL and Java code, but no error was found.
    It is very important: help me!!!
    Thx

    So here is what you are doing:
    ArrayList results = //get employees from database
    ListIterator langIt = results.listIterator();
    while (langIt.hasNext()) {
      Employee emp = langIt.next();
      String name2 = emp.getName();
      String SSNo = emp.getSSNum();
      results.add(name2);
      results.add(SSNo);
    }So you get a list or Employee objects, then you get an iterator over the list. For each Employee in the list you add the name and SSNo as Strings back to the same list. From the API for ConcurrentModificationException the exception can be thrown when you modify a collection while iterating over the collection - which is precisely what you are doing.
    The ListIterator interface allows you to modify the list through its own methods. Try using:
      langIt.add(name2);
      langIt.add(SSNo);instead.
    Why are you taking the name and SSNo out of the Employee object and placing them back in the same List anyway? That makes no sense to me.

  • Inconsistent datatypes: expected - got CHAR, Detail view bind variables

    Hi.
    Here is my problem:
    I have master detail views connected with a view link. Both of views have bind variables that hold some session info:
    It's a menu on database and I am trying to hide some values based on user permissions.
    When running application module, everything works fine. The problem occurs when I try to show menu as a tree table, or any other table, on a page.
    The root view executes fine, but then I get an
    "java.sql.SQLSyntaxErrorException: ORA-00932: inconsistent datatypes: expected - got CHAR"
    error in executeQueryForCollection method of detail view. (this method is overridden)
    Bind Variables are:
    - :menuRoot -> which holds value of Root node. (In detail view it's just a dummy variable. It is explaned later on why i used it.)
    - :listOfUserPermmission -> array of user permissions.
    My query looks like this:
    1.Master View:
    SELECT MetVMenu.CHILD_ID,
           MetVMenu.CHILD_IME_MODULA,
           MetVMenu.PARENT_ID,
           MetVMenu.PARENT_IME_MODULA,
           MetVMenu.ZST,
           MetVMenu.NIVO,
           MetVMenu.CHILD_NAZIV_V_MENIJU,
           MetVMenu.CHILD_TIP_MODULA,
           MetVMenu.CHILD_OPIS_MODULA
    FROM MET_V_MENU MetVMenu
    WHERE MetVMenu.PARENT_IME_MODULA like :menuRoot
    and MetVMenu.CHILD_IME_MODULA in (SELECT * FROM TABLE(CAST(:listOfUserPermission AS STRARRAY)))CHILD_IME_MODULA and PARENT_IME_MODULA are also names of permissions.
    2.View Link that connects master.CHILD_ID and detail PARENT_ID
    3.Detail view, that then links to itself... to get the tree menu.
    SELECT MetVMenu.CHILD_ID,
           MetVMenu.CHILD_IME_MODULA,
           MetVMenu.PARENT_ID,
           MetVMenu.PARENT_IME_MODULA,
           MetVMenu.ZST,
           MetVMenu.NIVO,
           MetVMenu.CHILD_NAZIV_V_MENIJU,
           MetVMenu.CHILD_TIP_MODULA,
           MetVMenu.CHILD_OPIS_MODULA
    FROM MET_V_MENU MetVMenu
    WHERE :menuRoot like 'a'
    and
    MetVMenu.CHILD_IME_MODULA in (SELECT * FROM TABLE(CAST(:listOfUserPermission AS STRARRAY)))4. ViewLink that connects CHILD_ID and PARENT_ID of this "detail" view.
    Both views executeQuery methods are overridden to set Bind variables before execution.
    I get an arrayList of strings (permissions) from session and then convert it to Array.
         ArrayList permmissionsArray = (ArrayList)MyUserSession.getSessionValue("permissions");
         Array permissions = new Array(permissionsArray.toArray());
            HashMap context = new HashMap();
            context.put(DomainContext.ELEMENT_SQL_NAME, "STRARRAY");
            context.put(DomainContext.ELEMENT_TYPE, String.class);
            if(permissions != null){
                permissions.setContext(null, null, context);
                setlistOfUserPermission(permissions);
         //Here I set menuRoot variable.
         I also noticed that there are problems with how I define bind variables (the order matters).
    So when i didn't use menuRoot variable in detail view I got the
    “inconsistent datatypes: expected - got CHAR"
    error in application module.

    I went through those links, and I am sure the user has enough rights on STRARRAY object.
    I noticed that when running application module things work fine if I firstly execute RootView - Master view.
    and then double click on VL which shows detail view in table.
    The error occurs if I click on ViewLink first. I am not sure if I am even "allowed" to do that.
    I set the parameters with "setNamedWhereClauseParam" and print them out before i call super.executeQueryForCollection() and this the output i get:
    ExecuteQueryForCollectionRoot
    Permission: [AdfIn2Ogrodje.ROOT, AdfIn2Ogrodje.ADMINISTRACIJA, HOME]
    [87] MetVMenuRoot1 ViewRowSetImpl.setNamedWhereClauseParam(listOfUserPermission, oracle.jbo.domain.Array@e1af74d9)
    [88] MetVMenuRoot1 ViewRowSetImpl.setNamedWhereClauseParam(menuRoot, AdfIn2Ogrodje.ROOT)
    //Print before execution.
    EXECUTE_MENUROOT menuRoot: AdfIn2Ogrodje.ROOT
    EXECUTE_MENUROOT permission: oracle.jbo.domain.Array@e1af74d9
        Permission: AdfIn2Ogrodje.ROOT
        Permission: AdfIn2Ogrodje.ADMINISTRACIJA
        Permission: HOME
    [89] MetVMenuRoot1>#q computed SQLStmtBufLen: 537, actual=447, storing=477
    [90] SELECT MetVMenu.CHILD_ID,         MetVMenu.CHILD_IME_MODULA,         MetVMenu.PARENT_ID,         MetVMenu.PARENT_IME_MODULA,         MetVMenu.ZST,         MetVMenu.NIVO,         MetVMenu.CHILD_NAZIV_V_MENIJU,         MetVMenu.CHILD_TIP_MODULA,         MetVMenu.CHILD_OPIS_MODULA FROM MET_V_MENU MetVMenu WHERE MetVMenu.PARENT_IME_MODULA like :menuRoot and MetVMenu.CHILD_IME_MODULA in (SELECT * FROM TABLE(CAST(:listOfUserPermission AS STRARRAY)))
    [91] ViewObject: [adfin2.menu.model.views.MetVMenuRoot]MetMenuAppModule.MetVMenuRoot1 Created new QUERY statement
    [92] Bind params for ViewObject: [adfin2.menu.model.views.MetVMenuRoot]MetMenuAppModule.MetVMenuRoot1
    [93] Binding null of type 12 for "menuRoot"
    [94] Binding null of type 12 for "listOfUserPermission"
    protected void executeQueryForCollection(Object object, Object[] object2, int i) {
            System.out.println("ExecuteQueryForCollectionRoot");
            setParametersForSessionTest(); // method where i set the parameters.
            printExecute(); // printing
            super.executeQueryForCollection(object, object2, i);
        }After a few clicks on OK button the query executes normally.
    What I am guessing is, that executeQueryForCollection just takes whatever is in object2 and that's null at the beginning.
    I tried to use this method, which sets the bind variables in object2. And it gives me "Invalid column type" error.
    http://packtlib.packtpub.com/library/9781849684767/ch04lvl1sec07

  • ORA-00932: inconsistent datatypes: expected DATE got NUMBER at OCI call OCIStmtExecute in OBIEE 11g

    Hi Friends,
    I am getting this error : ORA-00932: inconsistent datatypes: expected DATE got NUMBER at OCI call OCIStmtExecute when I am trying to put the filter condition on the date column.
    "Dim-Time"."Day" <= cast(MAX("Dim-Time"."Day") as date)  and "Dim-Time"."Day" >= TIMESTAMPADD(SQL_TSI_MONTH, -1,cast(MAX("Dim-Time"."Day") as date).
    I have casted the max date but though I am getting the above error. I am thinking max(date) is creating the problem.
    Please suggest your on opinion this.
    Thanks.

    Not sure why you need cast in your statement if at all it is required then you need to do as below
    cast("Dim-Time"."Day"  as date)<= cast(MAX("Dim-Time"."Day") as date)  and cast("Dim-Time"."Day"  as date) >= TIMESTAMPADD(SQL_TSI_MONTH, -1,cast(MAX("Dim-Time"."Day") as date).
    ~ http://cool-bi.com

  • Sync error....ORA-00932 Inconsistent datatypes

    Hey all,
    I am getting the following error when syncing:
    MS-9109 n@86e554 (this seems to be random string) || ORA-00932: inconsistent datatypes
    Now, I've narrowed it down to the field that causes this error to occur. It is important to note that if I don't touch the field (just keep the initial value from the initial sync to 8.1.7, things sync fine.
    The error only occurs if I change the field value in 9iLite (which I am doing through me eVB app).
    In 9iLite it is defined as:
    Data_Type = Number, Len = 5, N = Y, Prec = 5, Scale = 4
    In 8.1.7 it is defined as:
    Data_type = Number (5,4) Null = N
    I'm not sure why in Lite null is Y and in 8.1.7 null is N. I just let Oracle create the lite tables based on my snapshot. At any rate, the field is not null.
    Does anyone have any thoughts? Does anyone know what the first part (MS-9109) of the error message is about? I can't find anything on it in Google.
    Thx.
    Darren

    Well,
    If fixed my problem. I just re-wrote the sql I had defined in the snapshot for the table in question. Still not sure why it didn't initally work as I didn't change the logic at all.
    Darren.

  • PL/SQL: ORA-00932: inconsistent datatypes: expected UDT got NUMBER

    Hi all,
    Wondering if you could assist? I'm exploring User Types and having a small problem. I'm getting the above error for a user type I have created which I'm calling in a function. Here's what my code looks like which I'm running the 'scott' schema for testing purposes
    SQL> CREATE OR REPLACE TYPE NBR_COLL AS TABLE OF NUMBER;
    2 /
    Type created.
    SQL> create or replace FUNCTION first_rec_only
    2 (
    3 NUM_ID IN NUMBER
    4 ) RETURN NUMBER IS
    5 v_num NBR_COLL;
    6 BEGIN
    7 select deptno into v_num from dept;
    8 RETURN v_num(v_num.FIRST);
    9 END first_rec_only;
    10 /
    Warning: Function created with compilation errors.
    SQL> show errors
    Errors for FUNCTION FIRST_REC_ONLY:
    LINE/COL ERROR
    7/4 PL/SQL: SQL Statement ignored
    7/11 PL/SQL: ORA-00932: inconsistent datatypes: expected UDT got
    NUMBER
    SQL>
    Any clues to what I'm doing wrong? Cheers.

    The deptno column is a number, you cannot directly select a number into your type, you need to use your type's constructor.
    Something like:
    CREATE OR REPLACE FUNCTION first_rec_only (NUM_ID IN NUMBER) RETURN NUMBER IS
       v_num NBR_COLL;
    BEGIN
       SELECT nbr_coll(deptno) INTO v_num from dept;
       RETURN v_num(v_num.FIRST);
    END first_rec_only;Note that although this will compile, it will throw ORA-01422: exact fetch returns more than requested number of rows when you run it. you need to either use the input parameter as a predicate on your query against dept, use rownum = 1 in the query or use bulk BULK COLLECT INTO, depending on what exactly you want to accomplish.
    John

  • PL/SQL: ORA-00932: inconsistent datatypes: expected REF got CHAR

    SQL> desc o.rel_module;
    Name Null? Type
    ID NOT NULL NUMBER(6)
    TYPE NOT NULL CHAR(7)
    BUILDDATE NOT NULL NUMBER(4)
    DESIGNROOT NOT NULL NUMBER(6)
    SQL> desc rel_module
    Name Null? Type
    ID NOT NULL NUMBER(6)
    DESIGNROOT NOT NULL NUMBER(6)
    REL_COMPOSITEPARTS REL_COMPOSITEPART_TAB
    SQL> desc REL_COMPOSITEPART_TAB
    REL_COMPOSITEPART_TAB TABLE OF REL_COMPOSITEPART
    SQL> desc REL_COMPOSITEPART
    Name Null? Type
    TYPE CHAR(7)
    BUILDDATE NUMBER(4)
    SQL> create or replace procedure rel_module_p
    2 as
    3 cursor c is select ID, TYPE, BUILDDATE, DESIGNROOT from o.rel_module;
    4 begin
    5 FOR i in c
    6 LOOP
    7 INSERT into rel_module(id,REL_CompositeParts,DESIGNROOT)
    Values (i.ID,REL_CompositePart_TAB(i.type,i.builddate), i.designroot);
    8 END LOOP;
    9 END;
    10 /
    Warning: Procedure created with compilation errors.
    SQL> show err
    Errors for PROCEDURE REL_MODULE_P:
    LINE/COL ERROR
    7/1 PL/SQL: SQL Statement ignored
    7/93 PL/SQL: ORA-00932: inconsistent datatypes: expected REF got CHAR
    Can you please tell me where needs correction.

    801556 wrote:
    Can you please tell me where needs correction.Just a fix would be:
    create or replace procedure rel_module_p
    as
    cursor c is select ID, TYPE, BUILDDATE, DESIGNROOT from o.rel_module;
    begin
    FOR i in c
    LOOP
    INSERT into rel_module(id,REL_CompositeParts,DESIGNROOT)
    values (i.ID,REL_CompositePart_TAB(REL_COMPOSITEPART(i.type,i.builddate)), i.designroot);
    END LOOP;
    END;
    /However, I'd assume what you want is:
    create or replace procedure rel_module_p
    as
    cursor c is select ID,CAST(COLLECT(REL_COMPOSITEPART(TYPE,BUILDDATE)) AS REL_CompositePart_TAB) REL_COMPOSITEPARTS, DESIGNROOT
    from rel_module
    group by id,DESIGNROOT;
    begin
    FOR i in c
    LOOP
    INSERT into rel_moduleX(id,REL_CompositeParts,DESIGNROOT)
    values (i.ID,i.REL_COMPOSITEPARTS, i.designroot);
    END LOOP;
    END;
    /SY.

  • Inconsistent datatypes error when inserting into a object

    I am trying to insert some test data into the table emp.I have managed to succesfully create the objects and types but when I try to insert into the emp table I get a inconsistent datatypes error however I have checked the datatypes and they all seem fine. Can anyone help me.
    thanks
    CREATE OR REPLACE TYPE Address_T AS object
    (ADDR1                VC2_40,
    ADDR2               VC2_40,
    CITY_TX          VC2_40,
    COUNTY_CD          VC2_40,
    POST_CD          VC2_40);
    CREATE OR REPLACE TYPE PERSON_T AS OBJECT (
    LNAME_TX           NAME_T,
    FNAME_TX           NAME_T,
    BIRTH_DATE          DATE,
    TELEPHONE          VC2_20,
    EMAIL               VC2_40);
    CREATE OR REPLACE TYPE EMP_T AS OBJECT (
    EMP_ID     NUMBER (10),
    PERSON     PERSON_T,
    ADDRESS ADDRESS_T,
    HIRE_DATE DATE)
    CREATE TABLE EMP OF EMP_T
    (EMP_ID NOT NULL PRIMARY KEY);
    INSERT INTO EMP VALUES (1,           
    PERSON_T('PETCH',
    'GAVIN',
    '23-JAN-80',
    '(01964)550700',
    '[email protected]'),
    ADDRESS_T('67 CANADA',
    'WALKINGTON',
    'BEVERLEY',
    'EAST YORKSHIRE',
    'HU17 7RL'),
    '11-FEB-02'
    ERROR at line 1:
    ORA-00932: inconsistent datatypes

    Gavin,
    What is your VC2_40 and NAME_T type definition? Your insert used these as varchar2, which is a built-in type not a user-defined type. If you explicitly define these to be varchar2's, the insert statement works fine.
    Regards,
    Geoff
    I am trying to insert some test data into the table emp.I have managed to succesfully create the objects and types but when I try to insert into the emp table I get a inconsistent datatypes error however I have checked the datatypes and they all seem fine. Can anyone help me.
    thanks
    CREATE OR REPLACE TYPE Address_T AS object
    (ADDR1                VC2_40,
    ADDR2               VC2_40,
    CITY_TX          VC2_40,
    COUNTY_CD          VC2_40,
    POST_CD          VC2_40);
    CREATE OR REPLACE TYPE PERSON_T AS OBJECT (
    LNAME_TX           NAME_T,
    FNAME_TX           NAME_T,
    BIRTH_DATE          DATE,
    TELEPHONE          VC2_20,
    EMAIL               VC2_40);
    CREATE OR REPLACE TYPE EMP_T AS OBJECT (
    EMP_ID     NUMBER (10),
    PERSON     PERSON_T,
    ADDRESS ADDRESS_T,
    HIRE_DATE DATE)
    CREATE TABLE EMP OF EMP_T
    (EMP_ID NOT NULL PRIMARY KEY);
    INSERT INTO EMP VALUES (1,           
    PERSON_T('PETCH',
    'GAVIN',
    '23-JAN-80',
    '(01964)550700',
    '[email protected]'),
    ADDRESS_T('67 CANADA',
    'WALKINGTON',
    'BEVERLEY',
    'EAST YORKSHIRE',
    'HU17 7RL'),
    '11-FEB-02'
    ERROR at line 1:
    ORA-00932: inconsistent datatypes

  • Function issue:  inconsistent datatypes?

    Hi all.
    I'm having an issue with a function that converts coordinates to a spatial data type.
    My database version is:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE     11.2.0.2.0     Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production
    Here's my package that I'm using
    create or replace package make_geometry
    as
                function get_geometry_from_coords (p_coords in clob  )
              return sdo_geometry;
    end;
    create or replace package body make_geometry
    as
              function get_geometry_from_coords (p_coords in clob)
              return sdo_geometry
              is
                 v_geometry sdo_geometry;
              begin
                 --with t as (select p_coords coords from dual)
              select MDSYS.SDO_GEOMETRY(2003,8307,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1)
                                  ,cast(multiset(
                                      select ordset
                                     from (
                                            select regexp_substr( regexp_replace(
                                                                                replace(p_coords,chr(10))
                                                                                 ,' {1,}',',')
                                                                  ,'[^,]+',1,level)  ordset
                                                  ,rownum rn
                                              from dual
                                                               connect by level <= length(regexp_replace(regexp_replace(
                                                                                                   replace(p_coords,chr(10))
                                                                                                   ,' {1,}',','),'[^,]+')) + 1
                                            where mod(rn,3) <> 0
                        ) as sdo_ordinate_array))
                  into v_geometry
                  from dual;
                  return v_geometry;
              end;
    end;
    /basically, it takes a list of coordinates, in the following format:
    with t as (select '130.88214073599997,-12.377589935499998,0 130.88189276799997,-12.378437734999997,0 130.88164895999998,-12.379271400499997,0 ' coords from dual)replaces the spaces with commas and splits the resultant string by comma, then removes the third coordinate in each set (sets delimited by spaces in above example) and converts the result to sdo_geometry type.
    This logic is not where my problem is occurring
    If I run the query found in the package separately, it works fine:
    SQL> with t as (select '130.88214073599997,-12.377589935499998,0 130.88189276799997,-12.378437734999997,0 130.88164895999998,
    -12.379271400499997,0 ' coords from dual)
      2            select MDSYS.SDO_GEOMETRY(2003,8307,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1)
      3                                ,cast(multiset(
      4                                    select ordset
      5                                   from (
      6                                          select regexp_substr( regexp_replace(
      7                                                                              replace(coords,chr(10))
      8                                                                               ,' {1,}',',')
      9                                                                ,'[^,]+',1,level)  ordset
    10                                                ,rownum rn
    11                                            from t
    12                                                             connect by level <= length(regexp_replace(regexp_replace(
    13                                                                                                 replace(coords,chr(10))
    14                                                                                                 ,' {1,}',','),'[^,]+')) +
    1
    15                                                               )
    16                                          where mod(rn,3) <> 0
    17                      ) as sdo_ordinate_array))
    18                from dual;
    MDSYS.SDO_GEOMETRY(2003,8307,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),CAST(MULTISET(SELECTORDSETFROM(SELECTREGEXP_SUBSTR(REGE
    XP_REPL
    SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(130.882141, -12.37759, 130.881893, -12.378
    438, 13
    0.881649, -12.379271, NULL))but if I call the function:
    SQL> with t as (select '130.88214073599997,-12.377589935499998,0 130.88189276799997,-12.378
    -12.379271400499997,0 ' coords from dual)
      2  select make_geometry.get_geometry_from_coords(coords)
      3    from t;
    select make_geometry.get_geometry_from_coords(coords)
    ERROR at line 2:
    ORA-00932: inconsistent datatypes: expected NUMBER got CLOB
    ORA-06512: at "HR.MAKE_GEOMETRY", line 13If I change the package to expect varchar2 the above example coordinate list works fine, but obviously that doesn't work when the coordinate list exceeds 4000 characters.
    any thoughts?

    not sure that is the problem:
    SQL> create table foo (mr_clob clob);
    Table created.
    SQL>
    SQL> insert into foo values ('testing'||chr(10)||'testing');
    1 row created.
    SQL>
    SQL> select replace(mr_clob,chr(10),'blah') from foo;
    REPLACE(MR_CLOB,CHR(10),'BLAH')
    testingblahtesting
    1 row selected.

  • Inconsistent datatypes:expected - got - error in handling xml

    hi i am getting the error Error(45,12): PL/SQL: ORA-00932: inconsistent datatypes: expected - got - in this procedure
    i tried a lot and landed in confused state..
    create or replace
    PROCEDURE BT_CPE_XML_READ1 IS
    dest_clob CLOB;
    src_clob BFILE := BFILENAME('DOC_PATH', 'tester.xml');
    dst_offset number := 1 ;
    src_offset number := 1 ;
    lang_ctx number := DBMS_LOB.DEFAULT_LANG_CTX;
    warning number;
    ex number;
    v_cast xmltype;
    v_varchar varchar2(32767);
    BEGIN
    DBMS_LOB.CREATETEMPORARY(dest_clob,true);
    ex := dbms_lob.fileexists(src_clob);
    if ex = 1 then
    INSERT INTO test_clob(id, file_name, XML_FILE_COLUMN, timestamp)
    VALUES(1001, 'test.xml', empty_clob(), sysdate)
    RETURNING XML_FILE_COLUMN INTO dest_clob;
    DBMS_LOB.OPEN(src_clob, DBMS_LOB.LOB_READONLY);
    DBMS_LOB.LoadCLOBFromFile(
    DEST_LOB => dest_clob
    , SRC_BFILE => src_clob
    , AMOUNT => DBMS_LOB.GETLENGTH(src_clob)
    , DEST_OFFSET => dst_offset
    , SRC_OFFSET => src_offset
    , BFILE_CSID => DBMS_LOB.DEFAULT_CSID
    , LANG_CONTEXT => lang_ctx
    , WARNING => warning
    DBMS_OUTPUT.ENABLE(100000);
    DBMS_LOB.CLOSE(src_clob);
    COMMIT;
    DBMS_OUTPUT.PUT_LINE('Loaded XML File using DBMS_LOB.LoadCLOBFromFile: (ID=1001).');
    v_cast :=xmltype(dest_clob);
    --dbms_output.put_line(v_cast);
    select extractvalue(XML_FILE_COLUMN,'/modifyProductPortfolioRequest/ns1:stateCode') from test_clob;
    end if;
    END BT_CPE_XML_READ1;
    is there any other way to get the value(xml)from the clob column of a table

    I see two issues off a quick eye-ball of the code<br><br>
    #1) You insert an empty clob into your table, load a local variable with the XML from disk, and then query the table. You never insert the XML into the table so you are querying on an empty column in the table.<br><br>
    #2) extractValue allows a third parm which is the namespace string. Since your XPath contains ns1: you'll need to use the third parm

  • Inconsistent datatypes: expected - got -

    hi i am getting the error Error(45,12): PL/SQL: ORA-00932: inconsistent datatypes: expected - got - in this procedure
    i tried a lot and landed in confused state..
    create or replace
    PROCEDURE BT_CPE_XML_READ1 IS
    dest_clob CLOB;
    src_clob BFILE := BFILENAME('DOC_PATH', 'tester.xml');
    dst_offset number := 1 ;
    src_offset number := 1 ;
    lang_ctx number := DBMS_LOB.DEFAULT_LANG_CTX;
    warning number;
    ex number;
    v_cast xmltype;
    v_varchar varchar2(32767);
    BEGIN
    DBMS_LOB.CREATETEMPORARY(dest_clob,true);
    ex := dbms_lob.fileexists(src_clob);
    if ex = 1 then
    INSERT INTO test_clob(id, file_name, XML_FILE_COLUMN, timestamp)
    VALUES(1001, 'test.xml', empty_clob(), sysdate)
    RETURNING XML_FILE_COLUMN INTO dest_clob;
    DBMS_LOB.OPEN(src_clob, DBMS_LOB.LOB_READONLY);
    DBMS_LOB.LoadCLOBFromFile(
    DEST_LOB => dest_clob
    , SRC_BFILE => src_clob
    , AMOUNT => DBMS_LOB.GETLENGTH(src_clob)
    , DEST_OFFSET => dst_offset
    , SRC_OFFSET => src_offset
    , BFILE_CSID => DBMS_LOB.DEFAULT_CSID
    , LANG_CONTEXT => lang_ctx
    , WARNING => warning
    DBMS_OUTPUT.ENABLE(100000);
    DBMS_LOB.CLOSE(src_clob);
    COMMIT;
    DBMS_OUTPUT.PUT_LINE('Loaded XML File using DBMS_LOB.LoadCLOBFromFile: (ID=1001).');
    v_cast :=xmltype(dest_clob);
    --dbms_output.put_line(v_cast);
    select extractvalue(XML_FILE_COLUMN,'/modifyProductPortfolioRequest/ns1:stateCode') from test_clob;
    end if;
    END BT_CPE_XML_READ1;
    is there any other way to get the value(xml)from the clob column of a table

    I see two issues off a quick eye-ball of the code<br><br>
    #1) You insert an empty clob into your table, load a local variable with the XML from disk, and then query the table. You never insert the XML into the table so you are querying on an empty column in the table.<br><br>
    #2) extractValue allows a third parm which is the namespace string. Since your XPath contains ns1: you'll need to use the third parm

  • A problem with inconsistent datatypes

    Whenever I try inserting a new record of type t_cliente_societa in my Cliente table, I get ORA-00932 inconsistent datatypes error and I'm not able to find the reason.
    Could anyone help me? Thanks in advance.
    I'll post my SQL code here. please ignore member functions for I havent' included the code necessary to create the needed tables.
    I defined some types useful for storing informations about the entities I have to deal with.
    The main type is t_cliente and its subtypes are t_cliente_pers and t_cliente_soc.
    I use polymorphism to insert records based on subtypes instancies into a table based on supertype.
    When I would add a new t_cliente_pers record, first I add it into Persona table and then into Cliente table.
    The latter contains a REF to Persona for I have several "persons" who aren't "clients" and I use a single table to store them all.
    create or replace TYPE t_indirizzo AS OBJECT (
    via VARCHAR(45),
    numero NUMBER(4),
    cap INTEGER(5),
    citta VARCHAR(30),
    provincia VARCHAR(30),
    regione VARCHAR(30),
    MEMBER FUNCTION indirizzoCompleto RETURN VARCHAR
    create or replace TYPE t_telefono AS OBJECT (
    num_tel NUMBER(15)
    create or replace TYPE t_telefono_array IS VARRAY(3) OF t_telefono
    create or replace TYPE t_anagrafica AS OBJECT (
    nome VARCHAR(45),
    cognome VARCHAR(45),
    sesso CHAR(1),
    cod_fiscale VARCHAR(16),
    data_nascita DATE
    create or replace TYPE t_ragioneSociale AS OBJECT (
    nome_soc VARCHAR(45),
    data_cost DATE,
    part_iva NUMBER(11)
    create or replace TYPE t_persona AS OBJECT (
    dati_anagrafici t_anagrafica,
    indirizzo t_indirizzo,
    email VARCHAR(45),
    telefono t_telefono_array
    create or replace TYPE t_societa AS OBJECT (
    ragione_sociale t_ragioneSociale,
    indirizzo t_indirizzo,
    email VARCHAR(45),
    telefono t_telefono_array,
    persona_rif t_persona
    create or replace TYPE t_cliente AS OBJECT (
    cod_cliente NUMBER(8),
    MEMBER FUNCTION incFatti RETURN NUMBER,
    MEMBER FUNCTION incSubiti RETURN NUMBER,
    MEMBER FUNCTION incFattiPeriodo RETURN NUMBER,
    MEMBER FUNCTION incSubitiPeriodo RETURN NUMBER,
    MEMBER FUNCTION nomeCliente RETURN VARCHAR,
    MEMBER FUNCTION tipoCliente RETURN VARCHAR
    ) NOT FINAL
    CREATE OR REPLACE TYPE BODY t_cliente AS
    MEMBER FUNCTION incFatti RETURN NUMBER
    IS incidenti NUMBER;
    BEGIN
    SELECT count(i. cod_incidente) INTO incidenti
    FROM Incidenti i, Mezzi m
    WHERE SELF.cod_cliente = m.possessore.cod_cliente AND m.num_targa = i.mezzo. num_targa AND i. responsabilita = ‘c’;
    RETURN (incidenti);
    END;
    MEMBER FUNCTION incSubiti RETURN NUMBER
    IS incidenti NUMBER;
    BEGIN
    SELECT count(i. cod_incidente) INTO incidenti
    FROM Incidenti i, Mezzi m
    WHERE SELF.cod_cliente = m.possessore.cod_cliente AND m.num_targa = i.mezzo. num_targa AND i. responsabilita = ‘s’;
    RETURN (incidenti);
    END;
    MEMBER FUNCTION incFattiPeriodo (da DATE, a DATE) RETURN NUMBER
    IS incidenti NUMBER;
    BEGIN
    SELECT count(i. cod_incidente) INTO incidenti
    FROM Incidenti i ,Mezzi m
    WHERE SELF. cod_cliente = m.possessore.cod_cliente AND m. num_targa = i.mezzo. num_targa AND i. responsabilita = ‘c’ AND (i.data BETWEEN da and a);
    RETURN (incidenti);
    END;
    MEMBER FUNCTION incSubitiPeriodo (da DATE, a DATE) RETURN NUMBER
    IS incidenti NUMBER;
    BEGIN
    SELECT count(i. cod_incidente) INTO incidenti
    FROM Incidenti i ,Mezzi m
    WHERE SELF. cod_cliente = m.possessore.cod_cliente AND m. num_targa = i.mezzo. num_targa AND i. responsabilita = ‘s’ AND (i.data BETWEEN da and a);
    RETURN (incidenti);
    END;
    MEMBER FUNCTION nomeCliente RETURN VARCHAR
    IS
    BEGIN
    RETURN TO_CHAR(cod_cliente);
    END;
    MEMBER FUNCTION tipoCliente RETURN VARCHAR
    IS
    BEGIN
    RETURN (‘u’);
    END;
    END ;
    create or replace TYPE t_cliente_pers UNDER t_cliente (
    persona REF t_persona,
    OVERRIDING MEMBER FUNCTION nomeCliente RETURN VARCHAR,
    OVERRIDING MEMBER FUNCTION tipoCliente RETURN VARCHAR
    ) NOT FINAL
    CREATE OR REPLACE TYPE BODY t_cliente_pers AS
    MEMBER FUNCTION nomeCliente RETURN VARCHAR
    IS nc VARCHAR(90) ;
    BEGIN
    SELECT concat(p.dati_anagrafici.nome, concat(' ',p.dati_anagrafici.cognome)) INTO nc
    FROM d;
    RETURN (nc);
    END;
    MEMBER FUNCTION tipoCliente RETURN VARCHAR
    IS
    BEGIN
    RETURN (‘p’);
    END;
    END ;
    create or replace TYPE t_cliente_soc UNDER t_cliente (
    societa t_societa,
    OVERRIDING MEMBER FUNCTION nomeCliente RETURN VARCHAR,
    OVERRIDING MEMBER FUNCTION tipoCliente RETURN VARCHAR
    ) NOT FINAL
    CREATE OR REPLACE TYPE BODY t_cliente_soc AS
    MEMBER FUNCTION nomeCliente RETURN VARCHAR
    IS
    BEGIN
    RETURN (ragione_sociale.nome_soc);
    END;
    MEMBER FUNCTION tipoCliente RETURN VARCHAR
    IS
    BEGIN
    RETURN (‘s’);
    END;
    END ;
    CREATE TABLE persona OF t_persona(
    dati_anagrafici NOT NULL,
    indirizzo NOT NULL,
    email NOT NULL,
    telefono NOT NULL,
    PRIMARY KEY (dati_anagrafici.cod_fiscale)
    CREATE TABLE cliente OF t_cliente(
    PRIMARY KEY (cod_cliente)
    CREATE SEQUENCE seqCliente
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    NOMAXVALUE
    NOCYCLE;
    And finally this is the instruction that gives me problems.*
    INSERT INTO cliente VALUES(
    t_cliente_soc(
    seqCliente.NEXTVAL,
    t_societa(
    t_ragioneSociale('Adecco', '01-gen-1999', '12345678901'),
    t_indirizzo('Milano', '18', '21100', 'Varese', 'Varese', 'Lombardia'),
    '[email protected]',
    t_telefono_array(t_telefono('0332563214')),
    t_persona(
    t_anagrafica('Giulia', 'Macchi', 'f', 'MCCGLA80C23L682L', '23-gen-1980'),
    t_indirizzo('Tofane', '2', '23026', 'Arona', 'Novara', 'Piemonte'),
    '[email protected]',
    t_telefono_array(t_telefono('0322123456'), t_telefono('3337894561'))
    /

    I eliminated the entire database and recreated everything. Now it works... Thanks anyway.

  • Inconsistent datatypes error

    Hi,
    I have faced on the following problem in sql statement.
    SQL> SELECT B.NAME, C.FST_NAME, C.LAST_NAME FROM SIEBEL.S_PARTY_PER A, SIEBEL.S_ORG_EXT B, SIEBEL.S_CONTACT C WHERE (B.ROW_ID = A.PARTY_ID AND C.ROW_ID = A.PERSON_ID AND A.PERSON_ID IN (select D.NEW_VAL from SIEBEL.S_AUDIT_ITEM D where D.OPERATION_CD = 'Associate' and (trunc(OPERATION_DT) Between TRUNC (&from) AND TRUNC (&to))));
    Enter value for from: 10/8/2008
    Enter value for to: 10/10/2008
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected DATE got NUMBER
    plz help me....

    Your input value is wrong.
    SQL> select * from dual where trunc(sysdate)=&a
      2  /
    Enter value for a: 10/10/2008
    old   1: select * from dual where trunc(sysdate)=&a
    new   1: select * from dual where trunc(sysdate)=10/10/2008
    select * from dual where trunc(sysdate)=10/10/2008
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected DATE got NUMBER
    SQL> select * from dual where trunc(sysdate)=&a
      2  /
    Enter value for a: to_date('10/10/2008','dd/mm/yyyy')
    old   1: select * from dual where trunc(sysdate)=&a
    new   1: select * from dual where trunc(sysdate)=to_date('10/10/2008','dd/mm/yyyy')
    D
    X
    SQL>

Maybe you are looking for