How to read the objects and collections dynamically?

Hello
I want to read database/collection objects dynamically. Please advice!
Here is an example

Create the user as an object type (name varchar2 (100), number (3)) of the age
/

create a family of fonts as a user table
/

I want to do something like this

DECLARE
user of the var;
BEGIN
...
...
SELECT "family (1)" INTO var FROM DUAL;
...
...
END;
/

Thank you

As I suggested, you can define your own method of "diff" for the object. You haven't told us exactly what form you would like to work to take. I'll define a (pretty useless) function which will just create a string that tells you how to modify the data of an object to match the data in another. Obviously, you would like a more useful output. Potentially, rather than a member function, you can choose a procedure Member who emits DML is required for the underlying table is necessary.

SQL> ed
Wrote file afiedt.buf

  1  CREATE OR REPLACE TYPE location_typ AS
  2  OBJECT
  3  (
  4    building_no NUMBER,
  5    city        VARCHAR2(40),
  6    MEMBER FUNCTION diff(
  7                l location_typ)
  8    RETURN VARCHAR2
  9  )
 10* ;
SQL> /

Type created.

SQL> ed
Wrote file afiedt.buf

  1  CREATE OR REPLACE TYPE BODY location_typ
  2  AS
  3    MEMBER FUNCTION diff(
  4      l location_typ)
  5    RETURN VARCHAR2
  6    IS
  7      l_diff_str varchar2(4000);
  8    BEGIN
  9      IF building_no != l.building_no THEN
 10        l_diff_str := 'Building_no needs to change from ' || building_no ||
 11                         ' to ' || l.building_no;
 12      END IF;
 13      IF city != l.city THEN
 14        l_diff_str := l_diff_str ||
 15                        'City needs to change from ' || city ||
 16                          ' to ' || l.city;
 17      END IF;
 18      RETURN l_diff_str;
 19    END;
 20* END;
 21  /

Type body created.

SQL> DECLARE
  2    loc location_typ;
  3    secloc location_typ;
  4    a NUMBER;
  5  BEGIN
  6    loc    :=NEW location_typ(300, 'San Francisco');
  7    secloc :=NEW location_typ(200, 'Redwood Shores');
  8    dbms_output.put_line( loc.diff( secloc ) );
  9  END;
 10  /
Building_no needs to change from 300 to 200City needs to change from San
Francisco to Redwood Shores

PL/SQL procedure successfully completed.

Justin

Published by: Justin Cave on 9 April 2012 14:12

Tags: Database

