How can i extract data from oracle table  to flat file or excel spread shee

Hello,
DB Version is 10.1.0.3.0
How can i extract data from oracle table to flat file or excel spread sheet by using sub programs?
Regards,
D

Here what I did
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 80
SET PAGESIZE 0
SET ECHO OFF
SET FEEDBACK OFF
SET VERIFY OFF
SET HEADING OFF
SET MARKUP HTML OFF SPOOL OFF
Sql> SPOOL bing
select * from -------;
SPOOL OFF;
I do not see file.
I also tried
Sql> SPOOL /tmp/bing
select * from -------;
SPOOL OFF;
But still not seeing the fie,

Similar Messages

  • Import data from Oracle table into flat file

    How to import the data in the oracle table into flat file using UTL File of PL/SQL....
    I am new in PL/SQL..
    can someone help me in writing query?

    Note : Not Tested.
    DECLARE
    V1 VARCHAR2(32767);
    F1 UTL_FILE.FILE_TYPE;
    cursor c1 is select ename,empno from emp;
    r_c1 c1%rowtype;
    BEGIN
    -- In this example MAX_LINESIZE is less than GET_LINE's length request
    -- so the number of bytes returned will be 256 or less if a line terminator is seen.
    open c1;
    F1 := UTL_FILE.FOPEN('MYDIR','MYFILE','W',256);
    loop
    fetch c1 into r_c1;
    v1:= r_c1.ename||''||To_char(r_c1.empno);
    UTL_FILE.PUT_LINE (F1, v1,TRUE);
    v1:= null;
    Exit when c1%not found;
    end loop;
    UTL_FILE.FCLOSE(F1);
    END;
    http://download.oracle.com/docs/cd/B19306_01/appdev.102
    ------------------------------------------------------------------

  • Extracting data from Oracle to a flat file

    I'm looking for options to extract data a table or view at a time to a text file. Short of writing the SQL to do it, are there any other ideas? I'm dealing with large volumes of data, and would like a bulk copy routine.
    Thanks in advance for your help.

    Is there any script which i can use for pulling data from tables to a flat file and then import that data to other DB'sFlat file is adequate only from VARCHAR2, NUMBER, & DATA datatypes.
    Other datatypes present a challenge within text file.
    A more robust solution is to use export/import to move data between Oracle DBs.

  • How to extract data From Hyperion Essbase to Flat Files

    Hi ,
    Can anyone tell me how to extract data from Hyperion essbase to Flat file(e.g. .csv , .txt ,...) or Oracle Table using ODI.
    Regards,
    Avneet

    Hi sutirtha,
    I have make one column as key column now i am getting this error,
    org.apache.bsf.BSFException: exception from Jython:
    Traceback (innermost last):
    File "<string>", line 1, in ?
    com.hyperion.odi.essbase.ODIEssbaseException: The number of columns returned by script [10] is less than the source data columns exposed [12]
    at com.hyperion.odi.essbase.ODIEssbaseDataReader.getAppData(Unknown Source)
    at com.hyperion.odi.essbase.AbstractEssbaseReader.extract(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
    at org.python.core.PyMethod.__call__(PyMethod.java)
    at org.python.core.PyObject.__call__(PyObject.java)
    at org.python.core.PyInstance.invoke(PyInstance.java)
    at org.python.pycode._pyx7.f$0(<string>:1)
    at org.python.pycode._pyx7.call_function(<string>)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyCode.call(PyCode.java)
    at org.python.core.Py.runCode(Py.java)
    at org.python.core.Py.exec(Py.java)
    at org.python.util.PythonInterpreter.exec(PythonInterpreter.java)
    at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:144)
    at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.k(e.java)
    at com.sunopsis.dwg.cmd.g.A(g.java)
    at com.sunopsis.dwg.cmd.e.run(e.java)
    at java.lang.Thread.run(Unknown Source)
    Caused by: com.hyperion.odi.essbase.ODIEssbaseException: The number of columns returned by script [10] is less than the source data columns exposed [12]
    at com.hyperion.odi.essbase.wrapper.EssbaseReportDataIterator.validateColumns(Unknown Source)
    at com.hyperion.odi.essbase.wrapper.EssbaseReportDataIterator.init(Unknown Source)
    ... 33 more
    com.hyperion.odi.essbase.ODIEssbaseException: com.hyperion.odi.essbase.ODIEssbaseException: The number of columns returned by script [10] is less than the source data columns exposed [12]
    at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:146)
    at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.k(e.java)
    at com.sunopsis.dwg.cmd.g.A(g.java)
    at com.sunopsis.dwg.cmd.e.run(e.java)
    at java.lang.Thread.run(Unknown Source)

  • Download data from internal table to flat file.

    I need to download the data from Internal table to Flat file. can any one suggest how to do it? i suppose WS_Download OR GUI_DOWNLOAD.
    but if it is please guide me how to use this.
    is thre any other F.M. please provide the information.
    Thanks in advance

    Hi,
    Try this,
    * File download, uses older techniques but achieves a perfectly
    * acceptable solution which also allows the user to append data to
    * an existing file.
      PARAMETERS: p_file like rlgrap-filename.
    * Internal table to store export data  
      DATA: begin of it_excelfile occurs 0,
       row(500) type c,
       end of it_excelfile.
      DATA: rc TYPE sy-ucomm,
            ld_answer TYPE c.
      CALL FUNCTION 'WS_QUERY'
           EXPORTING
                query    = 'FE'  "File Exist?
                filename = p_file
           IMPORTING
                return   = rc.
      IF rc NE 0.                       "If File alread exists
        CALL FUNCTION 'POPUP_TO_CONFIRM'
          EXPORTING
    *          TITLEBAR              = ' '
    *          DIAGNOSE_OBJECT       = ' '
               text_question         = 'File Already exists!!'
               text_button_1         = 'Replace'
    *          ICON_BUTTON_1         = ' '
               text_button_2         = 'New name'
    *          ICON_BUTTON_2         = ' '
    *          DEFAULT_BUTTON        = '1'
    *          DISPLAY_CANCEL_BUTTON = 'X'
    *          USERDEFINED_F1_HELP   = ' '
    *          START_COLUMN          = 25
    *          START_ROW             = 6
    *          POPUP_TYPE            =
          IMPORTING
               answer                = ld_answer
    *     TABLES
    *         PARAMETER              =
          EXCEPTIONS
              text_not_found         = 1
              OTHERS                 = 2.
    * Option 1: Overwrite
        IF ld_answer EQ '1'.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
    *            BIN_FILESIZE            =
                 filename                = p_file        "File Name
                 filetype                = 'ASC'
    *       IMPORTING
    *            FILELENGTH              =
            TABLES
                data_tab                = it_excelfile   "Data table
            EXCEPTIONS
                file_write_error        = 1
                no_batch                = 2
                gui_refuse_filetransfer = 3
                invalid_type            = 4
                OTHERS                  = 5.
          IF sy-subrc <> 0.
            MESSAGE i003(zp) WITH
                     'There was an error during Excel file creation'(200).
            exit. "Causes short dump if removed and excel document was open 
          ENDIF.
    * Option 2: New name.
        ELSEIF ld_answer EQ '2'.
          CALL FUNCTION 'DOWNLOAD'
            EXPORTING
                 filename            = p_file          "File name
                 filetype            = 'ASC'           "File type
    *             col_select          = 'X'            "COL_SELECT
    *             col_selectmask      = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
    *                                                   "COL_SELECTMASK
                 filetype_no_show    = 'X'     "Show file type selection?
    *       IMPORTING
    *             act_filename        = filename_dat
            TABLES
                 data_tab            = it_excelfile    "Data table
    *            fieldnames          =
            EXCEPTIONS
                 file_open_error     = 01
                 file_write_error    = 02
                 invalid_filesize    = 03
                 invalid_table_width = 04
                 invalid_type        = 05
                 no_batch            = 06
                 unknown_error       = 07.
        ENDIF.
      ELSE.                               "File does not alread exist.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
    *          BIN_FILESIZE            =
               filename                = p_file         "File name
               filetype                = 'ASC'          "File type
    *     IMPORTING
    *          FILELENGTH              =
          TABLES
               data_tab                = it_excelfile   "Data table
          EXCEPTIONS
               file_write_error        = 1
               no_batch                = 2
               gui_refuse_filetransfer = 3
               invalid_type            = 4
               OTHERS                  = 5.
        IF sy-subrc <> 0.
          MESSAGE i003(zp) WITH
                   'There was an error during Excel file creation'(200).
          exit. "Causes short dump if removed and excel document was open 
        ENDIF.
      ENDIF.
    Regards,
    Raghav

  • Extract of Data from Oracle in a Flat File with Column and Record seperator

    I have a case where I have to extract whole data froma Oracle Table where the Columns should be seperated by |@|
    and Records by ^*^.
    The reason for this is My data has Space and New line in it. So My Program to recoganize each column and record I want them to be seperated by special chars.
    Itried this but of no much help.
    set echo off newpage 0 space 0 pagesize 0 feed off head off trimspool on;
    spool on;
    set colsep '|@|';
    set recsepchar '^*^';
    spool "T_COMPLAINT.dat";
    select * from T_COMPLAINT where ROWNUM < '100' order by cptoid;
    spool off;

    Having '@' and '*' characters in the data will not make any difference if you are using a combined column separator of '|@|' - provided any process you use subsequently can handle it.
    However, the recsepchar parameter appears to be restricted to a single character which is repeated right across the page, so I don't think you could have a single iteration of '|*|' using this method:
    SQL> set  newpage 0 space 0 pagesize 0 feed off head off trimspool on
    SQL> set recsep EACH
    SQL> set recsepchar '*'
    SQL> set colsep '|@|'
    SQL> select * from testa;
    A         |@|1@        |@|22-JUN-2010
    B         |@|2*        |@|22-JUN-2010
    B         |@|2*        |@|22-JUN-2010
    ********************************************************************************Edited by: LindaA on 23-Jun-2010 08:33

  • Loading data from oracle table to text file........

    how can i load data from a oracle table to a text file or CSV file using PL/SQL procedures where the pls/sql code will take the table name dynamically.........
    soumen

    Try this thread..
    Is it possible to export a pl/sql region as a csv file?

  • How to copy the Data From Oracle Table To SAP Table

    Hi Friends,
    We need to copy the data from Oracle Database Table to SAP Table. The data should be updated simultaneously in both tables . Should I write a program that contains the native sql statement like EXEC SQL PERFORMING WRITE,....
    I appreciate any suggestions regarding this.
    Regards
    CSM Reddy

    Hi,
    since you posted this question in the DB2 forum I assume that you are using a DB2 database for your SAP system.
    To access a table from a legacy ORACLE database you may use the DBSL multiconnect feature. I.e. you open a secondary connecction in the SAP system to your ORALE database. You can then ready the data from the ORACLE database into an ABAP internal table and insert it afterwards into the DB2 table on the main connection.
    Another way to access an ORACLE table from a DB2 database is to use the DB2 federated database feature. This requires a little bit more DB2 skill. With this feature you can make the ORACLE table visible within the DB2 database. To copy data you can then simply use a "INSERT ... SELECT" statement. 
    Regards
             Frank

  • How can I extract data from a sound file in carbon

    hello,
    I am a student and I start recently learning carbon. I have to do a application which can read and extract data from a sound file and use that data to do some kind of visual representation of the file. I would like to know if someone can give some directions, tutorial,some code sample etc.
    thank you for your help
    chenita7

    hello orangekay
    My idea is to create an application that can read a sound file( AIFF, MP3 or other) in order to extract some kind of data ( numbers or any values) and use that data to represent the sound file visually.
    I dont know which kind of data can be extract from a sound file, and in which way i can manipulate that data to became a visual representation of the sound file. this is what I want to do as my second assignment for a subject at school, introduction to programming. has to be done based in carbon.
    regards
    chenita7

  • Extracting data from Essbase & loading into flat file through ODI

    Hi,
    I want to extract data from Essbase and load it into a flat file through ODI(for extraction from essbase I'm using a report script) and I’m using these KM’s:- LKM Hyperion Essbase data to SQL,IKM SQL to FILE Append & for reversing I’m using RKM Hyperion Essbase.All the mappings have been done and the interface has been made. But when I’m executing the interface it is throwing the error below:-
    ODI-1217: Session ESS_FILEI (114001) fails with return code 7000.
    ODI-1226: Step ESS_FILEI fails after 1 attempt(s).
    ODI-1240: Flow ESS_FILEI fails while performing a Loading operation. This flow loads target table ESS_FILE.
    ODI-1228: Task SrcSet0 (Loading) fails on the target FILE connection FILE_PS_ODI.
    Caused By: java.sql.SQLException: ODI-40417: An IOException was caught while creating the file saying The system cannot find the path specified
    at com.sunopsis.jdbc.driver.file.impl.commands.CommandCreateTable.execute(CommandCreateTable.java:62)
    at com.sunopsis.jdbc.driver.file.CommandExecutor.executeCommand(CommandExecutor.java:33)
    at com.sunopsis.jdbc.driver.file.FilePreparedStatement.execute(FilePreparedStatement.java:178)
    at oracle.odi.runtime.agent.execution.sql.SQLCommand.execute(SQLCommand.java:163)
    at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:102)
    at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:1)
    at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:50)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2906)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2609)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:537)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:453)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:1740)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:338)
    at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:214)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:272)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:263)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:822)
    at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:123)
    at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:82)
    at java.lang.Thread.run(Thread.java:619)
    Please let me know what I'm missing and how I can resolve this error.
    Thanks

    It seems that you are trying to use the file as your staging areas. Hyperion LKM extracts essbase data into a DB staging area which can then be used by your file IKM to load it into file.
    You need to use a RDBMS for your staging area.

  • Extract data from Query to a Flat File - scheduling in the background

    Hi All,
    We need to extract data from a query to a flat file periodically, but each time 10 separate executions based on 10 profit centers, to get the separate files.
    So, we have PC1, PC2, ... PC10 Profit centeres.
    We have Query1, with profit center variable.
    We have created 10 variants for Query1 so that we can execute for 10 profit centers.
    Now, we have used RSCRM_BAPI to execute the Query1 and write to a flat file. Now we are having a problem in getting this feature used to execute the query automatically for 10 different varaints.
    Thanks in advance,
    _ Shashi

    Shashi,
       You can try using Information Broadcasting or Reporting Agent. You can schedule this in Information Broadcasting.
    check this link for Information Broadcasting... <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/a5/359840dfa5a160e10000000a1550b0/content.htm">http://help.sap.com/saphelp_nw04s/helpdata/en/a5/359840dfa5a160e10000000a1550b0/content.htm</a>
    Nagesh Ganisetti.

  • How to extract data from Oracle Table to an Oracle XMLtype field

    All,
    I'm very new with ODI and I'm looking for a way to implement the following scenario:
    I have the Oracle table A, already mapped to Data Model A. This table has the following fields:
    field X (PK)
    field Y
    field Z
    field W
    I have a table B, already mapped to Data Model B. This table has the following fields:
    field X (PK)
    field V (XMLType)
    I want to extract the data from Table A to a XML file with the following structure:
    <X> yada yada yada </X>
    <Y> yada yada yada </Y>
    <Z> yada yada yada </Z>
    <W> yada yada yada </W>
    and then insert this file into the field V of Table B. How can I do that?
    TIA,
    Rodrigo

    You can use UDConnect to get from Oracle database in to BW
    <b>Data Transfer with UD Connect -</b>
    http://help.sap.com/saphelp_nw04/helpdata/en/78/ef1441a509064abee6ffd6f38278fd/content.htm
    <b>Prerequisites</b>
    You have installed the SAP WAS J2EE Engine with BI Java components.  You can find more information on this in the SAP BW installation guide on the SAP Service Marketplace at service.sap.com/instguides.
    Hope it Helps
    Chetan
    @CP..

  • How can I extract data from ST03 - what tables are used?

    Hi
    I currently have to create performance statistics daily for management. To do this I use transaction ST03 and manually copy the previous days Dialog average response time, DB, CPU and GU av. times into a spreadsheet, and also the average dialog response time for 4 key transactions from the transaction profile.
    It would be nice to automate this. I was thinking of writing a basic ABAP program to query the relevant tables to extract this data - does anyone know which tables are used? I'd tried running a trace but it was not clear which tables/rows etc would be required.
    Thanks
    Ross

    Ok, that FM is an old one - for NW2004s (700) need to use 'SWNC_COLLECTOR_GET_AGGREGATES'.
    Have a basic program below. What I'm trying to do is get the average response time for transactions. I can get 'respti' from the table but I think this is the total response time - what field represents average response time?
    Also, the numbers that it's pulling back don't seem to match the numbers in ST03 at all... except 'dcount'. This seems to correct ly show the number of steps... but the other values don't match anything. What am I doing wrong?
    Program below...
    Cheers
    Ross
    REPORT  Z_GETSTATS.
    PARAMETER: day TYPE dats DEFAULT sy-datum.
    DATA: t_usertcode  TYPE swnc_t_aggusertcode,
          wa_usertcode TYPE swncaggusertcode.
    START-OF-SELECTION.
    CALL FUNCTION 'SWNC_COLLECTOR_GET_AGGREGATES'
        EXPORTING
          component     = 'TOTAL'
          periodtype    = 'D'
          periodstrt    = day
        TABLES
          usertcode     = t_usertcode
        EXCEPTIONS
          no_data_found = 1
          OTHERS        = 2.
      LOOP AT t_usertcode INTO wa_usertcode.
             WRITE:/ wa_usertcode-entry_id.
             WRITE:/ wa_usertcode-respti, wa_usertcode-procti, wa_usertcode-cputi, wa_usertcode-dcount, wa_usertcode-ucount.
             WRITE:/ '*************************************'.
      ENDLOOP.

  • How can I retrieve data from one table to another automatic in SQL?

    Hi, everione,
    I am having a big problem, trying to create datebase.
    I have 3 tables: SUPERAVATAR, MASTERAVATAR, MEGAAVATAR.
    - SuperAvatars are heroes in an online role playing gaming. They have an ID, ‘superavatarID’ which contain an UNIQUE NUMBER NOT NULL PRIMARY KEY to identify them.
    A wisdom – ‘trickster’,’conjuror’,’magician’, etc..
    A current owner… who is the user or player of the game and has that Super Avatar– we associate the link to USERID to know the person.
    SuperAvatars can be fathers or mothers of Mega Avatars.
    -MegaAvatars are the children of SuperAvatars…. They also have an ID UNIQUE NUMBER NOT NULL PRIMARY KEY to indentify them.
    A magic power – it can be a ‘Leader’ or ‘Sheep’…
    A ‘parent’ – parent is the number identifying to know to who Super Avatar belongs.
    e.g.
    SUPERAVAT WISD CURRENTOWNER FATHEROF MOTHEROF
    1 Thick 3 1
    2 Mentally Ch. 11 3
    3 Smart 9 2
    4 Genius 16 4
    5 Thick 19
    MEGAAVATARID MAGICPOWER PARENT
    1 MAGICIAN 1
    2 WIZARD 3
    3 SORCERER 2
    4 MAGICIAN 4
    -We see that MEGAAVATAR 1 has a magic power as Magician and his father is ‘1’. ‘1’ identifies the SUPERAVATAR.
    We see SUPERAVATARID…. who has the number ‘1’? the first in the row… who has wisdom – thick and he belongs to the USER with ID number 3.
    -We see MEGAAVATARID… we choose the number 2…. His magic power is as WIZARD… and his father is the number 3.
    We see SUPERAVATARID now… we look up the SuperavatarID 3…. We can see he has a wisdom – GENIUS… who belongs to the USERID 16 and he is father of MEGAAVATAR number 2.
    The list can carry on and never stop.
    I have this Problems:
    We create in this example 3 tables: Users, SuperAvatar, MegaAvatar
    SQL
    CREATE TABLE users(userID NUMBER CONSTRAINT pk_user PRIMARY KEY,email VARCHAR2(50) NOT NULL UNIQUE,password VARCHAR2(15) NOT NULL UNIQUE,subscription CHAR(8) NOT NULL CHECK (subscription IN('ACTIVE' , 'INACTIVE' ) ) );
    CREATE TABLE superavatar(superavatarID NUMBER CONSTRAINT pk_superavatar PRIMARY KEY, wisdom VARCHAR2(19) NOT NULL CHECK (wisdom IN ('THICK', 'MENTALLY CHALLENGED', 'AWAKE', 'SMART', 'GENIUS')), currentOwner NUMBER NOT NULL, fatherOf NUMBER,motherOf NUMBER);
    CREATE TABLE megaavatar (megaavatarID NUMBER CONSTRAINT pk_megaavatar PRIMARY KEY, magicPower VARCHAR2(12) NOT NULL CHECK (magicPower IN('TRICKSTER','CONJUROR','MAGICIAN','WIZARD','SORCERER')), parent NUMBER);
    Now, the 3 tables are created…..
    What happen when we try to insert values to this table?
    In this case we insert to User Table some examples:
    INSERT INTO users VALUES('3','[email protected]','great78','ACTIVE');
    INSERT INTO users VALUES('9','[email protected]','chrisandra)','ACTIVE');
    Now, we insert to SuperAvatar some examples;
    INSERT INTO superavatar VALUES('1','THICK','3','1','');
    INSERT INTO superavatar VALUES('3','SMART','9','3','');
    |
    |
    ‘9’ is the UserID that we already insert to the User table
    What’s the problem?
    We have to insert manually the data from USERID to CURRENTOWNER as we didn’t match or link CURRENTOWNER from SUPERAVATAR Table to USERID from USER Table with a SQL CODE.
    What happen if we have thousands of USERS that they register to this game…? We will never know to how belongs that SUPERAVATAR but if someone do it manually can spend a year.
    I am trying to fix this problem …. I add in SUPERAVATAR TABLE ‘CHECK’ in currentOwner..
    SQL> CREATE TABLE superavatar
    (superavatarID NUMBER CONSTRAINT pk_superavatar PRIMARY KEY, wisdom VARCHAR2(19) NOT NULL CHECK (wisdom IN ('THICK', 'MENTALLY CHALLENGED', 'AWAKE', 'SMART', 'GENIUS')),
    currentOwner NUMBER NOT NULL CHECK (currentOwner IN(SELECT userID FROM users)),
    fatherOf NUMBER,
    motherOf NUMBER);
    ERROR:
    ORA-02251: subquery not allowed here
    It doesn’t work.
    Please HELP, I have exam tomorrow
    thank you
    Desy

    Hallo,
    you can use trigger on table USER and fill the userid in AVATAR.currentowner,
    but i don't understand, how you join these tables ?
    Which user id must come in which column currentowner ?
    Design problem ?
    Regards
    Dmytro

  • How can I extract data from embedded collection??????

    I have 4 classes (class1, class2, class3, class4). Each of them contains properties, methods and a set (HashSet). The set declaration code is: private Set set1;
    The initialization occurs in the appropriate method (however I did declare and initialize as private Set set1= new HashSet(); without success). Each Set is declared and initialize in their own class. The insert and update method works perfectly well.
    When I load class1 object, I can see at runtime in the debug feature all properties data as well as all set elements (set1, set2, set3, and set4). I can extract the data from all properties belongs to the class1 as well as the set1 element. However I cannot extract the data from the set2, set 3 and set4. By writing the following �String s = class1.set1(). Property name;� and I will get the information. The problem that I have is that I cannot write the following �String s= class1.set1().set2().property name;� since set2 cannot be seen. What should I do to get the info from the other set collection???? The loading method provide an object that contains everything. This object is equal as class1 and the set are embedded one inside the other.
    Used hibernate and Struts.
    Could someone help???? Many thanks

    Are we talking about Java source code here or some weird expression language?
    Can you post a minimal, example Java program that demonstrates your problem?

