Question on Creating Table From Insert statement

Hi,
I want to create a table using a DBlink from another database using the create/insert statement. Will it also transfer the constraints or do I have to do it manually afterwards? Thanks.
Create table T1
SELECT a,b,c from T2 from DB@dblink;

As discussed above, the constraints, indexes, triggers are not copied. Only NOT NULL constraints are copied.
Look at this thread Re: Copying table structure.
for copying triggers/indexes from source table to destination table.
Thanks,
Navaneeth

Similar Messages

  • Question on Creating table from another table and copying the partition str

    Dear All,
    I want to know whether is there any way where we can create a table using another table and have the partitions of the new table to be exactly like the used table.
    Like
    CREATE TABLE TEST AS SELECT * FROM TEMP;
    The table TEMP is having range and hash partitions.
    Is there any way when we use the above command, we get the table partitions of TEMP to be copied to the new table TEST.
    Appreciate your suggestions on this one.
    Thanks,
    Madhu K.

    may this answer your question...
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:595568200346856483
    Ravi Kumar

  • [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

  • How to retrieve value from insert statement

    hi,
    how can i get a certain value from insert statement and store it in a variable.
    suppose i am inserting emp_no , emp_name , emp_salary to employee table
    and i want to store the emp_name in a variable for other processing,
    how can i accomplish this ? i'm guessing that i have to use trigger,
    but dont know the procedure .
    any help will be greatly appreciated
    thanks

    insert into <table> valiues (....) returning <expression> into <variable>
    You could and should have found this using the SQL Language reference manual
    or
    http://www.morganslibrary.org/reference/insert.html
    Sybrand Bakker
    Senior Oracle DBA

  • Should I create table before insert xml files

    Hi,,,
    I am developing a application that insert various xml files
    into oracle8i dbms..
    So, I am studying Oracle XML SQL Utility and I understood that
    I should create appropriate tables suit for the XML files..
    (tag <--> table column name...) before insert them to the dbms.
    But In my project, the xml file is not fixed.
    And new XML files (new tag name, new DTD required) can be
    generated by the end user.
    Is there any solution??? create table suit for xml
    automatically..
    And...
    How can I create table to insert the following xml file..
    <univ>
    <college name="engineering">
    <department name="electronic">
    <student id="11">
    <math> 100 </math>
    <english> 90 </english>
    </student>
    </department>
    </college>
    <college name="law">
    <department name="law">
    <student id="55">
    <math> 90 </math>
    <english> 100 </english>
    </student>
    </department>
    </college>
    </univ>
    null

    Hi,
    One more thing is that, you can use XSLT to transform any
    document that you get into a canonical representation that u can
    then use to put into the database.
    For example, if the user gave,
    <univ>
    <college name="eng">
    <...>
    </college>
    </univ>
    you can then use XSLT to transform it into all-element form,
    such as,
    <univ>
    <college>
    <name>engineering</name>
    </college>
    </univ>
    and use OracleXMLSave to put it into the database. Also if you
    have structured XML elements you can map them nicely into object
    types in Oracle 8.
    Regarding creating the table, for the exampe that you showed,
    you can create an object type column for storing it,example,
    CREATE TYPE college_type AS OBJECT
    name VARCHAR2(50),
    dept department_type,
    CREATE TYPE department_type AS OBJECT
    name VARCHAR2(40),
    CREATE TABLE univ_tab ( college college_type);
    You could have also created object views over multiple
    relational tables and achieved the same.
    Thx
    The OracleXML team.
    Oracle XML Team wrote:
    : Instead of using attributes to store your data, use elements.
    : For example:
    : <univ>
    : <college>
    : <collname>engineering</collname>
    : <department>
    : <deptname>electronic</deptname>
    : <student>
    : <id>11</id>
    : <math>100</math>
    : <english>90</english>
    : </student>
    : </college>
    : </univ>
    : Oracle XML Team
    : http://technet.oracle.com
    : Oracle Technology Network
    : Chong, Ho-chul (guest) wrote:
    : : Hi,,,
    : : I am developing a application that insert various xml files
    : : into oracle8i dbms..
    : : So, I am studying Oracle XML SQL Utility and I understood
    : that
    : : I should create appropriate tables suit for the XML files..
    : : (tag <--> table column name...) before insert them to the
    dbms.
    : : But In my project, the xml file is not fixed.
    : : And new XML files (new tag name, new DTD required) can be
    : : generated by the end user.
    : : Is there any solution??? create table suit for xml
    : : automatically..
    : : And...
    : : How can I create table to insert the following xml file..
    : : <univ>
    : : <college name="engineering">
    : : <department name="electronic">
    : : <student id="11">
    : : <math> 100 </math>
    : : <english> 90 </english>
    : : </student>
    : : </department>
    : : </college>
    : : <college name="law">
    : : <department name="law">
    : : <student id="55">
    : : <math> 90 </math>
    : : <english> 100 </english>
    : : </student>
    : : </department>
    : : </college>
    : : </univ>
    Oracle Technology Network
    http://technet.oracle.com
    null

  • "Create Table from select Query" Vs "Insert into"

    Hi
    Schenaio:
    My Select Query returns more than 10 million records, these records needs to be inserted into another table.
    Approach 1:
    I created table called TABLE1, and inserted the records using INSERT statement as a batch (batch size is 5000).
    Approach 2:
    I create table like,
    CREATE TABLE TABLE1 AS <SELECT QUERY>
    Here Apporach-1 took almost 40 minutes to complete the insert but Approach-2 took only 6 minutes.
    If anybody knows why it is? And is there any way to improve the performance of Approach-1?.
    Thanks
    Nidhi

    Most "batch" methods execute the same query multiple times. Row filtering is done after the rows are fetched from the source. The process of fetching all the rows could be a FullTableScan.
    Therefore, a FullTableScan is executed for each batch of 5000 rows.
    However, your query and batch definitions may well be different. We haven't seen the query and the execution plan.
    Another point : How are you "filtering" the rows (i.e the second execution inserts rows 5001 to 10000 and does not attempt to reinsert rows 1 to 5000) ?
    What is the overhead imposed by the filter ? (does the third execution have to exclude rows 1 to 10000 and inserts rows 10001 to 15000 and so on)
    Hemant K Chitale

  • How to create outline from perfstat.stats$SQL_PLAN table

    How do I create outline (Plan stability in 10gR2database) from perfstat.stats$SQL_PLAN table?
    Current V$SQL_PLAN does not contain good but but week older snapshots have good plan.
    I can't modify query, it's vendor query so I need to create outline/plan stability.
    Thanks for help.

    user7478143 wrote:
    Thanks for reply.
    I'm not saying I find it out doc but here is situation.
    I have query which change execution plan week ago.
    I have perfstat enable and I found out good execution plan from perfstat.stat$SQL_PLAN view.
    If it's our query I can modify query and able to get good execution plan but it's vendor supplied query (which is Oracle - it used to be Portal now Oracle acquired it) so I can't modified it.
    All I'm trying to do is how do I generate good plan and assigned to vendor query's hash_value/sql_id.If DBMS_ADVANCED_REWRITE is not an option for you and you want to use an outline, there is one significant problem. The Statspack captured data does not include quite enough information, in particular the OTHER_XML column, and the access predicates. So, what can you do? Note that this script is from page 214 of the book that I co-authored. Let's say you execute this SQL statement:
    SQL> SELECT
      2    SQL_ID,
      3    COUNT(DISTINCT PLAN_HASH_VALUE) C
      4  FROM
      5    PERFSTAT.STATS$SQL_PLAN_USAGE
      6  GROUP BY
      7    SQL_ID
      8  HAVING
      9    COUNT(DISTINCT PLAN_HASH_VALUE)>1;
    SQL_ID         C
    0fr8zhn4ymu3v  2
    0h6b2sajwb74n  2
    1gu8t96d0bdmu  2
    39m4sx9k63ba2  2
    4b57myt9mpz37  3
    52tr7ay85qwn0  5
    …Interesting, SQL_ID has 2 different execution plans, let's take a look at the execution plans:
    SQL> SET LINESIZE 150
    SQL> SET PAGESIZE 10000
    SQL> SPOOL StatspackPlan.txt
    SQL> SELECT /*+ ORDERED */
      2    T.*
      3  FROM
      4    (SELECT DISTINCT
      5       PLAN_HASH_VALUE
      6     FROM
      7       PERFSTAT.STATS$SQL_PLAN_USAGE
      8     WHERE
      9       SQL_ID='0fr8zhn4ymu3v'
    10     ORDER BY
    11       PLAN_HASH_VALUE) SPU,
    12    TABLE(DBMS_XPLAN.DISPLAY(
    13      'PERFSTAT.STATS$SQL_PLAN',
    14      NULL,
    15      'TYPICAL -PREDICATE -NOTE',
    16      'PLAN_HASH_VALUE='||SPU.PLAN_HASH_VALUE)) T;
    | Id  | Operation                   | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |*  0 | SELECT STATEMENT            |            |       |       |     2 (100)|          |
    |*  1 |  TABLE ACCESS BY INDEX ROWID| OPQTYPE$   |     1 |    27 |     2   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | I_OPQTYPE1 |     1 |       |     1   (0)| 00:00:01 |
    | Id  | Operation             | Name     | Cost  |
    |*  0 | SELECT STATEMENT      |          |       |
    |*  1 |  SORT ORDER BY        |          |     0 |
    |*  2 |   TABLE ACCESS CLUSTER| OPQTYPE$ |       |
    |*  3 |    INDEX UNIQUE SCAN  | I_OBJ#   |       |
    --------------------------------------------------As can be seen by the above, in one case the I_OBJ# index was used, and in another case the I_OPQTYPE1 index was used. Let's assume that I_OPQTYPE1 is the most efficient access path, so a hint like this needs to be inserted (assuming that the table does not have an alias in the SQL statement:
    /*+ INDEX(OPQTYPE$ I_OPQTYPE1) */Now what (obviously, we would not want to actually fix the above plan for an internal SQL statement)? Take a look at the following, which shows how to build a private outline for the unhinted version of the SQL statement, an outline for a hinted version, and then swap the resulting outlines, followed by building a public outline from the hacked outline:
    http://hoopercharles.wordpress.com/2009/12/18/tracking-performance-problems-inserting-a-hint-into-sql-in-a-compiled-program/
    Charles Hooper
    Co-author of "Expert Oracle Practices: Oracle Database Administration from the Oak Table"
    http://hoopercharles.wordpress.com/
    IT Manager/Oracle DBA
    K&M Machine-Fabricating, Inc.

  • In training, PL/SQL create table and insert question. (easy for some of you

    I have an empty table called messages. The task is this:
    a)Insert the numbers 1 to 10, excluding 6 and 8.
    b)Commit before the end of the block.
    I did this:
    SET SERVEROUTPUT ON
    SET VERIFY OFF
    BEGIN
    INSERT INTO messages VALUES (1,2,3,4,5,6,7,9,10);
    END;
    Which fails at messages. The table is there, I checked and it's empty. ORA-06550:

    Hello,
    c1 is not a valid column name I posted as an example , you need to provide valid column name of your table.
    Either post your table structure or replace c1, c2, c3 ... with valid column name from your table.
    INSERT INTO MESSAGES (c1, c2, c3, c4, c5, c9, c10)
    or
    insert into messages (your table column name1 , column name2 ,....) values (....);Regards
    Edited by: OrionNet on Feb 21, 2009 9:51 PM

  • How to create table from ref cursor

    I have a proc that returns a ref cursor, whats the simplest way to create a table based on the return of the ref cursor?
    declare
    type rc is ref cursor;
    p_data rc;
    begin
    call_my_proc(p_data);
    :result := p_data; -- If I run this in TOAD I can see the data here but I want to create a table based on it rather than outputting it)
    end;
    thanks.
    edit: sorry. typed this wrong first time, should be right now

    961469 wrote:
    I have a proc that returns a ref cursor, whats the simplest way to create a table based on the return of the ref cursor?Not to do it...
    A cursor is not a result set. A cursor is not a result set. Worth repeating several times as this is a common misconception
    A cursor is essentially a program. Executable code that was compiled from a SQL source code program.
    A SELECT cursor is "read" program. Each fetch instruction runs this program (from its current "paused state"), and outputs data.
    An INSERT cursor is a "write" program. You pass data to it (process called binding, via bind variables). You then execute the program. It writes the data it received (can be bulk data via a bulk bind) to table.
    Now your question is: How do I write the output of a cursor program back to the database?
    The answer is that a "write" cursor program is needed. Your code needs to execute (fetch output from) the ref (read/select) cursor. Then bind that data to the "write" cursor and execute it.
    In other words, you have a read cursor and a write cursor, and you need to pass data from one to the other.
    HOWEVER.. This is slow. This does not scale. This is also known as slow-by-slow row by row processing.
    The correct approach is to create a single program. One that reads the data, and then writes the data. No to send data via a detour through your code between the read part and write part.
    The cursor to create is an INSERT..SELECT cursor. This can do fast direct path inserts. This can be executed in parallel - i.e. the database executing several copies of this read-and-write program at the same time.

  • 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.

  • How to assign value from insert statement to variable from a trigger

    Hi,
    I got this really annoying problem and I don't know if I am doing it correctly.
    I have a BEFORE INSERT trigger on a table. When someone executes an insert statement I want to grab the value of a column from that statement and assign it to a variable and then do stuff with it. I'm stuck on the assignment.. look below..
    CREATE OR REPLACE TRIGGER CARS.geotest2_trigger
    BEFORE INSERT ON CARS.GEO_TEST2
    FOR EACH ROW
    DECLARE
    v_chainkey nchar(32);
    v_chainkey2 nchar(32);
    not_exists EXCEPTION;
    BEGIN
    :NEW.CHAINKEY := v_chainkey;
    SELECT GEO_TEST.CHAINKEY INTO v_chainkey2 FROM GEO_TEST WHERE GEO_TEST.CHAINKEY = v_chainkey;
    IF v_chainkey2 = '' or v_chainkey2 is null THEN
    RAISE not_exists;
    ELSE
    INSERT INTO GEO_TEST2 VALUES(:NEW.CHAINKEY, :NEW.BLA, :NEW.FOO);
    END IF;
    EXCEPTION
    WHEN not_exists THEN
    RAISE_APPLICATION_ERROR(-20010, 'Chainkey does not exist in parent table GEO_TEST');
    END;
    I keep getting this error
    Error: ORA-04098: trigger 'CARS.GEOTEST2_TRIGGER' is invalid and failed re-validation
    SQLState: 42000
    ErrorCode: 4098

    It isn't assigning because v_chainkey is not at the left hand side of the assignment statement.
    test@ORA10G>
    test@ORA10G>
    test@ORA10G> declare
      2    x  number := 5;
      3    y  number;
      4  begin
      5    x := y; -- does not assign anything to y; assigns NULL to x,
      6            -- because y is NULL at this point
      7            -- so, essentially the value 5 of x is *LOST* now
      8    dbms_output.put_line('x = '||x);
      9  end;
    10  /
    x =
    PL/SQL procedure successfully completed.
    test@ORA10G>
    test@ORA10G>
    test@ORA10G>In any case, here's what you are probably looking for:
    test@ORA10G>
    test@ORA10G> --
    test@ORA10G> drop table geo_test;
    drop table geo_test
    ERROR at line 1:
    ORA-00942: table or view does not exist
    test@ORA10G> drop table geo_test2;
    drop table geo_test2
    ERROR at line 1:
    ORA-00942: table or view does not exist
    test@ORA10G>
    test@ORA10G> create table geo_test (chainkey nchar(32));
    Table created.
    test@ORA10G> insert into  geo_test (chainkey) values ('a');
    1 row created.
    test@ORA10G> insert into  geo_test (chainkey) values ('');
    1 row created.
    test@ORA10G>
    test@ORA10G> create table geo_test2 (chainkey nchar(32), bla number(1), foo number(1));
    Table created.
    test@ORA10G>
    test@ORA10G>
    test@ORA10G> CREATE OR REPLACE TRIGGER geotest2_trigger
      2  BEFORE INSERT ON GEO_TEST2
      3  FOR EACH ROW
      4  DECLARE
      5    v_chainkey2  nchar(32);
      6    not_exists   EXCEPTION;
      7  BEGIN
      8    SELECT GEO_TEST.CHAINKEY INTO v_chainkey2 FROM GEO_TEST WHERE nvl(GEO_TEST.CHAINKEY,'~') = nvl(:new.chainkey,'~');
      9    IF v_chainkey2 is null THEN
    10      RAISE not_exists;
    11    END IF;
    12  EXCEPTION
    13    WHEN not_exists THEN
    14      RAISE_APPLICATION_ERROR(-20010, 'Chainkey does not exist in parent table GEO_TEST');
    15  END;
    16  /
    Trigger created.
    test@ORA10G>
    test@ORA10G> --
    test@ORA10G> insert into geo_test2 (chainkey,bla,foo) values ('b',1,1);
    insert into geo_test2 (chainkey,bla,foo) values ('b',1,1)
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at "TEST.GEOTEST2_TRIGGER", line 5
    ORA-04088: error during execution of trigger 'TEST.GEOTEST2_TRIGGER'
    test@ORA10G>
    test@ORA10G> --
    test@ORA10G> insert into geo_test2 (chainkey,bla,foo) values (null,1,1);
    insert into geo_test2 (chainkey,bla,foo) values (null,1,1)
    ERROR at line 1:
    ORA-20010: Chainkey does not exist in parent table GEO_TEST
    ORA-06512: at "TEST.GEOTEST2_TRIGGER", line 11
    ORA-04088: error during execution of trigger 'TEST.GEOTEST2_TRIGGER'
    test@ORA10G>
    test@ORA10G> --
    test@ORA10G> insert into geo_test2 (chainkey,bla,foo) values ('a',1,1);
    1 row created.
    test@ORA10G>
    test@ORA10G>
    test@ORA10G>pratz
    I think the sole purpose of that "not_exists" exception is this -
    If you try to insert a NULL value for GEO_TEST2.CHAINKEY, then this trigger will throw an error even if at least one NULL value exists in GEO_TEST.CHAINKEY column.
    Not sure if that's something that you wanted.
    Message was edited by:
    pratz

  • Create Table  From a Having Count Select

    Hello Folks, any ideas here, I need to create a table using the below 'Select' as the criteria.
    I have the following table and its has duplicate records, identified by double Unique_seq. I want to create a table of these else where, then delete them from schema.tablename.
    Schmea.tablename
    field1
    field2
    field3
    field4
    Unique_Seq
    SELECT Unique_Seq,COUNT(Unique_Seq)
    FROM Schema.Tablename
    GROUP BY Unique_Seq
    HAVING ( COUNT(Unique_Seq) > 1
    I want to create the table using all the fields from schema.tablename
    Thanks

    Thanks for the table script and insert statement.
    here is what you are looking for
    select * from tester_c;
    AD_ID                                    CD_ID                               UNIQUE_SEQ Z_MASTER_KEY
    OP0021889/10                             OP0021889/10                            529832 NNCC00491362OP0021889/1025-JAN-10
                                             OP0021889/10                            529832 NNCC0049136225-JAN-10
                                             OP0022096/10                            539481 NNCC0060037812-JAN-10
    OP0022096/10                             OP0022096/10                            539481 NNCC00600378OP0022096/1012-JAN-10
    LI0192                                   IK735241                                 53925 PP54TH34120988
                                             KL1923836                                65478 BG7892534KL1923836
                                             KL1923836                                65478 BG7892534KL1923836
    PQ8712346                                BN27345236                               64877 7234723642
    8 rows selected.
    Elapsed: 00:00:00.01Pushing duplicate data into a new table tester_c_dup
    CREATE Table tester_c_dup as SELECT * FROM tester_c A WHERE a.rowid > ANY (SELECT  B.rowid FROM
            Tester_c B
         WHERE
            a.Unique_Seq = B.Unique_Seq)
    select * from tester_c_dup;
    AD_ID                                    CD_ID                               UNIQUE_SEQ Z_MASTER_KEY
                                             OP0021889/10                            529832 NNCC0049136225-JAN-10
    OP0022096/10                             OP0022096/10                            539481 NNCC00600378OP0022096/1012-JAN-10
                                             KL1923836                                65478 BG7892534KL1923836
    Elapsed: 00:00:00.01Deleting duplicate data from tester_c table
    DELETE FROM tester_c A WHERE a.rowid > ANY (SELECT  B.rowid FROM
            Tester_c B
         WHERE
            a.Unique_Seq = B.Unique_Seq)
    select * from tester_c;
    AD_ID                                    CD_ID                               UNIQUE_SEQ Z_MASTER_KEY
    OP0021889/10                             OP0021889/10                            529832 NNCC00491362OP0021889/1025-JAN-10
                                             OP0022096/10                            539481 NNCC0060037812-JAN-10
    LI0192                                   IK735241                                 53925 PP54TH34120988
                                             KL1923836                                65478 BG7892534KL1923836
    PQ8712346                                BN27345236                               64877 7234723642
    Elapsed: 00:00:00.00HTH,
    Prazy

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Dynamic internal table from SELECT - statement ?

    Hi, is it possible to define an internal table just after a select statement is executed so that this internal table holds all the data that come back from the statement ?
    thanks in advance,

    Check the link -
    Re: Create Dynamic internal table
    Regards,
    Amit

  • 'create table..' statement behaves differently when alone or in a SP

    hello
    sorry for the title, I just couldnt think of a better description of the problem in very few words...
    the problem I have is:
    I created a stored procedure into the oracle db, and this procedure has the following code inside it:
    auxsql := 'create table tmp (id smallint, name varchar2(256))';
    execute immediate auxsql;
    - now this procedure I call from a java class, using a callable statement
    when I call the stored procedure, I get this message:
    ORA-01031: insufficient privileges (at the line containing the execute instruction)
    my dillema arises from the fact that if I change my callable statement to execute a query of the form:
    auxsql := 'create table tmp (id smallint, name varchar2(256))';
    execute immediate auxsql;
    - but executed as is, not embedded in a sp or something;
    - so if I change to execute simply this, all goes well....
    I would much appreciate if anyone knew at least where to start looking.
    Thank you,
    Silviu Lipovan Oanca
    p.s. for any further details, just say.
    Message was edited by:
    silviulipovan

    In all probability, the user that owns the stored procedure has the CREATE TABLE privilege through a role, not granted directly. In PL/SQL blocks (assuming definer's rights), only direct privilege grants are "visible", whereas straight SQL statements also "see" privileges granted through a role.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

Maybe you are looking for

  • DV9000 No longer recognizes my CD-ROM drive

     HI guys, I am by no means a computer guy, but I have been trying to figure out why my laptop no longer recognizes my CD drive.  It had the 3 yellow exclimation points in the devise manager, 2 for Base System Device and 1 for Coprocesser.  I updated

  • Waiting for printer to become available - OSX 10.8.4

    Hi, I foolishly allowed the HP printer updates on my imac running Mountain Lion, 10.8.4.  I learned not to do that on Snow Leopard but suffered a lapse resulting in 'waiting for printer to become available' and when it is reset, it only prints every

  • Permissions issues on views referencing other users [solved]

    Hi, I've hit a (for me) unexplainable problem; Situation: - Table T in schema A - View V in schema B, referencing the table T from schema A (B has SELECT/REFERENCES privileges on table T) - User C gets ORA-01031 when trying to SELECT from view V (C h

  • Authority Check on Value within standard transactions

    Hi Guruus ! Let's state that a user is allowed and has the profile/role to access a given transaction, let's say MI01, but ME21N will do to ! Now, actually, users are supposed an that project to be authorized on certain Storage Location (LGORT). How

  • One output PDF - multiple reports

    My client wants to get the output of 12 different reports in 1 PDF. What's the shortest possible method to do this. I am using forms/reports 10g