Create table from view giving error

i am trying to creating a table from view it is giving following error. can you please help
create table jd as
select * from A.ab_v where 1=2;
error
ORA-01723
zero columns not allowed

As others already pointed out you have NULL as view column(s). You need to either modify view and use CAST(NULL AS desired-type). For example:
SQL> create or replace
  2    view v1
  3      as
  4        select  null new_date
  5          from dual
  6  /
View created.
SQL> create table tbl
  2    as
  3      select  *
  4        from  v1
  5  /
    select  *
ERROR at line 3:
ORA-01723: zero-length columns are not allowed
SQL> create or replace
  2    view v1
  3      as
  4        select  cast(null as date) new_date
  5          from dual
  6  /
View created.
SQL> create table tbl
  2    as
  3      select  *
  4        from  v1
  5  /
Table created.
SQL> drop table tbl
  2  /
Table dropped.
SQL> create or replace
  2    view v1
  3      as
  4        select  cast(null as number) new_number
  5          from  dual
  6  /
View created.
SQL> create table tbl
  2    as
  3      select  *
  4        from  v1
  5  /
Table created.
SQL>  Or list individual view columns with NULL CASTing in CTAS:
SQL> create or replace
  2    view v1
  3      as
  4        select  null new_date
  5          from dual
  6  /
View created.
SQL> create table tbl
  2     as
  3       select  cast(new_date as date) new_date
  4         from  v1
  5  /
Table created.
SQL> desc tbl
Name                                      Null?    Type
NEW_DATE                                           DATE
SQL> set null NULL
SQL> select  *
  2    from  tbl
  3  /
NEW_DATE
NULL
SQL> SY.