Maybe you are looking for

  • How can I move the download backups and backups folder to a new location

    I am using Lightroom 4.3 on a windows 7 64 windows computer with two hard drives.  One dedicated to running programs and the larger one for storage of all my other stuff.  Well my backups and download backups folders are on the smaller drive and I ne

  • With a contract number, how to know the total PO release value against it?

    Usually one contract corresponds to multiple PO records, now we know the contract number, then how to know the total PO release value against this contract.  In other word, we would like to know the total release value of all the POs with the same co

  • Trouble Getting Started With Flex

    I am trying to go through the tutorials that come with Flex Builder 2 and cannot get any custom components to work. Projects that have custom components defined in them compile OK but I get a run-time error: Error #1009 Cannot access a property or me

  • BEA Sip Server 3.1 Socketexception

    Hi All, I am getting a SocketException on the multicast address specified for the Data and Engine Cluster while starting the managed servers in Weblogic SIP Server 3.1. Does anyone know how to fix this? Thanks !

  • Encore CS5 Blu-Ray Preview Playback Issues / Authoring Issues

    Hello, I'm using Adobe Encore CS5 on a Mac Pro (Nehalem) 2 x 2.26 GHz Quad-Core Intel Xeon w/ 8 GB Ram on Mac OS X 10.5.8. I've recently upgraded to CS5 after having no luck using CS3 to make Blu-Ray discs.  So far my experience has been a little dis