Bringing Classes Together

Hi I've been working on a calculator that now writes to file, and can activated from a main menu. I got the two to work together by extending the main menu to the calculator and simply running the method where it was needed.
Then I wanted to veiw the file. So I put together a program that would read and display the text when run, But I mentioned earlier that I extended the Calculator to the MainMenu to get them to work together, now how am supposed to extend the FileReader as well?
I have three classes:
A main Menu class. - asks user to input 1 for calculator, or 2 to veiw file. So if(input==1); run the method, which is inside the calculator class.
if(input==2); I want to view the file.
I have a lonely FileReader class, I've tried extending the MainMenu to it, but that hasn't worked. So I need help with using the method that's inside the FileReader class, in my MainMenu class.
This might be an easy one... too easy? Any help would really be appriecated. I can post the code for any or all of the classes if it helps.

This is the code for the main menu. Before I introduced the second option (view file), the classes worked together without problems.
it was originally:
class Menu_RunThis extends CalcSalesTax {I extended the CalcSalesTax class so that I could use the method in CalcSalesTax "salesTax()"
But now that I have another class with a method in it which I would like to use, how do I use it?
(See method getContents)
This is the broken code... of the MainMenu*:*
import java.io.*;
import java.util.*;
class Menu_RunThis    {
public static ReadLog getContents = new getContents;
public static CalcSakesTax salesTax = new salesTax;
public static void main(String[] args)throws java.io.IOException {
System.out.println("Instructions:");
System.out.println("**************");
System.out.println("Press '1' to calculate sales tax, specify the number of items you intend to\r\ncalculate, and their prices. This calculator assumes that sales tax is equal to 6.5 %.\r\nThe information you provide/recieve is stored in a text-file for your convience.");
System.out.println("");
System.out.println("Please Select:");
System.out.println("1: to Calculate Tax");
System.out.println("2: view Log File");
System.out.println("or");
System.out.println("0: to Exit");
int val = 3;
while (val != 0)
Scanner input = new Scanner(System.in);
val = input.nextInt();
if (val == 0) return;
else if (val == 1) salesTax(); //SalesTax method is called
else if (val == 2) subMenu();
else {System.out.println("Please Select:");
System.out.println("1: to Calculate Tax");
System.out.println("or");
System.out.println("0: to Exit");}}
public static void subMenu(){
System.out.println("Please Select:");
System.out.println("1: To view the Log file");
System.out.println("or");
System.out.println("0: to Exit");
int val = 3;
while (val != 0)
Scanner input = new Scanner(System.in);
val = input.nextInt();
if (val == 0) return;
else if (val == 1) getContents(); //getContents method is called
else {
System.out.println("Please Select:");
System.out.println("1: To view the Log file");
System.out.println("or");
System.out.println("0: to Exit");
}}Edited by: tark_theshark on Nov 26, 2007 10:58 PM

Similar Messages

  • When importing songs of a same album but different artist iTunes will separate the artists. How can I bring all together in the same album?

    When importing songs of a same album but different artist iTunes will separate the artists. How can I bring all together in the same album?

    Generally setting a common Album Artist will fix things. For deeper problems see Grouping tracks into albums.
    tt2

  • Using CSS class together with CSS Rule

    Hi,
    I design my web site in Dreamweaver and then use Web
    Developer 2005 Express for the dynamic stuff. I amalgamate all the
    work I have done in Dreamweaver into 2005 Express. However with the
    new server side controls I do not know how to add a CSS class
    together with a CSS rule.
    In the normal client side control in Dreamweaver I have -
    <input name="txtPassword" type="password" class="Input"
    id="SpacerBottom" />
    In the server side controls the ID keyword is used now -
    <asp:TextBox ID="txtPassword" runat="server"
    Style="z-index: 107" CssClass="Input" ></asp:TextBox>
    I have tried to use the name="txtPassword", but it ignores
    this.
    I would really like to know how I can use a class and an id
    selector with the new server side controls and would really
    appreciate some help on this.
    Many thanks,
    Polly Anna

