User-defined constructor

How can I tell database designer to create user-defined constructors?
I've not found any way to add the "constructor" keyword in front of function.

William,
You can use the default constructor in 9i release. In addition, a static method can be used as user-defined constructors. Please check out the documentation at http://otn.oracle.com/docs/products/oracle9i/doc_library/901_doc/appdev.901/a88878/adobjdes.htm#444053
Regards,
Geoff
Hi, I am currently working in O/R model in a 9i DB. I have a type hierarchy in which there are a super-type (not instantiable) and some sub-types that add new attributes. I want to create an instance(object) of an specific sub-type using the specific constructor for this sub-type(with his own parameters list, in this case the parameters that correspond to the new attributes added), inside this constructor I will set the values to the attributes that the sub-type inherited from his parent and the values passed to the new added attributes.
Is it possible programming in PL/SQL?

Similar Messages

  • How to add a user defined constructor to an existing type?

    Hi,
    I want to alter an existing type (ORDSys.ORDVideo), where I do not have the source code of the type body. There is only a wrapped version, where I don't know, how to alter it.
    Because the existing functions use the constructor of the original type I can't simply add new attributes. That's why I want to add a new user defined constructor which equals the old built in.
    Is there any way to do this, without having the bodys source code?
    Thanks, Christian

    Unfortunately, No.
    <quote source="oracle_documentation">
    Oracle interMedia describes the ORDVideo object type, which supports the storage and management of video data.
    </quote>
    It comes along with the Oracle interMedia and the modifications could not be performed by the customer.
    You could however, try to create a derived type based on this type and add your constructors/functions on top.

  • User-defined constructor in SQL

    Below is a SQL*Plus script to create an object type and a collection
    type, followed by an anonymous block. The anonymous block attempts to
    create 3 instances of the object type.
    1. With the default constructor in a SELECT.. INTO.. - it succeeds.
    2. With a user-defined constructor in an assignment statement - it succeeds.
    3. With a user-defined constructor in a SELECT.. INTO.. - it fails.
    Why does the third attempt fail?
    The server is Oracle9i Enterprise Edition Release 9.2.0.1.0 and the
    results are the same on Linux and Solaris.
    My attempts to search this forum resulted in "The page caused an ESI
    processing exception.", my apologies if my question has already been
    discussed.
    Thanks
    ----------------------------- Sample code -------------------------------------
    CREATE OR REPLACE TYPE t_thing AS OBJECT
    ( n INTEGER,
    x VARCHAR2(20),
    CONSTRUCTOR FUNCTION t_thing (i_n IN INTEGER) RETURN SELF AS RESULT
    CREATE OR REPLACE TYPE BODY t_thing AS
    CONSTRUCTOR FUNCTION t_thing (i_n IN INTEGER) RETURN SELF AS RESULT IS
    BEGIN
    SELF.n := i_n;
    SELF.x := 'some default';
    DBMS_OUTPUT.PUT_LINE('Constructor built thing ' || SELF.n);
    RETURN;
    END t_thing;
    END;
    CREATE TYPE t_things IS TABLE OF t_thing NOT NULL;
    DECLARE
    v_things t_things;
    v_one_thing t_thing;
    BEGIN
    -- 1.
    SELECT NEW t_thing(1, 'a') BULK COLLECT INTO v_things FROM dual;
    FOR i IN v_things.FIRST..v_things.LAST
    LOOP
    DBMS_OUTPUT.PUT_LINE
    ( 'This thing has n `' || v_things(i).n || ''''
    || ' and x `' || v_things(i).x || '''.'
    END LOOP;
    -- 2.
    v_one_thing := NEW t_thing(2);
    -- 3.
    SELECT NEW t_thing(3) BULK COLLECT INTO v_things FROM dual;
    END;
    ------------------------ The output from the sample code ----------------------
    SQL> @test
    Type created.
    Type body created.
    Type created.
    This thing has n `1' and x `a'.
    Constructor built thing 2
    DECLARE
    ERROR at line 1:
    ORA-06552: PL/SQL: Statement ignored
    ORA-06553: PLS-302: component 'T_THING' must be declared
    ORA-06512: at line 21

    William,
    You can use the default constructor in 9i release. In addition, a static method can be used as user-defined constructors. Please check out the documentation at http://otn.oracle.com/docs/products/oracle9i/doc_library/901_doc/appdev.901/a88878/adobjdes.htm#444053
    Regards,
    Geoff
    Hi, I am currently working in O/R model in a 9i DB. I have a type hierarchy in which there are a super-type (not instantiable) and some sub-types that add new attributes. I want to create an instance(object) of an specific sub-type using the specific constructor for this sub-type(with his own parameters list, in this case the parameters that correspond to the new attributes added), inside this constructor I will set the values to the attributes that the sub-type inherited from his parent and the values passed to the new added attributes.
    Is it possible programming in PL/SQL?

  • Using user-defined data types in Forms 6i

    When I use the following code in Oracle Forms 6i
    PROCEDURE test IS
    prcl prcl_ty;
    BEGIN
    prcl := prcl.setParcel('xxx-xx-xxxx');
    END;
    I get 'Error 801'. However the above does work in SQL editor. The online help says PL/SQL8 client-side program units cannot support Oracle 8 object-related functionality and I suspect this is the reason I get the error from Forms. Is there a work-around for this.
    The TYPE is defined as:
    CREATE OR REPLACE
    TYPE PRCL_TY AS OBJECT
    (parcel VARCHAR2(11),
    MEMBER FUNCTION getBook RETURN VARCHAR2,
    MEMBER FUNCTION getMap RETURN VARCHAR2,
    MEMBER FUNCTION getItem RETURN VARCHAR2,
    MEMBER FUNCTION getItem_NS RETURN VARCHAR2,
    MEMBER FUNCTION getSplit      RETURN VARCHAR2,
    MEMBER FUNCTION find RETURN VARCHAR2,
    MEMBER FUNCTION find (yr in VARCHAR2) RETURN VARCHAR2,
    MEMBER FUNCTION isValid RETURN BOOLEAN,
    MEMBER FUNCTION toString                     RETURN VARCHAR2,
    MEMBER FUNCTION toString (par IN VARCHAR2) RETURN VARCHAR2,
    STATIC FUNCTION setParcel (istr IN VARCHAR2 DEFAULT '000-00-000A') RETURN prcl_ty) -- to be used as a constructor
    NOT FINAL
    CREATE OR REPLACE
    TYPE BODY PRCL_TY AS
    MEMBER FUNCTION getBook RETURN VARCHAR2 IS
    BEGIN
    return substr(self.parcel,1,3);
    END;
    MEMBER FUNCTION getMap RETURN VARCHAR2 IS
    BEGIN
    return substr(self.parcel,4,2);
    END;
    MEMBER FUNCTION getItem RETURN VARCHAR2 IS
    BEGIN
    return substr(self.parcel,6);
    END;
    MEMBER FUNCTION getItem_NS RETURN VARCHAR2 IS
    BEGIN
    return substr(self.parcel,6,3);
    END;
    MEMBER FUNCTION getSplit RETURN VARCHAR2 IS
    BEGIN
    return substr(self.parcel,9,1);
    END;
    MEMBER FUNCTION find RETURN VARCHAR2 IS
    found varchar2(1);
    BEGIN
    begin
    select 'x'
         into found
         from casrp
         where cp_book_num = self.getBook
         and cp_map_num = self.getMap
         and cp_item_num = self.getItem
              and rownum = 1;
         return 'CASRP';
         exception
         when NO_DATA_FOUND then
         begin
    select 'x'
         into found
         from pro_prop
         where pp_book_num = self.getBook
         and pp_map_num = self.getMap
         and pp_item_num = self.getItem
              and rownum = 1
              and NOT EXISTS (select 'x'
                                  from cncl_prcl
                                  where cr_book_num = self.getBook
                                  and cr_book_num = self.getMap
                                       and cr_book_num = self.getItem
                                       and rownum = 1);
         return 'PRO_PROP';
         exception
         when NO_DATA_FOUND then
              return '';
         end;
    end;
    END;
    MEMBER FUNCTION find (yr IN VARCHAR2) RETURN VARCHAR2 IS
    found varchar2(1);
    BEGIN
    begin
    select 'x'
         into found
         from casrp
         where cp_book_num = self.getBook
         and cp_map_num = self.getMap
         and cp_item_num = self.getItem
              and cp_tax_yr = yr
              and rownum = 1;
         return 'CASRP';
         exception
         when NO_DATA_FOUND then
         begin
    select 'x'
         into found
         from pro_prop
         where pp_book_num = self.getBook
         and pp_map_num = self.getMap
         and pp_item_num = self.getItem
              and pp_tax_yr = yr
              and rownum = 1
              and NOT EXISTS (select 'x'
                                  from cncl_prcl
                                  where cr_book_num = self.getBook
                                  and cr_book_num = self.getMap
                                       and cr_book_num = self.getItem
                                       and cr_tax_yr = yr
                                       and rownum = 1);
         return 'PRO_PROP';
         exception
         when NO_DATA_FOUND then
              return '';
         end;
    end;
    END;
    MEMBER FUNCTION isValid RETURN BOOLEAN IS
    i number;
    BEGIN
    for i in 1..8 loop
         if substr(parcel,i,1) not between '0' and '9' then
         return FALSE;
         end if;
         end loop;
         if nvl(substr(parcel,9,1),'#') not between 'A' and 'Z' and
         nvl(substr(parcel,9,1),'#') != '#' then
         return FALSE;
         end if;
         return TRUE;
    END;
    MEMBER FUNCTION toString RETURN VARCHAR2 IS
    BEGIN
    return self.toString('-');
    END;
    MEMBER FUNCTION toString (par IN VARCHAR2) RETURN VARCHAR2 IS
    BEGIN
    return self.getBook||par|| self.getMap||par|| self.getItem;
    END;
    STATIC FUNCTION setParcel (istr IN VARCHAR2 DEFAULT '000-00-000A') RETURN prcl_ty IS
    len number;
    pos number;
         lastch varchar2(1);
    temp varchar2(30);
    invalid_format exception;
         pragma exception_init(invalid_format,-9001);
    BEGIN
    temp := upper(istr);
    -- Find 1st occurance of '-'. If not in correct postion, pad book num with zeros.
         pos := instr(temp,'-',1,1);
    if pos > 0 then
         if pos != 4 then
    temp := lpad(substr(temp,1,pos-1),3,'0')||substr(temp,pos);
         end if;
    -- Find 2nd occurance of '-'. If not in correct postion, pad map num with zeros.
         pos := instr(temp,'-',1,2);
         if pos != 7 then
    temp := substr(temp,1,4)||lpad(substr(temp,5,1),2,'0')||substr(temp,pos);
         end if;
         -- Pad item num
         len := length(temp);
         lastch := substr(temp,len);
         temp := substr(temp,1,7)||lpad(substr(temp,8,len-1),3,'0');
         if lastch between 'A' and 'Z' then
              temp := temp||lastch;
         end if;
    end if;
    temp := replace(temp,'-','');
         if prcl_ty(temp).isValid then
    return (prcl_ty(temp));
         else
         raise invalid_format;
         end if;
    END;
    END;
    Rich Hall
    [email protected]

    You are correct in your assumptions. Client side PLSQL does not support user defined types like the one you are trying to use.
    There are no workarounds I am afraid.

  • Adding user-defined number of text fields.

    Okay I am having problems, obviously. I am developing a program where the user will enter X and Y values and the program will calculate the relational data. However, I can't even get a start.
    First of all, the user defines the number of pairs of points they want to define. For example, they have 20 points, each with its own X and Y, so they click on 20 and then okay in the first window.
    The next window will then take their answer and display X and Y text fields for as many points as they defined. However, I can't figure out any way to do this.
    Feel free to run the program, the problem lies in the method setTextFields(). Help please!
    import javax.swing.*;               //FOR SWING COMPONENT CLASSES
    import java.awt.*;                  //FOR CONTAINER CLASS
    import java.awt.event.*;            //FOR EVENT HANDLING
    public class RegressInput extends JFrame
        private JComboBox listJComboBox;        //COMBO BOX TO HOLD HOW MANY PAIRS OF DATA POINTS THE USER HAS TO ENTER
        private JButton answerButton;           //BUTTON TO CLICK AFTER SELECTING PAIRS OF DATA POINTS
        private JPanel textFieldTopPanel;       //TEXT FIELD TOP PANEL
        private JPanel textFieldBottomPanel;    //TEXT FIELD BOTTOM PANEL
        private JPanel textFieldPanel;           //TEXT FIELD PANEL   
        private CardLayout cardSelector;        //DECLARE CARD LAYOUT OBJECT   
        private JPanel cardDeck;                //DECLARE CARD PANEL OBJECT
        public RegressInput(String title)
            super(title);               //CALL SUPERCLASS CONSTRUCTOR
            //CREATE A CONTAINER
            Container container = getContentPane();
            //INSTANTIATE CARD LAYOUT OBJECT
            cardSelector = new CardLayout();
            //INSTANTIATE PANEL OBJECT
            cardDeck = new JPanel();
            //SET LAYOUT OF CARD DECK PANEL TO CARD LAYOUT
            cardDeck.setLayout(cardSelector);
            //DEFINE LABEL FOR FIRST CARD
            Label question = new Label("How many PAIRS of data would you like to enter?");
            //BUTTON TO SUBMIT NUMBER OF POINTS TO PLOT
            answerButton = new JButton("OK");
            listJComboBox = new JComboBox( getArray() );//USE getArray() METHOD TO SET ITEM LIST OF THE COMBO BOX
            listJComboBox.setMaximumRowCount(10);       //SETS THE VISIBLE NUMBER OF ITEMS TO THE USER
            Label xValues = new Label("X Values");      //LABEL FOR X values
            Label yValues = new Label("Y Values");      //LABEL FOR Y values
            //BUILD CARD DECK
            JPanel comboBoxCard = new JPanel();     //CREATE FIRST CARD
            comboBoxCard.add(question);             //ADD question LABEL TO FIRST CARD
            comboBoxCard.add(listJComboBox);        //ADD listJComboBox TO FIRST CARD
            comboBoxCard.add(answerButton);         //ADD answerButton TO FIRST CARD
            textFieldTopPanel = new JPanel();       //CREATE TOP PANEL OF SECOND CARD
            textFieldTopPanel.add(xValues);         //ADD xValues Label TO SECOND CARD
            textFieldTopPanel.add(yValues);         //ADD yValues Label TO SECOND CARD
            textFieldBottomPanel = new JPanel();    //CREATE BOTTOM PANEL OF SECOND CARD
            textFieldBottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER,10,10));    //SET LAYOUT FOR BOTTOM PANEL
            textFieldPanel = new JPanel();          //CREATE PANEL FOR SECOND CARD
            textFieldPanel.setLayout(new BorderLayout(10, 10)); //SET LAYOUT FOR SECOND CARD
            textFieldPanel.add(textFieldTopPanel, "North"); //ADD textFieldTopPanel TO NORTH
            textFieldPanel.add(textFieldBottomPanel, "South");  //ADD textFieldBottomPanel TO SOUTH
            cardDeck.add(comboBoxCard, "Step 1");       //ADD FIRST CARD TO DECK
            cardDeck.add(textFieldPanel, "Step 2");     //ADD SECOND CARD TO DECK
            container.add(cardDeck);                    //ADD CARD DECK TO CONTAINER
            //DEFINE BUTTON HANDLER OBJECT
            ButtonHandler buttonHandler = new ButtonHandler();
            //ADD ACTION LISTENER FOR BUTTONS
            answerButton.addActionListener(new ButtonHandler());
        }//END RegressInput() CONSTRUCTOR
        //METHOD TO CREATE AND RETURN AN ARRAY OF VALUES FOR JComboBox
        private String[] getArray()
            //CREATE ARRAY TO HOLD 30 VALUES
            int numbers[] = new int[29];
            //CREATE int IN ORDER TO START THE ARRAY AT 2 INSTEAD OF 1
            int number = 2;
            //ASSIGN VALUES FROM 2 TO 30 TO numbers[] ARRAY
            for(int count=0; count < 29; ++count)
                numbers[count] = number;        //SETS EACH INDEX TO number
                number++;                       //INCREMENTS number
            }//END for LOOP
            //CREATE pairs[] ARRAY TO HOLD 30 STRINGS
            String pairs[] = new String[29];
            //ASSIGN VALUES 1 TO 30 IN STRING ARRAY FOR COMBO BOX
            for(int count = 0; count < 29; ++count)
                pairs[count] = "" + numbers[count];
            }//END for LOOP
            return pairs;//RETURNS pairs[] ARRAY FOR THE LIST ITEMS IN listJComboBox
        }//END getArray() METHOD8
        //RETURNS THE ITEM SELECTED BY THE USER FROM THE JComboBox
        private int getValue()
            //ASSIGNS STRING VALUE OF THE JComboBox TO A WRAPPER
            Integer v = new Integer((String) listJComboBox.getSelectedItem());
            //ASSIGNS WRAPPER VALUE TO int
            int value = v.intValue();
            //RETURN VALUE OF SELECTED ITEM
            return value;
        }//END getValue()
        private void setTextFields()
        {//HERE LIES THE PROBLEM! WHAT GOES IN THIS METHOD????
            for(int count = 0; count < (2 * getValue()); ++count)
        }//END setTextFields()
        //BUTTON EVENT HANDLER CLASS
        private class ButtonHandler implements ActionListener
         //PROCESS EVENT
            public void actionPerformed(ActionEvent e)
                //WHICH BUTTON CAUSED THE EVENT?
                if(e.getSource() == answerButton)
                    cardSelector.last(cardDeck);
                    cardDeck.setSize(600,600);
                }//END if STATEMENT
            }//END actionPerformed()
        }//END ButtonHandler CLASS
    }//END RegressInput CLASSHere is main:
    import javax.swing.JFrame;
    public class TestSharpStats
         public static void main(String[] args)
            //DEFINE FRAME OBJECT
            RegressInput window = new RegressInput("Hi");     //SETS TITLE BAR
            window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);      //CLOSES WINDOW
            window.setSize(400, 600);    //SET FRAME SIZE
            window.setResizable(true);  //PREVENTS USER FROM RESIZING WINDOW
            window.setVisible(true);     //SETS window TO VISIBLE
        }//END main()
    }//END TestSharpStats CLASS

    muit-post: http://forum.java.sun.com/thread.jspa?messageID=4442652

  • Adding user-defined data

    Okay I am having problems, obviously. I am developing a program where the user will enter X and Y values and the program will calculate the relational data. However, I can't even get a start.
    First of all, the user defines the number of pairs of points they want to define. For example, they have 20 points, each with its own X and Y, so they click on 30 and then okay in the first window.
    The next window will then take their answer and display X and Y text fields for as many points as they defined. However, I can't figure out any way to do this.
    Feel free to run the program, the problem lies in the method setTextFields(). Help please!
    import javax.swing.*;               //FOR SWING COMPONENT CLASSES
    import java.awt.*;                  //FOR CONTAINER CLASS
    import java.awt.event.*;            //FOR EVENT HANDLING
    public class RegressInput extends JFrame
        private JComboBox listJComboBox;        //COMBO BOX TO HOLD HOW MANY PAIRS OF DATA POINTS THE USER HAS TO ENTER
        private JButton answerButton;           //BUTTON TO CLICK AFTER SELECTING PAIRS OF DATA POINTS
        private JPanel textFieldTopPanel;       //TEXT FIELD TOP PANEL
        private JPanel textFieldBottomPanel;    //TEXT FIELD BOTTOM PANEL
        private JPanel textFieldPanel;           //TEXT FIELD PANEL   
        private CardLayout cardSelector;        //DECLARE CARD LAYOUT OBJECT   
        private JPanel cardDeck;                //DECLARE CARD PANEL OBJECT
        public RegressInput(String title)
            super(title);               //CALL SUPERCLASS CONSTRUCTOR
            //CREATE A CONTAINER
            Container container = getContentPane();
            //INSTANTIATE CARD LAYOUT OBJECT
            cardSelector = new CardLayout();
            //INSTANTIATE PANEL OBJECT
            cardDeck = new JPanel();
            //SET LAYOUT OF CARD DECK PANEL TO CARD LAYOUT
            cardDeck.setLayout(cardSelector);
            //DEFINE LABEL FOR FIRST CARD
            Label question = new Label("How many PAIRS of data would you like to enter?");
            //BUTTON TO SUBMIT NUMBER OF POINTS TO PLOT
            answerButton = new JButton("OK");
            listJComboBox = new JComboBox( getArray() );//USE getArray() METHOD TO SET ITEM LIST OF THE COMBO BOX
            listJComboBox.setMaximumRowCount(10);       //SETS THE VISIBLE NUMBER OF ITEMS TO THE USER
            Label xValues = new Label("X Values");      //LABEL FOR X values
            Label yValues = new Label("Y Values");      //LABEL FOR Y values
            //BUILD CARD DECK
            JPanel comboBoxCard = new JPanel();     //CREATE FIRST CARD
            comboBoxCard.add(question);             //ADD question LABEL TO FIRST CARD
            comboBoxCard.add(listJComboBox);        //ADD listJComboBox TO FIRST CARD
            comboBoxCard.add(answerButton);         //ADD answerButton TO FIRST CARD
            textFieldTopPanel = new JPanel();       //CREATE TOP PANEL OF SECOND CARD
            textFieldTopPanel.add(xValues);         //ADD xValues Label TO SECOND CARD
            textFieldTopPanel.add(yValues);         //ADD yValues Label TO SECOND CARD
            textFieldBottomPanel = new JPanel();    //CREATE BOTTOM PANEL OF SECOND CARD
            textFieldBottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER,10,10));    //SET LAYOUT FOR BOTTOM PANEL
            textFieldPanel = new JPanel();          //CREATE PANEL FOR SECOND CARD
            textFieldPanel.setLayout(new BorderLayout(10, 10)); //SET LAYOUT FOR SECOND CARD
            textFieldPanel.add(textFieldTopPanel, "North"); //ADD textFieldTopPanel TO NORTH
            textFieldPanel.add(textFieldBottomPanel, "South");  //ADD textFieldBottomPanel TO SOUTH
            cardDeck.add(comboBoxCard, "Step 1");       //ADD FIRST CARD TO DECK
            cardDeck.add(textFieldPanel, "Step 2");     //ADD SECOND CARD TO DECK
            container.add(cardDeck);                    //ADD CARD DECK TO CONTAINER
            //DEFINE BUTTON HANDLER OBJECT
            ButtonHandler buttonHandler = new ButtonHandler();
            //ADD ACTION LISTENER FOR BUTTONS
            answerButton.addActionListener(new ButtonHandler());
        }//END RegressInput() CONSTRUCTOR
        //METHOD TO CREATE AND RETURN AN ARRAY OF VALUES FOR JComboBox
        private String[] getArray()
            //CREATE ARRAY TO HOLD 30 VALUES
            int numbers[] = new int[29];
            //CREATE int IN ORDER TO START THE ARRAY AT 2 INSTEAD OF 1
            int number = 2;
            //ASSIGN VALUES FROM 2 TO 30 TO numbers[] ARRAY
            for(int count=0; count < 29; ++count)
                numbers[count] = number;        //SETS EACH INDEX TO number
                number++;                       //INCREMENTS number
            }//END for LOOP
            //CREATE pairs[] ARRAY TO HOLD 30 STRINGS
            String pairs[] = new String[29];
            //ASSIGN VALUES 1 TO 30 IN STRING ARRAY FOR COMBO BOX
            for(int count = 0; count < 29; ++count)
                pairs[count] = "" + numbers[count];
            }//END for LOOP
            return pairs;//RETURNS pairs[] ARRAY FOR THE LIST ITEMS IN listJComboBox
        }//END getArray() METHOD8
        //RETURNS THE ITEM SELECTED BY THE USER FROM THE JComboBox
        private int getValue()
            //ASSIGNS STRING VALUE OF THE JComboBox TO A WRAPPER
            Integer v = new Integer((String) listJComboBox.getSelectedItem());
            //ASSIGNS WRAPPER VALUE TO int
            int value = v.intValue();
            //RETURN VALUE OF SELECTED ITEM
            return value;
        }//END getValue()
        private void setTextFields()
        {//HERE LIES THE PROBLEM! WHAT GOES IN THIS METHOD????
            for(int count = 0; count < (2 * getValue()); ++count)
        }//END setTextFields()
        //BUTTON EVENT HANDLER CLASS
        private class ButtonHandler implements ActionListener
         //PROCESS EVENT
            public void actionPerformed(ActionEvent e)
                //WHICH BUTTON CAUSED THE EVENT?
                if(e.getSource() == answerButton)
                    cardSelector.last(cardDeck);
                    cardDeck.setSize(600,600);
                }//END if STATEMENT
            }//END actionPerformed()
        }//END ButtonHandler CLASS
    }//END RegressInput CLASS
    Here is main:
    import javax.swing.JFrame;
    public class TestSharpStats
         public static void main(String[] args)
            //DEFINE FRAME OBJECT
            RegressInput window = new RegressInput("Hi");     //SETS TITLE BAR
            window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);      //CLOSES WINDOW
            window.setSize(400, 600);    //SET FRAME SIZE
            window.setResizable(true);  //PREVENTS USER FROM RESIZING WINDOW
            window.setVisible(true);     //SETS window TO VISIBLE
        }//END main()
    }//END TestSharpStats CLASS

    If your teacher taught you to program like this they should be shot. There is no need to comment every single line (especially in upper case). The comments stand out more that the code does and doesn't add any usefull information. Obviously comments are important, but you need to pick and choose when to use them.
    Swing related questions should be posted in the Swing forum.
    Also, don't use AWT components in a Swing application. Label is AWT. JLabel is Swing.
    I would use a JTable to input the matching pairs of data. Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/table.html]How to Use Table to get started.

  • How to resolve the error while using user defined function.

    EPN Assembly file
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:osgi="http://www.springframework.org/schema/osgi"
    xmlns:wlevs="http://www.bea.com/ns/wlevs/spring"
    xmlns:jdbc="http://www.oracle.com/ns/ocep/jdbc"
    xmlns:spatial="http://www.oracle.com/ns/ocep/spatial"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/osgi
    http://www.springframework.org/schema/osgi/spring-osgi.xsd
    http://www.bea.com/ns/wlevs/spring
    http://www.bea.com/ns/wlevs/spring/spring-wlevs-v11_1_1_3.xsd
    http://www.oracle.com/ns/ocep/jdbc
    http://www.oracle.com/ns/ocep/jdbc/ocep-jdbc.xsd
    http://www.oracle.com/ns/ocep/spatial
    http://www.oracle.com/ns/ocep/spatial/ocep-spatial.xsd">
         <wlevs:event-type-repository>
              <wlevs:event-type type-name="TestEvent">
                   <wlevs:class>com.bea.wlevs.event.example.FunctionCEP.TestEvent</wlevs:class>
              </wlevs:event-type>
         </wlevs:event-type-repository>
         <wlevs:adapter id="InputAdapter"
              class="com.bea.wlevs.adapter.example.FunctionCEP.InputAdapter">
              <wlevs:listener ref="inputStream" />
         </wlevs:adapter>
         <wlevs:channel id="inputStream" event-type="TestEvent">
              <wlevs:listener ref="processor" />
         </wlevs:channel>
         <wlevs:processor id="processor">
              <wlevs:listener ref="outputStream" />
              <wlevs:function function-name="sum_fxn" exec-method="execute">
              <bean>com.bea.wlevs.example.FunctionCEP.TestFunction</bean>
              </wlevs:function>
         </wlevs:processor>
         <wlevs:channel id="outputStream" event-type="TestEvent">
              <wlevs:listener ref="bean" />
         </wlevs:channel>
         <bean id="bean" class="com.bea.wlevs.example.FunctionCEP.OutputBean">
         </bean>
    </beans>
    Event class
    package com.bea.wlevs.event.example.FunctionCEP;
    public class TestEvent {
         private int num_1;
         private int num_2;
         private int sum_num;
         public int getSum_num() {
              return sum_num;
         public void setSum_num(int sumNum) {
              sum_num = sumNum;
         public int getNum_1() {
              return num_1;
         public void setNum_1(int num_1) {
              this.num_1 = num_1;
         public int getNum_2() {
              return num_2;
         public void setNum_2(int num_2) {
              this.num_2 = num_2;
    Adapter class
    package com.bea.wlevs.adapter.example.FunctionCEP;
    import com.bea.wlevs.ede.api.RunnableBean;
    import com.bea.wlevs.ede.api.StreamSender;
    import com.bea.wlevs.ede.api.StreamSource;
    import com.bea.wlevs.event.example.FunctionCEP.TestEvent;
    public class InputAdapter implements RunnableBean, StreamSource {
    private StreamSender eventSender;
    public InputAdapter() {
    super();
    public void run() {
         generateMessage();
    private void generateMessage() {
         TestEvent event = new TestEvent();
         event.setNum_1(10);
         event.setNum_2(20);
         eventSender.sendInsertEvent(event);
    public void setEventSender(StreamSender sender) {
    eventSender = sender;
    public synchronized void suspend() {
    Output Bean class
    package com.bea.wlevs.example.FunctionCEP;
    import com.bea.wlevs.ede.api.StreamSink;
    import com.bea.wlevs.event.example.FunctionCEP.TestEvent;
    import com.bea.wlevs.util.Service;
    public class OutputBean implements StreamSink {
         public void onInsertEvent(Object event) {
              System.out.println("In Output Bean");
              TestEvent event1 = new TestEvent();
              System.out.println("Num_1 is :: " + event1.getNum_1());
              System.out.println("Num_2 is :: " +event1.getNum_2());
              System.out.println("Sum of the numbers is :: " +event1.getSum_num());
    Function Class
    package com.bea.wlevs.example.FunctionCEP;
    public class TestFunction {
         public Object execute(int num_1, int num_2)
              return (num_1 + num_2);
    config.xml file
    <?xml version="1.0" encoding="UTF-8"?>
    <wlevs:config xmlns:wlevs="http://www.bea.com/ns/wlevs/config/application"
    xmlns:jdbc="http://www.oracle.com/ns/ocep/config/jdbc">
         <processor>
              <name>processor</name>
                   <rules>
                   <view id="v1" schema="num_1 num_2">
                        <![CDATA[
                             select num_1, num_2 from inputStream     
                        ]]>
                   </view>
                   <view id="v2" schema="num_1 num_2">
                   <![CDATA[
                   select sum_fxn(num_1,num_2), num_2 from inputStream // I am getting error when i am trying to call this function
                   ]]>
                   </view>
                   <query id="q1">
                        <![CDATA[
                             select from v2[now] as num_2*     // Showing error while accessing the view also               ]]>
                   </query>
              </rules>
         </processor>
    </wlevs:config>
    Error I am getting is :
    Invalid statement: "select >>sum_fxn<<(num_1,num_2),age from inputStream"
    Description: Invalid call to function or constructor: sum_fxn
    Cause: Probable causes are: Function name sum_fxn(int,int) provided is invalid, or arguments are of
    the wrong type., or Error while handling member access to complex type. Constructor sum_fxn of type
    sum_fxn not found. or Probable causes are: Function name sum_fxn(int,int) provided is invalid, or
    arguments are of the wrong type., or Error while handling member access to complex type.
    Constructor sum_fxn of type sum_fxn not found.
    Action: Verify function or constructor for complex type exists, is not ambiguous, and has the correct
    number of parameters.
    I have made a user defined function in a java class and configured this function in the EPN assembly file under the processor tag.
    But when i am trying to access the function in the config.xml file , it is giving me an error in the query.
    Please provide urgent help that how to write the exact query.

    Hi,
    In the EPN Assembly file use
    <bean class="com.bea.wlevs.example.FunctionCEP.TestFunction"/>
    instead of
    <bean>com.bea.wlevs.example.FunctionCEP.TestFunction</bean>
    Best Regards,
    Sandeep

  • What the best way to create User defined table with ADDON purpose

    Hi folks, how are you ?
    I´m beginner in development to business one, and I m studying to develop ISV addons.
    But, during my exercises and analisys, I learned that have two ways to create tables and fields in business one. One way is throght by wizard in business one using Tools Menu > Configuration Tools > User Defined Tables >
    Obs: I ´m using Business One Patch Level 9.
    Other way, is create the tables and fields using DI API
    But, my question is. When I develop one addon, or one UDO form that uses one set of user defined tables or used defined fields that where created by the first way (by wizard in B1), how I deploy this in other business one installation ? The package process will ensure the creation of this tables in another enviroment or I must implement the creation of user defined tables using DI API so that this code is called during the installation?
    If in cases of addon develop I must use DI API to create user defined tables, How can I use my classes with this responsibility in package process ?
    Thanks my friends.

    Hi Renan,
    You just need to put your logic in to the startup of your application, after you've established your connection to the UI API and DI API. All this will be triggered in the constructor of your main class.
    namespace MyNamespace
    public class MyAddon
      bool runAddon = true;
      bool initialised = false;
      const string ADDON_NAME = "My Addon";
      public static void Main()
            MyAddon addOn = new MyAddon();
            if(runAddon)
                  System.Windows.Forms.Application.Run();
            else
             Application.Exit();
      public MyAddon()
            // Connect to SBO session for UI
            if(!SetApplication()) runAddon = false;
      private bool SetApplication()
            // Code goes in here to establish UI API and DI API connections
            // See SDK samples for examples
            // You should also define and filter the UI API events your addon will trap at this stage and create any menus
            // Call your routine to check if the required UDFs/UDTs exist on this company
            initialised = CheckInitialisation();
            if (!initialised)
               //  AddOn not yet intialised on this company so prompt the user to run the intialisation process
              int iResponse = app.MessageBox("The " + ADDON_NAME + " addon will now create all required fields and tables."
                                             + System.Environment.NewLine + System.Environment.NewLine
                                             + "WARNING: It is strongly recommended that all other users are logged out of this company "
                                             + "before running this process. Are you sure you wish to continue?", 2, "Yes", "No", "");
              if (iResponse == 1) initialised = InitialiseAddOn(); // Call your routine to create the objects
            return true;
    Kind Regards,
    Owen

  • How to clone a user-defined object?

    Hello,
    I need to clone an Object[] array (propArray) that holds objects of Integer, Double, Boolean type, along with objects of user-defined ClassA, ClassB, ClassC type. The matter is that the ClassA object isn't being cloned, while the rest of the user-defined objects are cloned just fine.
    In more detail, ClassA has two properties:
    public class ClassA implements Cloneable{
       private String penaltyFor;
       private Penalty[] penaltyArray;
       protected Object clone(){
          try{
             ClassA o = (ClassA)super.clone();
             o.penaltyFor = this.penaltyFor;
    //         o.penaltyArray = (Penalty[])penaltyArray.clone();  //This ain't working.
             //But neither does this :(.
             int penCount = this.penaltyArray.length;
             o.penaltyArray = new Penalty[penCount];
             for(int i = 0; i < penCount; i++)
                o.penaltyArray[i] = (Penalty)this.penaltyArray.clone();
    return o;
    } catch(CloneNotSupportedException e){ throw new InternalError(); }
    The Penalty class contains properties of primitive type and here is its clone() method:
    public class Penalty implements Cloneable{
       private String penaltyDesc;
       private int lowLimit, upperLimit, penaltyValue;
       protected Object clone(){
          try{
             Penalty o = (Penalty)super.clone();
             o.penaltyDesc = this.penaltyDesc;
             o.lowLimit = this.lowLimit;
             o.upperLimit = this.upperLimit;
             o.penaltyValue = this.penaltyValue;
             return o;
          } catch(CloneNotSupportedException e){ throw new InternalError(); }
       }I don't know what else to try. I suppose the problem is the Penalty[] array, but I may be wrong. An alternative would be to use Copy Constructors, but it will cause too many changes to the code, since the clone() method is used for the propArray copy in many places and the ClassA object is a late addition to the propArray (unfortunately it wasn't planned to exist from the beginning).
    Thank's.

    class ClassA implements Cloneable{
       private String penaltyFor;
       private Penalty[] penaltyArray;
       public Object clone(){
          try{
             ClassA o = (ClassA) super.clone();
             if (penaltyArray!=null){
                o.penaltyArray = (Penalty[]) penaltyArray.clone();
                for(int i = 0; i < penaltyArray.length; i++) {
                    Penalty penalty = this.penaltyArray;
    if (penalty!=null)
    o.penaltyArray[i] = (Penalty) penalty.clone();
    return o;
    } catch(CloneNotSupportedException e){
    throw new InternalError();
    class Penalty implements Cloneable{
    private String penaltyDesc;
    private int lowLimit, upperLimit, penaltyValue;
    public Object clone(){
    try{
    return super.clone();
    } catch(CloneNotSupportedException e){
    throw new InternalError();
    If your Penalties are immutable, you don't need to clone them -- rather,
    make then unclonable, like Strings.

  • User defined Exception in Stateless Java Class WS

    Hi,
    I'm experimenting with publishing some of my application's Java classes as web services under OC4J 10.1.2. I've been quite successfull to do so, but I'm stuck into a problem trying to have my class's methods throw my own type of exception and retrieving it at the client side.
    I'm using the proxies downloaded from the web service's automatic HTML page, and I see in the source code version that the proxy class specifically throws a org.apache.soap.SOAPException whenever there's a fault in the response message.
    What I've done is simply to create a type derived from Exception with a String (message) and an Integer (code) properties, with just my own constructor that accepts two parameters corresponding to that properties. Then I make the methods in my Java class throw that exception.
    I've tried both using both an Interface and a class, and also using just a class as parameters to StatelessWebServiceServlet / Web Service Assembler.
    I can't find anywhere in any docs that explains how this can be done in OC4J. I believe that throwing user-defined exceptions is included in J2EE 1.4 and so I think that there should be a way to do it in OC4J if it is compliant. Maybe there's no way, but I couldn't find any reference to that neither.
    I'll greatly appreciate any light on this issue.
    Thanks in advance
    Juan Alvarez Ferrando
    Mensaje editado por:
    user517323

    Thank you for your answer.
    I'd like to know something more about how far does that limited support go, in case it could be of some use.
    On the other hand, and just for the sake of constructive discussion, though I've contemplated the option of encoding error conditions on the result type, I always found that to be an ugly style from a interface design standpoint (not ws specifically but in general system desing terms), and when I saw a standard way to communicate custom error information separated from normal response I thought it to be the right way to go. After all, exceptions are just the way Java implements this design principle that has also found a place in most currently successful software environments (PL/SQL, .Net, ...).
    I don't expect to extend the meaning and programmatic use of Java exceptions to my ws clients, but to be able to communicate detailed error condition information as the standards contemplate (faults), which as I understand from your kind answer is out of my reach in 10.1.2.
    I have no experience with other ws platforms but I'd like to believe that if wsdl:fault is in the standards, those claming compliance will support it to the extent necessary to make it usable and interoperable as it is the way the standard covers error communication (and so that's why it is included in 10.1.3). I also beleve this would bring better interoperability than our home-made result types including error information, that no other application without our custom specifications can understand.
    Also better interoperability would come from that than for example what I now see in 10.1.2, where all exceptions are communicated to the client with a faultcode of soap:Server, which I believe to have the standard meaning that there's a chance for the client to success retrying later without modifying it's request. This translation could be better suited for Java errors (unrecoverable) but not for all kinds of exceptions, and so in this question, custom exception support could also improve interoperability with systems that interpret SOAP fault codes.
    Thank you.
    Juan Alvarez Ferrando

  • Problem regd USER DEFINED Exception heirarchy

    I have a strange class heirarchy regarding 'User defined exceptions'.
    This the heirarchy being used:<p>
    public class ExCalcFail extends SysException {<p>
         public ExCalcFail(UserConnection uc) {<p>
         super(uc);<p>
    }<p>
    }<p>
    public class SysException extends AutoDBObjectBase {<p>
    public SysException(UserConnection uc) {<p>
    super(uc);<p>
    }<p>
    <p>
    -- WHERE UserConnection is an INTERFACE.
    <p>
    Now my question is:
    <p>
    How can class ExCalFail's constructor call super(uc)?
    If this is the case,when is SysException's constructor called?
    <p>
    As class SysException has no default constructor how is the call
    super(uc) executed in ExCalcFail?
    <p>
    Shouldnt this give an error?

    How long have you been here? I'm surprised you still don't know about code tags.
    You can simply call super(uc) because that's the constructor the superclass - namely SysException - declares. And it's executed when it's called - at the beginning of ExCalcFail's c'tor. Where else?
    Why should it produce an error? It's perfectly valid and common code.

  • ORA-22979: cannot INSERT object view REF or user-defined REF

    I'm getting this error when trying to insert a parent_type object into an object table. The parent object contains a nested table of parent object references.
    CREATE TYPE cl_ArgList AS TABLE OF REF cl_Expression
    CREATE TYPE cl_Expression AS OBJECT (
    args cl_ArgList;
    Somehow the system-generated parent object REF that is returned from one STATIC function (using MAKE_REF) turns into a incompatible REF by the time it is passed to aother STATIC function and used in the constructor of the nested table for a new args instance.
    Does anybody know how this might be happening?
    Is there any way to test if a REF is a valid system-generated REF vs. a user-defined REF?
    I don't even know what a user-defined REF is, how I might be getting one, and what's wrong with it anyway. Shouldn't strong-typing ensure that the REF is okay if it is of the appropriate type?
    Glenn.

    Okay, solved that.
    FYI the problem is that the nested table arguments (REF cl_Expression) have to be SCOPED REFs, ie. constrained to refer only to objects in a particular table (although I don't really understand why).
    Then of course the trick is how to constrain the arguments in the nested table, because you can't do it in the CREATE TYPE statement. You also can't do it when you create the containing table, when you define how the nested table is stored:
    CREATE TABLE <containing table> OF cl_Expression (
    NESTED TABLE args STORE AS t_args
    Instead you have to modify the nested table properties after it has been created:
    ALTER TABLE t_args ADD (SCOPE FOR (column_value) IS t_Induhvidual);
    'column_value' is the actual syntax, not your own column name.
    But you probably knew that ;-)

  • OC4J and Oracle9i and user defined datatypes over SOAP.

    Does OC4J and Oracle9i, that comes with JDeveloper9i-rc, support user defined datatypes over SOAP?
    If I invoke the EJB over RMI it is working fine.
    But if I try to invoke it over SOAP I get this fault:
    500 Internal Server Error: Servlet error: Error building response envelope: java.lang.IllegalArgumentException: No Serializer found to serialize a 'mypackage.myObj' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.
    I have written the Deployment descripter like this:
    <?xml version = '1.0'?>
    <isd:service
    id="urn:mypackage.EJB2"
    type="rpc"
    xmlns:isd=" " target="_new">http://xmlns.oracle.com/soap/2001/04/deploy/service"> <isd:provider
    id="stateless-ejb-provider"
    methods="getData"
    scope="Request">
    <isd:option key="JNDILocation" value="EJB2"/>
    <isd:option key="DeploymentName" value="EJB2"/>
    </isd:provider>
    <isd:faultListener class="org.apache.soap.server.DOMFaultListener"/>
    <isd:mappings>
    <isd:map
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding" xmlns:x="http://glo2158" qname="x:mypackage.myObj"
    javaType="mypackage.myObj"
    java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer"
    xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/>
    </isd:mappings>
    </isd:service>

    AFAIK this is not possible with the Oracle 8i implementation. This is my main gripe about Oracle's so called objects - you can't define your own constructors, you can't put check constraints on them and you can't use them in triggers.
    In other words you can put any old scheisse in an object and you can't populate them with derived or default values.
    I'm on a 9i New Features course as I type and I'm hoping to hear that Oracle have added some features to objects that will make them worth using.
    regards, APC

  • Help needed for User-Defined Datatype

    Hi All,
    I have one table which has User-defined Column Datatype.
    Now Client wants us to rename the User-Defined Datatype for some Standardization process.
    How to do rename of it, coz Rename old to new doesnt work in Oracle 10.2.0.4G for TYPES.
    So we re-created it with the new names. Now our Problem is how do i re-assign the column datatype with the New User-Defined DataType.
    Regards,
    Prathamesh

    The Only Solution that i could found was - Create a new column with new User-Defined Datatype, copy the old column values to New Column, then drop the old column and rename the new Column to Old Column
    ORA-22859:     invalid modification of columns
    Cause:     An attempt was made to modify an object, REF, VARRAY, nested table, or LOB column type.
    Action:     Create a new column of the desired type and copy the current column data to the new type using the appropriate type constructor.

  • Error while processing a user defined screen

    Dear Experts,
    We have developed an add on for our client in which we have a user defined screen before adding the GRPO. While adding that we are getting the error to generate this document first define the numbering series in the administration module.
    this is happening only after we upgraded to the 2007 B PL 10 version. till that there was no problem. We are unable to remove and replace the UDO and UDT as we have data in it.
    due to this we are unable to proceed with the GRPO.
    Please help us.
    thanks and regards,
    Yeshwanth Prakash

    Hi,
    Please search the forum before posting a new message.
    There are endless posts about that error.
    Regards,
    Vítor Vieira

Maybe you are looking for

  • Context-sensitive F4 help

    Hello experts, I have a normal ABAP report with a selection screen. On this screen I have two input fields, field_A and field_B. In field_A the user can choose from one of 4 pre-set values (A, B, C, D). Now, depending on this value choosen for field_

  • Leaving room on Hard Disc for downloading Rental Movies.

    Using the Sync mode vs Streaming. How do you Sync music and playlists to the AppleTV and leave enough room for Rental Movie Downloans...need to save about 10 GB for HD movies. SUGGESTION: Seems like we need a selection on the Apple TV Summary page in

  • How can i get apps with out using credit card info because i do not have a card ?

    how can i get apps with out using credit card info because i do not have a card ?

  • [solved]open url in xchat2.8

    hi @ll when i wanna open an url in xchat, i get this message: Der Befehl lässt sich nicht ausführen. Die Datei oder der Ordner file:///home/defcon/www.colaforum.de existiert nicht. for non-germans: "file or folder file:///home/defcon/www.colaforum.de

  • Image source

    Hi, is it possible to directly show an image that is retrieved physically like the below?      out.println("</body><img src='http://192.168.125.125:8988/Application1-Project1-context-root/showworkloadimgservlet'></html>");