Traverse A Nested Struct

Any thoughts on the quickest way to the last struct in a
nested struct without knowing the keys or how deep it's nested? And
of course it could branch much like trying to traverse a
tree.

I wasn't looking for an alphabetical list, just trying to get
to the inner most nested struct the quickest. In you example, how
would I get the value of employee.phone.office.ext without
previousley knowing that phone.office.ext existed and I only know
about employee. I could iterate over it with some type of iterator
hasNext(), but was wondering if there was a quicker way.
<cfset employee.name.first = "Mary">
<cfset employee.name.last = "Smith">
<cfset employee.position = "Boss">
<cfset employee.phone.home = "111-2222-33333">
<cfset employee.phone.office.ext = "444">
<cfset employee.phone.office.number>

Similar Messages

  • Referencing a query in a nested struct

    I have a nested struct that is being brought back from a
    component. It looks like this
    office_struct[ floor1_struct[ some query results]
    floor2_struct[some query results] ....]
    I am trying to reference the query so I can print it out to
    screen. How would I do that?
    I know for a normal nested sctruct I can use dot notation.
    i.e office_struct.floor1_struct.value =
    #office_struct[floor1_struct].value#

    You can usually do the same thing, but I know in version
    past, and I do
    not know if it has yet been resolved, that some tags that
    expect a query
    variable get confused if the query is nested in too complex a
    data
    structure. For this I have just referenced the complex query
    value with
    a simple local variable name and then used that in the tags
    needing a
    reference to the query.
    I.E.
    If <cfoutput query="office_struct.floo1_struct" ....>
    does not work try:
    <cfset variables.localQuery =
    office_struct.floor_struct>
    <cfoutput query="variables.localQuery"....>

  • How to call LabView function with nested structs and arrays from C#

    Hi,
    I've got the following functions defined in a LabView-dll:
    uint32_t __stdcall VOSC04_General(uint32_t Command, TD18Hdl *Messages);
    uint32_t __stdcall CheckDiameter(uint32_t Command, TD6 *Parameter);
    typedef struct {
     double SP_Diameter;
     double SP_Tolerantie;
     double PV_Diameter;
     } TD6;
    typedef struct {
     int32_t dimSize;
     int32_t Numeric[1];
     } TD18;
    typedef TD18 **TD18Hdl;
    I've got some C#-code (generated by PInvoke-wizard) to call these functions:
    [DllImport("vosc04.dll")]
    public static extern uint32_t VOSC04_General (uint32_t Command, ref TD18Hdl Messages);
    [DllImport("vosc04.dll")]
    public static extern uint32_t CheckDiameter(uint32_t Command, ref TD6 Parameter);
    [StructLayout(LayoutKind.Sequential,Pack=4)]
    public struct TD18
       public int32_t dimSize;
       [ MarshalAs( UnmanagedType.ByValArray, SizeConst=1)]
       public int32_t [] Numeric;
    [StructLayout(LayoutKind.Sequential,Pack=4)]
    public struct TD6
       public Double SP_Diameter;
       public Double SP_Tolerantie;
       public Double PV_Diameter;
    The problem now is that when I try to read the Messages-output-parameter, I get wrong values (pointers?). I think that the problem lies in the fact that LabView generated a TD18 AND an TD18Hdl struct.
    How can I correct this problem?
    Can anyone give me some advise to correct this problem? I'm not an expert in C, only in C#.

    I think the problematic line is this:
    public struct TD18
       public int32_t dimSize;
       [ MarshalAs( UnmanagedType.ByValArray, SizeConst=1)]
       public int32_t [] Numeric;
    It looks like C# is forcing the array to be of size 1. The thing is, LabVIEW stores arrays as handles which are double pointers to a structure which contains a size element followed by the elements of the array. For your example, int32 arrays are stored in memory as:
    handle -> location -> |size|element 1|element 2| .... |element size-1|
    Because C does not do runtime array bounds checking, you can get away by declaring the structure as:
    typedef struct {
     int32_t dimSize;
     int32_t Numeric[1];
     } TD18;
    The correct declaration would've been:
    typedef struct {
     int32_t dimSize;
     int32_t Numeric[size];
     } TD18;
    But size is not a constant, so C/C++ won't let you do that. So, even though the array is declared to be of size 1, it can (and usually does) have more than 1 element. This does not cause a problem because LabVIEW allocates memory based on the actual size of the array.
    If I were you, I'd try to change the prototype of the LabVIEW DLL function to accept a pointer to array data, rather than an array handle, pre-allocate memory for the array in C# and pass a pointer to the allocated memory into LabVIEW so that LabVIEW can "fill it up".
    Let me know if you need more information.
    Pramod

  • Loading into Nested XML target

    Hi all,
    I need to load the data from a flat file into XML file(which has a nested structed).
    How can we achieve this through BODI?

    Yes, you can definitely do this through the NRDM (Nested Relational Data Model) feature in Data Integrator/Data Services.
    The standard documentation contains information on how to do this (check the Designer Guide >> Nested Data chapter) or have a look at our [Data Integrator Tips & Tricks wiki,|https://www.sdn.sap.com/irj/scn/wiki?path=/display/bobj/businessobjectsDataIntegratorTipsandTricks], here the section that covers NRDM : https://www.sdn.sap.com/irj/scn/wiki?path=/display/bobj/theNoneRelationalDataModelNRDM

  • Creating view to get first row for each table !!

    I am having tables(more than 10) which are related using foreign key and primary key relationship.
    Example:
    Table1:
    T1Prim T1Col1 T1Col2
    Table2
    T2For T2Prim T2Col1 T2Col2 T2Col3
    (here T2For will have value same as T1Prim and in my design it has same column name i.e. T1Prim)
    Table3
    T3For T3Prim T3Col1 T3Col2 T3Col3
    (here T3For will have value same as T2Prim)
    and so on.
    The data in the tables is like For table1 there will be one record, for table2 there will be one record and for table 3 there are more than one records.
    Can i view either the first record for each of them or all records from each of them by writing the following view.
    I have written a view like this:
    Create or replace view test (T1Prim,T1Col1, T1Col2,T2Prim,T2Col1 T2Col2, T2Col3, T3Prim,T3Col1, T3Col2, T3Col3)
    As
    Select
    Table1.T1Prim,
    Table1.T1Col1,
    Table1.T1Col2,
    Table2.T2Prim,
    Table2.T2Col1,
    Table2.T2Col2,
    Table2.T2Col3,
    Table3.T3Prim,
    Table3.T3Col1,
    Table3.T3Col2,
    Table3.T3Col3
    From
    Table1,
    Table2,
    Table3
    where
    Table1.Prim = Table2.For
    and Table2.Prim = Table3.For
    When i ran the select statement on the view I am not getting any data. Whereas there is data when select is ran on individual table.
    Can someone please tell me where i am goofing.
    Thanks in the anticipation that i will get some hint to solve this.
    Eagerly waiting for reply.
    Thanks !!

    I mean use a collection :
    Collection Methods
    A collection method is a built-in function or procedure that operates on collections and is called using dot notation. The methods EXISTS, COUNT, LIMIT, FIRST, LAST, PRIOR, NEXT, EXTEND, TRIM, and DELETE help generalize code, make collections easier to use, and make your applications easier to maintain.
    EXISTS, COUNT, LIMIT, FIRST, LAST, PRIOR, and NEXT are functions, which appear as part of an expression. EXTEND, TRIM, and DELETE are procedures, which appear as a statement. EXISTS, PRIOR, NEXT, TRIM, EXTEND, and DELETE take integer parameters. EXISTS, PRIOR, NEXT, and DELETE can also take VARCHAR2 parameters for associative arrays with string keys. EXTEND and TRIM cannot be used with index-by tables.
    For more information, see "Using Collection Methods".
    Syntax
    Text description of the illustration collection_method_call.gif
    Keyword and Parameter Description
    collection_name
    This identifies an index-by table, nested table, or varray previously declared within the current scope.
    COUNT
    COUNT returns the number of elements that a collection currently contains, which is useful because the current size of a collection is not always known. You can use COUNT wherever an integer expression is allowed.
    For varrays, COUNT always equals LAST. For nested tables, normally, COUNT equals LAST. But, if you delete elements from the middle of a nested table, COUNT is smaller than LAST.
    DELETE
    This procedure has three forms. DELETE removes all elements from a collection. DELETE(n) removes the nth element from an index-by table or nested table. If n is null, DELETE(n) does nothing. DELETE(m,n) removes all elements in the range m..n from an index-by table or nested table. If m is larger than n or if m or n is null, DELETE(m,n) does nothing.
    EXISTS
    EXISTS(n) returns TRUE if the nth element in a collection exists. Otherwise, EXISTS(n) returns FALSE. Mainly, you use EXISTS with DELETE to maintain sparse nested tables. You can also use EXISTS to avoid raising an exception when you reference a nonexistent element. When passed an out-of-range subscript, EXISTS returns FALSE instead of raising SUBSCRIPT_OUTSIDE_LIMIT.
    EXTEND
    This procedure has three forms. EXTEND appends one null element to a collection. EXTEND(n) appends n null elements to a collection. EXTEND(n,i) appends n copies of the ith element to a collection. EXTEND operates on the internal size of a collection. So, if EXTEND encounters deleted elements, it includes them in its tally. You cannot use EXTEND with index-by tables.
    FIRST, LAST
    FIRST and LAST return the first and last (smallest and largest) subscript values in a collection. The subscript values are usually integers, but can also be strings for associative arrays. If the collection is empty, FIRST and LAST return NULL. If the collection contains only one element, FIRST and LAST return the same subscript value.
    For varrays, FIRST always returns 1 and LAST always equals COUNT. For nested tables, normally, LAST equals COUNT. But, if you delete elements from the middle of a nested table, LAST is larger than COUNT.
    index
    This is an expression that must yield (or convert implicitly to) an integer in most cases, or a string for an associative array declared with string keys.
    LIMIT
    For nested tables, which have no maximum size, LIMIT returns NULL. For varrays, LIMIT returns the maximum number of elements that a varray can contain (which you must specify in its type definition).
    NEXT, PRIOR
    PRIOR(n) returns the subscript that precedes index n in a collection. NEXT(n) returns the subscript that succeeds index n. If n has no predecessor, PRIOR(n) returns NULL. Likewise, if n has no successor, NEXT(n) returns NULL.
    TRIM
    This procedure has two forms. TRIM removes one element from the end of a collection. TRIM(n) removes n elements from the end of a collection. If n is greater than COUNT, TRIM(n) raises SUBSCRIPT_BEYOND_COUNT. You cannot use TRIM with index-by tables.
    TRIM operates on the internal size of a collection. So, if TRIM encounters deleted elements, it includes them in its tally.
    Usage Notes
    You cannot use collection methods in a SQL statement. If you try, you get a compilation error.
    Only EXISTS can be applied to atomically null collections. If you apply another method to such collections, PL/SQL raises COLLECTION_IS_NULL.
    You can use PRIOR or NEXT to traverse collections indexed by any series of subscripts. For example, you can use PRIOR or NEXT to traverse a nested table from which some elements have been deleted.
    EXTEND operates on the internal size of a collection, which includes deleted elements. You cannot use EXTEND to initialize an atomically null collection. Also, if you impose the NOT NULL constraint on a TABLE or VARRAY type, you cannot apply the first two forms of EXTEND to collections of that type.
    If an element to be deleted does not exist, DELETE simply skips it; no exception is raised. Varrays are dense, so you cannot delete their individual elements.
    PL/SQL keeps placeholders for deleted elements. So, you can replace a deleted element simply by assigning it a new value. However, PL/SQL does not keep placeholders for trimmed elements.
    The amount of memory allocated to a nested table can increase or decrease dynamically. As you delete elements, memory is freed page by page. If you delete the entire table, all the memory is freed.
    In general, do not depend on the interaction between TRIM and DELETE. It is better to treat nested tables like fixed-size arrays and use only DELETE, or to treat them like stacks and use only TRIM and EXTEND.
    Within a subprogram, a collection parameter assumes the properties of the argument bound to it. So, you can apply methods FIRST, LAST, COUNT, and so on to such parameters. For varray parameters, the value of LIMIT is always derived from the parameter type definition, regardless of the parameter mode.
    Examples
    In the following example, you use NEXT to traverse a nested table from which some elements have been deleted:
    i := courses.FIRST; -- get subscript of first element
    WHILE i IS NOT NULL LOOP
    -- do something with courses(i)
    i := courses.NEXT(i); -- get subscript of next element
    END LOOP;
    In the following example, PL/SQL executes the assignment statement only if element i exists:
    IF courses.EXISTS(i) THEN
    courses(i) := new_course;
    END IF;
    The next example shows that you can use FIRST and LAST to specify the lower and upper bounds of a loop range provided each element in that range exists:
    FOR i IN courses.FIRST..courses.LAST LOOP ...
    In the following example, you delete elements 2 through 5 from a nested table:
    courses.DELETE(2, 5);
    In the final example, you use LIMIT to determine if you can add 20 more elements to varray projects:
    IF (projects.COUNT + 20) < projects.LIMIT THEN
    -- add 20 more elements
    Related Topics
    Collections, Functions, Procedures
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/13_elems7.htm#33054
    Joel P�rez

  • Content conversion Vs  Module (MessageTransformBean) - help?

    Hi All,
    Scenario- File Sender, reading file (header,data,*,trailer)
    when should we use standard content conversion, Module (MessageTransformBean) ?
    I need to generate complex XML structure from flat-file records.
    Source (using some key value to identify header/data/trailer)
    header
    data-record
    data-record
    trailer
    Target (nested structe - not sure how to do nested part using content conversion)
    <message_mt>
    <record>
    <header>
       <key>
       <info>
           <key1/>
            <key2/>
       </info>
    </header>
    <partner>
       <parvw/>
        <par1/>
    </partner>
    <line-ite>
      .. details ..
    </line-item>
    </record>
    <message_mt>
    I looked at all the logs related to this, how-to docs as well, no where mentioned how to create nested structures, most of them are flat structure
    Can anyone advise me how to do this and when should i use content coversion, module and why?
    Appreciate any help.
    Thanks
    Message was edited by: kumar p
    Message was edited by: kumar p

    The content conversion in file adapter and module 'MessageTransformBean' are similar. Therefore you use the module in file adapter only, when you want to write an adapter module which works on the plain text structure before the conversion. Mostly you use the 'MessageTransformBean' in other adapters like JMS- or Mail adapter, where no content conversion is possible by default.
    The content conversion is not able to create a nested structure. You have to create a flat structure first, then create a nested structure with mapping.
    Regards
    Stefan

  • Bad warning or not

    In SunStudio12 rh4, I get the following warning
    "/xxx.h", line 92: Warning: Types cannot be declared in anonymous union.
    Code is from
    union
    struct
    double xStart; /* 256 - 263 */
    double xDelta; /* 264 - 271 */
    uint32_t xUnits; /* 272 - 275 */
    } adjunct_1000;
    struct
    double rowStart; /* 256 - 263 */
    double rowDelta; /* 264 - 271 */
    uint32_t rowUnits; /* 272 - 275 */
    uint32_t columnRecs; /* 276 - 279 */
    double columnStart; /* 284 - 291 */
    double columnDelta; /* 292 - 299 */
    uint32_t columnUnits; /* 300 - 303 */
    } adjunct_2000;
    struct
    struct
    double tagStart; /* 256 - 263 */
    double tagDelta; /* 264 - 271 */
    uint32_t tagUnits; /* 272 - 275 */
    uint32_t numberSubrec; /* 276 - 279 */
    double r2Start; // 280 - 287 | Unused. Set to tagStart.
    double r2Delta; // 288 - 295 | Unused. Set to tagDelta.
    uint32_t r2Units; // 296 - 299 | Unused. Set to tagUnits.
    uint32_t recordLength; /* 300 - 303 */
    struct
    char name [4];
    char format[2];
    uint16_t offset;
    } subr[26];
    } adjunct_3000;
    I think this is legal. IBM's web site certainly seems to say this is ok. (this is within a big structuer).
    Comments?

    There are two separate issues.
    1. An anonymous union at global or namespace scope must be declared static.
    2. An anonymous union cannot declare nested types.
    Your original example showed an anonymous union at global scope that was not declared static, and that declared nested types.
    You later revised the example to show the anonymous union as a member of a struct, but it still declared nested types.
    Your new example is similar to the revised example. The anonymous union is a member of a struct, which is always OK. But the anonymous union declares two nested structs, which is not OK.
    You can make the example valid by naming the structs and moving them outside the anonymous union:
    struct S1 {
    int b;
    int c;
    struct S2 {
    int d;
    int e;
    struct my_struct {
    int a;
    union {
    S1 s1;
    S2 s2;
    or like this, to preserve some scope:
    struct my_struct {
    int a;
    struct S1 {
    int b;
    int c;
    struct S2 {
    int d;
    int e;
    union {
    S1 s1;
    S2 s2;
    };

  • Is there a similar 'setkeycodes' utility in Solaris?

    I'm currently working on using an LK461-A2 keyboard for Solaris on x86. There are 6 keys not working. I was able to get them working on Linux by using the setkeycodes utility to map the scan code to an appropriate key code.
    Keyboard Key      Key Scan code     Key Code Mapped
    F13     E03D     189
    F14     E03E     190
    Help     E03F     191
    Do     E040     192
    F17     E041     193
    Is there a similar utility in solaris that can be used to map scancodes to keycodes?
    I would greatly appreciate a possible solution.
    Thank you.

    Tom_RH wrote:
    I am just starting a project in Java (my first java project). I am wondering whether there is a concept in java that similar to the structure in C or C++.In C++ a struct and a class is exactly the same (apart from two minor differences).
    The C++ concept of a struct/class is supplied in Java by three language elements with different properties, namely the class, the interface and the enum.
    In my c++ projects, I used to define all my structures in a single file (say structures.cpp) and included the file in other files wherever I need. Is there a way to do similar thing in Java?How classes are distributed on files is not a Java language issue. It's a question for your development system. Most development system allow you to have one public class on each .java file only. So I suggest you nest the "structs" like this,
    public class Struct {
       public static class One {
       public static class Two {
       public static class Three {
       // etcetera
    }The above can be kept on a single .java file and you just import it whenever you need any of the Struct classes.
    The nested "structs" will behave like ordinary Javav classes apart from their naming. Their names must be qualified with the name of the outer class like Struct.One, Struct.Two, etcetera.

  • How to properly create complex OCI objects (for Annotation Text)

    I am upgrading a tool that will upload text objects to a table with a ST_ANNOTATION_TEXT field. The app is a C++ app and I need to instantiate a ST_ANNOTATION_TEXT (using OCIObjectNew??). I actually have 2 questions. First, does anyone have an example of how to accomplish this? I seem to be unable to correctly create the annotation text type in C++ to be able to append to (calling OCICollAppend). Second, since ST_ANNOTATION_TEXT is a complex type (contains an array of annotation text elements), do I need to call OCIObjectNew on not only the main ST_ANNOTATION_TEXT type but also for the ST_ANNOTATIONTEXTELEMENT_ARRAY, ST_ANNOT_TEXTELEMENT_ARRAY, and the ST_ANNOTATIONTEXTELEMENT?
    I can't seem to find in info on this so hopefully someone else has been through this.

    user3068343 wrote:
    I am still having an issue where the sub objects are still NULL.Actually I was mistaken. I must have confused getting an Object from OCIObjectNew with using one of its constructor method in a statement.
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28395/oci18nav004.htm#sthref3438 clearly state the object will have NULL attributes, unless the OCI_ATTR_OBJECT_NEWNOTNULL flag is set on the environment handle.
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28395/oci11obj.htm#i446308 further tells you what the default value for the object members will be.
    An older 9i doc http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96594/adobjadv.htm#1008774 also warns about resetting the indicator struct member when you update a member of the object.
    user3068343 wrote:
    ++a) you allocate the object's top-level struct yourself (SDO_GEOMETRY in my case) in C+++
    Above you suggest creating the objects top-level struct myself. How do you create that top level object? I have been using OCIObjectNew on that object as well as its sub objects? Is that how you are creating the top-level object?This technique works only on binds, as objects you get back from defines are always allocated from the object cache. I create the top-level object directly on the stack... This is something I discovered worked, but is not documented, so you're probably on safer ground using OCIObjectNew instead.
    BTW, the reason I can't easily post OCI example code is that my code uses wrappers around the objects that hides most of the OCI:
    Geometry Geometry::make_point(OCIEnv* envhp, OCIError* errhp, float x, float y) {
        Geometry point_geom(envhp, errhp);
        point_geom.set_null(false);
        point_geom.gtype() = 2001;
        PointRef point = point_geom.point();
        point.set_null(false);
        point.x() = x;
        point.y() = y;
        return point_geom;
    }The above creates an 2D point-type SDO_GEOMETRY hidden inside the Geometry class, itself deriving from a GeometryRef class. The latter wraps a C++ API on top of the struct pointers for a SDO_GEOMETRY/SDO_GEOMETRY_ind, while Geometry actually composes the OTT generated value/indicator structs by value, and passes addresses to its nested structs to GeometryRef (its parent class). So GeometryRef can manipulate an object irrelevant of where it was allocated, the stack or the object cache. The Geometry class is a value class, but it's useful for binds only, and like I said uses a behavior which appears to work but is not explicitly documented.
    Unless you have nested objects by reference, nested objects are composed by value in the OTT-generated structs, so the space for all nested objects is already allocated after the first OCIObjectNew. But the members themselves are not initialized, and thus marked as null in the indicator struct.
    In the code above, my Geometry instance is fully allocated (on the stack), but fully uninitialized (the indicator is by default set to all nulls). I first set the atomic flag to non-null, then get the Ref wrapper around its nested SDOPOINT_TYPE to also set it to non-null, and fill in the x/y member (via another NumberRef wrapper, which knows about the member and the indicator for that member, and sets it as non-null when assigned to). Notice how how I return the instance by copy: My point geometry instance doesn't have a pointer-aliasing issue here, only because its two OCIColl* are null. In the general case, you can't copy my value wrappers without making a true deep copy... But I'm getting into the weeds here.
    The important point is that OCIObjectNew doesn't init the nested objects unlike what I stated earlier. Sorry for misleading you on that. --DD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Using nested query to avoid repeated object traversal

    Hi everyone,
    My SQL is still very basic, hopefully this is not a dumb question ;-)
    I have a table with a single spatial column of type SDO_GEOMETRY:
    SQL> desc WITHIN_POINT_DISTANCE_TAB
    Name                                            Null?    Type
    POINT                                                    MDSYS.SDO_GEOMETRYin which I store only single point geometries. I discovered that using the min/max SQL operators to get the combined extend of my points is faster than using SDO_TUNE.EXTEND_OF:
    SQL> select min(e.point.sdo_point.x) min_x, max(e.point.sdo_point.x) max_x, min(e.point.sdo_point.y) min_y, max(e.point.
    sdo_point.y) max_y from WITHIN_POINT_DISTANCE_TAB e;
         MIN_X      MAX_X      MIN_Y      MAX_Y
    -44.700001 737.400024 -23.870001 1094.83008
    Elapsed: 00:00:00.01but it bothers me a bit to repeat e.point.sdo_point 4 times in the above (what can I say, I'm a developer ;-) So I thought I could use a nested query to select all the SDO_POINT_TYPE sdo_point's and refer it using a p alias, and be able to simplify the query to:
    SQL> select min(p.x), min(p.y), max(p.x), max(p.y) from (select t.point.sdo_point from WITHIN_POINT_DISTANCE_TAB t) p;
    select min(p.x), min(p.y), max(p.x), max(p.y) from (select t.point.sdo_point from WITHIN_POINT_DISTANCE_TAB t) p
    ERROR at line 1:
    ORA-00904: "P"."Y": invalid identifierBut obviously this is incorrect, yet I'd like to understand what I'm missing here.
    I posited that maybe the sub-query can't return an object member and needs to return a column, but that doesn't appear to be the case:
    SQL> select min(p.sdo_point.x), min(p.sdo_point.y), max(p.sdo_point.x), max(p.sdo_point.y) from (select t.point from WIT
    HIN_POINT_DISTANCE_TAB t) p;
    select min(p.sdo_point.x), min(p.sdo_point.y), max(p.sdo_point.x), max(p.sdo_point.y) from (select t.point from WITHIN_P
    OINT_DISTANCE_TAB t) p
    ERROR at line 1:
    ORA-00904: "P"."SDO_POINT"."Y": invalid identifierCan someone please explain why the nested query approach fails as written above?
    More generally, is it a bad idea to go for a nested query just for syntactic reasons? Are there performance implications going the nested query route above? (I actually wanted to see the perf. implications experimentally, but since it fails I can't...)
    Any insight would be appreciated. Thanks, --DD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Thank you Peter. I now understand that I need to alias the column in addition to the table (the latter only because I traverse objects which require table aliases).
    SQL> select min(t.p.x), min(t.p.y), max(t.p.x), max(t.p.y) from
      2  (select nt.point.sdo_point p from WITHIN_POINT_DISTANCE_TAB nt) t;
    MIN(T.P.X) MIN(T.P.Y) MAX(T.P.X) MAX(T.P.Y)
    -44.700001 -23.870001 737.400024 1094.83008
    Elapsed: 00:00:00.01Performance-wise it looks similar, but I need to test on a bigger table because it's too fast with 10K points to show differences. Overall it doesn't look that using the nested query syntax makes the query more readable once all pieces to make it work are there.
    Thanks again, --DD
    PS: Just aliasing the column and not the outer table fails:
    SQL> select min(p.x), min(p.y), max(p.x), max(p.y) from (select nt.point.sdo_point p from WITHIN_POINT_DISTANCE_TAB nt);
    select min(p.x), min(p.y), max(p.x), max(p.y) from (select nt.point.sdo_point p from WITHIN_POINT_DISTANCE_TAB nt)
    ERROR at line 1:
    ORA-00904: "P"."Y": invalid identifier

  • Nested Custom Oracle Objects as interpreted by JDBC

    Hello,
    I have a number of nested custom oracle objects that all extend ORAData and ORAFactory. Should I specify one object, it has no problem writing it to DB using OracleCallableStatement. But I need to write this custom oracle object with another (few) subobjects below, so I created different classes which all extend ORAData (.toDatum) of their own, and map to corresponding oracel objects, but now that I try to do SetObject -- I get
    java.sql.SQLException: Fail to convert to internal representation: prog.objMyObj@131303f
    so my question is: Can JDBC handle "nested" custom oracle objects? Or is it simple types only as part of one struct ?

    Doing the following should provide a correct tree. Try it with a simple example first.
    1. Create a type that you want in the database.
    2.Extract it using jdbc.
    3. Write it back without modification. If this fails then I would guess that you simply can't do it with the driver.
    4. if the write works then traverse it and print out the name of each object in it.
    If you get to the last step then it will allow you to determine the correct types (if you traverse it correctly.) You can then try more complex examples so you can figure out the correct way to produce it.
    (Note that if was me I would try to eliminate this entire thing. But then I am not a big fan of weird database objects.)

  • How to get the values from struct data type using java code..?

    Hi ,
    I am newer to java.
    we are using oracle database.
    How to get the data from struct data type using java code.
    Thanks in Advance.
    Regards,
    kumar

    Hi Rajeev,
    To retrieve a FilterContainer you will need to traverse the report structure:
    ReportStructure boReportStructure = boDocumentInstance.getStructure();
    ReportContainer boReportContainer = (ReportContainer) boReportStructure.getReportElement(0);
    FilterContainer boFilterContainer = null;
    if (boReportContainer.hasFilter()) {
         boFilterContainer = boReportContainer.getFilter();
    } else {
         boFilterContainer = boReportContainer.createFilter(LogicalOperator.AND);
    Calling boDocumentInstance.getStructure() will retrieve the entire structure for the document.
    Calling boReportStructure.getReportElement(0) will retrieve the structure for the first report of the document.
    Hope this helps.
    Regards,
    Dan

  • Problem in creating a nested table

    Hi i am working on Oracle 10g and cleint is sqlplus.
    Now while creating a nested table following error occured.
    This is the script for your reference.:
    CREATE OR REPLACE TYPE sec_pwd_hist_table
    AS
    TABLE OF sec_pwd_history_type
    index by binary_integer
    Warning: Type created with compilation errors.
    SQL> show error
    Errors for TYPE SEC_PWD_HIST_TABLE:
    LINE/COL ERROR
    0/0      PL/SQL: Compilation unit analysis terminated
    3/1      PLS-00355: use of pl/sql table not allowed in this context
    Please help on this issue
    Regards,
    Vikas Kumar

    > but i want to know just one thing why its working when i am removing "INDEX BY binaty_integer"
    Vikas, I trust I answered that question when I said? :
    "Do not confuse the two. Do not attempt to use PL/SQL array struct definition syntax in the SQL engine for defining an ADT collection. Which is why I referred you to the manual to see how an ADT is defined in SQL."
    In other words, you are trying to apply a PL/SQL concept and PL/SQL syntax to a definition of a data type in SQL.
    SQL is not PL/SQL.
    SQL ADTs are not PL/SQL arrays/tables.
    It is not even a syntax issue - it is a basic concept issue. SQL does not support PL/SQL arrays/tables. Period.

  • Accessing a field in nested internal table

    Hi,
    Could you please help me how to get value in nested structure 'COMT_PRODUCT_IL_API'.
    We need to access field 'DESTINGUID' in that nested structure.
    Thanks,
    Santosh

    Helo,
    I figured the previous reply would have solved ur issue,
    but doesnt look like as you ve still kept the issue open.
    So il again as well follow d same lines n leave a snippet fr yu to refer:-
    DATA : LT_COMT_PRODUCT_IL_API TYPE TABLE OF  COMT_PRODUCT_IL_API,
                LW_COMT_PRODUCT_IL_API TYPE COMT_PRODUCT_IL_API,
    ** i AM NOT SURE WHCIH DEEP STRUCT it is, Im just picking one of the deep strucs in this struc**
                LW_COMM_IL_ACCESS  TYPE COMT_IL_ACCESS_MAINTAIN.
    LOOP AT LT_COMT_PRODUCT_IL_API INTO LW_COMT_PRODUCT_IL_API.
    READ TABLE LW_COMT_PRODUCT_IL_API-COMM_IL_ACCESS INTO LW_COMM_IL_ACCESS INDEX 1.
    IF SY-SUBRC = 0.
    +<UR CODE HERE>+
    ENDIF.
    ENDLOOP.
    Shoudl work.
    Please close the thread if ur issue lays resolved
    Regards
    Dedeepya C
    Edited by: dedeepya reddy on Mar 23, 2010 1:21 PM

  • Can't get struct from Oracle via Weblogic DB connection?

    There are two ways to connect oracle, within Weblogic or without Weblogic.
    Without Weblogic way works. Code here:
    import java.sql.Connection;
    Class.forName("oracle.jdbc.driver.OracleDriver");
    dbConn = DriverManager.getConnection("Connection");
    StructDescriptor st = new StructDescriptor("Name of Object in Oracle ",dbConn);
    Within Weblogic way doesn’t work. Code here:
    import javax.naming.InitialContext;
    import javax.sql.DataSource
    import java.sql.Connection;
    Connection conn = null;
    javax.sql.DataSource ds = null;
    ds = (javax.sql.DataSource) _cntx.lookup(poolName);
    conn = ds.getConnection();
    StructDescriptor st = new StructDescriptor("Name of Object in Oracle ",dbConn); // Error java.rmi.MarshalException: error marshalling return; nested exception is: java.io.NotSerializableException: oracle.jdbc.driver.T4CConnection
    Reference:
    http://e-docs.bea.com/wls/docs81/jdbc/thirdparty.html#1090291
    I don’t know what the exact reason is. And my work is hanging by this thread. Could anyone help me pls? Thank you.

    Man, what problem?
    About how to use array,
    CREATE TYPE department_type AS OBJECT (
    DNO NUMBER (10),
    NAME VARCHAR2 (50),
    LOCATION VARCHAR2 (50)
    CREATE TYPE dept_array AS TABLE OF department_type;
    CREATE OR REPLACE PACKAGE objecttype AS
    PROCEDURE insert_object (d dept_array);
    END objecttype;
    CREATE OR REPLACE PACKAGE BODY objecttype
    AS
    PROCEDURE insert_object (d dept_array)
    AS
    BEGIN
    FOR i IN d.FIRST..d.LAST
    LOOP
    INSERT INTO department_teststruct
    VALUES (d(i).dno,d(i).name,d(i).location);
    END LOOP;
    END insert_object;
    END objecttype;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import oracle.jdbc.OracleCallableStatement;
    import oracle.sql.ARRAY;
    import oracle.sql.ArrayDescriptor;
    import oracle.sql.STRUCT;
    import oracle.sql.StructDescriptor;
    public class TestStruct ...{
    public static void main(String[] args)
    sendStruct();
    public static void sendStruct()
    Connection dbConn = null;
    try...{   
    Object[] so1 = ...{"10","Accounts","LHR"};
    Object[] so2 = ...{"20","HR","ISB"};
    OracleCallableStatement callStatement = null;
    Class.forName("oracle.jdbc.driver.OracleDriver");
    dbConn = DriverManager.getConnection("jdbc:oracle:thin:@ServerName:Port:ORa", "UserName", "Password");
    StructDescriptor st = new StructDescriptor("DEPARTMENT_TYPE",dbConn);
    STRUCT s1 = new STRUCT(st,dbConn,so1);
    STRUCT s2 = new STRUCT(st,dbConn,so2);
    STRUCT[] deptArray = ...{s1,s2};
    ArrayDescriptor arrayDept = ArrayDescriptor.createDescriptor("DEPT_ARRAY", dbConn);
    ARRAY deptArrayObject = new ARRAY(arrayDept, dbConn, deptArray);
    callStatement = (OracleCallableStatement)dbConn.prepareCall("{call insert_object(?)}");
    ((OracleCallableStatement)callStatement).setArray(1, deptArrayObject);
    callStatement.executeUpdate();
    dbConn.commit();
    callStatement.close();
    catch(Exception e)...{
    System.out.println(e.toString());
    About how to do explain plan
    EXPLAIN PLAN FOR
    SELECT * FROM TABLE(DEPT_ARRAY(DEPARTMENT_TYPE(
    1, --DNO NUMBER (10),
    'NAME', --NAME VARCHAR2 (50),
    'LOCATION' --LOCATION VARCHAR2 (50)
    ))) T
    JOIN TABLE2 T2 ON T.DNO = T2.DNO;
    SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
    But if u want let Oracle know how many rows in that array, one way follows can help.
    Usually way:
    EXPLAIN PLAN FOR
    SELECT * FROM TABLE(DEPT_ARRAY(DEPARTMENT_TYPE(
    1, --DNO NUMBER (10),
    'NAME', --NAME VARCHAR2 (50),
    'LOCATION' --LOCATION VARCHAR2 (50)
    ))) T
    JOIN TABLE2 T2 ON T.DNO = T2.DNO;
    SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
    PLAN_TABLE_OUTPUT
    1 Plan hash value: 1748000095
    2
    3 ----------------------------------------------------------------------------------------------
    4 | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    5 ----------------------------------------------------------------------------------------------
    6 | 0 | SELECT STATEMENT | | *8168* | 16336 | 24 (0)| 00:00:01 |
    7 | 1 | COLLECTION ITERATOR CONSTRUCTOR FETCH| | | | | |
    8 ----------------------------------------------------------------------------------------------
    When add cardinality parameter there, the result will be correct.
    EXPLAIN PLAN FOR
    SELECT /*+ cardinality(t 10 ) */ * FROM TABLE(DEPT_ARRAY(DEPARTMENT_TYPE(
    1, --DNO NUMBER (10),
    'NAME', --NAME VARCHAR2 (50),
    'LOCATION' --LOCATION VARCHAR2 (50)
    ))) T
    JOIN TABLE2 T2 ON T.DNO = T2.DNO;
    SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
    PLAN_TABLE_OUTPUT
    1 Plan hash value: 1748000095
    2
    3 ----------------------------------------------------------------------------------------------
    4 | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    5 ----------------------------------------------------------------------------------------------
    6 | 0 | SELECT STATEMENT | | 10 | 20 | 24 (0)| 00:00:01 |
    7 | 1 | COLLECTION ITERATOR CONSTRUCTOR FETCH| | | | | |
    8 ----------------------------------------------------------------------------------------------

Maybe you are looking for

  • Reference for Connecting EJB in KM scheduler Task

    Hi,        What are the main References we need to add portalapp.xml,when we connect Ejb in Km scheduler Tasks For Example: portalapp.xml <?xml version="1.0" encoding="UTF-8"?>   <application >     <application-config>     <property name="SharingRefe

  • Embed a pdf that has open in ability

    Hello! I would like to have a pdf in my iBooks Author so that the kids can preview it.  Then I would like them to be able to open in their notebook app.  Is this possible in iBooks Author? (I dont think it is).  Right now I have a link to the file on

  • Struts Portlet With Input Parameters

    Hi Everyone, Am I able to write a struts portlet that has input parameters? Right now, I have a struts portlet with a provider.xml that looks like this: <?xml version = '1.0' encoding = 'UTF-8'?> <?providerDefinition version="3.1"?> <provider class="

  • SIGSEGV and non-english?

    I'm also having problems with installing Oracle8iR2. While searching through the discussion archives here for a solution, I couldn't help but noticing the unusually high number of non-native English speakers that had similar problems. It seems that t

  • HT201269 In Iphone5 while Mail is reviewed and transfered to folder, for next mail folder list position changes. How to fix this error

    In Iphone5 while Mail is reviewed and transfered to folder, for next mail folder list position changes. How to fix this error