    the explicit " match-any" will do just that.So, a nested ACL can be configured for multiple criteria.
    The alternate is a "match-all" where all nested options in your acl MUST be met. Hope this helps.
    T

  • Linking classes together

    hi, do u guys know of any tutorials about linking two or more classes together?
    i need to learn anything and everything about it.
    thx,
    gildan2020

    class A
        public static void main(String[] args)
            // uses static PrintStream object in System class and
            // calls the println() method on that PrintStream object.
            System.out.println("Hello World");
    }http://java.sun.com/docs/books/tutorial/
    http://java.sun.com/learning/new2java/index.html
    http://javaalmanac.com
    http://www.jguru.com
    http://www.javaranch.com
    Bruce Eckel's Thinking in Java
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java

  • Running 2 classes together

    I have 2 classes that i want to run together. They both have
    GUI components to run there separate methods. The code is long
    so i've shown the stripped down basic idea below.
    public class Class2 extends JFrame
         public Class2(String name)
                super(name);
              //Code for GUI
         public Class2()
              //Default constructor to access the class
         public void createPopupFrame()
              //code to show the Internal Frame
              frame.show();
         public static void main(String[] args)
              //Runs the GUI
              new Class2("Class2");
    } i want to call the method for the internal Frame ( createPopupFrame() ) from Class1
    while Class2 is running and therefore popUp that frame in class2.
    class Class1 extends JFrame
         //Various GUI components
           public Class1(String name)
                 super(name);
                //Code for GUI
                //Button to call the method callPopUP()
           public Class1()
                //Default constructor to access the class
         public void callPopUP()
              Class2 dis = new Class2();
              dis.createPopupFrame();
         public static void main(String[] args)
              //Runs the GUI
              new Class1("Class1");
         }//end main
    }I'm having trouble implementing this in java. I searched around the api
    and the forums and found some stuff about Runnable interface but i'm not really
    any the wiser. I've tested the createPopupFrame() method and i works fine from within
    class2.
    When i call it from class1 while class2 is running i get a NullPointerException. Although
    i expected this because i knew, that would just be too easy.
    Any help appreciated.

    Line 171 in class2I assumed line 171 referenced an object created
    somewhere in line 170.I believe this to be an incorrect assumption.
    and line 7 in class1I fail to see the null reference here by virtue of
    line 6.Typically , a stack trace shows a call sequence. Since line 7 calls the method containing line 171, if frame is null, the NPE stack sequence would show:
    NPE in line 171
    called from line 7
    OP. Try the following:
    public void createPopupFrame()
        //code to show the Internal Frame
        if ( frame != null )
            frame.show();
        else
            System.out.println( "The frame object has not been instantiated." );
    }Good luck.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Using two versions of the one class together?? (I think)

    Hi, see the following small program, where the user can enter an int, and the program draws that amount of lines, joined together at a centre point. The user can then move these lines around the centre by dragging the red dot at the end of the lines.
    Anyway, what I want to be able to do, is have two different versions of this program running side by side, independently of each other. (ie one might have 4 lines, the other have 3). Each one, would also be able to read data from each other.
    Is this possible?
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Lines4 extends JFrame implements MouseListener, MouseMotionListener {
    private int startx = 200;
    private int starty = 200;
    private JLabel statusBar;
    private Road roads[];
    private static final int roadLength = 100;
    private static final int circleRadius = 4;
    private Road movingRoad;
    public Lines4() {
    super("Lines4");
    String ret = JOptionPane.showInputDialog("How many roads are there?");
    int numPoints = Integer.parseInt( ret );
    double factor = 2.0 * Math.PI / ( numPoints ) ;
    roads = new Road[numPoints];
    for (int i=0; i<numPoints; i++){
    int x = (int)( roadLength * Math.cos( factor * i ) );
    int y = (int)( roadLength * Math.sin( factor * i ) );
    roads[i] = new Road( i, startx, starty, circleRadius, startx+x, starty+y );
    addMouseListener(this);
    addMouseMotionListener(this);
    statusBar = new JLabel();
    getContentPane().add(statusBar, BorderLayout.SOUTH);
    public void paint( Graphics g ) {
    g.clearRect( 0, 0, getWidth(), getHeight() );
    for (int i=0; i<roads.length; i++) {
    roads.draw( g );
    // MouseListener Event Handlers
    public void mouseClicked( MouseEvent e ){
    statusBar.setText( "Clicked at [" + e.getX() +
    ", " + e.getY() + "]" );
    public void mousePressed( MouseEvent e ){
    statusBar.setText( "Pressed at [" + e.getX() +
    ", " + e.getY() + "]" );
    for (int i=0; i<roads.length; i++) {
    if ( roads[i].onCircle( e.getX(), e.getY() ) ) {
    movingRoad = roads[i];
    public void mouseReleased( MouseEvent e ){
    statusBar.setText( "Released at [" + e.getX() + ", " + e.getY() + "]" );
    movingRoad = null;
    public void mouseEntered( MouseEvent e ){
    statusBar.setText( "Mouse in window" );
    public void mouseExited( MouseEvent e ){
    statusBar.setText( "Mouse outside window" );
    // MouseMotionListener event handlers
    public void mouseDragged( MouseEvent e ){
    statusBar.setText( "Dragged at [" + e.getX() +
    ", " + e.getY() + "]" );
    if ( movingRoad != null ) {
    movingRoad.x = e.getX();
    movingRoad.y = e.getY();
    repaint();
    public void mouseMoved( MouseEvent e ) {
    statusBar.setText( "Moved at [" + e.getX() +
    ", " + e.getY() + "]" );
    public static void main( String args[] ) {
    Lines4 app = new Lines4();
    app.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    app.setSize( 400, 400 );
    app.setVisible( true );

    You need to be very careful which project you open in which version.
    For 2014 make sure its on 2014.1 build 81.

  • Tie classes together

    I want to include the shapes (my inventory logo) on the next button frame, which should display the next item on the array list (I havent gotten to the array yet). Both of these classes run when apart, but do not work together. Help?Advice?(Please dont tell me to drop the class)
    Only one more week to go in this class (and Im pretty sure I will pass) whew...i know yall will be happy when I go away lol
         import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class InventoryGUI1 extends JFrame
                              implements ActionListener {
        JTextField input;
          JTextField output;
          JButton next;
          Container c;
    public InventoryGUI1 (){
        super ("My Inventory GUI");
          input = new JTextField (15);
          output = new JTextField (15);
          output.setEditable(false);
          next = new JButton ("next->");
          next.addActionListener (this);
          c = getContentPane ();
          c.setLayout (new FlowLayout());
          c.add (input);
          c.add (next);
          c.add (output);
          setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
          setSize (400,300);
    public void actionPerformed (ActionEvent ev) {
        String userInput = input.getText ();
          output.setText (userInput);
          input.selectAll();
    public static void main (String args []) {
    InventoryGUI1 app = new InventoryGUI1 ();
    app.setVisible (true);
    SwingDrawInner app = new SwingDrawInner ();
    app.setVisible (true);
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class SwingDrawInner extends JFrame {
    Container fc;
    DrawingSurface ds;
    JLabel lbl;
    public SwingDrawInner() {
    super("A Swing Drawing Application");
    ds = new DrawingSurface();
    lbl = new JLabel("Stephanie's Music Inventory");
    fc = getContentPane();
    fc.setLayout(new FlowLayout());
    fc.add(ds);
    fc.add(lbl);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(300,200); }
    class DrawingSurface extends JPanel {
    Dimension preferredSize = new Dimension(300,100);
    public DrawingSurface() {
    super();
    public Dimension getPreferredSize() {
    return preferredSize;
    public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.drawOval(20, 20, 80, 60 );
    g.drawRect(110, 20, 80, 60);
    g.drawOval(200, 20, 80, 60);
    public static void main(String args[]) {
    SwingDrawInner app = new SwingDrawInner();
    app.setVisible(true);
    public static void main (String args []) {
    InventoryGUI1 app = new InventoryGUI1 ();
    app.setVisible (true);
    SwingDrawInner app = new SwingDrawInner ();
    app.setVisible (true);
                              

    Additionally
    -- Learn to format your code according to the conventions. It's difficult to read code that's all jammed up together.
    [http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html]
    -- For anything more complicated than the most basic GUIs, you need to show the GUI on the EDT. For that, your main method in the code I posted above would look like:    public static void main (String args []) {
            SwingUtilities.invokeLater (new Runnable () {
                public void run () {
                    InventoryGUI1 app = new InventoryGUI1 ();
                    app.setVisible (true);
                    SwingDrawInner app1 = new SwingDrawInner ();
                    app1.setVisible (true);
        }db

  • Linking 2 classes together

    This is always what i find hardest to do in java for some reason. Basically i have some code which is part of the class database, and this class adds records to my database as seen below;
    class Database
         public Database(){
         int answer = JOptionPane.YES_OPTION;
         int count = 0;
         final int ARRAY_SIZE = 12;
         CD[] data = new CD[ARRAY_SIZE];
         while (answer == JOptionPane.YES_OPTION)
         String a;
         String c;
         int n;
         a = JOptionPane.showInputDialog("Please, enter artist name");
         c = JOptionPane.showInputDialog("Please, enter CD name");
         n = Integer.parseInt(JOptionPane.showInputDialog("Please enter total number of tracks"));
         data[count] = new CD(a, c, n);
         answer = JOptionPane.showConfirmDialog(null, "Enter another record?",
                         "???", JOptionPane.YES_NO_OPTION);
         count++;
         System.exit(0);
    }Next i have a new class called search which is supposed to search for a CD typed in by the user. This is the code i have;
    class Search
    int result;
    String searchKey = JOptionPane.showInputDialog("Give me the name of a CD");
    result = linearSearch(data, searchKey, ARRAY_SIZE);
         if(result== -1)
         JOptionPane.showMessageDialog(null,"KEY " + searchKey + " NOT FOUND");
         else
         JOptionPane.showMessageDialog(null,"KEY " + searchKey + " FOUND in position " + result);
         System.exit(0);
    public static int linearSearch(String[] data, String key, int sizeOfArray)
    for (int counter = 0; counter < sizeOfArray; counter++)
    if (data[counter].equalsIgnoreCase (key))
    return counter;
    return -1;
    }How do i get the information from the database into my search class, because at the moment my search class wont compile due to identifiers being expected, most problably for the variables data and ARRAY_SIZE. Also, i am not sure if this makes a difference but the information i need from the database class is only the CD name and not the whole array object. If i am unclear, just let me know.
    Cheers

    above these 2 classes, i have a constructor and method which states my array object;
    class CD
         String artistName, CDname;
         int noOfTracks;
         public String records;     
         public CD (String ar, String cd, int no){
         //data that is passed is stored in variables below
         artistName=ar;
         CDname= cd;
         noOfTracks=no;
         String printData(){
         //processed data stored in variable record      
         records =artistName  + "    "+ CDname + "     " + noOfTracks ;
         //value of record returned
         return records;
    }Can i use this constructor and class to create a new method which will search the array, or do i have to create constructors for my other classes, and if so is it the database class or the search class i need these methods and constructors?

  • How to put or bring pages together to form a document?

    Have seprate pages and i wish to join them to form one document?
    I know i was able to do this with the old version of Pages (think you just cut and pasted thumnails to the respective files.)
    Dont seem to be able to to do that now, nor cutting/ copying and pasting from the opened documents?? And no joy from the pages for make help section.
    PLease please help
    Mack 120

    Have seprate pages and i wish to join them to form one document?
    I know i was able to do this with the old version of Pages (think you just cut and pasted thumnails to the respective files.)
    Dont seem to be able to to do that now, nor cutting/ copying and pasting from the opened documents?? And no joy from the pages for make help section.
    PLease please help
    Mack 120

  • Bringing it Together you say but how can BT better...

    When it comes to broadband and line install - Ive been amazed at the flaws in the system up to now. A line engineer called me on my home land line when trying to get access to my business premises to do a line install despite me passing my mobile number to BT prior and me being at the premises. Now I am going to get the line engineer and broadband engineer coming on the same day, BT cant seem to even contact them to make sure they arrive in the right order, if they dont it could be another fortnight without internet - how can you expect to get our british businesses on their feet with this lack of communication within the system.

    Hi simonmurray66,
    Welcome to the forum.
    Were you able to get this sorted?
    If the BT account is registered as a business, then the guys over at the BT Business Forum (http://btb.lithium.com/t5/Forums/ct-p/forums) will be able to help.
    If it's registered as a residential account, send me an email via our "Contact us" form (you can get it by clicking on my username) and we'll get back to you.
    Thanks,
    Stephanie
    Stephanie
    BTCare Community Manager
    If you like a post, or want to say thanks for a helpful answer, please click on the Ratings star on the left-hand side of the post. If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

  • Help - Can I bring video clips together just like a downloaded TV Show is?

    I have a series of short videos which are currently in iTunes. Each clip is a separate file but from a series. The files are separately sectioned within iTunes and not under a single entity, like a TV Show is if you download the entire series.
    I have put in groupings, artist etc, to sort them together, but I was wondering if there was anyway of bring them together under 1 banner, just as if it was a TV Show.

    Nevermind, i've just worked out a way. If I put them all under 1 Album name, it groups all the video clips. Then it sorts them in order of Grouping, etc.

  • Dear Apple, why not SIMPLY bring Photo Booth and Facetime together?

    Dear Apple,
    as I was going through your Website I noticed that FaceTime and PhotoBooth are very similar. I don't know how these two are built, but ins't this a great idea bring them together? Because I don't see any problems. And how about having iChat integrated like Windows Lync (Coorporate Communicator)?

    Hi,
    In actual fact iChat came first.
    It had Video Effects before Photo Booth came out and could/can take snapshots of the Preview pic or the chat.
    Face Time at one level (visually) is a much simpler app all round.
    It does one job.  Connecting Video chats on a 1-to-1 basis.
    iChat can connect to Jabber servers and/or use the AIM Network (i.e Screen Names and IDs from other servers)
    Face Time uses Apple IDs
    Face Time also uses port 5223 the same as Jabber servers do (Jabber servers use this for Login).
    Currently an MobileMe name ending in @me.com is:-
    1)  an Apple ID  (Access to Communities with an Alias, iTunes, On Line Store, MacApp Store and so on)
    2) A Working Email
    3) a Valid Screen Name with the AIM Service (providing your password is 16 characters or less (AIM Limit)
    4) a Face Time Name. (re 1) )  (Listed only to stress the point)
    A @mac.com name is:-
    1) a valid AIM Screen Name (Same password Restrictions)
    2) An Apple ID  (There was a time when names could be registered after MobileMe  was launched, up to about 6 months ago when the Apple ID part was Optional)
    3) May be a working email if linked to an MobileMe account at the Mobile Me launch.
    An Apple ID  can be any other name, most likely an email address that has been used to register in any of the places in 1) in the Mobileme bit.
    If an Email was used this way it cannot be linked to a new Apple ID (Such as an @mac.com registration for iChat or Face Time)
    There would be some use in Face Time having a Jabber server so that Face Time to iChat could be done.
    (It remains to be seen how many would wish to add Jabber as well as having an AIM (Valid) name in iChat.
    iChat and Face Time can in fact access the camera at the same time (the only two apps that I know can do this without the Camera in Use message).
    There might be a call for Video effects in Fact Time but this may be beyond the processor capabilities of iOS devices.
    All in all linking Photo Booth and Face Time would only recreate iChat.
    10:36 PM      Wednesday; June 22, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb( 10.6.7)
     Mac OS X (10.6.7),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • How to make a Abap Unit Test Suit with many test classes

    Hi,
    Problem space
    we have different packages(embedded) in our project and each package corresponds to a differnt functional layer in the design.
    We want to create abab unit test classes for these different layers.
    say embedded package 1 has 10 unit test classses
          embedded package 1 has 20 unit test classses
    How to grup these classes together so that we can start them frm a test suite.
    Code examples and blogs links will be appreciated.
    regards
    anubhav

    This sounds a bit like Project Administration 101 to me.
    I'm not exactly sure what you are actually trying to do here --but generally if you want to functionally test something you need to start with a business process -
    You need to create scripts which tell the user the data to be entered, the transaction to be used and the outcome.
    With SAP you might need to show screen shots of each stage as well.
    You follow this for each complete business process until you've covered the whole business cycle.
    You complete this say individually for Logistics, Purchasing and Finance and then compare what SAP gives you with what you expected to get.
    For some type of testing CATTS can help but without the business processes any testing is essentially meaningless.
    It is totally pointless trying to design a "generic" test plan until you've got the functional consultants to describe the business processes involved.
    Cheers
    jimbo

  • About the class packaging problem

    I used JBuilder 3 and 4 before and packaged some java classes together
    but now when I want to use earlier version of the JBuilder like 2007, the import can't resolve some of the packages.
    Any suggestions please.

    I think it doesn't know them.
    Do I need to add a JAR to the project manually? Yes, when you add a JAR you are telling JBuilder where to look which in turn sets your classpath, without this it will never find it.
    Do I need to do other operations before to add it?
    Because when I choose "Add JARs", there is nothing
    for me to add.Well I take it that it opens a File Chooser of some sort, you should then navigate to your JAR on drive.

  • Link persons together to get the total Household value

    Version
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    Hi
    i am trying to find all possible link and spouses to the persons and bring them together to find out the total sum for that household.
    We have a person table which lists all the persons in out DB
    a link table wich links identical persons
    a spouse table which has spouse relation
    Can some one please help me in building this logic.
    Persons in our database = 100 / 200 / 300 / 400 / 500 / 600 / 700 / 800
    Ids linked together that means they are the same people.
    100 --> 200
    200 --> 300
    200 --> 800
    300 --> 700
    400 --> 500
    Spouse
    100 -- 600
    200 -- 500
    400 -- 500
    Required Output
    ID  ID2     VALUE   VIA_WEPID
    100 100 --> 1000   100  ** Direct Link
    100 200 --> 2000   200  ** Direct Link
    100 800 --> 8000   200  ** In Direct Link
    100 300 --> 3000   200  ** In Direct Link
    100 300 --> 3000   300  ** In Direct Link
    100 700 --> 7000   300  ** In Direct Link
    100 600 --> 6000   600  ** Direct Link
    100 500 --> 5000   200  ** In Direct Link
    100 400 --> 4000   500  ** In Direct Link 
    /* Formatted on 8/24/2012 8:28:39 AM (QP5 v5.115.810.9015) */
    WITH PERSON AS (SELECT   100 ID, 1000 VALUE FROM DUAL
                    UNION ALL
                    SELECT   200 ID, 2000 VALUE FROM DUAL
                    UNION ALL
                    SELECT   300 ID, 3000 VALUE FROM DUAL
                    UNION ALL
                    SELECT   400 ID, 4000 VALUE FROM DUAL
                    UNION ALL
                    SELECT   500 ID, 5000 VALUE FROM DUAL
                    UNION ALL
                    SELECT   600 ID, 6000 VALUE FROM DUAL
                    UNION ALL
                    SELECT   700 ID, 7000 VALUE FROM DUAL
                    UNION ALL
                    SELECT   800 ID, 8000 VALUE FROM DUAL
        PERSON_LINK AS (SELECT   100 ID, 200 LINK_ID FROM DUAL
                        UNION ALL
                        SELECT   200 ID, 100 LINK_ID FROM DUAL
                        UNION ALL
                        SELECT   200 ID, 300 LINK_ID FROM DUAL
                        UNION ALL
                        SELECT   300 ID, 200 LINK_ID FROM DUAL
                        UNION ALL
                        SELECT   200 ID, 800 LINK_ID FROM DUAL
                        UNION ALL
                        SELECT   800 ID, 200 LINK_ID FROM DUAL
                        UNION ALL
                        SELECT   300 ID, 700 LINK_ID FROM DUAL
                        UNION ALL
                        SELECT   700 ID, 300 LINK_ID FROM DUAL
                        UNION ALL
                        SELECT   400 ID, 500 LINK_ID FROM DUAL
                        UNION ALL
                        SELECT   500 ID, 400 LINK_ID FROM DUAL
        SPOUSE AS (SELECT   400 ID, 500 SPOUSE_ID FROM DUAL
                   UNION ALL
                   SELECT   500 ID, 400 SPOUSE_ID FROM DUAL
                   UNION ALL
                   SELECT   200 ID, 500 SPOUSE_ID FROM DUAL
                   UNION ALL
                   SELECT   500 ID, 200 SPOUSE_ID FROM DUAL
                   UNION ALL
                   SELECT   100 ID, 600 SPOUSE_ID FROM DUAL
                   UNION ALL
                   SELECT   600 ID, 100 SPOUSE_ID FROM DUAL)
    SELECT   *
      FROM   person, person_link, spousei am trying to implement this logic but i am no where near to the reqired output
    SELECT   ID, ID ID2, VALUE FROM person
    UNION
    SELECT   a.ID, LINK_ID ID2, VALUE
      FROM   Person a, person_link b
    WHERE   a.id = b.id
    UNION
    SELECT   a.ID, spouse_id ID2, VALUE
      FROM   Person a, spouse b
    WHERE   a.id = b.idEdited by: new learner on Aug 24, 2012 6:05 AM
    Edited by: new learner on Aug 24, 2012 7:56 AM

    Does this make sense:
    with
    person(rid,the_value) as
    (select 100,1000 from dual union all
    select 200,2000 from dual union all
    select 300,3000 from dual union all
    select 400,4000 from dual union all
    select 500,5000 from dual union all
    select 600,6000 from dual union all
    select 700,7000 from dual union all
    select 800,8000 from dual
    person_link(rid,link_id) as
    (select 100,200 from dual union all
    select 200,100 from dual union all
    select 200,300 from dual union all
    select 200,800 from dual union all
    select 300,200 from dual union all
    select 300,700 from dual union all
    select 400,500 from dual union all
    select 500,400 from dual union all
    select 700,300 from dual union all
    select 800,200 from dual
    spouse(rid,spouse_id) as
    (select 100,600 from dual union all
    select 200,500 from dual union all
    select 400,500 from dual union all
    select 500,200 from dual union all
    select 500,400 from dual union all
    select 600,100 from dual
    person_link_x(rid,link_id) as
    (select 100,200 from dual union all
    select 200,300 from dual union all
    select 200,800 from dual union all
    select 300,700 from dual union all
    select 400,500 from dual
    person_link_x as
    (select rid,link_id
       from person_link
      where rid < link_id
    spouse_x(rid,spouse_id) as
    (select 100,600 from dual union all
    select 200,500 from dual union all
    select 400,500 from dual
    spouse_x as
    (select rid,spouse_id
       from spouse
      where rid < spouse_id
    )the order of rows is changed for readability
    the <tt> factors person_link_x </tt> and <tt> spouse_x </tt> are there to eliminate cycles
    using <tt> factors person_link_x </tt> by following links (connect by ...) you can get the following trees (hierarchies) - No Database at hand to do it myself
    1:   100     200   200   300   400
          |       |     |     |     |
    2:   200     300   800   700   500
         / \      |
    3: 300 800   700
        |
    4: 700thus you discover there are just two individuals in the table denoting the same persons as the trees in the middle are all subtrees of the first tree.
    taking the root values 100 and 400 as person ids and replacing all "alias" values with the corresponding root values in spouse_x you get
    spouse_x(rid,spouse_id) as
    (select 100,600 from dual union all
    select 100,400 from dual union all
    select 400,400 from dual
    )the last row makes no sense (data entry error, ... ) and: either she has two husbands or he has two wives ;)
    Regards
    Etbin

Maybe you are looking for