URGENT - Offset from GMT in Oracle

Everybody,
I am looking for getting offset (time difference from GMT) for local time zone using an SQL statement. Our server is set to GMT and using SQL, I should be getting local time and offset based on GMT on server. I know NEW_TIME function in oracle can be used to switch time zones. But not sure of how to get the offset. Any help greatly appreciated.
null

Hi,
CLOB is the datatype that you need to use.
You should download the Oracle Migration Workbench (http://technet.oracle.com/tech/migration). It will generate BCP and SQL Loader scripts for you.
It will also perform migration of all schema objects e.g. stored procedures , triggers and views etc
Regards
John

Similar Messages

  • Find time offset from GMT using time zone

    Hi,
    Is there any way i can query the time offset from GMT using the timezone of a place.
    E.g. If I am in India
    My TZNAME is 'Asia/Calcutta' and TZABBREV='IST'
    How can i get the time offset from GMT for this timezone?
    In this case I want +5:30 as the result.
    Regards
    Ravi

    SQL> select dbtimezone
      2  from dual;
    DBTIME
    +01:00
    SQL> Regards,
    Gerd

  • URGENT: Migrating from SQL to Oracle results in very poor performance!

    *** IMPORTANT, NEED YOUR HELP ***
    Dear, I have a banking business solution from Windows/SQL Server 2000 to Sun Solaris/ORACLE 10g migrated. In the test environment everything was working fine. On the production system we have very poor DB performance. About 100 times slower than SQL Server 2000!
    Environment at Customer Server Side:
    Hardware: SUN Fire 4 CPU's, OS: Solaris 5.8, DB Oracle 8 and 10
    Data Storage: Em2
    DB access thru OCCI [Environment:OBJECT, Connection Pool, Create Connection]
    Depending from older applications it's necessary to run ORACLE 8 as well on the same Server. Since we have running the new solution, which is using ORACLE 10, the listener for ORACLE 8 is frequently gone (or by someone killed?). The performance of the whole ORACLE 10 Environment is very poor. As a result of my analyse I figured out that the process to create a connection to the connection pool takes up to 14 seconds. Now I am wondering if it a problem to run different ORACLE versions on the same Server? The Customer has installed/created the new ORACLE 10 DB with the same user account (oracle) as the older version. To run the new solution we have to change the ORACLE environment settings manually. All hints/suggestions to solve this problem are welcome. Thanks in advance.
    Anton

    On the production system we have very poor DB performanceHave you identified the cause of the poor performance is not the queries and their plans being generated by the database?
    Do you know if some of the queries appear to take more time than what it used to be on old system? Did you analyze such queries to see what might be the problem?
    Are you running RBO or CBO?
    if stats are generated, how are they generated and how often?
    Did you see what autotrace and tkprof has to tell you about problem queries (if in fact such queries have been identified)?
    http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10752/sqltrace.htm#1052

  • Data transfer from MySQL to Oracle Urgent!

    Hi All,
    We have a table in MySQL database and we need to transfer a subset of its data over to Oracle table. The table in MySQL is big, so we created a temp table trying to do it several times. The question is, we set the the primary key column in both MySQL temp table and Oracle table ( a varchar column), when we transfered the data over using "insert into table_name select * from table_name@hsdobc", Oracle always gave the "Null value for not Null column" error, and it's only existed for one row no matter how many rows we want to transfer, but MySQL temp table has no such null value for the primary key column, it's very strange. Anyone knows what the problem might be? Thanks very much in advance.

    Hi, thanks for your answer. I checked the MySQL table again, and found that in both the original table and the temp table, there is a row with the primary key column value "null". Don't know what happened? Probably it's a MySQL bug.
    It's not Primary Key NULL value. If your new Oracle Table has ANY column defined
    NOT NULL and while inserting you have at least one value in one row of coming data is NULL - It will fail. You need either to drop NOT NULL constraint for that
    column(s), or provide value for it.
    Also you can drop that NOT NULL constraint, Insert your data as is,
    Update your data to get rid off all NULLs and put NOT NULL constraint back on.
    ALTER TABLE MY_NEW_TABLE MODIFY MY_NEW_COLUMN NULL;
    UPDATE MY_NEW_TABLE SET MY_NEW_COLUMN = 'Some_Value';
    ALTER TABLE MY_NEW_TABLE MODIFY MY_NEW_COLUMN NOT NULL;

  • Date Conversion from GMT to Local and Local To GMT considering DST.

    Hi,
    I have a application which displays the time in GMT across all the screens,and saves in Local/Default TimeZone as application would be deployed in europe and India.I have written a utility which does the conversion.
    I just want to know that how to handle the Daylight Saving Time[DST] as we are taking the data from database and converting it to LocalTime Zone.This works fine but what would happen if the sever time is changes due to DST.There would be problem between the object saved before the DST and after DST because we are simply converting stored time to GMT to show on the screen.
    Please share if you some solution/suggestions.
    Thanks.
    Akash.

    YoungWinston wrote:
    jschell wrote:
    That statement is phrased oddly.
    A java.util.Date uses a UTC offset with millisecond resolution.
    A jdbc driver converts that value into a "correct" value for the target database.And from.
    The form that is stored in the database is entirely database dependent. The actual form stored in the database can take many forms.True, but it is highly likely to be an offset from some "epoch" (Progress, for example, uses 00:00:00 1/1/-3714 UTC as I recall, and has 1-second granularity).Yes but as I said the phrasing was odd. A timestamp, by definition, must be an offset of something. Doesn't matter how it is represented. After all the year 2009 is an offset in the Gregorian calander.
    However in terms of actual storage the way it is stored is unlikely to be similar to what Java does. As examples neither Oracle nor MS SQL Server uses a single numeric offset.
    It might not even have a concept of timezone.Again true, although I've yet to come across one; and since OP is only concerned about the timezone in Java I'm not quite sure how relevant that is.
    Relevant in terms of the description in terms of what java does, what the database does and how it gets from java to the database.
    I would also expect any JDBC driver that cannot translate to or from a Java date correctly to document the fact in 60-point bold type, since it's a violation of the implied contract of ResultSet.getDate().Except that depends on your definition of "correct".
    Examples of that
    - Oracle doesn't have millisecond resolution at all in its common format.
    - MS SQL Server doesn't have the same resolution as java, instead there is an odd resolution (one three-hundredth of a second).
    - MS SQL Server doesn't have timezones, so if you don't take care and your data crosses timezones the timestamp will be different.
    The drivers will not warn you of things like that. At least not that I have seen.
    Format for Oracle.
    [http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:77562635789106]
    Format for MS SQL Server
    [http://msdn.microsoft.com/en-us/library/aa258277(SQL.80).aspx]

  • DST prob for conversion from US/Eastern- GMT but not from GMT- US/Eastern.

    Hi folks,
    I'm running the following SQL against a Oracle 10.2.0.1 g server using Oracle SqlDeveloper 1.5.3 & then again using SQLPlus 10.2.0.1.0.
    I'm attempting to provide SQL that highlights the jump forward by one hour at 2am US/Eastern on 14th Mar 2010.
    In order to do this I've converted times from GMT into US/Eastern using the oracle function from_tz and to_timestamp.
    The following sql statements are suffixed with a 'correct' or 'incorrect' as to whether they correlate to what I would expect and indeed to the time returned from the World Clock website.
    =======================
    = Via Oracle SqlDeveloper 1.5.3
    =======================
    -- The first section of selects highlight the jump of 1 hour forward that occurs on the 14th of March 2010 by converting the GMT time to the corresponding US/Eastern time and the second block reverses the conversion.
    select from_tz(to_timestamp('14-MAR-2010 0500' , 'DD-MON-YYYY HH24MI'), 'GMT') at time zone 'US/Eastern' from dual; -- returns 14-MAR-10 00:00:00.000000000 US/EASTERN correct
    select from_tz(to_timestamp('14-MAR-2010 0600' , 'DD-MON-YYYY HH24MI'), 'GMT') at time zone 'US/Eastern' from dual; -- returns 14-MAR-10 01:00:00.000000000 US/EASTERN correct
    select from_tz(to_timestamp('14-MAR-2010 0659' , 'DD-MON-YYYY HH24MI'), 'GMT') at time zone 'US/Eastern' from dual; -- returns 14-MAR-10 01:59:00.000000000 US/EASTERN correct
    select from_tz(to_timestamp('14-MAR-2010 0700' , 'DD-MON-YYYY HH24MI'), 'GMT') at time zone 'US/Eastern' from dual; -- returns 14-MAR-10 03:00:00.000000000 US/EASTERN correct
    select from_tz(to_timestamp('14-MAR-2010 0701' , 'DD-MON-YYYY HH24MI'), 'GMT') at time zone 'US/Eastern' from dual; -- returns 14-MAR-10 03:01:00.000000000 US/EASTERN correct
    select from_tz(to_timestamp('14-MAR-2010 0800' , 'DD-MON-YYYY HH24MI'), 'GMT') at time zone 'US/Eastern' from dual; -- returns 14-MAR-10 04:00:00.000000000 US/EASTERN correct
    select from_tz(to_timestamp('14-MAR-2010 0000' , 'DD-MON-YYYY HH24MI'), 'US/Eastern') at time zone 'GMT' from dual; -- returns 14-MAR-10 05:00:00.000000000 US/EASTERN correct
    select from_tz(to_timestamp('14-MAR-2010 0100' , 'DD-MON-YYYY HH24MI'), 'US/Eastern') at time zone 'GMT' from dual; -- returns 14-MAR-10 06:00:00.000000000 US/EASTERN correct
    select from_tz(to_timestamp('14-MAR-2010 0159' , 'DD-MON-YYYY HH24MI'), 'US/Eastern') at time zone 'GMT' from dual; -- returns 14-MAR-10 06:59:00.000000000 US/EASTERN correct
    select from_tz(to_timestamp('14-MAR-2010 0200' , 'DD-MON-YYYY HH24MI'), 'US/Eastern') at time zone 'GMT' from dual; -- returns 14-MAR-10 07:00:00.000000000 US/EASTERN incorrect
    select from_tz(to_timestamp('14-MAR-2010 0300' , 'DD-MON-YYYY HH24MI'), 'US/Eastern') at time zone 'GMT' from dual; -- returns 14-MAR-10 08:00:00.000000000 US/EASTERN incorrect
    select from_tz(to_timestamp('14-MAR-2010 0301' , 'DD-MON-YYYY HH24MI'), 'US/Eastern') at time zone 'GMT' from dual; -- returns 14-MAR-10 08:01:00.000000000 US/EASTERN incorrect
    select from_tz(to_timestamp('14-MAR-2010 0400' , 'DD-MON-YYYY HH24MI'), 'US/Eastern') at time zone 'GMT' from dual; -- returns 14-MAR-10 09:00:00.000000000 US/EASTERN incorrect
    which is as I would expect. At 6:59am GMT the time in US/Eastern is 1:59 am, however, at 7:00am the time in US/Eastern is now 3:00am. This correlates to the times I get back when I perform the same calculations using the converter at the WorldClock.
    http://www.timeanddate.com/worldclock/converter.html
    However when I attempt to perform the same conversions except in reverse i.e. from US/Eastern to GMT I get different results.
    -- everything is fine up until the actual time of the change over (2am US/Eastern). With the 2:00am time though I would expect Oracle or perhaps even the SqlDeveloper client to indicate either of the following :-
    a) the time 14-MAR-10 02:00am US/Eastern is actually a non-existant time as per the WorldClock.
    b) that it's defaulting the time 14-MAR-10 02:00am to 14-MAR-10 03:00am US/Eastern
    instead the results proceeding the sql statements are output and for any time on/after 2am they are 1 hour behind their correct GMT times as per the world clock.
    I understand that there is a patch for timezone's from 10.2.0.1 to 10.2.0.4 that should address this, however, the reason I'm posting this is because when I run the above SQL in sqlplus against the same server I get different results except this time both conversions are incorrect.
    =======================
    = Via SqlPlus 10.2.0.1.0
    =======================
    select from_tz(to_timestamp('14-MAR-2010 0500' , 'DD-MON-YYYY HH24MI'), 'GMT') at time zone 'US/Eastern' from dual; -- returns 14-MAR-10 00.00.00.000000000 US/EASTERN correct
    select from_tz(to_timestamp('14-MAR-2010 0600' , 'DD-MON-YYYY HH24MI'), 'GMT') at time zone 'US/Eastern' from dual; -- returns 14-MAR-10 01.00.00.000000000 US/EASTERN correct
    select from_tz(to_timestamp('14-MAR-2010 0659' , 'DD-MON-YYYY HH24MI'), 'GMT') at time zone 'US/Eastern' from dual; -- returns 14-MAR-10 01:59:00.000000000 US/EASTERN correct
    select from_tz(to_timestamp('14-MAR-2010 0700' , 'DD-MON-YYYY HH24MI'), 'GMT') at time zone 'US/Eastern' from dual; -- returns 14-MAR-10 02.00.00.000000000 US/EASTERN incorrect
    select from_tz(to_timestamp('14-MAR-2010 0701' , 'DD-MON-YYYY HH24MI'), 'GMT') at time zone 'US/Eastern' from dual; -- returns 14-MAR-10 03:01:00.000000000 US/EASTERN incorrect
    select from_tz(to_timestamp('14-MAR-2010 0800' , 'DD-MON-YYYY HH24MI'), 'GMT') at time zone 'US/Eastern' from dual; -- returns 14-MAR-10 03.00.00.000000000 US/EASTERN incorrect
    select from_tz(to_timestamp('13-MAR-2010 2300' , 'DD-MON-YYYY HH24MI'), 'US/Eastern') at time zone 'GMT' from dual; -- returns 14-MAR-10 04.00.00.000000000 GMT correct
    select from_tz(to_timestamp('14-MAR-2010 0000' , 'DD-MON-YYYY HH24MI'), 'US/Eastern') at time zone 'GMT' from dual; -- returns 14-MAR-10 05.00.00.000000000 GMT correct
    select from_tz(to_timestamp('14-MAR-2010 0100' , 'DD-MON-YYYY HH24MI'), 'US/Eastern') at time zone 'GMT' from dual; -- returns 14-MAR-10 06.00.00.000000000 GMT correct
    select from_tz(to_timestamp('14-MAR-2010 0159' , 'DD-MON-YYYY HH24MI'), 'US/Eastern') at time zone 'GMT' from dual; -- returns 14-MAR-10 06.00.00.000000000 GMT correct
    select from_tz(to_timestamp('14-MAR-2010 0200' , 'DD-MON-YYYY HH24MI'), 'US/Eastern') at time zone 'GMT' from dual; -- returns 14-MAR-10 07.00.00.000000000 GMT incorrect
    select from_tz(to_timestamp('14-MAR-2010 0300' , 'DD-MON-YYYY HH24MI'), 'US/Eastern') at time zone 'GMT' from dual; -- returns 14-MAR-10 08.00.00.000000000 GMT incorrect
    select from_tz(to_timestamp('14-MAR-2010 0301' , 'DD-MON-YYYY HH24MI'), 'US/Eastern') at time zone 'GMT' from dual; -- returns 14-MAR-10 08.01.00.000000000 GMT incorrect
    select from_tz(to_timestamp('14-MAR-2010 0400' , 'DD-MON-YYYY HH24MI'), 'US/Eastern') at time zone 'GMT' from dual; -- returns 14-MAR-10 09.00.00.000000000 GMT incorrect
    so it's as if the Oracle Client SqlDeveloper somehow intervenes as the results come back from the server an adjusts it for the first set of conversions but not the second.
    Basically it looks like I need the patch for the timezones for 10.2.0.1 but what about the Clients? Is there patches I then need for them? Would the SqlPlus client that ships with 10.2.0.4 return the correct results or once the patch is applied to the server.
    Has anyone else encountered this problem and if so would they be able to point me in the direction of a resource describing and resolving it?
    Thanks,
    Mark.

    Hey Robert,
    Yes indeed we are paying for Oracle support? As far as I know I logged in through metalink in an effort to investigate this problem.
    Our DBA upgraded from 10.2.0.4 to 10.2.0.1 and all the inconsistency went away thankfully.
    Thanks for taking the time to reply to me,
    Mark.

  • Migrating database from PostgreSql to Oracle 10g

    Hi
    can anybody help me by providing steps to migrating database from PostgreSql to Oracle 10g. its very urgent requirement. so please let me know if anyone know about this setps.
    thanks in advance.
    jayesh
    cignex technology pvt ltd

    NPD wrote:
    Hi Guys,
    Can one migrate database from sql2005 to Oracle.
    Thanx.You can use [Oracle Migration Tool |http://www.oracle.com/technology/tech/migration/workbench/index.html]
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • UTC timestamps in milliseconds offset from January 1, 1970

    Hello,
    The problem is that I must generate miliseconds offset from jan-1-1970 for a java app from my PL/SQL application.
    how do I can, from a given datetime, get UTC timestamps in milliseconds offset from January 1, 1970?
    I'm in the Canada/Eastern time zone and I'm using the following function:
    CREATE OR REPLACE FUNCTION date_to_float (dt IN DATE)
    RETURN FLOAT
    IS
    BEGIN
    RETURN 24 * 3600 * 1000 * (NEW_TIME (dt, 'EDT', 'GMT') - TO_DATE ('1970-01-01', 'YYYY-MM-DD'));
    END;
    so when I use this function to generate events after the november 2nd, the hour isn't accurate on the application side because the static usage of new_time with EDT source timezone.
    How can I make this function reliable over time?
    Thanks

    It looks like you are looking for the unix style epoch time:
    This code will give it to you plus allow you to configure the resolution, by default it will return the number of seconds since 1-Jan-1970, but by varying either the scale or precision you can get more or less detail, and you can even change the date epoch date used in the calculation.
    create or replace
    function date_to_epoch(
          p_date timestamp with time zone default systimestamp,
          p_scale number default 1,
          p_precision number default 0,
          epoch timestamp with time zone
              default to_timestamp_tz('1970-01-01 utc',
                                      'yyyy-mm-dd tzr')
      ) return number is
        tmp interval day(9) to second;
        sec number;
      begin
        tmp := p_date-epoch;
        sec := extract(day from tmp)*24*60*60;
        sec := sec + extract(hour from tmp)*60*60;
        sec := sec + extract(minute from tmp)*60;
        sec := sec + extract(second from tmp);
        return trunc(sec*p_scale,p_precision);
      end;Edited by: Sentinel on Aug 28, 2008 3:14 PM

  • Upload data from excel to oracle table

    Hi,
    if i'm user and using an application and i want to upload data from excel to oracle table on button click . Is it possible by using sql loader.
    If yes then please clarify it .
    is it possible from client end.
    thanks
    kam

    Yes it is possible using SQL*LDR, External tables and ORCL Export Utility. Though I didn't try Export Utility to load the external files.
    SQLLdr sysntax:
    Create a control file.
    It looks like this
    Load data
    Infile 'source.dat' 
    Into Table tablename
    Fields terminated by ',' optionally enclosed by '"'
    {code}
    then use sqlldr command from your OS.
    {code}
    sqlldr userid/password@sid control = filename.ctl, data = source.dat, log = logname.log, bad = badname.log, discard = discardname.discard
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Data From Excel to Oracle

    Hi, how can I do a Stored Procedure or free code to import data from Excel to Oracle Table? Tanks for all.

    I never use UTL_FILE. I use Delphi and I need to make a subrotine to import xls file to oracle. So, I prefer to do into DataBase, using database resource, but I do not oracle expertise, I have some difficulties. Tanks.

  • Data from Excel to Oracle DB

    Hi,
    I can upload data from excel to access having created stored procedure on access.
    I do the upload using my vb code.
    How can I upload data from excel to oracle db? could i use the same technique as above? only problem is im not sure if that vb code will work with oracle?
    has anyone done this before? anyone have example code?
    kindly assist me here
    thanks

    The easiest way to do this is to use a Oracle ODBC connection which can be found on OTN. You do not need a stored proc.
    After installing Oracle ODBC on the machine where Excel and Access live, do the following.
    Note, you already have steps 1, 2 and 3. I list all the steps for others.
    1. Create your MS/Excel workbook
    2. Add data to it.
    3. Save it as "book1.xls".
    4. Open MS/Access
    5. Create new blank database, call it db1.
    6. Then from the file menu, get external data, import, make sure the file type is xls, select book1.xls.
    7. The wizard will walk you through the process of importing you Excel workbook into a new table.
    8. Save
    9. From the file menu select export table.
    10. Select ODBC at the bottom of the "Save as type list".
    11. Then (depending how you set up ODBC) select Machine Data Source.
    12 . Select your Oracle ODBC connection and press OK.
    You now have taken data from Excel to Access and placed it in the Oracle schema that was named when you setup your Oracle ODBC connection.
    BG...

  • Handling a List returned from a Stored Oracle Procedure

    I'm trying to put a PL/SQL oracle wrapper around some post code lookup
    software.
    We're planning to get the wrapper to return a List and then JDBC to handle this list.
    Has anyone already done/attempted to do this? Does anyone know if it can be done using a List and can oracle stored procedures return a List?

    It appears that Oracle does support an array type:
    In Oracle
    CREATE OR REPLACE FUNCTION getEmpArray RETURN EMPARRAY
    AS
    l_data EmpArray := EmpArray();
    CURSOR c_emp IS SELECT ename FROM EMP;
    BEGIN
    FOR emp_rec IN c_emp LOOP
    l_data.extend;
    l_data(l_data.count) := emp_rec.ename;
    END LOOP;
    RETURN l_data;
    END;
    In Java
    public static void main( ) {
      OracleCallableStatement stmt =(OracleCallableStatement)conn.prepareCall
                    ( "begin ? := getEMpArray; end;" );
        // The name we use below, EMPARRAY, has to match the name of the
        // type defined in the PL/SQL Stored Function
        stmt.registerOutParameter( 1, OracleTypes.ARRAY,"EMPARRAY" );
        stmt.executeUpdate();
        // Get the ARRAY object and print the meta data assosiated with it
        ARRAY simpleArray = stmt.getARRAY(1);
        System.out.println("Array is of type " +  simpleArray.getSQLTypeName());
        System.out.println("Array element is of type code "+simpleArray.getBaseType());
        System.out.println("Array is of length " + simpleArray.length());
        // Print the contents of the array
        String[] values = (String[])simpleArray.getArray();
        for( int i = 0; i < values.length; i++ )
          System.out.println( "row " + i + " = '" + values[i] +"'" );
    This was taken from:
    http://otn.oracle.com/sample_code/tech/java/codesnippet/jdbc/varray/index.html

  • GL Data Conversion from Legacy to Oracle EBS

    Hi All,
    I am tasked with converting legacy data into GL. I have worked on other conversions like supplier, AR and AP conversions but never worked on GL conversion, so I don't know how and where to start, what are the pre-requisites for entering data into gl_interface table how to ensure that data is correct in the .csv file etc.
    Kindly request you all to guide me in right direction. Hope to hear from you all very soon!!! :)
    Regards

    Hi,
    When you talk about GL-Data it is the trial balance to be loaded from legacy to oracle applications.
    You can use Web-ADI to upload it ,the check list are
    The balance for each account comibnation in the legacy system to be mapped to GL-Oracle code combination balance
    With respect to open AR, AP Invoices if the invoices are converted using a control account for migration in GL then
    the the balance transfered from AP,AR need not be reversed in GL from the source receivables and payables.
    In case if the same account combination are for migrating the balances from AP,AR to GL ..Then the balances transferred from AP,AR should be reversed ..so that it does not affect the TB-GL-Balance
    Finally ensure that the balance for the TB-tallys with your legacy system and upload it using Web-ADI ,import and
    review and post it.
    Hope this points helps your GL-Data conversion.
    Regards,
    Ramaa

  • Generate Insert Statement Script to Extract Data from Table in Oracle 7i

    Hi all, I have an old Oracle legacy system that is running for over 15 years.Every now and then we need to extract data from this table@ ORacle 7i to be imported back to Oracle 10G.
    My thoughts are to create a script of Insert statements in oracle 7 and that to be deployed back to Oracle 10G.
    I found this scripts in Google and not sure how exactly this works.Any explanation on thsi scripts , would be greatly appreciated.I find this scripst may help to generate a set of insert statements from that table to the latest table at 10G.
    <pre>
    -- Step 1: Create this procedure:
    create or replace Function ExtractData(v_table_name varchar2) return varchar2 As
    b_found boolean:=false;
    v_tempa varchar2(8000);
    v_tempb varchar2(8000);
    v_tempc varchar2(255);
    begin
    for tab_rec in (select table_name from user_tables where table_name=upper(v_table_name))
    loop
    b_found:=true;
    v_tempa:='select ''insert into '||tab_rec.table_name||' (';
    for col_rec in (select * from user_tab_columns
    where
    table_name=tab_rec.table_name
    order by
    column_id)
    loop
    if col_rec.column_id=1 then
    v_tempa:=v_tempa||'''||chr(10)||''';
    else
    v_tempa:=v_tempa||',''||chr(10)||''';
    v_tempb:=v_tempb||',''||chr(10)||''';
    end if;
    v_tempa:=v_tempa||col_rec.column_name;
    if instr(col_rec.data_type,'CHAR') > 0 then
    v_tempc:='''''''''||'||col_rec.column_name||'||''''''''';
    elsif instr(col_rec.data_type,'DATE') > 0 then
    v_tempc:='''to_date(''''''||to_char('||col_rec.column_name||',''mm/dd/yyyy hh24:mi'')||'''''',''''mm/dd/yyyy hh24:mi'''')''';
    else
    v_tempc:=col_rec.column_name;
    end if;
    v_tempb:=v_tempb||'''||decode('||col_rec.column_name||',Null,''Null'','||v_tempc||')||''';
    end loop;
    v_tempa:=v_tempa||') values ('||v_tempb||');'' from '||tab_rec.table_name||';';
    end loop;
    if Not b_found then
    v_tempa:='-- Table '||v_table_name||' not found';
    else
    v_tempa:=v_tempa||chr(10)||'select ''-- commit;'' from dual;';
    end if;
    return v_tempa;
    end;
    show errors
    -- STEP 2: Run the following code to extract the data.
    set head off
    set pages 0
    set trims on
    set lines 2000
    set feed off
    set echo off
    var retline varchar2(4000)
    spool c:\t1.sql
    select 'set echo off' from dual;
    select 'spool c:\recreatedata.sql' from dual;
    select 'select ''-- This data was extracted on ''||to_char(sysdate,''mm/dd/yyyy hh24:mi'') from dual;' from dual;
    -- Repeat the following two lines as many times as tables you want to extract
    exec :retline:=ExtractData('dept');
    print :retline;
    exec :retline:=ExtractData('emp');
    print :retline;
    select 'spool off' from dual;
    spool off
    @c:\t1
    -- STEP3: Run the spooled output c:\recreatedata.sql to recreate data.
    Source:http://www.idevelopment.info/data/Oracle/DBA_tips/PL_SQL/PLSQL_5.shtml
    </pre>

    Thanks Justin.
    I get what you are saying,i really wanted to see the output of the codes, because the furtherst i could get from that code is
    SELECT EXTRACTDATA('MYTABLE') FROM MYTABLE;
    and it generated this:
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    I was expecting a string of
    insert into mytable values (19/1/2009,1,1);
    insert into mytable values (19/10/2008,5,10);
    Thanks for the explanation .

  • Migrating from Informix to Oracle 11g

    Hi,
    I have downloaded the Migration workbench, and the plug-ins Inofrmix7.jar from http://www.oracle.com/technetwork/topics/index-095746.html. Kindly could you please tell me from where i can download the ifxjdbc.jar. Are these files same with different name.
    Regards

    Hello,
    What you need is the Informix Dynamic Server JDBC Driver, version 1.4 JAR file, ifxjdbc.jar.
    This driver is shipped with the Informix Dynamic Server software. I am not sure you can download it freely.
    Regards,
    Jean-Patrick

Maybe you are looking for

  • NW2004sSP7_Preview J2EE Server error

    Hi, I am not able to start the J2ee server after install. Here is the trace file from the server. trc file: "C:\usr\sap\J2E\JC01\work\dev_server0", trc level: 1, release: "700" node name   : ID14203250 pid         : 5668 system name : J2E system nr. 

  • Po line items in bdc

    requirment: to load a file filed with ean no and populate line item of me23n with the respective eans number and their quan and it shuld populate the line items and not save them so user can check a few things and then save it manually while creating

  • Listener: ORA-00604 ORA-01219

    We have a database on 10.2.0.5.0. Sometimes we are able to login, sometimes we get the error below (this is from the client, on the server it works): SQL> conn dba@tst ERROR: ORA-00604: error occurred at recursive SQL level 1 ORA-01219: database not

  • Best site for Photoshop tutorials?

    I'm mocking up some dummy ads and need to brush up on a few Photoshop skills that I haven't used in a while. I'm finding that Google's completely useless for this. Nothing but pages and pages of spammy results. Any good Photoshop tutorial sites out t

  • Multiple EUL Connections in Discoverer 9i Plus

    Discoverer 9i Plus doesn't allow you to change your default EUL anymore. I currently have to set up different connections for each EUL. Is there a way to set up one connection and change between my EULs like it had done in previous versions?