Similar Messages

  • How to see DDL script(create table) from view

    i want to view create table script(DDL command)
    can u suggest me any view for that.

    Hi
    There's no view where the DDL statement is directly available. It must be reconstructed from many views...
    If you use 9i the simpler way to do that is with DBMS_METADATA. Below and example....
    SQL> SET LONG 1000000
    SQL> SELECT dbms_metadata.get_ddl('TABLE','EMP') FROM dual;
    DBMS_METADATA.GET_DDL('TABLE','EMP')
    CREATE TABLE "SCOTT"."EMP"
    ( "EMPNO" NUMBER(4,0) NOT NULL ENABLE,
    "ENAME" VARCHAR2(10),
    "JOB" VARCHAR2(9),
    "MGR" NUMBER(4,0),
    "HIREDATE" DATE,
    "SAL" NUMBER(7,2),
    "COMM" NUMBER(7,2),
    "DEPTNO" NUMBER(2,0),
    CONSTRAINT "EMP_PK" PRIMARY KEY ("EMPNO")
    USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "USERS" ENABLE,
    CONSTRAINT "EMP_DEPT_FK" FOREIGN KEY ("DEPTNO")
    REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
    ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "USERS"
    Chris

  • ADF BC creating table from view

    This is plain stupid all this crap of IDE's and Frameworks and things alike. I just loose a few days of work trying to do the simplest thing, create a table from a BC view. I did what the tutorials say, just drag&drop a %$$/& data control from the data control pallete and so on...
    The IDE just add a lot of libraries to my project, changed a bunch of things in web.xml and God knows where more, and the result is this:
    java.lang.ClassCastException: oracle.adfinternal.view.faces.uinode.UIComponentUINode     at oracle.adfinternal.view.faces.uinode.UIXComponentUINode.__getAdapter(UIXComponentUINode.java:435)     at oracle.adfinternal.view.faces.uinode.UINodeRendererBase.encodeBegin(UINodeRendererBase.java:29)     at oracle.adf.view.faces.component.UIXComponentBase.encodeBegin(UIXComponentBase.java:528)     at javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java:584)     at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:471)     at oracle.adf.view.faces.webapp.UIXComponentTag.doStartTag(UIXComponentTag.java:82)     at loginPage.jspService(_loginPage.java:70)     [loginPage.jsp]     at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.0.0) ].http.OrionHttpJspPage.service(OrionHttpJspPage.java:60)     at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:416)     at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:478)     at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:401)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:719)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher.java:298)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher.java:42)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher$2.oc4jRun(ServletRequestDispatcher.java:205)     at oracle.oc4j.security.OC4JSecurity.doPrivileged(OC4JSecurity.java:283)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:209)     at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)     at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:147)     at oracle.adfinternal.view.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:134)     at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)     at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)     at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)     at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:264)     at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:151)     at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:123)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)     at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:332)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:17)     at oracle.adfinternal.view.faces.webapp.FacesFilter.doFilter(FacesFilter.java:89)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:627)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:218)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:119)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)     at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)     at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:230)     at oracle.oc4j.network.ServerSocketAcceptHandler.access$800(ServerSocketAcceptHandler.java:33)     at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:831)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:298)     at java.lang.Thread.run(Thread.java:595)
    What's the use of these tools? If i were to made this on my one i had my work done by know instead of loosing some days of work...
    Anybody could help here

    So basically that means that instead of being me, the programmer, that tells the machine what to do, it's the machine, by means of a framework, that tells me what to do... So much for the fun and criativity of being a programmer, now we're supposed to be some simple technocrats that assemble code in a production-line instead of artists that create some nice piece of work that not only works but it's beautifull too. I think i'm getting too old for this, maybe it's time to move up onto management...
    I don't resist to tell this little story:
    Once upon a time, in mid-ages Rome, a wise bishop was walking down the lane when he sees two workers laying down bricks. He ask one of then;
    - Good men , what are you doing?
    - Laying down bricks, the man answers...
    And then asks the second man,
    - And you, my good man, what are you doing?
    - I'm building a Cathedral...
    I allways think of myself as "building Cathedrals", now after all these years i have to just "lay out bricks"?

  • Can create view, but cannot create table / materialized view: Xpath is null

    Hi all,
    We recently moved some XML documents into the database in an XMLType column and want to query the data. I've been writing some queries and turning them into materialized views. I got to one query, and something really strange is happening. My query returns the expected results, but I am getting an error when I try to create a materialized view out of it. Even stranger, I can create a view out of it, and I can manually insert its data into an existing table, but I cannot create a materialized view out of it and I cannot create a table out of it. Here is a brief summary, please let me know if anyone has suggestions.
    Issuing the following commands fails in SQLDeveloper
    -- Creating a materialized view out of the query fails:
    create materialized view element REFRESH COMPLETE ON DEMAND as [query];
    Error at Command Line:1 Column:1 SQL Error: ORA-31063: XPath compilation failed: Xpath is null.
    -- Creating a table out of the query with the following shortcut fails:
    create table element as [query];
    Error at Command Line:1 Column:1 SQL Error: ORA-31063: XPath compilation failed: Xpath is null.
    Issuing the following commands in SQLDeveloper works fine:
    -- Creating a view out of the query works:
    create or replace view element as [query];
    -- Creating a blank table from the query and then inserting data works:
    create table element as select * from [query] where 1 = 2;
    insert into element select * from [query];
    Here is a simplified version of the query...
    I have changed the names around, and cut the query down so maybe it will be a little easier to understand. I did confirm that this query is also having the same symptoms described above. Since I changed the names, executing the query returns no results. However creating a materialized view out of the query still fails with the 'Xpath is null' error.
    create materialized view element REFRESH COMPLETE ON DEMAND as
    select
    m.resource_id,
    xml.*
    from metadata_sources m,
    xmltable(
    'for $i in /metadata/app//*[(self::elem1 or self::elem2) and (parent::form or parent::subform)]
    let $formName := if($i/parent::subform) then $i/../../@name else $i/../@name
    let $subformName := if($i/parent::subform) then $i/../@name else ""
    return <data
    appId="{$i/ancestor::app[1]/idField}"
    formName="{$formName}"
    subformName="{$subformName}"
    elemName="{$i/@name}"></data>' passing m.xml_content
    columns
    app_id NUMBER path '@appId',
    form_name VARCHAR2(50 char) path '@formName',
    subform_name VARCHAR2(50 char) path '@subformName',
    elem_name VARCHAR2(50 char) path '@elemName'
    ) xml;
    Edited by: user11949534 on Feb 22, 2013 1:55 PM

    As far as creating a structured index, I was under the impression that I would need to then register an XSD. No, you can use it without an XML schema.
    How about a regular relational view, with an underlying xml index?
    That way you also eliminate the need for an explicit refresh step as you would then be querying real-time data, as if it were relational data.
    For example :
    Connected to:
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    SQL> create table tmp_xml of xmltype ;
    Table created.
    SQL> insert into tmp_xml values (
      2    xmlparse(document '<root><item id="1">ABC</item><item id="2">DEF</item></root>')
      3  ) ;
    1 row created.
    SQL> insert into tmp_xml values (
      2    xmlparse(document '<root><item id="3">GHI</item><item id="4">JKL</item></root>')
      3  ) ;
    1 row created.
    SQL> create or replace view tmp_xml_v as
      2  select x.item_id, x.item_val
      3  from tmp_xml
      4     , xmltable(
      5         '/root/item' passing object_value
      6         columns item_id  number      path '@id'
      7               , item_val varchar2(3) path '.'
      8       ) x
      9  ;
    View created.
    SQL> create index tmp_xml_sxi on tmp_xml (object_value)
      2  indextype is xdb.xmlindex
      3  parameters (q'#
      4  XMLTABLE tmp_xml_xtb '/root/item'
      5  COLUMNS item_id  number      path '@id'
      6        , item_val varchar2(3) path '.' #'
      7  ) ;
    Index created.
    SQL> exec dbms_stats.gather_table_stats(user, 'TMP_XML');
    PL/SQL procedure successfully completed.
    SQL> set autotrace on explain
    SQL> set lines 200
    SQL> select * from tmp_xml_v ;
       ITEM_ID ITE
             3 GHI
             4 JKL
             1 ABC
             2 DEF
    Execution Plan
    Plan hash value: 4168126828
    | Id  | Operation                    | Name                   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                        |     4 |   164 |     3   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS                |                        |       |       |            |          |
    |   2 |   NESTED LOOPS               |                        |     4 |   164 |     3   (0)| 00:00:01 |
    |   3 |    INDEX FULL SCAN           | SYS_C009273            |     2 |    34 |     1   (0)| 00:00:01 |
    |*  4 |    INDEX RANGE SCAN          | SYS30366_30367_OID_IDX |     2 |       |     0   (0)| 00:00:01 |
    |   5 |   TABLE ACCESS BY INDEX ROWID| TMP_XML_XTB            |     2 |    48 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("TMP_XML"."SYS_NC_OID$"="SYS_SXI_0"."OID")

  • Recovering table from Flashback getting error

    Recovering table from Flashback getting error what is the reson
    1* FLASHBACK TABLE "BIN$e7TIAEKgSYO2WJ0L+hNuTA==$0" TO BEFORE DROP
    SQL> /
    FLASHBACK TABLE "BIN$e7TIAEKgSYO2WJ0L+hNuTA==$0" TO BEFORE DROP
    ERROR at line 1:
    ORA-38312: original name is used by an existing object

    This droped object original name is now taken by some other object in database so u can give this cmd like
    FLASHBACK TABLE TEST TO BEFORE DROP RENAME TO TEST2;
    it recover the table test and give the name as test2 because test table is already exist and that is created while this table is in recyclebin.

  • Inserting the column values into table from view through procedure!!!

    below is my example code
    Create or replace procedure test_proc
    is
    cursor test_cur is
    select a.col1 , b.col2, c.col3, d.col4, e.col5
    from tableA a, tableB b, tableC c, tableD d, tableE e;
    test_cur_rec test_cur%rowtype;
    Begin
    insert into test_stg ( col1, col2, col3, col4, col5, col6, col7)
    Values ( test_cur_rec. col1,
    test_cur_rec .col2,
    test_cur_rec .col3,
    test_cur_rec .col4,
    test_cur_rec .col5
    -- col6, col7 );
    create view test2 (
    select f.col6, g.col7 from tableF f,tableG g);
    I m trying to insert values into the table test_stg but for col6 and col7 i need to get the data from the view test2.
    In simple word, all i need to do is get the 2 columns data from view and insert into a table through procedure. The above code is the example which looks very much like my actual code.
    How do i accomplish this task ??

    well there is joining condition for a, b,c ,d, e tables, i have not mentioned here. The where condition has nothing to do with the other two columns of the view.
    There is no relation ship between the these tables the view. The col 6 and 7 i m inserting from view is sysdate timestamp and the job_id number.
    so its pretty straight forward insertion into the table from view columns. These two columns has just one row with id number and timestamp. so i need to insert these data into the the table when i run a procedure.
    Thank you so much!!!

  • Error while creating datasource from view ZBSIS_VIEW

    Hi all,
    I could not create  the datasource on the database table BSIS as it said "Invalid extract structure template BSIS of Datasource". I had suggestions that I should create a view and then create the Datasource on it. So I created the view and tried. But still I am facing an error message while creating datasource from custom Database View ZBSIS_VIEW.
    "Invalid extract structure template ZBSIS_VIEW of DataSource"
    Can anyone help on this regard.
    thanks.

    Hi,
    Yes. You need a create a view on tables BSIS, BKPF and T001 as the currency/quantity fields in BSIS have reference fields from the other 2 tables.
    In BSIS, in the currency/quantity fields tab, you have some ref tables and fields. You would need to include these tables and join in the view. You would also need to include the ref fields like WAERS, HWAE2, HWAE3, etc in the view. Then you would be able to create the datasource.

  • Error while creating table from csv file

    I am getting an error while creating a table using 'Import Data' button for a csv file containing 22 columns and 8 rows. For primary key, I am using an existing column 'Line' and 'Not generated' options.
    ORA-20001: Excel load run ddl error: drop table "RESTORE" ORA-00942: table or view does not exist ORA-20001: Excel load run ddl error: create table "RESTORE" ( "LINE" NUMBER, "PHASE" VARCHAR2(30), "RDC_MEDIA_ID" VARCHAR2(30), "CLIENT_MEDIA_LABEL" VARCHAR2(30), "MEDIA_TYPE" VARCHAR2(30), "SIZE_GB" NUMBER, "RDC_IMG_HD_A" NUMBER, "START_TECH" VARCHAR2(30), "CREATE_DATE" VARCHAR2(30), "RDC_MEDIA_DEST" VARCHAR2(30), "POD" NUMBER, "TAPE" NUMBER, "ERRORS_YN" VA
    Any idea?

    I am getting an error while creating a table using 'Import Data' button for a csv file containing 22 columns and 8 rows. For primary key, I am using an existing column 'Line' and 'Not generated' options.
    ORA-20001: Excel load run ddl error: drop table "RESTORE" ORA-00942: table or view does not exist ORA-20001: Excel load run ddl error: create table "RESTORE" ( "LINE" NUMBER, "PHASE" VARCHAR2(30), "RDC_MEDIA_ID" VARCHAR2(30), "CLIENT_MEDIA_LABEL" VARCHAR2(30), "MEDIA_TYPE" VARCHAR2(30), "SIZE_GB" NUMBER, "RDC_IMG_HD_A" NUMBER, "START_TECH" VARCHAR2(30), "CREATE_DATE" VARCHAR2(30), "RDC_MEDIA_DEST" VARCHAR2(30), "POD" NUMBER, "TAPE" NUMBER, "ERRORS_YN" VA
    Any idea?

  • Getting error while creating table from one database to other.

    Hi,
    We are getting below error while creating the table from one database to other.
    SQL> create table fnd_lobs parallel compress as select * from [email protected];
    create table fnd_lobs parallel compress as select * from [email protected]
    ERROR at line 1:
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    ORA-02063: preceding line from EEXIT2TEST
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    ORA-02063: preceding line from EEXIT2TEST
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    ORA-02063: preceding line from EEXIT2TEST
    ORA-01555: snapshot too old: rollback segment number 28 with name "_SYSSMU28$"
    too small
    Regards,
    Bhatia

    hi
    what are the apps version local and remote database???
    Snapshot too old errors occur because Oracle can 't reconstruct a consistent
    image of a block for the purposes of a consistent read.
    I feel at remote database, you are using UNDO, it will be rather easy to iincrease the undo retention time or increase the undo tablespace size.. if you are dealing with roll back segments, you may have rollback segments whose optimal values are too small...
    increase roll back segments size and select again then
    the following metalink notes might be helpful
    ORA-01555 "Snapshot too old" - Detailed Explanation Doc ID: 40689.1
    How To Avoid ORA-01555: Snapshot Too Old When Running PAAPIMP Doc ID: 603259.1
    OERR: ORA 1555 "snapshot too old (rollback segment too small)" Doc ID: 18954.1

  • Create Table from Spreadsheet Error / Privileges

    Using Application Express 2.2.0.00.32.
    I can create a table using the Object Browser or via the SQL Command utility. If I try to load data from a csv or create an application from a spreadsheet, I get the following:
    ORA-20001: Unable to create modules. ORA-20001: create_table error: ORA-20001: Excel load run ddl error: ORA-01031: insufficient privileges
    I've tried searching the forums, but haven't found the needle in this haystack yet.
    Probably a common problem but it has me perplexed.
    What piece of the puzzle am I not understanding?
    Thanks.
    cagora

    Then make sure the parsing schema of that other workspace has create table privilege granted directly to it. Better yet, review the system privileges of the working schema and make sure the broken schema has the same privs. Do not grant privileges using roles.
    Scott

  • Staging different from target giving error

    Hi Friends.
    when i am making staging different from target its giving error not enough privillege to create table.
    What changes i should do so that my IKM will work.
    Thanks in advance for the help.
    Linkan

    Wow
    Thank you very much for such quick response.I have privillege to create table,view,..... in my staging area not on target. I had asked DBA but he denided to give create privillege in target.Its only in my staging schema.
    I will try to change the schema & will check if its working or not.
    Thank you very much again.

  • Creating table or View using UNION Operator ???????

    Hi all
    please need some help ,i have created aquery using UNION operator
    (i.e
    select A,to_number(null),C from table1
    Union
    select A,B,To_number(null) from table2)
    it gives the output correctly and i need to make this output as View ot table
    eacg time i use
    Create or replace view v_1 ...........
    it gives me this error :: unknown command "UNION" - rest of line ignored.
    can any one pls tell me what to do
    Thanks

    Hi,
    I found there is no error in your sql
    create view x_v
    as
    select a from x
    union
    select to_number(null) from y;
    this works fine.
    in your sql check your right or left peranthesis
    regards
    Ripudaman

  • Create table from user scott

    Hi,
    Can you help me with this?
    I wrote this
    {declare
    cursor c1 is
    select *
    from
    all_objects
    where lower(owner) like 'scott'
    and lower(object_type)='table';
    i varchar2(50);
    begin
    for i in c1
    loop
    execute immediate 'create table '||i.object_name|| ' as select *
    from ' ||i.object_name;
    end loop;
    close c1;
    end;
    and I have the following errors:
    ERROR at line 1:
    ORA-00942: table or view does not exist
    ORA-06512: at line 12
    Thank you

    Could you please show output of your generated code using dbms_output.put_line command?
    declare
    cursor c1 is
    select *
    from
    all_objects
    where lower(owner) like 'scott'
    and lower(object_type)='table';
    i varchar2(50);
    begin
    for i in c1
    loop
    dbms_output.put_line('create table '||i.object_name|| ' as select *
    from ' ||i.object_name);
    end loop;
    close c1;
    end;
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com

  • Returning newly created IDs from View with Instead Of

    Hi All,
    I have the following table:
    CREATE TABLE TBLSIM_SUPPLIER_H
        "SS_ID" NUMBER(10,0) NOT NULL ENABLE,
        "SS_GUID" NVARCHAR2(36) NOT NULL ENABLE,
        "SS_NAME" NVARCHAR2(50) NOT NULL ENABLE,
        "SS_H_IS_ACTIVE" NUMBER(1,0) DEFAULT 1 NOT NULL ENABLE,
        "SS_H_RE_ID"     NUMBER(10,0) NOT NULL ENABLE,
        "SS_H_DATE" DATE DEFAULT SYSDATE NOT NULL ENABLE,
        "SS_H_MASTER_ID" NUMBER(10,0),
        CONSTRAINT "TBLSIM_SUPPLIER_PK" PRIMARY KEY ("SS_ID") ENABLE,
        CONSTRAINT "TBLSIM_SUPPLIER_FK_M_ID" FOREIGN KEY ("SS_H_MASTER_ID") REFERENCES "TBLSIM_SUPPLIER_H" ("SS_ID") ENABLE
      )on which is enabled this trigger
    CREATE OR REPLACE TRIGGER TBLSIM_SUPPLIER_H_TRG BEFORE
      INSERT ON TBLSIM_SUPPLIER_H FOR EACH ROW BEGIN <<COLUMN_SEQUENCES>> BEGIN IF :NEW.SS_ID IS NULL THEN
      SELECT TBLSIM_SUPPLIER_H_SEQ.NEXTVAL INTO :NEW.SS_ID FROM DUAL;
    END IF;
    IF :NEW.SS_GUID IS NULL THEN
      :NEW.SS_GUID  := UTILITYPKG.formatted_guid;
    END IF;
    END COLUMN_SEQUENCES;
    END;UTILITYPKG.formatted_guid returns a standard 36chr GUID
    I then created a view
    CREATE OR REPLACE FORCE VIEW TBLSIM_SUPPLIER
    AS
      SELECT SS_ID,
        SS_GUID,
        SS_NAME,
        SS_H_IS_ACTIVE,
        SS_H_RE_ID,
        SS_H_DATE
      FROM TBLSIM_SUPPLIER_H
      WHERE (ss_h_is_active = 1);on which I enabled the trigger
    CREATE OR REPLACE TRIGGER TBLSIM_SUPPLIER_INS INSTEAD OF
      INSERT ON TBLSIM_SUPPLIER FOR EACH ROW
        BEGIN
      INSERT INTO TBLSIM_SUPPLIER_H (ss_name, ss_h_is_active, ss_h_re_id, ss_h_date)
        VALUES (:NEW.ss_name, 1, :NEW.ss_h_re_id, SYSDATE);
    END TBLSIM_SUPPLIER_INS;I then have a stored Procedure
    PROCEDURE SimSupplier_Create(
          cur_tblresource_id_in IN tblresource.re_id%TYPE
        , ss_name_in IN tblsim_supplier.ss_name%TYPE
        , ss_id_out OUT tblsim_supplier.ss_id%TYPE
        , ss_guid_out OUT tblsim_supplier.ss_guid%TYPE
      ) AS
      BEGIN
        INSERT INTO tblsim_supplier (
          , ss_name
          , ss_h_re_id
        VALUES ( 
          , ss_name_in
          , cur_tblresource_id_in
       RETURNING ss_id, ss_guid INTO ss_id_out, ss_guid_out;
      END SimSupplier_Create; What happens is that the RETURNING clause is not available.
    Any way of getting the ID & GUID of the just inserted record out of the prcedure?
    Thanks
    Andrea

    Why do you need this instead of trigger? Can't you simply insert into the view? Maybe enable WITH CHECK OPTION to prevent wrong values beeing entered via the view. Or simply insert into the table and not the view. As long as it is done in the procedure, you are safe that there is no priviledge confict.
    Edited by: Sven W. on Oct 17, 2012 5:38 PM

  • Create table from external data with dates

    I have a CSV that looks somewhat like this:
    abcuser,12345,5/12/2012,5,250.55
    xyzuser,67890,5/1/2012,1,50
    ghjuser,52523,1/1/1900,0,0
    When I create the external table, then query it I get a date error:
    CREATE TABLE xtern_ipay
    userid VARCHAR2(50),
    acctnbr NUMBER(20, 0),
    datelastused DATE,
    number_rtxns NUMBER(12, 0),
    amtused NUMBER(12, 0)
    organization external ( TYPE oracle_loader DEFAULT directory "XTERN_DATA_DIR"
    ACCESS parameters (
    records delimited BY newline fields terminated BY "," )
    location ('SubscriberStatistics.csv') ) reject limit UNLIMITED;
    Error I see in the reject log:
    Field Definitions for table XTERN_IPAY
    Record format DELIMITED BY NEWLINE
    Data in file has same endianness as the platform
    Rows with all null fields are accepted
    Fields in Data Source:
    USERID CHAR (255)
    Terminated by ","
    Trim whitespace same as SQL Loader
    ACCTNBR CHAR (255)
    Terminated by ","
    Trim whitespace same as SQL Loader
    DATELASTUSED CHAR (255)
    Terminated by ","
    Trim whitespace same as SQL Loader
    NUMBER_RTXNS CHAR (255)
    Terminated by ","
    Trim whitespace same as SQL Loader
    AMTUSED CHAR (255)
    Terminated by ","
    Trim whitespace same as SQL Loader
    error processing column DATELASTUSED in row 1 for datafile g:\externaltables\SubscriberStatistics.csv
    ORA-01858: a non-numeric character was found where a numeric was expected
    error processing column DATELASTUSED in row 2 for datafile g:\externaltables\SubscriberStatistics.csv
    ORA-01858: a non-numeric character was found where a numeric was expected
    error processing column DATELASTUSED in row 3 for datafile g:\externaltables\SubscriberStatistics.csv
    ORA-01858: a non-numeric character was found where a numeric was expected
    Any ideas on this? I know I need to tell oracle the format of the date on the external file, but I can't figure it out.

    Try this:
    CREATE TABLE xtern_ipay
       userid         VARCHAR2 (50)
    , acctnbr        NUMBER (20, 0)
    , datelastused   DATE
    , number_rtxns   NUMBER (12, 0)
    , amtused        NUMBER (12, 2)
    ORGANIZATION EXTERNAL
        ( TYPE oracle_loader DEFAULT DIRECTORY "XTERN_DATA_DIR"
    ACCESS PARAMETERS (
    RECORDS DELIMITED BY NEWLINE FIELDS TERMINATED BY "," MISSING FIELD VALUES ARE NULL
    (   userid
      , acctnbr
      , datelastused DATE 'mm/dd/yyyy'
      , number_rtxns
      , amtused)
    location ('SubscriberStatistics.csv') ) reject LIMIT unlimited;
    select * from xtern_ipay;
    USERID                                                ACCTNBR DATELASTU NUMBER_RTXNS    AMTUSED
    abcuser                                                 12345 12-MAY-12            5     250.55
    xyzuser                                                 67890 01-MAY-12            1         50
    ghjuser                                                 52523 01-JAN-00            0          0
    {code}
    Sorry I had to correct the previous statement again for the date format and for the column amtused that was defined without decimals.
    Regards
    Al
    Edited by: Alberto Faenza on May 31, 2012 6:34 PM
    wrong date format mm/dd/yy instead of dd/mm/yy
    Edited by: Alberto Faenza on May 31, 2012 6:40 PM
    Fixed again the date format and the amtused defined with 2 decimals                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • Sales BOM Wise Stock report

    Dear Gurus, Good Afternoon!! My user' requirement is, he wants a BOM wise stock report. He will just enter the Header Item, Plant and the storage location, and system should list all its sub-items with the stock available in that plant & the storage

  • Splash Screen in my AppleScript

    hi, actually i have done a small applescript which is using exiftool to change some efix-data in my images. After finishing the basic function i would like to tune it a bit, if possible Is it possible to create a SplashScreen or similar with AppleScr

  • Email Body formatting Issue

    Hi, We have a requirement to send an email with body in the below mentioned format. I have populated the final internal table with necessary data. I have concatenated all the columns of each record of the final internal table into a text variable wit

  • How to solve javax.servlet.jsp.JspException: duplicate Id for a component?

    Dear everyone, I have built some customized JSF components. In the taglib, there is attribute "id" for my components. There is no problem when the page is run, but when I click submit button, there are errors. javax.servlet.jsp.JspException: duplicat

  • How to create EncryptDocument Process ?

    I'm new to Adobe LiveCycle ES, and I'm now stuck with all tutorials dealing with pdf encryption because most of them are using the EncryptDocument process. But I didn't manage to find where this process creation with Workbench ES is explained. If som