Proble creating Table Type = Select in 10gR3

In a very simple example case I have a customers table that I am trying to create a Table Type of Select in the physical layer.
Using the Admin tool I create "New Physical tabe" and enter select * from customer where region = 'East'
If I "Update All Row Counts" it now shows 56 rows - which is correct
If I try and "view data" I get an error
[nQSError: 17001] Oracle Error Code: 936, messgae: ORA-00936: missing expression at OCI cal OCIStmtExecute.
[nQSError: 17010] SQL Statement preparation failed.
If I deploy the view I can go to sqlplus and select from it.
I have tried qualifying table name and selecting specific columns - I know its not a permission issue and presumably the fact that it counted rows correctly confirms it must have generated correct SQL.
I'm puzzled - what am I missing here?

This is standard behavior..Update Row Count work fine since SELECT COUNT (*) FROM (select * from customer where region = 'East') is a valid SQL, View Data doesn't work since your columns aren't named, so OBI cant select col1, col2, etc.
Hope this explains.
Michael
Edited by: mkooloos on Jan 17, 2011 3:48 PM

Similar Messages

  • Creating table type

    Hi,
    I am new to ABAP, can any one tell me how to create Table type for a database table in se11.
    Example, I created a table ZEMP in se11, now I want to create a table type for this table. How can I do this?
    Thanks,
    Satish

    In SE11,  on initial screen, select Data Type radiobutton, enter your table type name, click create, select Table Type radiobutton, enter the attributes, click save.
    Regards,
    Rich Heilman

  • Physical tables - table type 'select' query

    Hello,
    I've been playing around with the migrateEUL tool and have noticed that all Discoverer custom folders get translated into Physical Tables with a table type of 'select' as I would expect.
    What I'm not sure about is the location in which it places these objects.
    With a database data source called 'Video Store Tutorial' at the top level, a Physical Schema of VIDEO5 gets created. Inside this Physical Schema are the regular tables. The 'select' tables are placed as siblings to the Physical Select folder, and not as a child object like the rest of the tables.
    Can someone please comment on what is the best practice regarding locating these 'select' tables (as children of the Physical Schema or children of the Database).
    If I create a new table of table type 'select' I can only do so by right clicking the Physical Schema and choosing 'New Physical Table', thereby making this new object a child of the schema. I cannot make it a child of the database directly - although I can drag the object out from within the Physical Schema and drop it on the database name, to make it so.
    Cheers,
    John

    Hi John,
    There not really an absolut truth for this. Normaly you would make 'single schema' view siblings of there physical schema and 'multi schema' views direct siblings. It doesn't influence performances if they use the same connection pool. It's just a matter of taste.
    regards
    John
    http://obiee101.blogspot.com/

  • DB Link Create table as select

    I ve a query which starts with create table as select ..
    When I run the select part of the query, it runs in 2 sec.
    But the whole query runs in 10min. It is fetching data from dblink.
    I think if select can finish in 2 sec. All is left to do is create table and insert.
    Why is takin so long?
    Oracle DB version 9.2.0.8

    When I run the select part of the query, it runs in 2 sec.Does the select finish in 2 seconds or does it start returning rows in 2 seconds?
    Big difference.

  • Create table as select (CTAS)statement is taking very long time.

    Hi All,
    One of my procedure run a create table as select statement every month.
    Usually it finishes in 20 mins. for 6172063 records and 1 hour in 13699067.
    But this time it is taking forever even for 38076 records.
    When I checked all it is doing is CPU usage. No I/O.
    I did a count(*) using the query it brought results fine.
    BUT CTAS keeps going on.
    I'm using Oracle 10.2.0.4 .
    main table temp_ip has 38076
    table nhs_opcs_hier has 26769 records.
    and table nhs_icd10_hier has 49551 records.
    Query is as follows:
    create table analytic_hes.temp_ip_hier as
    select b.*, (select nvl(max(hierarchy), 0)
    from ref_hd.nhs_opcs_hier a
    where fiscal_year = b.hd_spell_fiscal_year
    and a.code in
    (primary_PROCEDURE, secondary_procedure_1, secondary_procedure_2,
    secondary_procedure_3, secondary_procedure_4, secondary_procedure_5,
    secondary_procedure_6, secondary_procedure_7, secondary_procedure_8,
    secondary_procedure_9, secondary_procedure_10,
    secondary_procedure_11, secondary_procedure_12)) as hd_procedure_hierarchy,
    (select nvl(max(hierarchy), 0) from ref_hd.nhs_icd10_hier a
    where fiscal_year = b.hd_spell_fiscal_year
    and a.code in
    (primary_diagnosis, secondary_diagnosis_1,
    secondary_diagnosis_2, secondary_diagnosis_3,
    secondary_diagnosis_4, secondary_diagnosis_5,
    secondary_diagnosis_6, secondary_diagnosis_7,
    secondary_diagnosis_8, secondary_diagnosis_9,
    secondary_diagnosis_10, secondary_diagnosis_11,
    secondary_diagnosis_12, secondary_diagnosis_13,
    secondary_diagnosis_14)) as hd_diagnosis_hierarchy
    from analytic_hes.temp_ip b
    Any help would be greatly appreciated

    Hello
    This is a bit of a wild card I think because it's going to require 14 fill scans of the temp_ip table to unpivot the diagnosis and procedure codes, so it's lilkely this will run slower than the original. However, as this is a temporary table, I'm guessing you might have some control over its structure, or at least have the ability to sack it and try something else. If you are able to alter this table structure, you could make the query much simpler and most likely much quicker. I think you need to have a list of procedure codes for the fiscal year and a list of diagnosis codes for the fiscal year. I'm doing that through the big list of UNION ALL statements, but you may have a more efficient way to do it based on the core tables you're populating temp_ip from. Anyway, here it is (as far as I can tell this will do the same job)
    WITH codes AS
    (   SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            primary_PROCEDURE       procedure_code,
            primary_diagnosis       diagnosis_code,
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_1    procedure_code,
            secondary_diagnosis_1    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_2    procedure_code ,
            secondary_diagnosis_2    diagnosis_code     
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_3    procedure_code,
            secondary_diagnosis_3    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_4    procedure_code,
            secondary_diagnosis_4    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_5    procedure_code,
            secondary_diagnosis_5    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_6    procedure_code,
            secondary_diagnosis_6    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_7    procedure_code,
            secondary_diagnosis_7    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_8    procedure_code,
            secondary_diagnosis_8    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_9    procedure_code,
            secondary_diagnosis_9    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_10  procedure_code,
            secondary_diagnosis_10    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_11  procedure_code,
            secondary_diagnosis_11    diagnosis_code
        FROM
            temp_ip    
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_12  procedure_code,
            secondary_diagnosis_12    diagnosis_code
        FROM
            temp_ip
    ), hd_procedure_hierarchy AS
    (   SELECT
            NVL (MAX (a.hierarchy), 0) hd_procedure_hierarchy,
            a.fiscal_year
        FROM
            ref_hd.nhs_opcs_hier a,
            codes pc
        WHERE
            a.fiscal_year = pc.hd_spell_fiscal_year
        AND
            a.code = pc.procedure_code
        GROUP BY
            a.fiscal_year
    ),hd_diagnosis_hierarchy AS
    (   SELECT
            NVL (MAX (a.hierarchy), 0) hd_diagnosis_hierarchy,
            a.fiscal_year
        FROM
            ref_hd.nhs_icd10_hier a,
            codes pc
        WHERE
            a.fiscal_year = pc.hd_spell_fiscal_year
        AND
            a.code = pc.diagnosis_code
        GROUP BY
            a.fiscal_year
    SELECT b.*, a.hd_procedure_hierarchy, c.hd_diagnosis_hierarchy
      FROM analytic_hes.temp_ip b,
           LEFT OUTER JOIN hd_procedure_hierarchy a
              ON (a.fiscal_year = b.hd_spell_fiscal_year)
           LEFT OUTER JOIN hd_diagnosis_hierarchy c
              ON (c.fiscal_year = b.hd_spell_fiscal_year)HTH
    David

  • Identify tablspace in create table as select

    I am trying to run a create table as select query that specifies which tablspace to create the table in. When I run the query below I get an error, any ideas?
    create table roi_call_record_backup as (select * from prod.roi_call_record)
    tablespace roi_data01;
    null

    Try this ...
    create table roi_call_record_backup
    tablespace roi_data01
    as
    (select * from prod.roi_call_record)
    null

  • How to create table type in SAP3.1i ?

    Hi Friends,
    Is it posible to create table type in SAP 3.1i server ?

    Hi amit,
    I think there were no table types in 3.1i. Still you can define a structured table, i.e.
    DATA: BEGIN OF SORT_SPFLI OCCURS 100,
            CARRID   LIKE SPFLI-CARRID,
            CONNID   LIKE SPFLI-CONNID,
            CITYFROM LIKE SPFLI-CITYFROM,
            CITYTO   LIKE SPFLI-CITYTO,
            SFLIGHT  LIKE SORT_SFLIGHT OCCURS 100,
          END OF SORT_SPFLI.
    You can use field-symbols, but no loop assigning.
    What is it you want to do?
    Anyway: Have fun with good old 3.1 - I put my old docu CD in the trash recently.
    Regards
    Clemens

  • Create Table type

    Hi All,
    How to create table type of record type which is declared in another package. For example,
    package a has record type lr_rec_type. i have to create table type of lr_rec_type in package b. how can this be done
    Thanks and Regards,
    Mahesh
    Edited by: magu on May 4, 2009 2:00 PM

    Are you looking for this?
    satyaki>
    satyaki>create or replace package bb_pack
      2  is
      3    type a is table of number;
      4    b a;
      5  end;
      6  /
    Package created.
    Elapsed: 00:00:01.07
    satyaki>
    satyaki>ed
    Wrote file afiedt.buf
      1  declare
      2    aa bb_pack.a;
      3  begin
      4    dbms_output.put_line('Executes');
      5* end;
    satyaki>/
    Executes
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>Regards.
    Satyaki De

  • How to create table type

    I have created table type like this..
    type type_cname_tab is table of varchar2(20)
    index by binary_integer;
    i want to know that only 20 columns are added in this table type..

    i want to know that only 20 columns are added in this table type.. Maybe you may change it to a VARRAY type?
    Then
    SQL> declare
       type type_cname_tab is varray (20) of varchar2 (20);
       cname   type_cname_tab := type_cname_tab ();
    begin
       cname.extend (20);
    end;
    PL/SQL procedure successfully completed.
    But
    SQL> declare
       type type_cname_tab is varray (20) of varchar2 (20);
       cname   type_cname_tab := type_cname_tab ();
    begin
       cname.extend (21);
    end;
    Error at line 11
    ORA-06532: Subscript outside of limit
    ORA-06512: at line 6

  • Issue while writing a query in table type select.in the physical layer

    Hi gurus,
    I am actually trying to create a table using select in the physical layer..... i acutally am not aware what it is called but its when i click a table in the physical layer i have an option table type and i chose select which allows me type my query..the query is
    Select
    coln name(which is a lengthly list of conversion) AS column_name
    From Table name.
    when i view the data rom the physical layer everthing seems to be fine. but when i try to view the data in the frnt end it gives me an error maximum length is too long than 128....
    i am aware of this issue the sql server allows only column of length 128..but none of my column length is greater than 128..
    Could you please help me in this
    Many thanks in advance

    hi veeravalli ,
    Thanks for the reply....actually the corresponding reports for this have already been prepared...i created a view in the backend with the same select which i wrote before and and tried calling the view from her.. i have viewed the data and all is perfect...but when i try viewing it from the front end it error saying invaild object name select * from databasename.dbo.View_name...but i have checked the view exists in the backend...
    Thanks in advance....

  • CREATE TABLE AS SELECT PROBLEM

    Dear members,
    I created a table whose definition is a select query.
    for ex: I created a table xx_customer as :
    create table xx_customer as
    select customer_name,customer_number
    from xx_ar_customer
    where org_id = '87'when i run the query
    select  count(*)
    from xx_customer;The count was 120 records.
    This was done as part of performance tunning.
    Now few days after the table xx_customer was created few records were inserted into table xx_ar_customer for org_id = '87' .
    So ideally the count should be more than 120 but its not.
    when i run the same query again
    select  count(*)
    from xx_customer;I get count as 120 Records which is wrong.
    It looks like it not refreshing data. If i run the table definition query i am getting count as more than 120 but if i do a select on the table count is still 120.
    Any ideas?
    Thanks
    Sandeep

    Hi,
    795291 wrote:
    I cant create view. I tried that before. If i use view then my query runs for a very long time and if i create a table then the run time is reduced by half :)
    So if we create Table as a select statement, then will it give data at the point of time it was created? Exactly!
    Will it not give latest data?Not unless the latest data happens to be the same as the data at the time it was created.
    CREATE TABLE AS is kind of like putting a photograph of yourself on your web site. If you smile, that doesn't mean the picture smiles.
    CREATE VIEW is kind of like hanging a video camea from your hat, and streaming the output to your web page. As soon as you smile, the picture smiles. It's more expensive than a still picture.
    A compromise apprioach is a Materialized View , which is really a type of table. Like any other table, it occupies space, and is relatively fast to use. You can define a materialized view to be refreshed at regular intervals (once a day, once an hour, once a week, ...) or whenever there is a change in the base table(s).

  • [Solved]SIMPLE Question ON "CREATE TABLE as SELECT".

    Hi there,
    I was wondering how to work it out smartly and briefly.
    For example, I already have a "tableA" as following.
    tableA
    id name
    1 name1
    2 name2
    create table tmp as
    select id, name from tableA;
    It will create the tmp table successfully.
    If I want to add a new column 'tel' in tmp table,
    I can run as following.
    create table tmp as
    select id, name, 999 tel, 'aaaaaaaaa' ps from tableA;
    It will add 'tel NUMBER' column and 'ps char(9)' in tableA.
    If I want to add 'col varchar(50)' in tableA,
    I do not want to make a string which contains 50 characters in Select command.
    How can I make it work in a smart way?
    Thanks.
    Phil
    Message was edited by:
    user615355

    Is there a reason that you need this to be in a single statement? You would normally be better served here with a separate CREATE TABLE and INSERT (possibly as a direct path operation).
    That said, you could use the CAST operator, i.e.
    SCOTT @ jcave102 Local> create table a as select cast('a' as varchar2(50)) col1 from dual;
    Table created.
    Elapsed: 00:00:00.48
    SCOTT @ jcave102 Local> desc a;
    Name                                                  Null?    Type
    COL1                                                           VARCHAR2(50)
    SCOTT @ jcave102 Local> Justin

  • Create Table As Select From Select

    Table_2
    CREATE TABLE TABLE_2
    "ID" VARCHAR2(10),
    "EXCL" VARCHAR2(10),
    "SEQ" NUMBER(10)
    Inserts
    INSERT INTO TABLE_2 (ID ,EXCL ,SEQ ) VALUES ('123456' ,'' ,1 );
    INSERT INTO TABLE_2 (ID ,EXCL ,SEQ ) VALUES ('123456' ,'EX' ,2 );
    INSERT INTO TABLE_2 (ID ,EXCL ,SEQ ) VALUES ('123456' ,'' ,3 );
    INSERT INTO TABLE_2 (ID ,EXCL ,SEQ ) VALUES ('321654' ,'' ,4 );
    INSERT INTO TABLE_2 (ID ,EXCL ,SEQ ) VALUES ('123798' ,'EX' ,5 );
    INSERT INTO TABLE_2 (ID ,EXCL ,SEQ ) VALUES ('123785' ,'' ,6 );
    INSERT INTO TABLE_2 (ID ,EXCL ,SEQ ) VALUES ('654787' ,'' ,7 );
    INSERT INTO TABLE_2 (ID ,EXCL ,SEQ ) VALUES ('654787' ,'' ,8 );
    INSERT INTO TABLE_2 (ID ,EXCL ,SEQ ) VALUES ('654787' ,'' ,9 );
    INSERT INTO TABLE_2 (ID ,EXCL ,SEQ ) VALUES ('985217' ,'EX' ,10 );
    INSERT INTO TABLE_2 (ID ,EXCL ,SEQ ) VALUES ('985217' ,'' ,11 );
    INSERT INTO TABLE_2 (ID ,EXCL ,SEQ ) VALUES ('937158' ,'' ,12 );
    INSERT INTO TABLE_2 (ID ,EXCL ,SEQ ) VALUES ('937158' ,'' ,13 );
    Select *
    ID EXCL SEQ
    123456 1
    123456 EX 2
    123456 3
    321654 4
    123798 EX 5
    123785 6
    654787 7
    654787 8
    654787 9
    985217 EX 10
    985217 11
    937158 12
    937158 13
    I need to create a table based on for all Records which are EXC not null - but I need to bring through all the records which have the same ID as EXC not null field.
    Desired output: -
    ID EXCL SEQ
    123456 1
    123456 EX 2
    123456 3
    123798 EX 5
    985217 EX 10
    985217 11
    Any ideas folks?

    Hi,
    Here's one way:
    CREATE     TABLE     table_x
    AS
    SELECT     *
    FROM     table_2
    WHERE     id     IN (
                     SELECT  id
                     FROM    table_2
                     WHERE   excl     IS NOT NULL
    ;By the way, whenever you post formatted text (such as query results) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    You'll get better answers quicker if people can read:ID EXCL SEQ
    123456 1
    123456 EX 2
    123456 3
    123798 EX 5
    985217 EX 10
    985217 11
    (for example) rather than
    Deeds_2001 wrote:
    ID EXCL SEQ
    123456 1
    123456 EX 2
    123456 3
    123798 EX 5
    985217 EX 10
    985217 11

  • To make the query more efficient (create table wiht select command)

    Hi,
    I have written this query to create another table, but it takes approx two hours while both tables are indexed with 891353, 769023, i have used the following query.
    create table source1 as select a.idx, a.source from tt a where a.idx not in (select b.idx from ttt b)
    thanks

    Try this one if you're on oracle 8i or older
    create table source1 as
      select a.idx, a.source
        from tt a
       where not exists (select null from ttt b where a.idx = b.idx)

  • Create table as select statement.

    Hello Oracle Gurus,
    I am trying to create a table using select * from other table.
    The procedure that I am following is this:-
    I have a temp table whose signature is on commit delete rows.
    I insert records in this table.
    when I do select * from temp_table,perm_table I get some rows.
    then I try to create a result_table using this
    CREATE TABLE result_table
    AS SELECT * FROM temp_table,perm_table;
    I see the table in created but number of records in 0. Can anyone please explain where commit takes place while sequence in this query occurs.
    Thanks
    Edited by: user10696492 on Nov 10, 2009 8:47 AM

    Create table statement is a ddl - so an implicit commit is performed before the create statement begins. The implicit commit will delete all the rows from the temp table. If it is feasible change the definition of the temp table to on commit preserve rows.

Maybe you are looking for