Search code examples
oracle-apex-5

Importing data from one workspace to another workspace


In oracle apex export of data from table is done in .csv format and during loading the data into another workspace it shows an error ORA-01843: not a valid month

I tried to import the data in .xml format but it also produces an error:

ORA-31011: XML parsing failed ORA-19202: Error occurred in XML processing LPX-00222: error received from SAX callback function ORA-02291: integrity constraint (RETAIL_CLOUD.RCM_CUSTOMER_FK2) violated - parent key not found

Could someone help me to sort out this error


Solution

  • You got something wrong. A workspace is a container for your Apex applications, it doesn't contain user data. That's what your question suggests ("export data in a CSV format"). Data is stored in a table (which resides in a tablespace) and belongs to a certain user.

    As of an invalid month: check whether NLS settings are equal for both source and target. For example, 20.03.2018 can't be valid if date format is set to YYYY-MM-DD. Or, if your dates were stored in a VARCHAR2 column and now should be inserted into a DATE data type column, you should beware invalid dates (such as Feb 30th or 30.42.2018 etc.).

    Trying to do that via XML produces an error which doesn't have anything to do with the previous one - it says that you are trying to load child values into some table, but its parent doesn't exist yet which violated the foreign key constraint.

    If I were you, I wouldn't migrate data with CSV nor XML files, but use Oracle's (Data Pump) Export & Import utilities which are designed for such things. I encourage you to investigate Data Pump, or - at least - original EXP and IMP utilities.

    [EDIT: example of a simple EXP/IMP utilities usage]

    User SCOTT has table named DEPT. I'd like to export it, and then import it to MIKE's schema (which currently doesn't have that table):

    SQL> connect mike/lion@orcl
    Connected.
    SQL> select * from tab where tname = 'DEPT';
    
    no rows selected
    
    SQL> $exp scott/tiger@orcl tables=dept file=my_export.dmp
    
    Export: Release 11.2.0.2.0 - Production on Pet O×u 9 08:23:13 2018
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
    Data Mining and Real Application Tes
    Export done in EE8MSWIN1250 character set and AL16UTF16 NCHAR character set
    
    About to export specified tables via Conventional Path ...
    . . exporting table                           DEPT          4 rows exported
    Export terminated successfully without warnings.
    

    Export has been done. Now, import:

    SQL> $imp mike/lion@orcl file=my_export.dmp full=y
    
    Import: Release 11.2.0.2.0 - Production on Pet O×u 9 08:23:29 2018
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
    Data Mining and Real Application Tes
    
    Export file created by EXPORT:V11.02.00 via conventional path
    
    Warning: the objects were exported by SCOTT, not by you
    
    import done in EE8MSWIN1250 character set and AL16UTF16 NCHAR character set
    . importing SCOTT's objects into MIKE
    . importing SCOTT's objects into MIKE
    . . importing table                         "DEPT"          4 rows imported
    Import terminated successfully without warnings.
    

    It has also finished successfully. Finally, let's check whether MIKE now has the DEPT table and what's in there:

    SQL> show user
    USER is "MIKE"
    SQL> select * From dept;
    
        DEPTNO DNAME          LOC
    ---------- -------------- -------------
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    
    SQL>
    

    As you can see, it is quite simple. Both EXP and IMP have numerous parameters you can use; once again - check the documentation.