How do I reference the instance in a constraint on an object table?

I want to create a unique constraint that involves the result of a deterministic member function.
I can do it just fine if I create table with a column of the object type:
drop table test_table1;
drop table test_table2;
drop type test_type;
create type test_type as object (
     alpha varchar2(30),
     member function get_beta return varchar2 deterministic
show errors;
create type body test_type as
     member function get_beta return varchar2 deterministic is
     begin
          return 'Beta';
     end;
end;
show errors;
create table test_table1 (
     test_instance mattk.test_type,
     beta varchar2(4000) as (test_type.get_beta(test_instance)),
     constraint test_table1_pk primary key (beta)
insert into test_table1 (test_instance) values (test_type('Alpha'));
commit;
insert into test_table1 (test_instance) values (test_type('Gamma'));
commit;As I said, this works just fine, and the second insert statement produces the following error:
insert into test_table1 (test_instance) values (test_type('Gamma'))
ORA-00001: unique constraint (MATTK.TEST_TABLE1_PK) violatedHowever, I'd really like my table to be an object table.
If I do that:
create table test_table2 of test_type;How do I then reference the object instance that the row represents?

I've got it all worked out now. Thanks everyone for the helpful advice.
I changed the type definition slightly. I added an Attribute for Beta, in addition to keeping the deterministic member function.
drop table test_table2;
drop type test_type;
create type test_type as object (
     alpha varchar2(30),
     beta varchar2(30),
     member function get_beta return varchar2 deterministic
show errors;
create type body test_type as
     member function get_beta return varchar2 deterministic is
     begin
          if (self.beta <> 'Beta') then
               raise_application_error(-20000, 'Beta is not properly set.');
          end if;
          return 'Beta';
     end;
end;
show errors;
create table test_table2 of test_type;
alter table test_table2 add (
     constraint test_table2_pk primary key (alpha, beta)
create unique index test_table2_idx1 on test_table2(test_type.get_beta(object_value));
insert into test_table2 values (test_type('Alpha', 'Beta'));
commit;
insert into test_table2 values (test_type('Gamma', 'Beta'));
update test_table2 t set t.beta = 'BETA';
insert into test_table2 values (test_type('Delta', 'Delta'));Correctly produces the following errors:
insert into test_table2 values (test_type('Gamma', 'Beta'))
ORA-00001: unique constraint (MATTK.TEST_TABLE2_IDX1) violated
update test_table2 t set t.beta = 'BETA'
ORA-20000: Beta is not properly set.
ORA-06512: at "MATTK.TEST_TYPE", line 5
insert into test_table2 values (test_type('Delta', 'Delta'))
ORA-20000: Beta is not properly set.
ORA-06512: at "MATTK.TEST_TYPE", line 5The presence of the unique index over the deterministic member function guarantees that function will be called on any insert or update, which gives it the opportunity to error out if the attribute is not properly set.
The reason I was interested in doing this is because Oracle does not support constant attribute values.
Again, thanks everyone for the helpful replies.

Similar Messages

  • How can I reference the last value in a column?

    How can I reference the last value in a column? For example, today I want the value of A1 to appear in another cell. Tomorrow, I will add a row and want to reference A2, next day A3, and so forth.

    Now I got it:
    =OFFSET(A1,COUNT(A)-1,0)

  • How do I change the background color of a row in a table indicator?

    Hello,
      How do I change the background color of a row in a table indicator? I know how to change the background color in a active cell, but that is not what I want. My first intent is to make the background color of the first row a unique color, such as green, just to highlight the top row of the table.
    Regards,
    Kaspar
    Regards,
    Kaspar

    I have done this before by using a for loop to change the active cell of a row in order to give the appearance that the whole row is turning the color at once.
    CLA, CLED, CTD,CPI, LabVIEW Champion
    Platinum Alliance Partner
    Senior Engineer
    Using LV 2013, 2012
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.

  • How do you count the multiple columns of a field in a table

    How do you count the multiple columns of a field in a table

    Hi,
    4396bf34-e890-4202-a6b0-4e08c9ff0e89 wrote:
    How do you count the multiple columns of a field in a table
    Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    "Field" isn't a standard database term.  Some people say "field" when they mean "column", but I don't think that's what you mean ("How do you count the multiple columns of a column ..").  Do you want to know how many times a column is used (as opposed to NULL), or the number of different values in a column?  You really need to show what you want.

  • How to reference the Instance name using Substitution string or SQL

    All:
    We have an Application that will be replicated in multiple Apex instances and would like to display the current Oracle Apex Instance name ( Similar to the &APP_USER. on the Welcome portion of the page ) .
    Is there a substitution string for this ?
    We plan on using a Show/Hide region on the splash page titled [About], that when clicked displays an HTML region with the subsitution strings.
    If no substitution strings, can someone help with an SQL that returns the Instance name ?
    Thanks for all the help.
    Aubrey Fernandes

    Aubrey Fernandes wrote:
    I currently have 3 URLs to get to my Development, QA and Production servers & will have many more production servers with different Application Ids.
    Development = http://canqa101:7777/pls/ngcrmd01/apex
    QA = http://canqa101:7777/pls/ngcrmq01/f?p=100:1
    Production = http://cancs105:7777/pls/ngcrmp01/f?p=100:1
    What I need are the portions before the final forward slash ( canqa101:7777/pls/ngcrmd01 ) which I assumed is the Oracle Apex instance.That information is determined by the web server configuration (e.g. the DADs when using OHS) rather than through APEX itself. There are no built-in substitution strings for this. Create an application item and an On New Instance (new session) computation to set the value using the function<tt>owa_util.get_cgi_env</tt> function to get the CGI environment variables <tt> HTTP_HOST</tt> and <tt>SCRIPT_NAME</tt>. You can then reference the value in the region using substitution string syntax.

  • How to find all the instances for specific recurring report

    How can I use UQery Builder to find out all the instance related to specific Recurring job. I have tried using following query to get the result with poor performance.
    select SI_ID, IS_SCHEDUILE_STATUS from ci_infoobjects where SI_NEW_JOB_ID = 2604480
    Since I find that SI_ID stores the current instance id and SI_NEW_JOB_ID stores the recurrign job's ID.
    Please Help.
    Edited by: Gabriel Luk on Feb 14, 2011 5:21 PM

    I can not find 'SI_KEYWORD' is a indexed properties in following SAP Notes.
    1364250 - Which BusinessObjects Enterprise InfoObject properties are indexed
    1499196 - Which of the InfoObject properties are indexed
    Edited by: Gabriel Luk on Feb 15, 2011 5:09 AM

  • How can I reference the symbol that contains the code.

    I am trying to create a circle that is dynamically added to the stage.
    Iwant to add all of the programatic animations in the symbol's stage but I can't figure out how to reference teh symbol itself with something I use to do in AS3 using the keyword this
    For example:
    - I create a symbol called Light, with a png inside
    - I open it and place a series of code lines
    var myW = this.width(); // how to reference the symbol from itself?
    var myH = this.height();
    funciton init()
         this.getSymbolElement().css("left", Math.random() * 1024);
         this.getSymbolElement().css("top", Math.random() * 768);
         this.getSymbolElement().css("scale", 1); // how to reset the scale?
         TweenMax.to(this, 2 + Math.random()*4,{opacity:0, scale:4, delay:Math.random()*10, onComplete:init});
    init();
    So each time the TweenMax completes the action, the symbol changes its position and resets the scale (how to reset it is another question)
    After that I create the symbols with a for loop and scatter them over the stage randomly.
    A

    Thank Cindy it was dummy code typed here.
    This worked perfectly! So here is how I did my PARTICLE SYSTEM:
    var root = sym.getSymbolElement();
    root.css("position", "absolute");
    var myW = root.width();
    var myH = root.height();
    function init()
              var lightX = 40 + Math.random() * (1036 - 80);
              var lightY = 30 + Math.random() * 170;
              root.css("opacity", 1);
              root.css("transform","scale(0)").css("-moz-transform","scale(0)").css("-webkit-trans form","scale(0)");
              root.css("left", lightX);
              root.css("top", lightY);
              TweenMax.to(root, 0.5 + Math.random() * 1.5, {opacity:0, scale:3, delay:Math.random()*2, onComplete:init});
    init();

  • How do I get the instance of a serviceticket in ICCMP_BTPARTNER?!

    Hi all,
    I want to find out which instance/ibase is currently set in a serviceticket. I am in the component "ICCMP_BTPARTNER" in the view "PARTNERTABLE".
    I thought I might get the instance of the serviceticket in the global data context in GDC_CURRENTIBASE or GDC_CURRENTSERVICETICKET. But the CURRENTIBASE is initial and in SERVICETICKET the only information I get is the CRM_GUID. 
    I tried something like this...
      CLEAR: lr_gdc.
      TRY.
          lr_gdc ?= cl_crm_ui_data_context_srv=>get_instance( iv_controller = me ).
        CATCH cx_root.
      ENDTRY.
      CHECK lr_gdc IS BOUND.
      CALL METHOD lr_gdc->get_entity
        EXPORTING
          name  = if_iccmp_global_data_cont_con=>gdc_currentibase
        RECEIVING
          value = lr_serviceticket.
      CHECK lr_ibase IS BOUND.
    So, does anyone know how to get the current instance of a serviceticket in any other components view (here ICCMP_BTPARTNER/PartnerTable)?
    Thanks for your help.
    Best regards.
    Ben

    Done.
      DATA: lr_gdc             TYPE REF TO if_crm_ui_data_context.
      DATA: lr_serviceticket   TYPE REF TO if_bol_bo_property_access.
      DATA: lr_entity          TYPE REF TO cl_crm_bol_entity.
      DATA: lv_instance        TYPE ib_instance.
      CLEAR: lr_gdc.
      TRY.
          lr_gdc ?= cl_crm_ui_data_context_srv=>get_instance( iv_controller = me ).
        CATCH cx_root.
      ENDTRY.
      CHECK lr_gdc IS BOUND.
      CALL METHOD lr_gdc->get_entity
        EXPORTING
          name  = if_iccmp_global_data_cont_con=>gdc_currentserviceticket
        RECEIVING
          value = lr_serviceticket.
      CHECK lr_serviceticket IS BOUND.
      CLEAR: lr_entity.
      lr_entity ?= lr_serviceticket.
      CHECK lr_entity IS BOUND.
      CLEAR: lv_instance.
      TRY.
          lr_entity = lr_entity->get_related_entity( 'BTOrderHeader' ).
          CHECK lr_entity IS BOUND.
          lr_entity = lr_entity->get_related_entity( iv_relation_name = 'BTHeaderBOSSet' ).
          CHECK lr_entity IS BOUND.
          lr_entity = lr_entity->get_related_entity( iv_relation_name = 'BTRefObjSet_A' ).
          CHECK lr_entity IS BOUND.
          lr_entity = lr_entity->get_related_entity( iv_relation_name = 'BTRefObjectComponentsAll' ).
          CHECK lr_entity IS BOUND.
          lv_instance = lr_entity->if_bol_bo_property_access~get_property_as_string( 'IB_INSTANCE' ).
        CATCH cx_crm_genil_model_error cx_root.
      ENDTRY.

  • How can we destroy the instance of a singleton object?

    I think by writing a method like getInstance and making null in that method will not the correct answer of this. Can someone tell me what should I do.

    why do you need to destroy the singleton?
    normally..it should live for the duration of the application.
    most singleton i've worked with are used by sevarals different classes.
    if you're singleton use by only one class...refactor your code to make the singleton an inner class. so the singleton will be destroy when that class is no longer references 9and gc kick in)
    if the singleton is share among several class...you can have a destroy method...like destroyInstance() where you null the singleton. keep in mind about synchronization of the method as well as the instance ... example createInstance() and destroyInstance() get call at the same time.. Also, make sure you have condition to check to determine if your singleton class is null or not
    example
    MySingleton s = MySingleton.createInstance();
    Object obj = s.getData(); // what happen when another thread call MySingleton.destroyInstance() you're s.getData would result in NullPointerException
    so..it's not wise to destroy a singleton.
    I think what is better for your app is an Object Pool that create new instance (if none exist) and hand it out to any requester...and recycle the object...or null it after use)

  • How do I reference the data object in a DataGrid to show an image correctly in Acrobat?

    I'm creating an inferface for an Acrobat application  and I'm having a issue with displaying an image in a grid.  When I hard code the source="statusNONE.png" it works as intended (with an image, not the image associated with each grid item), however, when I try to use the source="{data.@icon}" to reference the dataProvider (XMLListCollection) I get nothing.  Not a broken image or anything.  I think I may just not be referencing the XMLListCollection correctly, otherwise I don't know why it would work with hard coding vs. fetching the string from the XML.
    //Application Header (Flex 4.5)
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                                     xmlns:s="library://ns.adobe.com/flex/spark"
                                     xmlns:mx="library://ns.adobe.com/flex/mx"
                                     width="100%" height="100%" creationComplete="eaton_creationCompleteHandler(event)"
                                     currentState="Review">
    //Sample of XML that gets used as basis for XMLListCollection
    <Annots>
         <Annot name='TEST' index='14' feedback='' canConstruct='0' icon='statusNONE.png'/>
    </Annots>
    //creation of the XMLListCollection from String
    [Bindable] protected var fullXML:XML;
    [Bindable] protected var fullXMLCol:XMLListCollection;
    protected function loadXML(xmlString:String):void
          fullXML = new XML(xmlString);
         var fullXMLList:XMLList = fullXML.children();
          fullXMLCol = new XMLListCollection(fullXMLList);
    //DataGrid
    <s:DataGrid left="0" top="0" bottom="0" width="142" dataProvider="{fullXMLCol}"
                                            requestedRowCount="4" rowHeight="30"
                                            top.Confirm="87">
                        <s:columns>
                                  <s:ArrayList>
                                            <s:GridColumn dataField="@name" headerText="Annotations"></s:GridColumn>
                                            <s:GridColumn headerText="status" width="30" >
                                                      <s:itemRenderer>
                                                                <fx:Component>
                                                                          <s:GridItemRenderer>
                                                                                    <s:Image width="30" height="30" source="{data.@icon}"/> //THIS IS THE PART THAT SEEMS TO BE GIVNG ME TROUBLE!
                                                                          </s:GridItemRenderer>
                                                                </fx:Component>
                                                      </s:itemRenderer>
                                            </s:GridColumn>
                                  </s:ArrayList>
                        </s:columns>
                        <s:typicalItem>
                                  <fx:Object dataField1="Sample Data" dataField2="Sample Data" dataField3="Sample Data"></fx:Object>
                        </s:typicalItem>
              </s:DataGrid>
    Additional information.  I'm using the resources tab for the flash embedding in Acrobat for my images. This works when I am hard coding the file name string works for the source without having to add a full path, the images are not technically bundled into the swf.   I just don't understand why using the data object to get that same string would show different results.
    tl;dr: GridItemRenderer works to show images when hard coded but not when using {data}.
    UPDATE: Figured it out, needed to add a toString() to the data.@icon.   I had assumed it was a string being handed over, I assumed wrong.

    Probably because data.@icon isn't a String, it is an XMLList, and source property is an Object not a String so the runtime doesn't automatically convert it.
      Try [email protected]()

  • Acrobat pro 9 - How do I reference the text in another textbox on another page?

    Near the top of each page on my form I have a text box that users are to enter their company name.  Unfortunately, there is the same information requested on each page in the form.  It is too far down to use a header, but I don't think you can place a field in the header.
    I know that you can use the Calculate tab to reference the numeric values of other fields, for mathematical purposes.  What I would like to do is: Have the other company name fields in the rest of document reference the first one so the user only has to enter it once.
    I have been searching and googling without success, and I even checked the manual but found no reference in the logical areas.  Can this be done with Acrobat Pro 9?
    Thanks in advance for your help.
    Gregory

    Huh.  Whaddya know, it does.  Such an easy solution.  And it is probably documented somewhere.  I guess I should have done more than skim through the manual.  Thanks Gilad.

  • How can I make the Instance name the same as the name of the Movie clip in an animation.

    Hi, I am an animator for a small game project and I have this really big problem. Even though I used flash for animation for a long time I am a newbie when it comes to something technical. I just received a request to make every movie clip that I use  to have a consistent <Instance name> in every frame of the animation. Only if they told me this earlier... Is there an easier way to make the <Instance name> the same as the name of the Movie clip used other than manually entering it. I have 16 characters with 12 body parts with 20 animations each with about 6-7 frames for each body part it will take me months and nightmares evey night to enter everything by hand. Please help me keep my sanity!
    I'm not sure if I explain correctly, so here is a picture:
    Thank you!

    Thank you for the fast answer! I found this video on jsfl functionality that deals with a similar problem, I am not a coder so it will take me some time to figure it out, but when I do I will probably post the answer here. Here is the video:

  • How to Find whether the instance of  Oracle 9iAS is running

    Dear All,
    Is it possible to find out whether the instances of 9ias running,in which port,the home directory of the instance.
    This is Very Urgent
    Regds
    Sree

    solaris has a command lsof
    lsof -i TCP:port
    this shows the uid of the process that is running on the given port.
    If you know the port, you can do
    ps -ef |grep lsof -i TCP:port
    Also try
    ps -ef |grep java
    This would give you a bunch of processes
    Don't know if the pipe would work, but you get the idea....

  • [CS3/CS4 JS] How can you get the associatedXMLElement of a merged cell in a table?

    Hi!
    Inserting a table, and autotagging it, I get a table with a number of cell elements in the XML Structure.
    Selecting an item in the table, I can find the associated XML by the following line of code:
    app.selection[0].associatedXMLElement
    My problems begin when cells are merged. Then the associatedXMLElement for the cell returns null.
    How can I find the associatedXMLElement for a merged cell?
    Using the getElements makes no difference.
    app.selection[0].getElements()[0].associatedXMLElement
    (returns null)
    In the XML structure I can see that the merged cell is still associated to an XML Element, which becomes underlined and also referrs back to the cell, selecting it when double clicking the XML Element link in the structure.
    Is there no way to get to the xml element of a merged cell?
    I have tested in CS3 and CS4 as well, and they act in the same way.
    I also found a similar, unanswered, question from Anne-Laure Jallon in the "With CS3, some things have changed" ( http://forums.adobe.com/message/1105813#1105813 ):
    Hello,
    I'm working with VBscript.
    Is there a difference between cell.associatedXmlElement in CS2 and CS3?
    All my cells in CS2 had an associatedXmlElement.
    In CS3, my table has an associatedXmlElement, but all its cells don't (The value is Nothing)
    Is this a bug? Is it linked with XML evolution?   Thanks Anne Laure
    Adding some more info:
    I made a test, by selecting the XMLElement in the structure, and from that object finding the cell, and finding back to the assiciatedXMLElement:
    app.selection[0].getElements()[0].cells[0].associatedXMLElement
    Result: [object XMLElement]
    So that kind of "chain" works.
    But with the merged cell as only reference, I can't find its associatedXMLElement. Any ideas would be appreciated.
    Best regards,
    Andreas Jansson
    Message was edited by: Andreas Jansson

    In my opinion, locate a cell according to his content is not so effortable. What happens if contents of more than two cells are equals?
    I take xml elements of associated xml element of table and put them into an array.
    This array contains associated xml elements of every cell ordered by cell positions into table.
    Now, locate associated xml element of a cell based on its array position (index) is more reliable:
    var myCell_cell = app.selection[0];
    var myElement = myCell.associateXMLElement
    if (!myElement || !myElement.isValid)  {
         var table =  myCell.parent;
         var xml_tab = table.associatedXMLElement;
         var xml_cells_arr = xml_tab.xmlElements.everyItem().getElements();
         var idx = myCell.index;
         myElement = xml_cells_arr[idx];
    Alex ;-)

  • How to programmatically retrieve the real field name from a view object ?

    Dear all,
    when I map a business component (a database table) to a view, the fields are automatically converted by JDeveloper, for example, a field named 'user_id' in the oracle table definition, becomes 'userid' in the view.
    The question: how can I retrieve the right table column name from within a backing bean ? Please explain also what should I bind and how; should I use an iterator ?
    Another more: since we can change the label of a field on a view, how can then I get the mapping between the column name on the view and the column name on the table in the database ?
    Thanks in advance,
    Sergio.

    Hi Timo,
    many thanks for your answer.
    The rest of my question: you know we can drop a view from the DataControls onto a ADF page, with each field of the table having a label.
    That label is initially set like the internal table field name, so for instance, if user_id is the real table field name, userid will be the (by JDeveloper) internal renamed table field name, and the label would be userid too.
    If I then change the label text to, for example, "myUserid", the question is: how can I know which real table field does "myUserid" point to ?
    In other words, when my form is submitted, I want to know which field name has been changed and prepare an update sql in a bean.
    For this purpose I bind each view field to a validator function in the bean, and collect al the pairs "label_name + submitted value" in an hash table.
    Now inorder to build up that update query, I need the mapping between the label_name ("myUserid") and the real table field name ("user_id"). The question: how to map the label to the real table field name ?
    By the way, I'm using JDeveloper 11g rel. 2.
    Regards,
    Sergio.

Maybe you are looking for