Recursive Self Reference

Hi,
I am trying to do a recursive self reference. Is this the best way of doing it as I keep getting errors?
SQL> CREATE OR REPLACE TYPE type_objtyp AS OBJECT (
2 type_id NUMBER (10),
3 type_name VARCHAR2 (100),
4 sub_type REF type_objtyp
5 )
6 NOT FINAL
7 /
Type created.
SQL> CREATE OR REPLACE TYPE data_objtyp
2 /
Type created.
SQL> CREATE OR REPLACE TYPE data_list_objtyp AS TABLE OF data_objtyp
2 /
Warning: Type created with compilation errors.
SQL> CREATE OR REPLACE TYPE data_objtyp AS OBJECT (
2 data_id NUMBER (10),
3 type_ref REF type_objtyp,
4 creation_date DATE,
5 child_list_ref REF data_list_objtyp
6 )
7 NOT FINAL
8 /
Warning: Type created with compilation errors.
SQL>
SQL> COMMIT
2 /
Commit complete.
SQL> show errors
Errors for TYPE DATA_OBJTYP:
LINE/COL ERROR
0/0 PL/SQL: Compilation unit analysis terminated
5/25 PLS-00532: Target of REF must be a complete or incomplete object
type.

you can't have a REF to a table type, only to object types. so, instead use a table of REFs:
-- incomplete declaration
create or replace type data_objtyp;
-- declare table type
create or replace type data_objtyp_list is table of REF data_objtyp;
-- complete data object declaration
create or replace type data_objtyp is object (
data_id NUMBER (10),
type_ref REF type_objtyp,
creation_date DATE,
child_list data_objtyp_list
NOT FINAL;
hope that helps... g

Similar Messages

  • Data Modeler: How to create a self reference in ER?

    e.g. I create the entity EMP in a logical Subview. Two attributes are here essential for a self-reference: EMPNO and MGR. So each Employee has a reference to his boss. And this information is stored in MGR.
    Now I create the entity EMP with the 8 columns from the SCOTT/TIGER schema. After that I define a 1:N-Relation between EMP and EMP. but it looks like I cannot define, which attributes are starting point of the relation and destination.
    Who can help me here?
    Gerd

    Gerd,
    you cannot select destination (as you said) attribute - they are automatically generated. However you can achieve what you want - it depends on your starting point:
    1) start from logical model (analysis first)
    - you create 1:n recursive relationship -
    - change the name of created FK attribute to MGR or what ever you want - this is controlled by "FK Attribute name synchronization" setting at "General options>Model>Logical" page
    2) start from relational model (reverse engineering of existing status)
    - create self reference foreign key - select MGR as FK column;
    - reverse engineer to logical model - you'll have FK attribute named MGR
    Philip

  • Why do we need a Self Reference "me" to use the components of a class

    Hi
    I am not clear why do we need a self reference variable "me" to call the components of its own class? when it can be accessed directly as in the following examples?
    In my first example below i can call the method display_name directly without creating a reference object or instance of the class within the class.
    In the second example i am using the self refernce Write me->name to access the component of a class.
    My question is why do we need "me" when i can use the components directly as shown in my first example.
    CLASS egocentric DEFINITION.
      PUBLIC SECTION.
        DATA:
         name(10) TYPE c READ-ONLY.
        METHODS set_name.
        METHODS display_name.
    ENDCLASS.                    "egocentric DEFINITION
    *       CLASS egocentric IMPLEMENTATION
    CLASS egocentric IMPLEMENTATION.
      METHOD set_name.
        MOVE 'Abap Objects' TO name.
        CALL method display_name.
      ENDMETHOD.                    "write_name
      METHOD display_name.
        write: name.
      ENDMETHOD.                    "display_name
    ENDCLASS.                    "egocentric IMPLEMENTATION
    *Global Data
    DATA oref TYPE REF TO egocentric.
    START-OF-SELECTION.
      CREATE OBJECT oref.
      CALL METHOD oref->set_name.
    CLASS egocentric DEFINITION.
            PUBLIC SECTION.
                DATA:
                 name(10) TYPE c VALUE u2018Instructoru2019
    READ-ONLY.
                 METHODS write_name.
    ENDCLASS.
    CLASS egocentric IMPLEMENTATION.
            METHOD write_name.
                WRITE me->name.
            ENDMETHOD.
    ENDCLASS.
    *Global Data
    DATA oref TYPE REF TO egocentric.
    START-OF-SELECTION.
            CREATE OBJECT oref.
            CALL METHOD oref->write_name.

    You can go WIKI and search with ABAP Objects.
    Or do the same in 'advanced search'  and select a search area. You are bound to find something.
    Or this link perhaps:
    [abap objects|http://help.sap.com/saphelp_nw70/helpdata/EN/ce/b518b6513611d194a50000e8353423/content.htm]

  • Resolve self-reference table by alias tables in detail

    Hello Gurus,
            can you tell me how to resolve self-reference table by alias tables in detail?
    Many thanks.

    Hello, for the following step 3, I don't understand, will you please give me some explanation for step 3?
    Save your Staff universe, and test the results in Web Intelligence Rich Client as follows:
    1. Run a query using Manager and Employee. Add a count on both columns.
    2. Add a query with only the Manager object. Add a count. Is this the correct value?
    3. Open your Staff universe in Universe Designer and edit the Manager object. To ensure
    that the data is restricted to only manager data, use the Tables button. Select the
    EMPLOYEE table, to force the object to use the join between the table and restrict the
    data.
    4. Test the result, creating a new query with only the Manager object. It returns the correct
    number of managers.
    5. Edit the query and add Employee. Run and display the count. There are 26 rows. Why?
    The join restricts the data to look only for employees that have managers. However, there
    is a manager that does not have a manager, and is now excluded.
    6. Open your Staff universe in Universe Designer and add an outer join on the MANAGER
    table side.
    7. Save the changes and test the results in Web Intelligence Rich Client.

  • Example of Self Reference

    Hello experts,
    I am totally new to ABAP Objects and was going through a book for the same to learn the concepts.
    There is a section of Self Reference in this book. I could not understand this concept by myself. Could you please help me out to explain this thing.
    PFB the code that is given in this book to explain Self Reference.
    REPORT  z_self_reference.
    *       CLASS client DEFINITION
    CLASS client DEFINITION.
      PUBLIC SECTION.
        DATA name(10) TYPE c VALUE 'Master' READ-ONLY.
        METHODS create_server.
    ENDCLASS.                    "client DEFINITION
    *       CLASS server DEFINITION
    CLASS server DEFINITION.
      PUBLIC SECTION.
        METHODS acknowledge
         IMPORTING creator TYPE REF TO client.
      PRIVATE SECTION.
        DATA name(10) TYPE c VALUE 'Servant'.
    ENDCLASS.                    "server DEFINITION
    *       CLASS client IMPLEMENTATION
    CLASS client IMPLEMENTATION.
      METHOD create_server.
        DATA server_ref TYPE REF TO server.
        CREATE OBJECT server_ref.
        CALL METHOD server_ref->acknowledge
          EXPORTING
            creator = me.
      ENDMETHOD.                    "create_server
    ENDCLASS.                    "client IMPLEMENTATION
    *       CLASS server IMPLEMENTATION
    CLASS server IMPLEMENTATION.
      METHOD acknowledge.
        DATA name TYPE string.
        name = creator->name.
        WRITE: me->name, 'create by', name.
      ENDMETHOD.                    "acknowledge
    ENDCLASS.                    "server IMPLEMENTATION
    DATA client_ref TYPE REF TO client.
    START-OF-SELECTION.
      CREATE OBJECT client_ref.
      CALL METHOD client_ref->create_server.
    Thanks,
    Mohit Goel.
    Edited by: Matt on Apr 8, 2009 10:50 AM

    Hi Mohit,
    me is used to self reference the attributes and methods of a class within that class.In your program,
    within client class implementation, you can use me->name and me->create_server to call the name variable and create_server method in the same class if required.Here me represents "client class".Similarly ,in Server class, you can use me->name and me->acknowledge to call the name variable and acknowledge method in the same class if required.
    In your program ,
    CALL METHOD server_ref->acknowledge
    EXPORTING
    creator = me.  
    is not correct.me is not used as variable . Its only a reference variable.it shoud used me->class attribute(name)/method.
    I hope , you could understand the above explanation.
    by
    Prasad GVK.

  • Create two one-to-one self-reference mappings

    We need help on the following problem with Toplink:
    We have a table massnahme with several attributes.
    table massnahme
    massnahmeID
    prevMassnahme
    nextMassnahme
    prevMassnahme, nextMassnahme are self-references on massnahme. We take prevMassnahme and nextMassnahme as a one-to-one mapping to massnahme. The target reference on prevMassnahme and nextMassnahme is massnahmeID.
    If we create a new Object massnahme_B and set prevMassnahme on this massnahme_B to an existing massnahme_A and set the nextMassnahme on the existing massnahme_A to the new massnahme_B, then it seems that toplink tries to make the update on the existing massnahme_A before the insert of the new massnahme_B. That causes an exception, because toplink tries to insert an empty massnahme into the database.
    Any help on this topic would be appreciated.
    The Toplink Mapping Workbench we use has the version 9.0.4.2.
    Thomas

    Here the Java-Code and Descriptor Snippets, where Anamnese and Aufnahmevorgang are both derived classes of Massnahme and cloneAufnahmevorgang is registered earlier in the code (same UnitOfWork).
    <mapping>
    <inherited>false</inherited>
    <instance-variable-name>prevMassnahme</instance-variable-name>
    <uses-method-accessing>false</uses-method-accessing>
    <read-only>false</read-only>
    <get-method-handle>
    <method-handle empty-aggregate="true"/>
    </get-method-handle>
    <set-method-handle>
    <method-handle empty-aggregate="true"/>
    </set-method-handle>
    <reference-descriptor>de.kvwl.masc.se.model.Massnahme.ClassDescriptor</reference-descriptor>
    <private-owned>false</private-owned>
    <uses-batch-reading>false</uses-batch-reading>
    <table-reference-mapping-reference-handle>
    <reference-handle>
    <reference-table>MASSNAHME</reference-table>
    <reference-name>MASSNAHME_C05</reference-name>
    </reference-handle>
    </table-reference-mapping-reference-handle>
    <uses-joining>false</uses-joining>
    <one-to-one-mapping-indirection-policy>
    <indirection-policy>
    <uses-indirection>true</uses-indirection>
    </indirection-policy>
    </one-to-one-mapping-indirection-policy>
    <mapping-class>MWOneToOneMapping</mapping-class>
    </mapping>
    <mapping>
    <inherited>false</inherited>
    <instance-variable-name>nextMassnahme</instance-variable-name>
    <uses-method-accessing>false</uses-method-accessing>
    <read-only>false</read-only>
    <get-method-handle>
    <method-handle empty-aggregate="true"/>
    </get-method-handle>
    <set-method-handle>
    <method-handle empty-aggregate="true"/>
    </set-method-handle>
    <reference-descriptor>de.kvwl.masc.se.model.Massnahme.ClassDescriptor</reference-descriptor>
    <private-owned>false</private-owned>
    <uses-batch-reading>false</uses-batch-reading>
    <table-reference-mapping-reference-handle>
    <reference-handle>
    <reference-table>MASSNAHME</reference-table>
    <reference-name>MASSNAHME_C07</reference-name>
    </reference-handle>
    </table-reference-mapping-reference-handle>
    <uses-joining>false</uses-joining>
    <one-to-one-mapping-indirection-policy>
    <indirection-policy>
    <uses-indirection>true</uses-indirection>
    </indirection-policy>
    </one-to-one-mapping-indirection-policy>
    <mapping-class>MWOneToOneMapping</mapping-class>
    </mapping>
    Anamnese cloneAnamnese = (Anamnese) getUow().registerExistingObject(anamnese);
    cloneAufnahmevorgang.setPrevMassnahme(cloneAnamnese);
    cloneAnamnese.setNextMassnahme(cloneAufnahmevorgang);
    getUow().commit();
    Any further Information needed?
    Thomas

  • Self Reference Model Class - How to populate using Entity Framework

    Hi,i have table in SQL Server named Employees as follows:
    EmployeeId lastName FirstName reportsTo
    1 Davolio Nancy 2
    2 Fuller Andrew NULL
    3 Leverling Janet 2
    4 Peacock Margaret 2
    5 Buchanan Steven 2
    6 Suyama Michael 5
    7 King Robert 5
    8 Callahan Laura 2
    9 Dodsworth Anne 5
    I would like to use Entity Framework to populate my Model Class .My model class looks as follows:
    public class Employees
        readonly List<Employees> _children = new List<Employees>();
        public IList<Employees> Children
            get { return _children; }
        public string FirstName { get; set; }
        public string LastName {get; set;}
    I want to use this class in ViewModel  to populate my TreeView control. Can anyone help me in order to define Linq to Entities in order to populate my model class Employees from table in SQL Server as defined. Thanks in advance.
    Almir

    Hello Fred,
    unfortunately it does not work, maybe I can be more specific about what I'm trying to get. I'm following Josh Smith's article on CodeProject related to WFP TreeView
    Josh Smith article. He has Class named Person with the following structure
    public class Person
    readonly List<Person> _children = new List<Person>();
    public List<Person> Children
    get
    return _children;
    public string Name { get; set; }
    The same is populated from Database class using method named GetFamilyTree() which look as follows:
    public static Person GetFamilyTree()
    // In a real app this method would access a database.
    return new Person
    Name = "David Weatherbeam",
    Children =
    new Person
    Name="Alberto Weatherbeam",
    Children=
    new Person
    Name="Zena Hairmonger",
    Children=
    new Person
    Name="Sarah Applifunk",
    new Person
    Name="Jenny van Machoqueen",
    Children=
    new Person
    Name="Nick van Machoqueen",
    new Person
    Name="Matilda Porcupinicus",
    new Person
    Name="Bronco van Machoqueen",
    new Person
    Name="Komrade Winkleford",
    Children=
    new Person
    Name="Maurice Winkleford",
    Children=
    new Person
    Name="Divinity W. Llamafoot",
    new Person
    Name="Komrade Winkleford, Jr.",
    Children=
    new Person
    Name="Saratoga Z. Crankentoe",
    new Person
    Name="Excaliber Winkleford",
    I'm trying to figure out how should I write
    GetFamilyTree() method using Entity Framework in order to connect to my SQL Server database and populate this Person class as it was populated manually in Joshs Example. The table I'm using in SQL Server is described in
    my first post named Employees (it's self reference table)

  • Self reference This  in java

    Hi all
    Does any one know, how the self reference variable "this" works. That is how and when "this" variable is instantiated.
    How value of "this" keeps on changing???
    Is "This" static, final, private??
    Any help will be appreciated.
    regards
    prince.k

    Well lets assume it is a keyword. What i want to know
    is how it is made to refer to the current object. I
    guess the compiler adds some code for "this", so what
    is that code??What makes you think the compiler adds code? Do you mean Java code?
    U said it isn't static; No I didn't. I said that if you insist on thinking about it as a variable, then consider it non-static.
    but it is static as u can
    access it from ur class by saying "classname.this".That is just a syntax. As this is not a variable, classname.this does not imply it is static. There is one value per instance of any class (namely, the value for any given instance is a reference to that instance). If it were static, there would be one value shared by all instances of the class. Either way, this is a moot point.
    But had it been final, it should be able to to refer
    to only one object.It does. The current object.
    but it keeps on changing....as it refer to the object
    which called a particuler method of that class.No it doesn't - can you give an example of what you believe is the value of this changing?

  • Recursive Self Join

    Hi. I need to query the database of a document management system.   Documents are logically stored in folders in a tree structure and may be nested to arbitrary depth.  The FOLDER table lists the names and metadata of folders. 
    Ultimately, I want to join the FOLDER table ("f") to the DOCUMENT table ("d") to get a list of documents by folder.  The main thing I need help with is to build folder paths.  I don't necessarily even
    need to build full paths.  I would be happy just listing all the individual folders under the root, and the documents they contain.  I imagine to build folder paths involves a self join, but I don't know how to hadle arbitrary depth
    The first two columns of the FOLDER table are FOLDER_ID and PARENT_FOLDER_ID.  The data looks like this (where FOLDER_ID 1 represents the root folder):
    FOLDER_ID     PARENT_FOLDER_ID
    1                    null
    2                    1
    3                    1
    4                    1
    5                    2
    6                    2
    7                    1
    etc.
    Thanks for your help!

    See Itzik Ben-Gan examples dealing with such queries.
    CREATE TABLE Employees
      empid   int         NOT NULL,
      mgrid   int         NULL,
      empname varchar(25) NOT NULL,
      salary  money       NOT NULL,
      CONSTRAINT PK_Employees PRIMARY KEY(empid),
      CONSTRAINT FK_Employees_mgrid_empid
        FOREIGN KEY(mgrid)
        REFERENCES Employees(empid)
    CREATE INDEX idx_nci_mgrid ON Employees(mgrid)
    SET NOCOUNT ON
    INSERT INTO Employees VALUES(1 , NULL, 'Nancy'   , $10000.00)
    INSERT INTO Employees VALUES(2 , 1   , 'Andrew'  , $5000.00)
    INSERT INTO Employees VALUES(3 , 1   , 'Janet'   , $5000.00)
    INSERT INTO Employees VALUES(4 , 1   , 'Margaret', $5000.00) 
    INSERT INTO Employees VALUES(5 , 2   , 'Steven'  , $2500.00)
    INSERT INTO Employees VALUES(6 , 2   , 'Michael' , $2500.00)
    INSERT INTO Employees VALUES(7 , 3   , 'Robert'  , $2500.00)
    INSERT INTO Employees VALUES(8 , 3   , 'Laura'   , $2500.00)
    INSERT INTO Employees VALUES(9 , 3   , 'Ann'     , $2500.00)
    INSERT INTO Employees VALUES(10, 4   , 'Ina'     , $2500.00)
    INSERT INTO Employees VALUES(11, 7   , 'David'   , $2000.00)
    INSERT INTO Employees VALUES(12, 7   , 'Ron'     , $2000.00)
    INSERT INTO Employees VALUES(13, 7   , 'Dan'     , $2000.00)
    INSERT INTO Employees VALUES(14, 11  , 'James'   , $1500.00)
    The first request is probably the most common one:
     returning an employee (for example, Robert whose empid=7) 
    and his/her subordinates in all levels. 
    The following CTE provides a solution to this request:
    WITH EmpCTE(empid, empname, mgrid, lvl)
    AS
      -- Anchor Member (AM)
      SELECT empid, empname, mgrid, 0
      FROM Employees
      WHERE empid = 7
      UNION ALL
      -- Recursive Member (RM)
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1
      FROM Employees AS E
        JOIN EmpCTE AS M
          ON E.mgrid = M.empid
    SELECT * FROM EmpCTE
    Using this level counter you can limit the number of iterations
     in the recursion. For example, the following CTE is used to return 
    all employees who are two levels below Janet:
    WITH EmpCTEJanet(empid, empname, mgrid, lvl)
    AS
      SELECT empid, empname, mgrid, 0
      FROM Employees
      WHERE empid = 3
      UNION ALL
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1
      FROM Employees as E
        JOIN EmpCTEJanet as M
          ON E.mgrid = M.empid
      WHERE lvl < 2
    SELECT empid, empname
    FROM EmpCTEJanet
    WHERE lvl = 2
    As mentioned earlier, CTEs can refer to
     local variables that are defined within the same batch.
     For example, to make the query more generic, you can use 
    variables instead of constants for employee ID and level:
    DECLARE @empid AS INT, @lvl AS INT
    SET @empid = 3 -- Janet
    SET @lvl   = 2 -- two levels
    WITH EmpCTE(empid, empname, mgrid, lvl)
    AS
      SELECT empid, empname, mgrid, 0
      FROM Employees
      WHERE empid = @empid
      UNION ALL
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1
      FROM Employees as E
        JOIN EmpCTE as M
          ON E.mgrid = M.empid
      WHERE lvl < @lvl
    SELECT empid, empname
    FROM EmpCTE
    WHERE lvl = @lvl
    Results generated thus far might be returned (but are not guaranteed to be), 
    and error 530 is generated. You might think of using the MAXRECURSION option 
    to implement the request to return employees who are two levels below 
    Janet using the MAXRECURSION hint instead of the filter in the recursive member
    WITH EmpCTE(empid, empname, mgrid, lvl)
    AS
      SELECT empid, empname, mgrid, 0
      FROM Employees
      WHERE empid = 1
      UNION ALL
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1
      FROM Employees as E
        JOIN EmpCTE as M
          ON E.mgrid = M.empid
    SELECT * FROM EmpCTE
    OPTION (MAXRECURSION 2)
    WITH EmpCTE(empid, empname, mgrid, lvl, sortcol)
    AS
      SELECT empid, empname, mgrid, 0,
        CAST(empid AS VARBINARY(900))
      FROM Employees
      WHERE empid = 1
      UNION ALL
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1,
        CAST(sortcol + CAST(E.empid AS BINARY(4)) AS VARBINARY(900))
      FROM Employees AS E
        JOIN EmpCTE AS M
          ON E.mgrid = M.empid
    SELECT
      REPLICATE(' | ', lvl)
        + '(' + (CAST(empid AS VARCHAR(10))) + ') '
        + empname AS empname
    FROM EmpCTE
    ORDER BY sortcol
    (1) Nancy
     | (2) Andrew
     |  | (5) Steven
     |  | (6) Michael
     | (3) Janet
     |  | (7) Robert
     |  |  | (11) David
     |  |  |  | (14) James
     |  |  | (12) Ron
     |  |  | (13) Dan
     |  | (8) Laura
     |  | (9) Ann
     | (4) Margaret
     |  | (10) Ina
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Recursion with reference cursors

    Hi,
    I need to do a recursive SQL select in a report. Using reference
    cursors I can do dynamic SQL selects. What do I need to do if I
    must do this recursively. I run into cursor already open error
    trying to close the cursor does not help as well.
    Any ideas?
    TIA
    Srinivas

    Ok, so you know how the if- test works, and you even seem to almost understand the code you have posted (presuming your professor has written the code, right?). Good start! I like the way you post the code and ask the question can it be done? It is far better than just writing please do my homework for me, because I am too lazy to do it myself...
    Have a look in your programming book and reed the chapter about loops. It should give you an idea of how to solve your assignment.
    And try posting to the right forum. This question belongs to the New To Java Technology forum. Later on you may advance to the Java Programming forum.
    Good luck!

  • Recursive By reference passing of hashtable value in C#

    Basically, I'm trying to graft a hashtable to to another, and in any other language, I can get it to work...C#, not so much. If anyone could give me some insight on how I should be doing this, I'd appreciate it. This is what I have so far (which doesn't work - it throws an error saying that I can only pass an lvalue by reference - I understand the problem, just not how to solve it).
    private void GraftTables(ref Hashtable mainHash, Hashtable branch)
    try
    foreach (object key in branch.Keys)
    if ( !mainHash.ContainsKey(key) )
    //graft
    mainHash.Add(key, branch[key]);
    else
    GraftTables(ref (Hashtable) mainHash[key], (Hashtable)branch[key]);
    catch (Exception ex)
    throw ex;
    Thanks for any help,
    Chuck Charbeneau
    Lear Corporation
    [email protected]

    If you are trying to do what Ricky described, I don't think you need to use the ref keyword in the first place. I think your method could just be:
    private void GraftTables(Hashtable mainHash, Hashtable branch)
    The key point here is that mainHash is essentially a pointer to a Hashtable object, so you end up pointing to and manipulating the same object inside your function whether you pass it by value or by reference. The only difference in passing it as a reference is that you can modify the pointer itself, for example:
    private void f1(Hashtable h){  h.Add("A", 1);  h = new Hashtable();  h.Add("A", 2);}
    private void f2(ref Hashtable h){  h.Add("A", 1);  h = new Hashtable();  h.Add("A", 2);}
    If I call:
    Hashtable h = new Hashtable();f1(h);object x = h["A"];
    I will get x==1, but if I call:
    Hashtable h = new Hashtable();f2(ref h);object x = h["A"];
    I will get x==2.

  • Reg: self reference ME

    Hi,
    I created a class in se24 and in method wrote simple addition logic
    I created a object in my prog for the class and entered the numbers it works fine.
    But when I use ME to reference the method its showing an error ME is not defined by any DATA statemnt
    the code is as follows
    class zp_class definition load.
    PARAMETERS : p_x type i,
                 p_y type i.
    data : z type i.
    CALL METHOD me->zadd
      EXPORTING
        v_x    = p_x
        v_y    = p_y
      IMPORTING
        v_z    = z
    write :z  .
    How to make use of ME plz guide me
    regards

    Hi ,
    me is used to refer the methods and attributes of the same class within the methods of that class only.
    This will explain by the folllowing example.
    *& Report  Z_SIMPLE_CLASS
    REPORT  z_simple_class.
          CLASS c1 DEFINITION
    CLASS c1 DEFINITION.
      PUBLIC SECTION.
        DATA: a TYPE i value 3,
                  b TYPE i value 4.
        METHODS: m_add exporting a type i
                                 b type i,
                          m_sub.
    ENDCLASS.                    "c1 DEFINITION
    CLASS c1 IMPLEMENTATION.
      METHOD m_add.
        DATA c TYPE i.
        c = a + b.
        WRITE: 'c:= ', c.
      ENDMETHOD.                    "m_add
      METHOD m_sub.
        DATA c TYPE i.
        CALL METHOD me->m_add.
        b = c.
        a = b.
        c = a - b.
        WRITE: 'c:= ', c.
      ENDMETHOD.                    "m_sub
    ENDCLASS.                    "c1 IMPLEMENTATION
    START-OF-SELECTION.
      DATA: cc1 TYPE REF TO c1,
            a1 type i value -4,
            b1 type i value -4.
      CREATE OBJECT cc1.
      cc1->m_add( importing a = a1 b = b1 ).
      write: cc1->a.
      write: cc1->b.
    by
    Prasad G.V.K
    Edited by: PRASAD GVK on Jul 21, 2008 3:03 PM

  • Passing self reference to a method call.

    I have classes 'A' & 'B'.
    A's method 'M1' calls a B's method 'M2'which takes object of type 'A' as an argument.
    Is it possible to use 'this' keyword or do I need to use Class.forName('A')
    If not, is there a better way to accomplish the same.
    Ex:
    public class A
    public M1()
    //calls a method M2 on B that takes object of type 'A' as argument
    B b = new B().M2(this);
    }//end of class
    public class B
    public Object M2(A a)
    }//end of class B
    Thanks in advance.

    Class.forName("A") returns an object of type Class, not an object of type A. So it won't work. this would work.

  • Issue with self reference on ManyToOne relationship

    Hi,
    I have a scenario where one of the columns on a table refers to the ID of the same table for a @ManyToOne relationship. Here is an example class below to better explain the situation:
    @Entity
    @Table(name = "DEPARTMENT")
    public class Department implements java.io.Serializable
    @Id
    private int ID;
    @ManyToOne(targetEntity = Department.class, fetch = FetchType.EAGER)
    @JoinColumn(name = "PARENT_ID")
    private Department parent;
    @OneToMany(mappedBy = "parent", targetEntity = Department.class, fetch = FetchType.LAZY)
    private Set<Category> children = new HashSet<Category>(0);
    Here if you notice the parent is the ID of another Department. When I use this during a create it seems to be trying to update the ID of an existing Department record, which is causing an exception as follows:
    SEVERE: Error processing request from 127.0.0.1 for <anon>: javax.persistence.RollbackException: Exception [TOPLINK-7251] (Oracle TopLink Essentials - 2.0 (Build b41d-beta2 (04/24/2007))): oracle.toplink.essentials.exceptions.ValidationException
    Exception Description: The attribute [ID] of class [Department] is mapped to a primary key column in the database. Updates are not allowed.
    Any thoughts on what I might be doing wrong. Appreciate your help.
    Thanks,
    Sharanya

    Thanks for the help.
    It turns out the problem was related to executing a SELECT query on the entities prior to committing the transaction. Essentially, there were entities which were being created and persisted (but not committed), and these records were being retrieved via a SELECT query. At the point the query was executed, an attempt was made to flush, and since the record hadn’t been updated in the persistence context, TopLink saw the SELECT query execution as an update and thus threw the exception.
    /* simplified for brevity */
    @Entity
    class Record {
        @Id
        @GeneratedValue(…)
        private Integer id;
        @ManyToOne(…)
        private Record parent;
        @OneToMany(…)
        private Collection<Record> children;
    class RecordService {
        void addRecords(Record records…) {
            for (Record record : records) {
                addRecord(record);
        void addRecord(Record record) {
            // Execute a SELECT to get related record(s).
            // Update the record(s).
            em.persist(record);
    To resolve this, I simply persist the records before executing the SELECT query, and then after the records are updated, execute a merge:
        void addRecord(Record record) {
            em.persist(record);
            // Execute a SELECT query to get related record(s).
            // Update the record(s).
            em.merge(record);
    I'm not completely clear as to what point TopLink thought that the ID had been updated (it could be related to the previous post?), but this resolution seems to be working.

  • Self reference to the table issue-Query required

    Hi,
    I have the below query which will give me the result as
    select DC.Fullname as Fullname, DSL.Skills as Skills, AdminSC.SkillRatingID as Rating
                        from dim_Contacts DC
                        inner join admin_skills AdminSC on DC.attid = AdminSC.attid
                        inner join dim_Skill DSL on DSL.ID = AdminSC.skillID
                        inner join dim_Pattern DPS on DPS.SkillID = DSL.ID
                        where DPS.PatternTypeID = '2'
    Fullname
    Skills
    Rating
    Rahul
    BO Universe
    2
    Kiran
    Crystal Reports / Webi
    4
    Now what I am looking for is,I need to get 2 more rows with null values(eg :Rahul-Crystal Reports/Webi-0).Please find the required result set.
    Fullname
    Skills
    Rating
    Rahul
    BO Universe
    2
    Kiran
    Crystal Reports / Webi
    4
    Rahul
    Crystal Reports / Webi
    0
    Kiran
    BO Universe
    0
    Please help me in providing the query.Thanks

    You can use LEFT OUTER JOIN with Skills Table like follow query:
    SELECT DC.Fullname AS Fullname ,
    DSL.Skills AS Skills ,
    AdminSC.SkillRatingID AS Rating
    FROM dim_Contacts DC
    INNER JOIN admin_skills AdminSC ON DC.attid = AdminSC.attid
    LEFT OUTER JOIN dim_Skill DSL ON DSL.ID = AdminSC.skillID
    INNER JOIN dim_Pattern DPS ON DPS.SkillID = DSL.ID
    WHERE DPS.PatternTypeID = '2'
    sqldevelop.wordpress.com

Maybe you are looking for

  • Capture Problem with FCP 5.1

    I just loaded 2 new titanium macbookpros with 5.1. When testing the basics of the programs I found that one worked fine and the 2nd kept quitting FCP when I batch captured some test clips. I tried throwing out the preferences and when that didn't hel

  • Performnace problem in migrating form SOlaris2.5.1 to Solaris8

    have a working system in production for the last six years. It was done on Solaris 2.5.1 using C++ version 4.2. Now i am migrating it to Solaris 8 using C++ 5.4. I use class library from Recursionsw called ObjectSPace. My code requires lots of messag

  • Users able to build reports and dashboards via the Web browser

    Hi All, My requiremts is "Users able to build reports and dashboards via the Web browser and perform ad-hoc queries and analysis online via the internet" . Requesting to kindly let us me know  the procedure to get resolve the above requirement. Thank

  • OnComplet for video imported from url

    i made an ios app. in the app i have a video imporeted from url using StageWebView. how do i remove the video from stage on complete? the viseo is in second frame. can i force the on Complete to remove + goto 1 frame again?

  • CS3 slicing behavior not like FW8

    I just upgraded to CS3, and slicing is not behaving as it did in FW 8. I have a simple image, which I cut up into three slices. The slices do not overlap, although they are arranged on the page so that the slicing guides would overlap if they extende