Similar Questions

  • How to read the date and time of a file by labview information

    How to read the date and time of a file by labview information? for example, time created and updated time.

    The similar question had already spoken here (this is the old thread but still seems topical):

    http://forums.NI.com/T5/LabVIEW/file-date-created/TD-p/109836

  • How to read the xml and save the contents of the ITA in .txt format

    Hello

    Is it possible to read an xml file and save it in the .txt format. Please let me know if there is a way to do it.

    Thank you

    Ankit G

    That read the function is only for xml files written using the LabVIEW diagram, so if you have something else, you need the functions in the range of xml parser.

  • How to read the object space analytical Java work, when it is in reconstruction?

    Is Hi possible to save the OLAP object java so that it can be read, even if it is in reconstruction?
    so when I have reconstitute the AW (analytic workspace), the other user can still read the old AW object while waiting for the new object AW is built

    I even try to create 2 AW, while I create 1 AW, I try to read another AW in the same database schema
    but then the process of reading for the second AW is to hang until the creation of the first AW is finished
    is there somehow so that the process can occur at the same time without waiting for the process of construction is finished?

    A second user should be able to access an AW even while it builds as long both users have different sessions - OracleConnection instances in terms of jdbc. It is not enough to use two Threads Java, sharing the same connection.

  • How to find the object and remove from the WordPress site.

    There is a search form that appear on each page. It is just below the entrance by the WP user content for each page.

    I've been using Firebug in Firefox and I can see the code it puts in Firebug, but I can't find the source file so that I can change the code using DW to remove this search form.

    Please help if you can.

    I found it. It is searchform.php and she is called to sidebar.php where the other widgets are called from.

    I hope this helps someone else.

    Thanks for your help Nancy OShea

  • Read the BLOB and insert data into a table

    Hi all

    Let us examine below on Oracle DB 12 c:

    create table xx_test3 (c blob);
    
    insert into xx_test3 (c) values (utl_raw.cast_to_raw(
    'azertyuiop,qsdfghjklm,wxcvbn'));
    
    
    create table xx_target (col1 varchar2(50));
    
    
    
    

    Can someone guide me how to read the data and insert it into the xx_target table?

    Necessary result is:

    
    select * from xx_target;
    
    
    COL1                                              
    
    --------------------------------------------------
    azertyuiop                                        
    qsdfghjklm                                        
    wxcvbn                                            
    
    3 rows selected.
    
    
    
    
    

    Thanks in advance,

    Stoyanov.

    insert into xx_target (col1)

    with the data as)

    Select utl_raw.cast_to_varchar2 (dbms_lob.substr (c, 32000, 1)) CBC

    of xx_test3

    )

    Select regexp_substr (CBC, ' [^,] +', 1, level)

    from the data

    connect by level<= regexp_count(src,="" ',')="" +="">

  • How to read the data of BLOB and save to the file system

    Hi friends.

    I have called DEMO table there image stored as a BLOB. now my requirement is to know how to read the data of BLOB and saved in the file system. is there a procedure
    to read the blob object and stored in the file system. pls suggest me with an example.
    Thank you

    HI - don't know what version you have, but have a read through this:

    http://www.Oracle-base.com/articles/9i/ExportBlob9i.php

    Hoek link is to import the blobs in the db, it is export, to a file.

  • Don't know how to read the results of netstat EI s list? If I received 860592506 bytes sent from 43421482 how to convert MB? And does this mean byte received?

    Don't know how to read the results of netstat EI s list? If I received 860592506 bytes sent from 43421482 how to convert MB? And does this mean byte received?

    Hello

    This shows the total number of bytes transmitted and received via the Ethernet card. This is the total of the amount of use up to this day.

    This includes all the Web sites you have visited and emails you sent, etc..

    You can calculate using one of the following methods:

    Method 1:

    860592506 / 1048576 = 820,72 MB

    Method 2:

    Multiply 860592506 with 9.53674316 * 10 ^-7 that will give us the result in mega bytes.

    860592506 bytes = 820 MB 9MB not, accept my apology for the miscalculation.
    Similarly 43421482 acroos = 40MB

  • have 5 LR and CC. The folders are different, some are missing in the CC. And some complete are not available in CC. I'm looking forward to use CC rather than LR5 so how can I make the folders and collections even on each?

    have 5 LR and CC. The folders are different, some are missing in the CC. And some Collections are not available in CC. I'm looking forward to use CC rather than LR5 so how can I make the folders and collections even on each?

    Hi cjohnm,

    You can use the 5 Lightroom Catalog and improve it in Lightroom 6, therefor all folders and collections will be identical in both version.

    Open the Lightroom all holding the key Alt/Opt and select only the 5 Lightroom Catalog and it will switch to it.

    Let us know if that helps.

    Kind regards

    Mohit

  • How to reduce an object and also the race together...?

    Hello

    The subject line was not easy to convey what is my problem.

    Here goes.

    When I have a line on something and I reduce the race remains the same, so it seems bigger.

    Is there a way to prevent this?

    So, when I reduce a vector image I did not find the object and manually set the race.

    I hope this makes sense

    Sorry, but im English is my mother tongue...

    See you soon

  • Grids of, how to place above the objects and placed images?

    PS the grid can be displayed above the jpegs allowing me to measure exactly, AI shows the grid below placed images and vector obects, which means that I am not the squares of the Board through the objects and images to place my other lines and shapes, is this possible? Place the rack over the objects and placed images?

    Yes. In the preferences: guides & grids: uncheck the box for the grids at the rear. easy.

  • How to set the height and width of an object

    I could not find in CS4.

    Thank you!

    If the object is on a separate layer, then you can just use Edit-> free transform to change it, otherwise, you will first need to select the object and then set up the free transform command

  • How to read the data in a device connected to the usb port

    Is there a class or object, or the piece of code in Java that is comparable to the PDQComm32.ocx and the mscomm32.ocx used in VB6? I need to know how to read the data of a device plugged into the usb port of the BBerry. Is it possible to use the BB to read data from a device via a usb cable?

    I'm new in Java and I'm looking for the opportunity to write a project to read the data in a device with this program that can turn on a BB instead of on a pc.

    Thank you

    Did you watch net.rim.device.api.system.USBPort?

    That's what the doc says:

    Provides access to the USB port of the device.

    Avoid using this class in applications, as it is not portable. On the contrary, if you need to access the USB port, use factory CLDC Connector to serve a connection.

    Rab

  • How to read the value of an independent textInput element inside the method?

    Hello

    I had a group of detail based on a readonly viewobject. I added an independent element textInput, you say, EndDate to this group that the user can enter a value inside. Now, when I run the app I select a row in the table and press a button that triggers a method inside a bean. My question is how I read the value in independent textInput (EndDate) within the method element?

    getTable () .getRowData () does not print the unbound attribute. It seems that it only contains attributes underlying viewobject

    I use JDev 11.1.1.4

    Kind regards
    Will do

    Will do,

    You can better create a transitional attribute for that in your view object, so you can use a regular expression #{row.bindings...} to get the value.

    Steven Davelaar,
    JHeadstart team.

  • Camileo S20 - How to display the date and time

    Hi, all. I got as Christmas present the Camileo S20, and I am not able to view the date and time in the video. In the manual is no reference on this subject, only how to set the date and time. But what is the intention to set the date and time in the camera, if it is not possible to display video?

    Hello

    Have you checked the user manual of your TV cam?

    If it of possible to display the data and the time you can find in your user manual how to do this. It always interesting to read ;) s

Maybe you are looking for