Table(cast  - invalid datatype problem

Hi All,
Basic scenario:
PACKAGE
create or replace
PACKAGE C2_PAYMENT_DOC IS
TYPE bin_array IS TABLE OF NUMBER
INDEX BY BINARY_INTEGER;
FUNCTION test_fun(l_doc_id IN integer) RETURN bin_array;
PACKAGE_BODY
create or replace
package body C2_PAYMENT_DOC as
FUNCTION test_fun (l_doc_id IN integer) RETURN bin_array IS
l_gross bin_array;
begin
c2_purchase_invoice.get_inv_gross_amount(l_doc_id, l_gross(1));
return l_gross;
end;
END;
QUERY
select * from Table(Cast(c2_payment_doc.test_fun(1) As bin_array));
Result of the query is ORA-00902: invalid datatype
How can I make the select statement valid?
Thanks in advance,
Bartek

You can not use local collection types in SQL. You must create type bin_array as SQL nested table type. Also, depending on version you might not need to cast:
SQL> CREATE OR REPLACE
  2    TYPE bin_array
  3      AS TABLE OF NUMBER
  4  /
Type created.
SQL>  create or replace
  2   PACKAGE C2_PAYMENT_DOC IS
  3  FUNCTION test_fun(l_doc_id IN integer) RETURN bin_array;
  4  end;
  5  /
Package created.
SQL> create or replace
  2  package body C2_PAYMENT_DOC as
  3 
  4  FUNCTION test_fun (l_doc_id IN integer) RETURN bin_array IS
  5  l_gross bin_array := bin_array();
  6  begin
  7      l_gross.extend;
  8      l_gross(1) := l_doc_id;
  9  return l_gross;
10  end;
11  END;
12  /
Package body created.
SQL> select * from Table(Cast(c2_payment_doc.test_fun(1) As bin_array));
COLUMN_VALUE
           1
SQL> select * from Table(c2_payment_doc.test_fun(1))
  2  /
COLUMN_VALUE
           1
SQL> SY.

Similar Messages

  • Table cast PL/SQL: ORA-00902: invalid datatype

    I m getting
    PL/SQL: ORA-00902: invalid datatype
    error in
    OPEN pPymtCur FOR
    SELECT *
    FROM TABLE(CAST( up_gap_tra_reports.myArray AS traArray));
    in my package up_gap_tra_reports.
    CREATE OR REPLACE PACKAGE GAPSDVEL.up_gap_tra_reports
    AS
    TYPE traRecord IS RECORD
    group1StudEnrol NUMBER(6,1),
    group2StudEnrol NUMBER(6,1),
    pymtAmt gap_payment.NET_AMT%TYPE
    TYPE traArray IS TABLE OF traRecord;
    myArray traArray := traArray() ;
    END up_gap_tra_reports;
    I hv alreay declared traArray type.
    pls help me to solve this.

    Meghna wrote:
    is there any way to use pl/sql collection in SQL or refcur without creating it because i am not able to create type in database.The only way I am aware of is pipelined function:
    create or replace
      package pkg1
        is
          type traRecord
            is record(
                      ename emp.ename%type,
                      sal   emp.sal%type
          TYPE traArray IS TABLE OF traRecord;
          function f1
            return traArray
            pipelined;
    end;
    create or replace
      package body pkg1
        is
        function f1
            return traArray
            pipelined
          is
              v_rec traRecord;
          begin
              v_rec.ename := 'Sam';
              v_rec.sal := 1000;
              pipe row(v_rec);
              v_rec.ename := 'John';
              v_rec.sal := 1500;
              pipe row(v_rec);
              v_rec.ename := 'Mary';
              v_rec.sal := 2000;
              pipe row(v_rec);
              return;
        end;
    end;
    /Now you can:
    SQL> select * from table(pkg1.f1)
      2  /
    ENAME             SAL
    Sam              1000
    John             1500
    Mary             2000
    SQL>Keep in mind, it will create system generated types:
    SQL> select type_name from user_types
      2  /
    TYPE_NAME
    SYS_PLSQL_73305_9_1
    SYS_PLSQL_73305_DUMMY_1
    SYS_PLSQL_73305_34_1
    SQL> desc SYS_PLSQL_73305_9_1
    Name                                      Null?    Type
    ENAME                                              VARCHAR2(10)
    SAL                                                NUMBER(7,2)
    SQL> desc SYS_PLSQL_73305_DUMMY_1
    SYS_PLSQL_73305_DUMMY_1 TABLE OF NUMBER
    SQL> desc SYS_PLSQL_73305_34_1
    SYS_PLSQL_73305_34_1 TABLE OF SYS_PLSQL_73305_9_1
    Name                                      Null?    Type
    ENAME                                              VARCHAR2(10)
    SAL                                                NUMBER(7,2)
    SQL> SY.

  • Pl sql invalid datatype error for table casting(PL/SQL: ORA-00902: invalid)

    See the code snippet -
    Create or Replace Package xyz.abc as
    TYPE rec_local is record of (primary_key emp.p_key%type, nam emp.name%type,addres emp.address%type);
    Type tab_local is Table of rec_local;
    Procedure exclude_pkey (tab1 IN tab_local );
    End xyz.abc
    Create or Replace Package Body xyz.abc as
    Procedure exclude_pkey (tab1 IN tab_local );
    Cursor cur is
    select primary_key
    from table(*cast(tab1 as tab_local *)))
    where primary_key NOT IN (select primary_key
    from emp)
    BEGIN
    END exclude_pkey ;
    End abc;
    I came to know the process that for query purpose we cant use pl/sql type, it must sql type, i.e. creating object and table of that object type in sql,and use of MEMEBER OF ,but what should i do in this case where insted of IN(MEMBER OF can be used for the case of IN) ,NOT IN is used for query.
    please reply,
    thank you

    You are only selecting a single column, primary_key, in your cursor.
    You could use the built in sys.ODCINumberlist or sys.ODCIVarchar2list data types instead and pass in only the primary_key.
    Re: Passing an array to an Oracle stored procedure
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10765/ext_types_ref.htm#ADDCI5012
    If you are on an old version you can create your own types with the same definition.
    Using a cursor like that I can tell that you want to do whatever this does as slowly and inefficiently as possible though.
    Re: using cursor to sum  numbers, gives error
    Re: global temporary table row order

  • What this problem? table(cast(array))

    exits in databse one type
    " type InNumberTab is table of number;"
    declare
    v_tbseq_trans:= InNumberTab(null);
    select count(*) into v_cont
    from dados_propriedade dp
    where dp.num_pessoa=p_num_pessoa
    group by num_nirf;
    v_tbseq_trans.EXTEND(SQL%ROWCOUNT);
    v_cont:=0;
    for v_cs in
    (select to_number(replace(dp.num_nirf,'-','')) nirf, max(dp.seq_transacao) seq_transacao
    from dados_propriedade dp
    where dp.num_pessoa=p_num_pessoa
    group by dp.num_nirf) loop
    v_tbseq_trans(v_cont):=v_cs.seq_transacao;
    v_cont:=v_cont+1;
    END LOOP;
    open p_cursor_prop for
    select
    from dados_propriedade dp
    where dp.seq_transacao in (SELECT column_value FROM TABLE(CAST(v_tbseq_trans as InNumberTab)));

    I'll try to guess what you mean.
    If you need to use object or collection type in SQL query you should declare in in SQL server not in PL/SQL code:
    SQL> declare
      2   type na is table of number;
      3   nat na := na(1,2,3);
      4  begin
      5   for x in (select column_value y from table(cast(nat as na))) loop
      6     dbms_output.put_line(x.y);
      7   end loop;
      8  end;
      9  /
    for x in (select column_value y from table(cast(nat as na))) loop
    ERROR at line 5:
    ORA-06550: line 5, column 56:
    PL/SQL: ORA-00902: invalid datatype
    ORA-06550: line 5, column 11:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 6, column 25:
    PLS-00364: loop index variable 'X' use is invalid
    ORA-06550: line 6, column 4:
    PL/SQL: Statement ignored
    SQL> set serveroutput on
    SQL> create type na is table of number;
      2  /
    Type created.
    SQL> declare
      2   nat na := na(1,2,3);
      3  begin
      4   for x in (select column_value y from table(cast(nat as na))) loop
      5     dbms_output.put_line(x.y);
      6   end loop;
      7  end;
      8  /
    1
    2
    3
    PL/SQL procedure successfully completed.Is it your problem ?
    Rgds.

  • Problems using table (cast as)

    Hi
    I have some code like this:
    declare
    TYPE t_forall_bags IS TABLE OF misbag.bags%ROWTYPE;
    l_forall_bags t_forall_bags := t_forall_bags ();
    begin
    open c2;
    FETCH c2 BULK COLLECT INTO l_forall_bags LIMIT v_array_size;
    if l_forall_bags.COUNT > 0 then
    begin
    merge into misbag.bags dest
    using (select col1,
    col2,
    colx
    from TABLE( cast( l_forall_bags as t_forall_bags ) ) ) src
    on (dest.bag_id = src.bag_id )
    when matched then
    --do update stuff
    when not matched then
    --do insert stuff;
    end;
    end if;
    end;
    on compilation I am getting an ora-00902 invalid datatype seemingly on the t_forall_bags in side the cast (as highlighted in bold)
    I thought I had the syntax correct, but maybe not.
    rgds
    Tony

    BluShadow wrote:Why are you querying data from the database into a collection (in expensive PGA memory) to then pass that back down to the SQL engine to be treated as a table (and incidently one without any indexes or the other benefits of a database table).Well that is a very good question.
    The task is to take a generally smaller number of very recent rows from one table and apply them to a similar table in another schema. This task will run very frequently (ie every second or two) so generally will have a smallish number fo rows (ie 100-200) each time it runs. Some rows are updates and some rows are inserts.
    If there is a delay on running the task, we don't necessarily want to process all of the outstanding rows in one go, but to take them in chunks until is catches up.
    One way to do this would be to perform multiple queries on the original data to check how many rows where outstanding, then to select which ones were to be merged, then go ahead and do the merge (with both main tables as you propose). This alternate idea (that I was looking at here) was to bulk collect the first n rows from the table into the array (up to the defined limit) and then to merge this list of rows into the destination table. The goal was to perform fewer data accesses and make the process least expensive in I/O. By bulk selecting up to N rows into the array, it was felt that there was less I/O on the source table, and probably the same amount of I/O on the destination table.
    The very first method of writing was to bulk select the first N rows into an array, delete any that already existed in the dest table then to "forall" insert the array contents into the destination table. This seemed to work quite well, we wanted to compare the merge version and see how it compared in speed and I/O usage.
    Tony
    rgds
    Tony

  • ORA-00902: invalid datatype comile error while using CAST function

    Hi everyone,
    I'm getting ORA-00902: invalid datatype compilation error while using CAST function.
    open ref_cursor_list for select empName from TABLE(CAST(part_t AS partnumberlist));
    The partnumberlist and ref_cursor_list is declared in the Package spec as given below.
    TYPE ref_cursor_list IS REF CURSOR;
    TYPE partnumberlist IS TABLE OF emp.empName%TYPE;
    The error points the partnumberlist as invalid datatype in TOAD because of this i'm unable to compile the package.
    Any suggestion
    Thanks and regards
    Sathish Gopal

    Here is my code for
    package Spec
    CREATE OR REPLACE PACKAGE "HISTORICAL_COMMENTZ" AS
    TYPE prior_part_data_record IS RECORD (
    prior_part_row_id PGM_RPLCMNT_PART.PR_PART_ROW_S_ID%TYPE,
    prior_pgm_chng_s_id PGM_RPLCMNT_PART.PR_PGM_CHNG_S_ID%TYPE
    TYPE parts_list IS TABLE OF prior_part_data_record;
    --TYPE parts_list IS TABLE OF NUMBER;
    TYPE partnumberlist IS TABLE OF PGM_RPLCMNT_PART.PR_PART_ROW_S_ID%TYPE;
    TYPE partnumber_cursor IS REF CURSOR;
    TYPE comment_record IS RECORD (
    pgm_s_id                     PGM_PART_CMNT.PGM_S_ID%TYPE,
    part_row_s_id                PGM_PART_CMNT.PART_ROW_S_ID%TYPE,
    pgm_chng_s_id                PGM_PART_CMNT.PGM_CHNG_S_ID%TYPE,
    cmnt_txt                     PGM_PART_CMNT.CMNT_TXT%TYPE,
    cmnt_dt                     PGM_PART_CMNT.CMNT_DT%TYPE,
    updt_rsrc_id                PGM_PART_CMNT.UPDT_RSRC_ID%TYPE
    TYPE comment_list IS TABLE OF comment_record;
    global_pgm_s_id INTEGER := 0;
    global_part_row_s_id INTEGER := 0;
    err_num NUMBER := 999999;
    err_msg VARCHAR2 (250);
    PROCEDURE getComments (
    pgm_s_id IN NUMBER,
    part_row_s_id IN NUMBER,
    partnumber_cursorlist out partnumber_cursor);
    END;
    Package Body
    CREATE OR REPLACE PACKAGE BODY HISTORICAL_COMMENTZ
    AS
    FUNCTION getPriorPart
    (param_prior_pgm_chng_s_id IN PGM_RPLCMNT_PART.PR_PGM_CHNG_S_ID%TYPE,
    return_prior_part_data_record IN OUT prior_part_data_record
    RETURN INTEGER
    IS
    retVal INTEGER;
    prior_part_row_id INTEGER;
    prior_pgm_chng_s_id INTEGER;
    local_prior_part_data_record prior_part_data_record;
    BEGIN
    SELECT PR_PART_ROW_S_ID AS prior_part_row_id, PR_PGM_CHNG_S_ID AS prior_pgm_chng_s_id
    INTO local_prior_part_data_record
    --SELECT PR_PART_ROW_S_ID INTO retVal
    FROM PGM_RPLCMNT_PART
    WHERE PGM_S_ID = global_pgm_s_id AND CUR_PGM_CHNG_S_ID = param_prior_pgm_chng_s_id;
    return_prior_part_data_record := local_prior_part_data_record;
    retVal := 0;
    RETURN retVal;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    err_num := SQLCODE;
    err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
    DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
    retVal := -1;
    RETURN retVal;
    WHEN OTHERS
    THEN
    err_num := SQLCODE;
    err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
    DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
    retVal := -1;
    RETURN retVal;
    END getPriorPart;
    FUNCTION getComment (found_parts_list IN parts_list, comments OUT comment_list)
    RETURN INTEGER
    IS
    CURSOR init_cursor
    IS
    SELECT PGM_S_ID,PART_ROW_S_ID,PGM_CHNG_S_ID,CMNT_TXT,CMNT_DT,UPDT_RSRC_ID
    FROM PGM_PART_CMNT WHERE 1 = 2;
    retVal INTEGER;
    indexNum PLS_INTEGER;
    local_part_record prior_part_data_record;
    local_comment_record comment_record;
    local_part_row_s_id NUMBER;
    i PLS_INTEGER;
    BEGIN
    OPEN init_cursor;
    FETCH init_cursor
    BULK COLLECT INTO comments;
    i := 0;
    indexNum := found_parts_list.FIRST;
    WHILE indexNum IS NOT NULL
    LOOP
    local_part_record := found_parts_list(indexnum);
    local_part_row_s_id := local_part_record.prior_part_row_id;
    SELECT PGM_S_ID,PART_ROW_S_ID,PGM_CHNG_S_ID,CMNT_TXT,CMNT_DT,UPDT_RSRC_ID
    INTO local_comment_record FROM PGM_PART_CMNT
    WHERE PGM_S_ID = global_pgm_s_id
    AND PART_ROW_S_ID = local_part_row_s_id;
    comments(i) := local_comment_record;
    i := i + 1;
    END LOOP;
    RETURN retval;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    err_num := SQLCODE;
    err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
    DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
    RETURN retval;
    WHEN OTHERS
    THEN
    err_num := SQLCODE;
    err_msg := 'SQL Error ' || SUBSTR (SQLERRM, 1, 250);
    DBMS_OUTPUT.put_line ('SQLERROR = ' || err_msg);
    RETURN retval;
    END getComment;
    PROCEDURE getComments
    pgm_s_id IN NUMBER,
    part_row_s_id IN NUMBER,
    partnumber_cursorlist OUT partnumber_cursor)
    IS
    comment_recordlist comment_record;
    retPartnumberlist partnumberlist;
    found_parts_list parts_list;
    local_part_record prior_part_data_record;
    is_more_parts BOOLEAN;
    driver_chng_s_id NUMBER;
    num_parts NUMBER;
    retVal NUMBER;
    comments comment_list;
    returnPartnumberlist partnumberlist;
    iloopCounter PLS_INTEGER;
    inx1 PLS_INTEGER;
    part_t partnumberlist :=partnumberlist(100,200,300);
    CURSOR part_list_init_cursor
    IS
    SELECT PR_PART_ROW_S_ID,PR_PGM_CHNG_S_ID FROM PGM_RPLCMNT_PART WHERE 1 = 2;
    CURSOR inIt_cursor
    IS
    SELECT 0 FROM DUAL WHERE 1 = 2;
    BEGIN
    DBMS_OUTPUT.ENABLE (5000000);
    global_pgm_s_id := pgm_s_id;
    global_part_row_s_id := part_row_s_id;
    SELECT PART_ROW_S_ID AS prior_part_row_id, PR_PGM_CHNG_S_ID AS prior_pgm_chng_s_id
    INTO local_part_record
    FROM PGM_RPLCMNT_PART
    WHERE PGM_S_ID = global_pgm_s_id AND PART_ROW_S_ID = global_part_row_s_id AND
    CUR_PGM_CHNG_S_ID IN (SELECT MAX(CUR_PGM_CHNG_S_ID) FROM PGM_RPLCMNT_PART WHERE
    PGM_S_ID = global_pgm_s_id AND PART_ROW_S_ID = global_part_row_s_id
    GROUP BY PART_ROW_S_ID);
    OPEN part_list_init_cursor;
    FETCH part_list_init_cursor
    BULK COLLECT INTO found_parts_list;
    -- Add the existing part to the found list
    found_parts_list.EXTEND;
    found_parts_list(1) := local_part_record;
    driver_chng_s_id := local_part_record.prior_pgm_chng_s_id;
    num_parts := 1;
    is_more_parts := TRUE;
    WHILE (is_more_parts) LOOP
    retVal := getPriorPart(driver_chng_s_id,local_part_record);
    IF (retVal != -1) THEN
    found_parts_list.EXTEND;
    num_parts := num_parts + 1;
    found_parts_list(num_parts) := local_part_record;
    driver_chng_s_id := local_part_record.prior_pgm_chng_s_id;
    ELSE
    is_more_parts := FALSE;
    END IF;
    END LOOP;
    --num_parts := getComment(found_parts_list,comments);
    OPEN init_cursor;
    FETCH init_cursor
    BULK COLLECT INTO returnPartnumberlist;
    num_parts := found_parts_list.COUNT;
    FOR iloopCounter IN 1 .. num_parts
    LOOP
    returnPartnumberlist.EXTEND;
    returnPartnumberlist(iloopCounter) := found_parts_list(iloopCounter).prior_part_row_id;
    END LOOP;
    retPartnumberlist := returnPartnumberlist;
    open
    *          partnumber_cursorlist for select PR_PART_ROW_S_ID from TABLE(CAST(retPartnumberlist AS historical_commentz.partnumberlist));*                              
    DBMS_OUTPUT.put_line('Done....!');
    EXCEPTION
    some code..............................
    END getComments;
    END HISTORICAL_COMMENTZ;
    /

  • Problem with table(cast..)) clause - timeout

    Hello,
    I've in shared memory one query in multiple copies - one differences between copies is in arguments count given with in clause. For example, in shared memory i have:
    select name from a where id in (?);
    select name from a where id in (?,?);
    select name from a where id in (?,?,?);
    I try to minimize size of shared memory by change this query as in example:
    select name from a where id in (select * from table(cast(? as seqintegertable)))
    In this case my shared memory is ok, but I have problem with timeout exception:
    - time of executing query without cast is about 250 ms
    - with cast: about 10560 ms and sometimes I get ORA-01652
    Why this time is so long? Can I reduce it? Maybe I should change something other?

    user13241971 wrote:
    Why this time is so long? Can I reduce it? Maybe I should change something other?To know why your query takes so long: {thread:id=501834}
    Likely it's because of wrong cardinalities, to which this excellent article gives possible solutions: http://www.oracle-developer.net/display.php?id=427
    Regards,
    Rob.

  • 10gr2 TABLE(CAST( problem

    We have an existing report that uses existing function to table cast back data in the from clause. A very simplified example:
    FROM grant g, grantparticipant gt, table(cast(getSchedule(g.grant_pk, gt.grantparticipant_pk) as r_sched)) sched
    where g.grant_pk = gt.grant_fk
    and sched.grantparticipant_pk = gt.grantparticipant_pk
    The grantparticipant_pk is NULL when captured in the function. There are no null values in the table (it's a primary key). When the where clause is changed to reference a specific pk it works fine and the value is filled in.
    The works in our production db where the Oracle version is 10g. It works in development which is also 10g. The problem only appears to be with our 10gr2 DB.
    Any ideas....

    The problem was solved with ANSI JOINs. Would still like to know why that problem occurred?

  • Problem in table(cast(

    i have two collection variables v1_coll and v2_coll(both are of same table type 'tt_coll' and 'rt_coll' is a record type)
    tt_coll  is table of  rt_coll;
    v1_coll    tt_coll := tt_coll();
    v2_coll    tt_coll := tt_coll();
    now i am populating the v1_coll through a select clause..
    select ......... from table1, table2, table3 into v_coll1 where <lots of joins>;
    now i want to populate the second collection v_coll2 from the first collection.
    i dont want to make a for loop assigning each and every row of the first collection into the second..
    so i table cast the first collection and do a select on that into the second...
    select ......... into v2_coll from table(cast(v_coll1 as tt_coll));
    but it is failing......please help me...

    Note that you can use bulk collect to select into a local collection type, and to assign each and every row of the first collection to the second you can just use v2_coll := v1_coll
    declare
    type tt_coll is table of emp%rowtype;
    v1_coll tt_coll := tt_coll();
    v2_coll tt_coll := tt_coll();
    begin
      select * bulk collect into v1_coll from emp where ename like 'S%';
      dbms_output.put_line('rows returned = '||to_char(SQL%ROWCOUNT));
      v2_coll := v1_coll;
      dbms_output.put_line('v2_col1(1).ename = '||v2_coll(1).ename);
      v2_coll(1).ename := 'JONES';
      dbms_output.put_line('v2_col1(1).ename = '||v2_coll(1).ename);
      dbms_output.put_line('v1_col1(1).ename = '||v1_coll(1).ename);
    end;
    rows returned = 2
    v2_col1(1).ename = SMITH
    v2_col1(1).ename = JONES
    v1_col1(1).ename = SMITHRegards,
    Bob

  • Problem while importing table with blob datatype

    hi i am having a database 9i on windows xp and dev database 9i on AIX 5.2
    while i am taking export of normal tables and trying to import i am successful.but when i am trying to import a table with blob datatype it is throwing "tablespace <tablespace_name> doesn't exist" error
    here how i followed.
    SQL*Plus: Release 9.2.0.1.0 - Production on Mon Oct 8 14:08:29 2007
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Enter user-name: test@test
    Enter password: ****
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    SQL> create table x(photo blob);
    Table created.
    exporting:
    D:\>exp file=x.dmp log=x.log tables='TEST.X'
    Export: Release 9.2.0.1.0 - Production on Mon Oct 8 14:09:40 2007
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Username: pavan@test
    Password:
    Connected to: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    About to export specified tables via Conventional Path ...
    Current user changed to TEST
    . . exporting table X 0 rows exported
    Export terminated successfully without warnings.
    importing:
    D:\>imp file=x.dmp log=ximp.log fromuser='TEST' touser='IBT' tables='X'
    Import: Release 9.2.0.1.0 - Production on Mon Oct 8 14:10:42 2007
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Username: system@mch
    Password:
    Connected to: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
    With the Partitioning, Real Application Clusters, OLAP and Oracle Data Mining op
    tions
    JServer Release 9.2.0.6.0 - Production
    Export file created by EXPORT:V09.02.00 via conventional path
    Warning: the objects were exported by PAVAN, not by you
    import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    import server uses US7ASCII character set (possible charset conversion)
    . importing TEST's objects into IBT
    IMP-00017: following statement failed with ORACLE error 959:
    "CREATE TABLE "X" ("PHOTO" BLOB) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS "
    "255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "TESTTB"
    "S" LOGGING NOCOMPRESS LOB ("PHOTO") STORE AS (TABLESPACE "TESTTBS" ENABLE "
    "STORAGE IN ROW CHUNK 8192 PCTVERSION 10 NOCACHE STORAGE(INITIAL 65536 FREE"
    "LISTS 1 FREELIST GROUPS 1))"
    IMP-00003: ORACLE error 959 encountered
    ORA-00959: tablespace 'TESTTBS' does not exist
    Import terminated successfully with warnings.
    why it is happening for this table alone?plz help me
    thanks in advance

    Here is exerpt from {
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:378418239571}
    =============================================
    Hi Tom,
    I have a dump file containing blob datatypes, when i import the dump file in a schema it gives an
    error stating that the tablespace for Blob datatype does not exists. My question is how do i import
    the dump file in the default tablespace of the importing user.
    Followup March 2, 2004 - 7am US/Eastern:
    You'll have to precreate the table.
    do this:
    imp userid=u/p tables=that_table indexfile=that_table.sql
    edit that_table.sql, fix up the tablespace references to be whatever you want to be, run that sql.
    then imp with ignore=y
    for any MULTI-SEGMENT object (iot's with overflows, tables with lobs, partitioned tables, for
    example), you have to do this -- imp will not rewrite ALL of the tablespaces in that
    multi-tablespace create -- hence you either need to have the same tablespaces in place or precreate
    the object with the proper tablespaces.
    Only for single tablespace segments will imp rewrite the create to go into the default if the
    requested tablespace does not exist.
    ===================================================
    To summarize: precreate target table when importing multi-segment tables

  • OEHR Sample Objects Installation - ORA-00902: invalid datatype

    When I was trying to install the supporting objects, I received a CREATE TYPE privilege error previously. Then the DBA updated APEX to 2.2.1 to fix the problem. It did but know I'm gettingn ORA-00901:invalid datatype and othere errors with creating the tables, views,etc. Can somebody help me. I'm running APEX with database version 9.2

    Can somebody help me? I can not install the database objects. I get an invalid datatype error when the install script attempts to install the tables.
    Please help!

  • Need help with "ORA-00902: invalid datatype"  while creating a view

    I am using Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options.....
    when I try ti create a view, I am getting ORA-00902 error.
    SQL> create view sales_view as
    2 select *
    3 from table(OLAP_TABLE('global DURATION session',
    4 'sales_type_table',
    5 '',
    6 'DIMENSION time_id FROM time
    7 DIMENSION channel_id FROM channel
    8 DIMENSION product_id FROM product
    9 DIMENSION customer_id FROM customer
    10 MEASURE sales FROM sales
    11 MEASURE units FROM units
    12 MEASURE extended_cost FROM extended_cost
    13 MEASURE forecast_sales FROM fcast_sales
    14 ROW2CELL olap_calc'));
    create view sales_view as
    ERROR at line 1:
    ORA-00902: invalid datatype
    ORA-06512: at "SYS.OLAPIMPL_T", line 23
    ORA-06512: at "SYS.OLAPIMPL_T", line 17
    ORA-06512: at line 4
    I am new to Oracle.... using document "40261_leveragingtools.pdf" as a guide against a cube created using "Global_AWM10g_Handson.doc".
    AWM displays data from cube without a problem.
    I would welcome any assistance.

    Can you provide the definition of sales_type_table? Also, Are all of the dimensions you have created of type TEXT?
    Swapan.

  • TABLE(CAST()) function not returning the correct results in few scenarios.

    I am using TABLE(CAST()) operation in PL/SQL and it is returning me no data.
    Here is what I have done:
    1.     Created Record type
    CREATE OR REPLACE TYPE target_rec AS OBJECT
    target__id          NUMBER(10),
    target_entity_id NUMBER(10),
    dd           CHAR(3),
    fd           CHAR(3),
    code      NUMBER(10),
    target_pct      NUMBER,
    template_nm VARCHAR2(50),
    p_symbol      VARCHAR2(10),
    pm_init          VARCHAR2(3),
    target_name     VARCHAR2(20),
    targe_type     VARCHAR2(30),
    target_caption     VARCHAR2(30),
    sort_order      NUMBER (4)
    2.     Created Table type
    CREATE OR REPLACE TYPE target_arr AS TABLE OF target_rec
    3.     Created Stored procedure which accepts parameter of type target_arr and runs the Table(Cast()) function on it.
         Following is the simplified form of my procedure.
         PROCEDURE get_target_weights
         p_in_template_target IN target_arr,
         p_out_count          OUT NUMBER,
         IS
         BEGIN
              SELECT count(*) into p_out_count
         FROM TABLE(CAST(p_in_template_target AS                     target_arr)) arr;
         END;
    I am calling get_target_weights from my java code and passing p_in_template_target with 10140 records.
    Scenario 1: If target_pct in the last record is 0, p_out_count returned from the procedure is 0.
    Scenario 2: If target_pct in the last record is any other value(say 0.01), p_out_count returned from the procedure is 10140.
    Please help me understand why the Table(Cast()) is not returning the correct results in Scenario 1. Also adding or deleting any record from the test data returns the correct results (i.e. if keep target_pct in the last record as 0 but add or delete any record).
    Let me know how can I attach the test data I am using to help you debugging as I don’t see any Attach file button on Post Message screen on the forum.

    I am not able to reproduce this problem with a small data set. I can only reproduce with the data having 10140 records.
    I am not sure if this is the memory issue as adding a new record also solves the problem.
    This should not be the error because of wrong way of filling the records in java as for testing purpose I just saved the records which I am sending from java in a table. I updated the stored procedure as well to read the data from the table and then perform TABLE(CAST()) operation. I am still getting 0 as the output for scenario 1 mentioned in my last mail.
    Here is what I have updated:
    1.     Created the table target_table
    CREATE Table target_table
    target_id          NUMBER(10),
    target_entity_id NUMBER(10),
    dd           CHAR(3),
    fd           CHAR(3),
    code      NUMBER(10),
    target_pct      NUMBER,
    template_nm VARCHAR2(50),
    p_symbol      VARCHAR2(10),
    pm_init          VARCHAR2(3),
    target_name     VARCHAR2(20),
    target_type     VARCHAR2(30),
    target_caption     VARCHAR2(30),
    sort_order      NUMBER (4)
    2.     Inserted data into the table : The script has around 10140 rows. Pls let me know how can I send it to you
    3.     Updated procedure to read data from table and stored into variable of type target_arr. Run Table(cast()) operation on target_arr and get the count
    PROCEDURE test_target_weights
    IS
         v_target_rec target_table%ROWTYPE;
         CURSOR wt_cursor IS
         Select * from target_table;
         v_count NUMBER := 1;
         v_target_arr cws_target_arr:= target_arr ();
         v_target_arr_rec target_rec;
         v_rec_count NUMBER;
         BEGIN
         OPEN wt_cursor;
         loop
              fetch wt_cursor into v_target_rec; -- fetch data from table into local           record.
              exit when wt_cursor%notfound;
              --move data into target_arr
              v_target_arr_rec :=                     cws_curr_pair_entity_wt_rec(v_target_rec target_id,v_target_rec. target_entity_id,
                        v_target_rec.dd,v_target_rec.fd,v_target_rec.code,v_target_rec.target_pct,
         v_target_rec.template_nm,v_target_rec.p_symbol,v_target_rec.pm_init,v_target_rec.template_name,
         v_target_rec.template_type,v_target_rec.template_caption,v_target_rec.sort_order);
              v_target_arr.extend();
              v_target_arr(v_count) := v_target_arr_rec;
              v_count := v_count + 1;
         end loop;
         close wt_cursor;
         -- run table cast on target_arr
         SELECT count(*) into v_rec_count
         FROM TABLE(CAST(v_target_arr AS target_arr)) arr;
         DBMS_OUTPUT.enable;
         DBMS_OUTPUT.PUT_LINE('p_out_count ' || v_rec_count);
         DBMS_OUTPUT.PUT_LINE('v_count ' || v_count);
    END;
    Output is
    p_out_count 0
    v_count 10140
    Expected output
    p_out_count 10140
    v_count 10140

  • Ora-1460 during select using table(cast(type))

    Hi all!
    I've got a problem with a query that fails with a ora-1460 at random time intervals. This is a 10.2.0.3 version database running on a sun os.
    We've managed to reproduce this error controlled when running an analyze on the table in question at the same time this query runs.
    The error looks like this:
    Unexpected system error, see server log for details. Root message is: org.apache.ojb.broker.PersistenceBrokerSQLException: * SQLException during execution of sql-statement: * sql statement was 'SELECT A0.ID,A0.LOCK_VERSION,A0.CLASS_NAME,A0.DESCRIPTION,A0.NAME,A0.EXTERNAL_ID,A0.ORDER_NUMBER,A0.LEVEL_ID,A0.ROOT_AH_ID,A0.DIFF_END_DATE,A0.DIFF_START_DATE,A0.SUPPORTED_BY_ASS_CAL,A0.CATEGORY_ROLE_ID FROM CATEGORY A0 WHERE A0.ID IN (select /*+ cardinality(1) */ * from table(cast( ems_string_to_table(?) as ems_table_of_number_type ))union select /*+ cardinality(1) */ * from table(cast( ems_string_to_table('') as ems_table_of_number_type)))' * Exception message is [ORA-01460: unimplemented or unreasonable conversion requested ] * Vendor error code [1460] * SQL state code [72000]
    ems_string_to_table is a function thats populates a type with a unknown number of values. Though, the length of the string never exceeds 4k.
    ems_table_of_number_type is a type define as "table of numbers".
    Has anybody seen this error before, or have any idea why this should be?
    Best regards,
    Heyers

    There is an IN clause constaraint i.e max number of characters you can pass from Oracle .Please check your select inner query which might be resulting to cross more than the boundary IN clause ,

  • Invalid datatype in OCI call ?

    Hello,
    Why i got
    ORA-01024: invalid datatype in OCI call
    when i'm trying to select a clob column from a table? that column contains 'hello world'. i don't know what causes this error..
    Thanks

    ORA-01024:     invalid datatype in OCI call
    Cause:     An OCI program call specified an invalid datatype. In OCI calls, Oracle datatypes are specified as numbers between 1 and 7.
    Action:     Check the datatype description and enter the correct number for the datatype. Please use search, before posting.

Maybe you are looking for

  • Deletion of digit in internal table field

    Hi friends,               i have internal table itab.That itab contains the field A the contents of a is "@01' i want to delete that @ before uploading.Where can i put that logic after uploading function or anywhere? and tell me the best logic to del

  • Abap internal tabel to xml

    Hi All, I have generated xml file from internal table and need to display in excel as a report..but i need to add the custom column names and other formating options..could any one help  me how to generate the xml with those column headings or attrib

  • ODI-1217 session fails with return code 904

    Hi all, I am anil, I new to ODI, can any one help me in it. I have just created a one on one mapping, and then executed it, and I am getting "ODI-1217 session fails with return code 904" this error, what to do, why it happens, can any have any idea.

  • Pricing change in sales documents

    Hi, Anyone aware of a FM that can change (redetermine) the prices for all sales documents whenever there is a change in the pricing condition records? I want to pass sales document numbers to an FM...and if there is a update in the condition record o

  • Transaction codes/path for Customer(Sold To) and related associations

    Hello all, being very new to this, can any one tell me the transactions/path to add the records in tables KNVS-Customer master shipping data KNVP-Customer master partner functions(Sold to Ship to association) KNVV-Customer master sales data TVKBT-Org