How swap two objects into a UILoader

Hi.
I'm taking a snapshot from a webcam and adding a frame around this snapshot.
I add the snapshot before to load the frame from a file. How can I swap between those objects? because the frame appears at last and the snapshot appears infront. I wanna swap those in the way that the snapshot appears at last and then the frame.

A UILoader (or any loader) can only hold/load one object, so I don't know how that fits into swapping two things into it.  If the frame is a movieclip, just use addChild(frameName) to have the frame move out front.

Similar Messages

  • Swap two objects method

    Hi,
    I got this code from the forum that can swap two objects. Can anyone explain the code to me? Thanks.
    public static Object swap(Object o1,Object o2){
    return o1;
    o2=swap(o1,o1=o2);
    It looks like o2=swap(o1,o1=o2) is passing o1 object and o2 object, the method create new reference for o1 and o2, return the o1 object and assign the reference to o2. Now o2 is o1 but how about o1?

    Don't touch that code, it's rubbish. The method claims to "swap" two objects, but it doesn't actually do that unless you call it in precisely that tricky and confusing way.
    Anyway, "swap two objects" is not a good way to ask the question because it confuses objects with the variables that refer to them. If you want to change two variables so that they each end up referring to the object originally referred to by the other, just write this:Object temp = o1;
    o1=o2;
    o2=temp;You can't do it with a method.

  • Swap two objects

    Can anyone please explain to me why the following code does not swap two objects?
    public void swap(Object a, Object b) {
    Object temp = a;
    a = b;
    b = temp;
    I know when you do a=b, it means assigning the b reference to a. So this piece of code should work. First assign the a reference to temp, then assign b referene to a and assign temp to b. So now a has b's reference and b has a's reference. So why is this wrong? Thanks.

    Simply because all parameters are passed by
    value, not by reference.right, to further clarify, all object parameters are references. So when you pass references by value, you make a copy of it and send it to the method. Therefore, changing what the reference points to has no effect outside of the method.

  • Can I combine two objects into one?

    Hi all:
    I got a problem here: I just wonder if anyone knows how to combine the informations which I grabed from a SQL database to an object I obtained from an OO database at runtime.
    I look forward to your reply and appreciate your concern!
    regards
    David
    at [email protected]

    Thanks for you reply, but the combined two objects can not be pre-defined because it is defined at runtime, say, there are a number of objects in database, only when you select the one for combining, you know what it is!
    Cheers
    David

  • How to combine objects into one

    Can I combine two or more objects (say, text box and rectangle) so that they effectively become one object? Other software calls this Grouping of objects.

    Welcome to the Apple Discussions. See Old Toad's Tutorial #7 - Converting Photos w/Frames, Drop Shadows and/or Reflections into a Single JPG Image. It describes exactly what you want to do.
    OT

  • Re: [JExcel API] how to insert object into a cell

    Hi all,
    i am using JExcel API for Excel file creation. i want to
    insert object like file in particular cell how can i do it.
    i tried WritableHyperLink but it is only inserting hyper link.
    i want proper object inserted into the specific cell.
    please help me out.
    VenuG.

    I am using jxl api to generate a report. i want the insert->object->create from file excel functionality to be implemented using jxl. Help me

  • How can two object have tow behaivors?

    I have added 2 objects by using object loder, then i want to give these objects some behaivors . I did add transform , zoon in and zoon out. However , when i move one object , the other one is following to move .
    is there any idea can seperate them . i mean if i use mouse to move one object , then just this object move. when i move another object , just that one move . Thank you so much for ur help .
    regards
    jojo

    *     @(#)SphereMotion.java 1.38 02/10/21 13:55:06
    * Copyright (c) 1996-2002 Sun Microsystems, Inc. All Rights Reserved.
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    * - Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    * - Redistribution in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in
    * the documentation and/or other materials provided with the
    * distribution.
    * Neither the name of Sun Microsystems, Inc. or the names of
    * contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    * This software is provided "AS IS," without a warranty of any
    * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
    * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
    * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
    * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
    * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
    * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
    * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
    * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
    * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
    * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
    * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
    * You acknowledge that Software is not designed,licensed or intended
    * for use in the design, construction, operation or maintenance of
    * any nuclear facility.
    import java.applet.Applet;
    import java.awt.*;
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.geometry.Sphere;
    import com.sun.j3d.utils.universe.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import java.util.Enumeration;
    public class SphereMotion extends Applet {
    // Constants for type of light to use
    private static final int DIRECTIONAL_LIGHT = 0;
    private static final int POINT_LIGHT = 1;
    private static final int SPOT_LIGHT = 2;
    // Flag indicates type of lights: directional, point, or spot
    // lights. This flag is set based on command line argument
    private static int lightType = POINT_LIGHT;
    private SimpleUniverse u = null;
    public BranchGroup createSceneGraph(SimpleUniverse u) {
         Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f);
         Color3f sColor = new Color3f(1.0f, 1.0f, 1.0f);
         Color3f objColor = new Color3f(0.6f, 0.6f, 0.6f);
         Color3f lColor1 = new Color3f(1.0f, 0.0f, 0.0f);
         Color3f lColor2 = new Color3f(0.0f, 1.0f, 0.0f);
         Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);
         Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f);
         Transform3D t;
         // Create the root of the branch graph
         BranchGroup objRoot = new BranchGroup();
    // Create a Transformgroup to scale all objects so they
    // appear in the scene.
    TransformGroup objScale = new TransformGroup();
    Transform3D t3d = new Transform3D();
    t3d.setScale(0.4);
    objScale.setTransform(t3d);
    objRoot.addChild(objScale);
         // Create a bounds for the background and lights
         BoundingSphere bounds =
         new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
         // Set up the background
         Background bg = new Background(bgColor);
         bg.setApplicationBounds(bounds);
         objScale.addChild(bg);
         // Create a Sphere object, generate one copy of the sphere,
         // and add it into the scene graph.
         Material m = new Material(objColor, eColor, objColor, sColor, 100.0f);
         Appearance a = new Appearance();
         m.setLightingEnable(true);
         a.setMaterial(m);
         Sphere sph = new Sphere(1.0f, Sphere.GENERATE_NORMALS, 80, a);
         objScale.addChild(sph);
         // Create the transform group node for the each light and initialize
         // it to the identity. Enable the TRANSFORM_WRITE capability so that
         // our behavior code can modify it at runtime. Add them to the root
         // of the subgraph.
         TransformGroup l1RotTrans = new TransformGroup();
         l1RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
         objScale.addChild(l1RotTrans);
         TransformGroup l2RotTrans = new TransformGroup();
         l2RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
         objScale.addChild(l2RotTrans);
         // Create transformations for the positional lights
         t = new Transform3D();
         Vector3d lPos1 = new Vector3d(0.0, 0.0, 2.0);
         t.set(lPos1);
         TransformGroup l1Trans = new TransformGroup(t);
         l1RotTrans.addChild(l1Trans);
         t = new Transform3D();
         Vector3d lPos2 = new Vector3d(0.5, 0.8, 2.0);
         t.set(lPos2);
         TransformGroup l2Trans = new TransformGroup(t);
         l2RotTrans.addChild(l2Trans);
         // Create Geometry for point lights
         ColoringAttributes caL1 = new ColoringAttributes();
         ColoringAttributes caL2 = new ColoringAttributes();
         caL1.setColor(lColor1);
         caL2.setColor(lColor2);
         Appearance appL1 = new Appearance();
         Appearance appL2 = new Appearance();
         appL1.setColoringAttributes(caL1);
         appL2.setColoringAttributes(caL2);
         l1Trans.addChild(new Sphere(0.05f, appL1));
         l2Trans.addChild(new Sphere(0.05f, appL2));
         // Create lights
         AmbientLight aLgt = new AmbientLight(alColor);
         Light lgt1 = null;
         Light lgt2 = null;
         Point3f lPoint = new Point3f(0.0f, 0.0f, 0.0f);
         Point3f atten = new Point3f(1.0f, 0.0f, 0.0f);
         Vector3f lDirect1 = new Vector3f(lPos1);
         Vector3f lDirect2 = new Vector3f(lPos2);
         lDirect1.negate();
         lDirect2.negate();
         switch (lightType) {
         case DIRECTIONAL_LIGHT:
         lgt1 = new DirectionalLight(lColor1, lDirect1);
         lgt2 = new DirectionalLight(lColor2, lDirect2);
         break;
         case POINT_LIGHT:
         lgt1 = new PointLight(lColor1, lPoint, atten);
         lgt2 = new PointLight(lColor2, lPoint, atten);
         break;
         case SPOT_LIGHT:
         lgt1 = new SpotLight(lColor1, lPoint, atten, lDirect1,
                        25.0f * (float)Math.PI / 180.0f, 10.0f);
         lgt2 = new SpotLight(lColor2, lPoint, atten, lDirect2,
                        25.0f * (float)Math.PI / 180.0f, 10.0f);
         break;
         // Set the influencing bounds
         aLgt.setInfluencingBounds(bounds);
         lgt1.setInfluencingBounds(bounds);
         lgt2.setInfluencingBounds(bounds);
         // Add the lights into the scene graph
         objScale.addChild(aLgt);
         l1Trans.addChild(lgt1);
         l2Trans.addChild(lgt2);
         // Create a new Behavior object that will perform the desired
         // operation on the specified transform object and add it into the
         // scene graph.
         Transform3D yAxis = new Transform3D();
         Alpha rotor1Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
                        0, 0,
                        4000, 0, 0,
                        0, 0, 0);
         RotationInterpolator rotator1 =
         new RotationInterpolator(rotor1Alpha,
                        l1RotTrans,
                        yAxis,
                        0.0f, (float) Math.PI*2.0f);
         rotator1.setSchedulingBounds(bounds);
         l1RotTrans.addChild(rotator1);
         // Create a new Behavior object that will perform the desired
         // operation on the specified transform object and add it into the
         // scene graph.
         Alpha rotor2Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
                        0, 0,
                        1000, 0, 0,
                        0, 0, 0);
         RotationInterpolator rotator2 =
         new RotationInterpolator(rotor2Alpha,
                        l2RotTrans,
                        yAxis,
                        0.0f, 0.0f);
         bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
         rotator2.setSchedulingBounds(bounds);
         l2RotTrans.addChild(rotator2);
         // Create a position interpolator and attach it to the view
         // platform
         TransformGroup vpTrans =
         u.getViewingPlatform().getViewPlatformTransform();
         Transform3D axisOfTranslation = new Transform3D();
         Alpha transAlpha = new Alpha(-1,
                        Alpha.INCREASING_ENABLE |
                        Alpha.DECREASING_ENABLE,
                        0, 0,
                        5000, 0, 0,
                        5000, 0, 0);
         axisOfTranslation.rotY(-Math.PI/2.0);
         PositionInterpolator translator =
         new PositionInterpolator(transAlpha,
                        vpTrans,
                        axisOfTranslation,
                        2.0f, 3.5f);
         translator.setSchedulingBounds(bounds);
         objScale.addChild(translator);
    // Let Java 3D perform optimizations on this scene graph.
    objRoot.compile();
         return objRoot;
    public SphereMotion() {
    public void init() {
         setLayout(new BorderLayout());
    GraphicsConfiguration config =
    SimpleUniverse.getPreferredConfiguration();
    Canvas3D c = new Canvas3D(config);
         add("Center", c);
         u = new SimpleUniverse(c);
         BranchGroup scene = createSceneGraph(u);
    // This will move the ViewPlatform back a bit so the
    // objects in the scene can be viewed.
    u.getViewingPlatform().setNominalViewingTransform();
         u.addBranchGraph(scene);
    public void destroy() {
         u.cleanup();
    // The following allows SphereMotion to be run as an application
    // as well as an applet
    public static void main(String[] args) {
    // Parse the Input Arguments
         String usage = "Usage: java SphereMotion [-point | -spot | -dir]";
    for (int i = 0; i < args.length; i++) {
    if (args.startsWith("-")) {
    if (args[i].equals("-point")) {
              System.out.println("Using point lights");
    lightType = POINT_LIGHT;
              else if (args[i].equals("-spot")) {
              System.out.println("Using spot lights");
    lightType = SPOT_LIGHT;
              else if (args[i].equals("-dir")) {
              System.out.println("Using directional lights");
    lightType = DIRECTIONAL_LIGHT;
              else {
              System.out.println(usage);
    System.exit(0);
         else {
              System.out.println(usage);
              System.exit(0);
         new MainFrame(new SphereMotion(), 700, 700);

  • Conversion of object into integer

    hi
    How to convert Object into integer.
    I want to get value of JTable cell.So im doing
    for(int i=0;i<4i++)
    String value=(String) JTable.getValueAt(i,2);
    s.o.p("Table value :"+JTable.getValueAt(i,2));
    int changedValue=Integer.parseInt(Value);
    s.o.p("Changed value :"+value);
    }JTable.getValueAt(0,2) : 0
    JTable.getValueAt(1,2) : 0
    JTable.getValueAt(2,2) : 2
    JTable.getValueAt(3,2) : 4
    Theses are the respective values of the respective row positions
    Im able to get values of 1st row and 2nd row which are of 0 values
    But the value of third row and 4th row im gettin an exception
    java.lang.Integer cannot cast to java.lang.String
    please help anyone

    If the data in the model is of type Integer you can't cast it to String.
    You need to cast this to Integer and call intValue method to get as int.
    If you want further help post a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html] that demonstrates the problem.

  • How to swap the position of two objects?

    I have four self made componensts that I imported them into my main mxml file
    and placed each on four corners.
    What I want to achieve is to drag each component onto others then swap their position.
    For example, comp A is dragged over comp B, when this is detected, swap the position of A and B.
    But at the moment it doesn't seem to work properly. I could not figure out what's wrong with my code. Could any one help me achieve that?
    Many thanks to any who could give me a hand!
    *********This is one of my component***********
    *********All other three components are made the same way, except each source of image file is different******************
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Box xmlns:mx="http://www.adobe.com/2006/mxml" width="42" height="42">
        <mx:Image source="Images/air.png"/>
    </mx:Box>
    *********This is my mxml that calls my components***********
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:comp="Comp.*" creationComplete = "onInit()">
        <mx:Script>
            <![CDATA[
                import mx.containers.Box;
                import Comp.Icon_illustrator;
                import Comp.Icon_air;
                import Comp.Icon_flash;
                import Comp.Icon_flex;
                private var i_1:Icon_air; //1
                private var i_2:Icon_flash; //2
                private var i_3:Icon_flex; //3
                private var i_4:Icon_illustrator; //4
                private var origX:Number;
                private var origY:Number;
                private var startObj:String;
                private var icons:Array;
                private var h_1:Box;
                private var h_2:Box;
                private var h_3:Box;
                private var h_4:Box;
                private function onInit():void{
                    //initialise all icons
                    i_1 = new Icon_air();
                    i_2 = new Icon_flash();
                    i_3 = new Icon_flex();
                    i_4 = new Icon_illustrator();
                    i_1.name = "i_1";
                    i_2.name = "i_2";
                    i_3.name = "i_3";
                    i_4.name = "i_4";
                    //populate icon
                    showArea.addChild(i_1);
                    showArea.addChild(i_2);
                    showArea.addChild(i_3);
                    showArea.addChild(i_4);
                    //set x position
                    i_1.x = 100;
                    i_2.x = 200;
                    i_3.x = 100;
                    i_4.x = 0;
                    //set y position
                    i_1.y = 0;
                    i_2.y = 100;
                    i_3.y = 200;
                    i_4.y = 100;
                    icons = [i_1, i_2, i_3, i_4];
                    //addEventListeners
                    for(var i:int=0; i<icons.length; i++){
                        icons[i].addEventListener(MouseEvent.MOUSE_DOWN, moveMe);
                        icons[i].addEventListener(MouseEvent.MOUSE_UP, stopDragMe);
                }//end of onInit
                private function moveMe(e:MouseEvent):void{
                    e.currentTarget.startDrag();   
                    showArea.setChildIndex(DisplayObject(e.currentTarget), 0);
                    origX = e.currentTarget.x;
                    origY = e.currentTarget.y;
                    startObj = e.currentTarget.name;   
                private function stopDragMe(e:MouseEvent):void{
                    if(this[startObj].hitTestObject(icons[1])){
                        trace("hit 2");
                        this[startObj].x = i_2.x;
                        this[startObj].y = i_2.y;
                        i_2.x = origX;
                        i_2.y = origY;
                    }else if(this[startObj].hitTestObject(icons[0])){
                        trace("hit 1");
                        this[startObj].x = i_1.x;
                        this[startObj].y = i_1.y;
                        i_1.x = origX;
                        i_1.y = origY;
                    }else{
                        trace("hit others");
                        this[startObj].x = origX;
                        this[startObj].y = origY;
                    e.currentTarget.stopDrag();
                }//end of stopDragMe
            ]]>
        </mx:Script>
        <mx:Panel id="showArea" width="400" height="300" layout="absolute" backgroundColor="0x999999"/>
    </mx:WindowedApplication>

    Here is a sample of swaping two objects in Flex (not Air)   I believe it is the same.  Take a look at the way the x and y coords are swapped using the dragInitator and the currentTarget object in the dragDropHandler.
    Hope this helps
    <?xml version="1.0" encoding="utf-8"?><mx:Application  xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
     <mx:Script>
    <![CDATA[
     import mx.containers.Box; 
    import mx.core.UIComponent; 
    import mx.managers.DragManager; 
    import mx.core.DragSource; 
    import mx.events.DragEvent; 
    private var dragProxy:Box= new Box(); 
    public function dragDropHandler(e:DragEvent): void { 
    //These variables are the x and y coords of the objects 
    //the e.dragInitator is the object being dragged 
    //the e.currentTarget is the object being dropped on 
    //First save the x and y coords of each of the objects 
    var xdi:int = e.dragInitiator.x; 
    var ydi:int = e.dragInitiator.y; 
    var xct:int = e.currentTarget.x; 
    var yct:int = e.currentTarget.y; 
    //now switch them around.e.dragInitiator.x = xct;
    e.dragInitiator.y = yct;
    e.currentTarget.x = xdi;
    e.currentTarget.y = ydi;
    public function dragEnterHandler(event:DragEvent):void { 
    DragManager.acceptDragDrop(UIComponent(event.target));
    public function mouseMoveHandler(event:MouseEvent):void { 
    if(event.buttonDown == false) return; 
    var dragInitiator:UIComponent = event.target as UIComponent; 
    var dragSource:DragSource = new DragSource(); 
    dragProxy =
    new Box();dragProxy.width = dragInitiator.width;
    dragProxy.height = dragInitiator.height;
    dragProxy.setStyle(
    "borderStyle","solid")dragProxy.setStyle(
    "borderColor","0x000000")dragProxy.setStyle(
    "backgroundColor","0xc6c6c6"); 
    DragManager.doDrag(dragInitiator, dragSource, event, dragProxy,
    event.localX * -1, event.localY * -1, 1.00);
    ]]>
    </mx:Script>
     <mx:Canvas width="84" height="93" x="23" y="14" borderStyle="
    solid" borderColor="
    #030303" backgroundColor="
    #F83C3C"dragEnter="dragEnterHandler(event)"
    dragDrop="dragDropHandler(event)"
    mouseMove="mouseMoveHandler(event)"
    >
     </mx:Canvas>
     <mx:Canvas width="84" height="93" x="223" y="14" borderStyle="
    solid" borderColor="
    #030303" backgroundColor="
    #C5F83C"dragEnter="dragEnterHandler(event)"
    dragDrop="dragDropHandler(event)"
    mouseMove="mouseMoveHandler(event)"
    >
     </mx:Canvas>
     </mx:Application>

  • How To Insert A object into Conext

    Hi Techies,
    I have 8 tables in my designer
    and I have two contexts at designer level
    And how to insert a object into a context that is not referencing any table.
    For Example I have an object like "rownum" (Which should must be added at Universe level only not at report level). Here this object is not referencing any table and I want this to be used in a query where the remaining objects are coming from the context..
    Thanks in Advance..

          Double-click the Objects and click the TABLES button and select the table you want to associate the object to for the context to work properly (see below).
    Regards,
    Ajay

  • How to swap two primitive dataelements using swap function??

    How to write a swap function that can swap two integer..??

    Now we are getting somewhere. Next time you post code, use the code tags!! See Formatting Tips or just select the code and click the Code button.
    you cant swap i,j using the above code...You're right. You can't do that.
    so how to do that??The ints must be within some object, like I showed you
    You cannot swap the values of two arguments to a method and expect the caller's variables be swapped because Java passes arguments by value not reference. There is no such thing as a pointer to a variable in Java as there is in C/C++.

  • How to convert bytes[] into File object

    hi
    how to convert byte array into File object
    pls.. help me
    Regards
    srinu

    rrrr007 wrote:
    Hi,
    How to convert bytes[] into multipage File object?? ]There's no such thing as a "multipage File object." You ought to re-read this thread closely, and read the [API docs for File|http://java.sun.com/javase/6/docs/api/java/io/File.html] to clear up your confusion about what a File object is.
    I used the java.io.SequenceInputStream to concatenate two input streams (basically .pdf files) into a single input stream. I need to create a single multipage pdf file using this input stream. Then you need a pdf API, like iText or fop. You can't just concatenate pdf files, word docs, excel sheets, etc., like you can text files. Google for java pdf api.

  • How to convert bytes[] into multipage File object

    Hi,
    How to convert bytes[] into multipage File object??
    I used the java.io.SequenceInputStream to concatenate two input streams (basically .pdf files) into a single input stream. I need to create a single multipage pdf file using this input stream.
    Thanks for you help in advance..

    Only text format allows you to concatenate two files together to get a longer files.
    Most formats have a header and a footer and so you cannot simply add one to the other.
    You need to use a PDF API which will allow you to build the new document (if one exists)

  • Why do i have two game center accounts on one apple id and how do i log into the other one

    One day while i was bored i started up a game but all of my progress items and everything that i paid for was gone and it was the same in all of my other game center related apps. After a long chain of emails with the maker of the game he stopped being helpful but we figured out that i have two game center accounts but only one apple id. So how do i log into the account with all of my data?

    Get a separate Apple ID for one of the phones. Or turn OFF iCloud contacts synching on the one you do not want contacts to synch.
    Settings>>iCloud

  • How can I insert values from table object into a regular table

    I have a table named "ITEM", an object "T_ITEM_OBJ", a table object "ITEM_TBL" and a stored procedure as below.
    CREATE TABLE ITEM
    ITEMID VARCHAR2(10) NOT NULL,
    PRODUCTID VARCHAR2(10) NOT NULL,
    LISTPRICE NUMBER(10,2),
    UNITCOST NUMBER(10,2),
    SUPPLIER INTEGER,
    STATUS VARCHAR2(2),
    ATTR1 VARCHAR2(80),
    ATTR2 VARCHAR2(80),
    ATTR3 VARCHAR2(80),
    ATTR4 VARCHAR2(80),
    ATTR5 VARCHAR2(80)
    TYPE T_ITEM_OBJ AS OBJECT
    ITEMID VARCHAR2(10),
    PRODUCTID VARCHAR2(10),
    LISTPRICE NUMBER(10,2),
    UNITCOST NUMBER(10,2),
    SUPPLIER INTEGER,
    STATUS VARCHAR2(2),
    ATTR1 VARCHAR2(80),
    ATTR2 VARCHAR2(80),
    ATTR3 VARCHAR2(80),
    ATTR4 VARCHAR2(80),
    ATTR5 VARCHAR2(80)
    TYPE ITEM_TBL AS TABLE OF T_ITEM_OBJ;
    PROCEDURE InsertItemByObj(p_item_tbl IN ITEM_TBL, p_Count OUT PLS_INTEGER);
    When I pass values from my java code through JDBC to this store procedure, how can I insert values from the "p_item_tbl" table object into ITEM table?
    In the stored procedure, I wrote the code as below but it doesn't work at all even I can see values if I use something like p_item_tbl(1).itemid. How can I fix the problem?
    INSERT INTO ITEM
    ITEMID,
    PRODUCTID,
    LISTPRICE,
    UNITCOST,
    STATUS,
    SUPPLIER,
    ATTR1
    ) SELECT ITEMID, PRODUCTID, LISTPRICE,
    UNITCOST, STATUS, SUPPLIER, ATTR1
    FROM TABLE( CAST(p_item_tbl AS ITEM_TBL) ) it
    WHERE it.ITEMID != NULL;
    COMMIT;
    Also, how can I count the number of objects in the table object p_item_tbl? and how can I use whole-loop or for-loop to retrieve values from the table object?
    Thanks.

    Sigh. I answered this in your other How can I convert table object into table record format?.
    Please do not open multiple threads. It just confuses people and makes the trreads hard to follow. Also, please remember we are not Oracle employees, we are all volunteers here. We answer questions if we can, when we can. There is no SLA so please be patient.
    Thank you for your future co-operation.
    Cheers, APC

Maybe you are looking for