Return value of inferred entity instance from relationship in SOAP Determinations

Hey,
I had an original thread open which indicates the problem I was trying to solve (Multiple Conclusion based on input values ). My rule base now behaves as expected and I can test it in the debugger as expected, only now I can't get the actual identifying values back I want using the determinations web service.
I get a whole bunch of inferred entity instances back from an inferred relationship the same as the situation/screen shot at the bottom of the "Investigate an inferred relationship" page on the Oracle Policy Automation Cloud Service User Guide, but in my SOAP response I only get the instances with hashed IDs. I want the actual identifying value of the entity.
e.g. Currently get this:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i18n="http://www.w3.org/2005/09/ws-i18n" xmlns:typ="http://oracle.com/determinations/server/11.0/rulebase/assess/types">
   <SOAP-ENV:Header>
      <i18n:international>
         <i18n:locale>en_GB</i18n:locale>
         <i18n:tz>GMT-0500</i18n:tz>
      </i18n:international>
   </SOAP-ENV:Header>
   <SOAP-ENV:Body>
      <typ:assess-response>
         <typ:global-instance>
            <typ:attribute id="course_code" type="text">
               <typ:text-val>AHPY</typ:text-val>
            </typ:attribute>
            <typ:entity id="the_supplementary_documents" inferred="true">
               <typ:instance id="0x608c2dc220e15d8c"></typ:instance>
               <typ:instance id="0x5b7e2d02e8780325"></typ:instance>
            </typ:entity>
            <typ:entity id="the_informational_documents" inferred="true">
               <typ:instance id="0x19387621439a43c7"></typ:instance>
            </typ:entity>
         </typ:global-instance>
      </typ:assess-response>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
But I want something like below and I'm having a lot of trouble figuring out how to actually do this. Also is there anywhere that defines the meaning of errors you get from OPA? I have tried to modify my rulebase and I got a few OPA-EXXXXX errors but apart from the description you get in OPM, I can't find anywhere that gives more detail on these and explains what they mean/how to fix it.
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i18n="http://www.w3.org/2005/09/ws-i18n" xmlns:typ="http://oracle.com/determinations/server/11.0/rulebase/assess/types">
   <SOAP-ENV:Header>
      <i18n:international>
         <i18n:locale>en_GB</i18n:locale>
         <i18n:tz>GMT-0500</i18n:tz>
      </i18n:international>
   </SOAP-ENV:Header>
   <SOAP-ENV:Body>
      <typ:assess-response>
         <typ:global-instance>
            <typ:attribute id="course_code" type="text">
               <typ:text-val>AHPY</typ:text-val>
            </typ:attribute>
            <typ:entity id="the_supplementary_documents" inferred="true">
               <typ:instance id="http://mydomain.com/mydocument.pdf">
               </typ:instance>
               <typ:instance id="http://mydomain.com/mydocument.pdf"></typ:instance>
            </typ:entity>
            <typ:entity id="the_informational_documents" inferred="true">
               <typ:instance id="http://mydomain.com/mydocument.pdf"></typ:instance>
            </typ:entity>
         </typ:global-instance>
      </typ:assess-response>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I managed to get this working by referring to this thread: Inferred Entity Instances IDs in output response
I had tried something similar but not quite the same. In the end my request looked something like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://oracle.com/determinations/server/11.0/rulebase/assess/types">
   <soapenv:Header/>
   <soapenv:Body>
      <typ:assess-request>
         <typ:config>
           <typ:outcome>
          <typ:entity id="the_supplementary_documents">
            <typ:attribute-outcome id="supplementary_documents" outcome-style="value-only"/>
          </typ:entity>
          <typ:entity id="the_informational_documents">
            <typ:attribute-outcome id="informational_documents" outcome-style="value-only"/>
          </typ:entity>
       </typ:outcome>
         </typ:config>
         <typ:global-instance>
            <typ:attribute id="course_code">
            <typ:text-val>AHPY</typ:text-val>
   </typ:attribute>
          </typ:global-instance>
      </typ:assess-request>
   </soapenv:Body>
</soapenv:Envelope>

Similar Messages

  • Creating infered entity instances

    How can I create infered entity instances..in opa 10.4.
    When I am trying to write rule using the "exists" keyword.. its not compiling as "Infered
    Instance" but it compiles as normal conclusion.
    and how can I create inferred instances conditionally..

    Sorry for the long delay in replying Rajan, I missed your request to elaborate.
    To be specific:
    When an entity instance is inferred that means that every attribute in it must also be inferred. The rule engine cannot cope with logic like: "this entity might or might not exist, but if it does, we need to ask for more information about it"
    There are a few ways to deal with setting information in an inferred entity:
    - most obviously infer any values from other entiy attributes in the session.
    - set attribute values on related, non-inferred entities and then use rules infer those attributes on the inferred entity.
    Its worth having a think about what the inferred entity instances means. If you want to use the rules as a convenient way to create an entity instance and you still need to set non-inferred attributes, then you are better off using an inferencing listener to create the instances.
    If the instances are truly derivable from rules, then any attribute values of those instances are probably also derivable.
    Cheers
    Frank

  • Clarify a Limitation for Inferred Entity Instances

    Hi,
    Under the section "Write rules that infer relationships and entities" in the User Guide there is the
    Notes /Limitations
    1) Combining manually created instances with inferred instances is not allowed.
    2) Combining inferred entity instances with temporal values is not supported.
    3) Only a single attribute of the entity instance can be inferred as a part of the entity rule. For example, the type of benefit ("unemployment benefit") can be set but the amount of the benefit would have to be set via a separate rule.
    4) Inferred entity instances may not contain base level attributes.
    5) A relationship that participates in an inferred entity instance rule is considered to be an inferred relationship. This means that an inferred relationship rule cannot be used to prove the same relationship used in an inferred entity instance rule.
    Can number 4 be explained in a little more detail?
    Thanks

    I'm not sure I understand the question so I'm going to guess what you're asking by suggesting a business scenario and talk about how that would work. It is always much easier to talk about a specific business requirement you have rather than product features in general - so if you have a specific requirement I strongly recommend sharing it as you'll get better quality help.
    Anyway, if we keep our existing example of an inferred entity "the product" (has attributes: the name of the product, the price of the product). Say we want to know want the price of the most expensive product you have selected (a concept which would be represented by an attribute at the global level).
    You can do that. The rules to do that are just the same as the rules you'd use if instead of inferring the products and prices you instead asked the user to provide them (ie instancemaximum across a relationship). I'd send an example showing these rules - but it's not possible to attach files to this forum. You use inferred entities in the rest of your rules as if they had been input by a user - there's no difference. The key difference between an inferred entity and a non-inferred entity is that you can't collect more information about it (ie it can't have any base level attributes).
    You can use any attribute in a rule so long as the usage of the attribute matches the entity level of the conclusion. ie You couldn't use "the price of the product" directly in a rule with a conclusion at the global level - because you revert to the problem of "the price of which product?".
    On the off chance that this is somehow a "programmer" question (ie you're trying to understand how OPA works by treating it the same as another method for creating programs, for example a programming language like Java) - attributes in OPA don't have a concept of "private" and "public". If I tried to put OPA In those terms (and it's a stretch because OPA is not Java) - in OPA: everything is public (declare once use everywhere). An entity model in OPA is different thing to a class hierarchy.

  • OPA 10.4 "Inferred Entity Instances", possible to integrate with Siebel?

    Hi,
    In OPA 10.4, I found a new feature "Inferred Entity Instances" using which we can create benefit plans, Opportunities, Service Request,Order lines using only rules.
    Does it mean we can create an Opportunity/Service Request/Order line by writing the information only in the rule when OPA 10.4 is integrated with Siebel?
    Thanks,
    Subhradeep

    The current Siebel Connector only supports OPA 10.3, which does not have inferred entity instances.
    The upcoming release of the Siebel Connector will support new 10.4 OPA features including inferred entities.
    Cheers
    Frank

  • Batch Processor, WIA and Inferred entity instances

    Hi All,
    I'm playing around with the new OPA 10.4. I bumped into an error in What-If-Analysis document when I tried to add a new worksheet for an inferred entity. Is this not possible in WIA? Does it mean it will not work as well with Batch Processor.
    Here's my data model:
    global
    --- the applicant
    --- --- the qualification
    --- --- --- the exempted course (inferred instances from 'the qualification' attributes)
    Thank you in advance!
    Regards,
    Jerome

    Brad Tuckett wrote:
    Jerome wrote:
    Is there a possible workaround right now in 10.4 to persist inferred instances in Batch Processor?The Batch Processor will not output any inferred instances in 10.4
    One more thing, I'm also using 10.2 and have implemented InferencingListener to create instances, would you happen to know if I will bump on the same issue with DSC?
    There probably isn't a way of having any entity instances created by an event listener appear in the Batch Processor output for database or CSV.
    However, you may be able to set the output to saved sessions. Although this isn't explicitly supported, I would expected that any instances you have created would show up in the exported sessions, which will be xml files in the xds format. This will create one session file for each case.
    You can set the output to be exported sessions by using "--export <dir>" in the command line or use the xml configuration for the Batch Processor.
    When 10.4.1 is released you should be able to switch to using inferred entities which will be compatible with the Batch Processor.

  • How to remove the entity instances from a decision report

    Please see below the rules and the resulting decision report
    How can I remove, from the decision report, the four lines that say "the persons in the family unit", instance 1, instance 2, instance 3?
    I just can't seem to find a place where the use of silent or invisible will cause the four lines not to appear
    The Rules
    the applicants for income assistance in a family unit have completed (and submitted) to the minister an application for income assistance (part1) form if
    forall(the persons in the family unit, the person satisfies the requirements to complete and submit an application for assistance (part 1) form)
    the person satisfies the requirements to complete and submit an application for assistance (part 1) form if
    all
    the person is an applicant
    s4.1(2)(a)(i)     the person has provided a social insurance number
    s4.1(2)(a)(ii)     the person has provided the information, authorizations, declarations and verifications specified by the minister as required in the application for assistance (part 1) form
    The Decision Report
    EA Regs s4.1(2)(a)(Application - Part1) is satisfied.
    The applicants for income assistance in a family unit have completed (and submitted) to the minister an application for income assistance (part1) form.
    the persons in the family unit
    instance #1
    instance #2
    instance #3
    Abel satisfies the requirements to complete and submit an application for assistance (part 1) form.
    Abel is an applicant.
    Abel satisfies section s4.1(2)(a)(i).
    Abel has provided a social insurance number.
    Abel satisfies section s4.1(2)(a)(ii).
    Abel has provided the information, authorizations, declarations and verifications specified by the minister as required in the application for assistance (part 1) form.
    Edited by: A Gibson on Oct 11, 2010 3:35 PM

    Here are some further details. If images could be attached to this forum then I would have included some screenshots, but this forum only allows text.
    1. Set up regular name substitution (See the sections "Set up substitution" and "Substitute the actual value of a variable for its text" in the OPM Help article "Change the text of an interview question or sentence").
    2. In the Properties file, double-click on the entity. This will open the Edit Entity dialog.
    3. In the Edit Entity dialog, fill in the Identifier field with the variable you're using for the regular name substitution.
    4. Click OK and you're done!
    Cheers,
    Jasmine

  • Refering to entity instances from a more specific entity context

    I have the global entity and two non-singleton entities; the obligation and the invoice. There are multiple obligations, and each obligation has multiple invoices, so it is a classic hierarchical entity structure.
    When I write a rule in the context of 'the invoice', I can't seem to be able to refer to the parent 'obligation' that owns the invoice, but I understand that I should be able to because there is no ambiguity as to which obligation I am referring to.
    Is this different now in version 10 of OPA? Does it require For()? Does anyone have an example of such a reference?

    Hi Michael,
    Had another look at this after we chatted. You need to use the 'For' function and the reverse text of the relationship between obligations and invoices.
    I have an example with the following entities:
    Global -- one-to-many --> the cat (Relationship text: the cats)
    the cat -- one-to-many --> the cat's toys (Relationship text: the cat's toys; Reverse relationship text: the toy of the cat)
    Here's an example rule which infers something about the cat's toy from something about the cat:
    the cat's toy is happy if
    …..For(the toy of the cat, the cat is happy)This compiles and runs fine in the debugger. Looks like we can't add attachments to posts on the external forum, but I can email the example to you separately.
    Cheers,
    Jasmine

  • SSRS Column Chart Design Returning values in a format different from SSRS -SSAS Query Designer

    Hi All,
    I have an SSAS cube Measure Group with Multiple Measures that I am attempting to return on one SSRS report and reflect the 
    values using a ssrs column chart.
    My Measure Group (Patients).
    Measures:
    PatientsOnMeds
    PatientOnRelapse
    PatientsCounseld
    TotalNumberOfPatientsRegisterd
    NewlyRegisteredPatients
    HealthPersonelTrainef
    Demension:
    Time (Year) :filtered to 2012 & 2013
    In my SSRS query designer I have filtered the above Measures with Time Dimesion year 2012 & 2013
    and the data is returned as :
    Year |PatientsOnMeds|PatientOnRelapse|TotalNumberOfPatientsRegisterd|NewlyRegisteredPatients|
    2012 | 700          | 526            |  25                          | 456
    2013 | 245          | 245            |  15                          | 70
    Now the problem is when I return this data on the column Chart it's in messed up mesh
    On the chart Data:
    -Values :Measures
    -Series Group: Dimension
    The report values are returned in multiple columns for each value segmented by year i.e year 2012,Year 2013.
    I want a single column for each Measure (value) for each single year and The chart axis to reflect the measures(values) 
    instead of grouping values according to series group.
    instead the legend returns:
    -Year A -PatientsOnMeds
    -Year A -PatientOnRelapse
    -Year B -PatientsOnMeds
    -Year B -PatientOnRelapse
    I would like the legend to reflect on -Year A,Year B in color code that will be highlighted in the column values.
    Please point me in the right course if you can.Your insights are highly appreciated.Thank you in advance.

    Hi Charlie, 
    Thank you for your kind response. 
    In actual I want the legend to show:
    -2012
    -2013
    And the bottom axis to show:
    PatientsOnMeds
    PatientOnRelapse
    PatientsCounseld
    TotalNumberOfPatientsRegisterd
    NewlyRegisteredPatients
    HealthPersonelTrained
    Indicating in color code for Year 2012 and Year 2013.
    This the challenge that I am struggling with.I hope you understand my scenario.
    It aint easy.

  • Return values from a jpd to a jpf

    I basically want to call a jpd from a page flow and then receive the results back from the jpd in my page flow. I have created a process control from the jpd and have included it in my page flow controller file using the following annotation.
    * @common:control
    private controls.leaveProcessPControl leaveControl ;
    But since my jpd has a client response node for sending back the results (which corresponds to callback interface in the code), my page flow controller file is throwing an error saying that leaveControl implements a callback interface and page flow cannot receive asynchronous callbacks. Can anyone tell me how to resolve this.
    I would also like to know if there are different approaches for returning values back to the jpf from a jpd.
    Thanks,
    RK

    We are talking web interface here, so forget about Callbacks. I suggest that
    you create Web Servicethat implements your proces or a control that calls
    proces. Then Call that WS fro a controller, but in sync. way. Send a request
    and then pull for response. This pull can be implemented as while loop in
    Controler, with wait inside loop.
    That wont work realy well if jour proces is long running, as controller will
    block. In that case you will have to implement some kind of pulling in every
    action method in your controller and react - fill data in internal variable
    of controller for example.
    I hope it helps, butt remember thin is not always the best.
    "rohini k" <[email protected]> wrote in message
    news:4042178.1101851602508.JavaMail.root@jserv5...
    I basically want to call a jpd from a page flow and then receive the
    results back from the jpd in my page flow. I have created a process control
    from the jpd and have included in my page flow controller file using the
    following annotation.
    * @common:control
    private controls.leaveProcessPControl leaveControl ;
    But since my jpd has a client response node for sending back the results
    (which corresponds to callback interface in the code), my page flow
    controller file is throwing an error saying that leaveControl implements a
    callback interface and page flow cannot receive asynchronous callbacks.
    Can anyone tell me how to resolve this.
    I would also like to know if there are different approaches for returning
    values back to the jpf from a jpd.
    Thanks,
    RK

  • Web Services  from ABAP function modules return values- leading zeros

    I am using several web services from SAP CRM (5.0) that were created from Function modules ( I am assuming that that they are in ABAP).
    I can call the web services fine and they work as expected, but I am seeing a lot of leading zeros in the return values of fields in tables from the Web service.
    The ABAP er’s are telling me that they cannot see the leading zero’s.
    So my question is where these are appended to the values in the whole process. When I execute the Function Module in SAP CRM from transaction SE37 I can see the leading zeros. So I think that this is something that has to be handled by the ABAP er’s and not in the client consuming the web service.
    Are the functions in SAP CRM that can remove leading zeros for fields in a table (that is an export parameter?)
    Jawahar

    Hello Jawahar
    If you run your (RFC-enabled) function modules using the SAP-GUI (i.e. in dialog) then the GUI automatically replaces leading zero when the function module returns any data. However, calling the same function module remotely you will always see these leading zeros.
    These so-called conversion exits are defined as attribute of domains in the ABAP dictionary. If the function module used for the WebService is a standard fm then you have little chances to get rid of the leading zero. Perhaps the WebService has some attribute to suppress conversion exits or activate them when retrieving the data.
    Regards, 
       Uwe

  • Dynamic creation of entity instances

    Hi,
    I create a custom function which dynamic create some entity instances and relationships.
    The base attributes of the entity intstances are filled with values. Running in debug mode
    with screens everything looks ok.
    Unfortunately the rules which operate on the entity instances are not triggered.
    Please help,
    Johan van der Graaf

    Hi Johan,
    as Davin mentioned it is really not advised to use custom functions to try to do this. What is the technical/business driver for doing this via a custom function rather than any of the other options that Davin suggests?
    The rules will be evaluated if there is enough information for it to be evaluated - the problem when you try to mess with the data set outside the inference cycle (which is what you're doing with a custom function to creeate entity instances) is that it doesn't know it knows the infromation - all it knows is the result returned from the custom function.
    At a high level: it's particularly awkward because you are asking it to set values behind the scenes - creating entity instances, properly setting up the relationships between those entity instances and then (I'd imagine) also populating the entity instances with their relevant values. You need to check that you are actually setting up all of those things properly.
    As I suggested before, you can see if it's a problem with the custom function not setting the values correctly or if it's a question of that need to make the engine know that you've added these values by going to the conclusion that you think should be evaulating in the debugger and specifically investigating it (right-click "Investigate") - you'll then be taken to the "decision" tab from where you can see what extra information the conclusion thinks it needs.
    If all of the data needed is actually already known then you'll get a result when you do this. If not then it will tell you what the extra information you need is and you can judge whether that's reasonable or because the custom function isn't actually setting up everything properly.
    If your custom function is setting everything outside the inference cycle then there are techniques you can use (basically relying on the result value for the custom function) to try to get the rule to evaluate, however these makes for some quite complex, non-intuitive rules which are awkard to maintain and the implementation of which often leads to people creating logical loops in their rules. It really would be best to look and see if there are other options availabel to achieve the same functional end.
    Have you investigated using the other options Davin has suggested? If so, we'd really appreciate knowing why you decided they weren't suitable as this will help us move the product forward in the future.
    Cheers,
    Sean.

  • Multiple return values (Bug-ID 4222792)

    I had exactly the same request for the same 3 reasons: strong type safety and code correctness verification at compile-time, code readability and ease of mantenance, performance.
    Here is what Sun replied to me:
    Autoboxing and varargs are provided as part of
    JSRs 14 and 201
    http://jcp.org/en/jsr/detail?id=14
    http://jcp.org/en/jsr/detail?id=201
    See also:
    http://forum.java.sun.com/forum.jsp?forum=316
    http://developer.java.sun.com/developer/earlyAccess/adding_generics/index.html
    Multiple return values is covered by Bug-ID 4222792
    Typically this is done by returning an array.
    http://developer.java.sun.com/developer/bugParade/bugs/4222792.html
    That's exactly the problem: we dynamically create instances of array objects that would better fit well within the operand stack without stressing the garbage collector with temporary Array object instances (and with their backing store: 2 separate allocations that need to be recycled when it is clearly a pollution that the operand stack would clean up more efficiently)
    If you would like to engage in a discussion with the Java Language developers, the Generics forum would be a better place:
    http://forum.java.sun.com/forum.jsp?forum=316
    I know that (my report was already refering to the JSR for language extension) Generics is not what I was refering to (even if a generic could handle multiple return values, it would still be an allocated Object
    instance to pack them, i.e. just less convenient than using a static class for type safety.
    The most common case of multiple return values involve values that have known static datatypes and that should be checked with strong typesafety.
    The simple case that involves returning two ints then will require at least two object instances and will not solve the garbage collection overhead.
    Using a array of variable objects is exactly similar, except that it requires two instances for the components and one instance for the generic array container. Using extra method parameters with Integer, Byte, ... boxing objects is more efficient, but for now the only practical solution (which causes the least pollution in the VM allocator and garbage collector) is to use a custom class to store the return values in a single instance.
    This is not natural, and needlessly complexifies many interfaces.
    So to avoid this pollution, some solutions are used such as packing two ints into a long and returning a long, depacking the long after return (not quite clean but still much faster at run-time for methods that need to be used with high frequencies within the application. In some case, the only way to cut down the overhead is to inline methods within the caller code, and this does not help code maintenance by splitting the implementation into small methods (something that C++ can do very easily, both because it supports native types parameters by reference, and because it also supports inline methods).
    Finally, suppose we don't want to use tricky code, difficult to maintain, then we'll have to use boxing Object types to allow passing arguments by reference. Shamely boxed native types cannot be allocated on the operand stack as local variables, so we need to instanciate these local variables before call, and we loose the capacity to track the cases where these local variables are not really initialized by an effective call to the method that will assign them. This does not help debugging, and is against the concept of a strongly typed language like Java should be:
    Java makes lots of efforts to track uninitialized variables, but has no way to determine if an already instanciated Object instance refered in a local variable has effectively received an effective assignment because only the instanciation is kept. A typical code will then need to be written like this:
    Integer a = null;
    Integer b = null;
    if (some condition) {
    //call.method(a, b, 0, 1, "dummy input arg");
    // the method is supposed to have assigned a value to a and b,
    // but can't if a and b have not been instanciated, so we perform:
    call.method(a = new Integer(), b = new Integer(), 0, 1, "dummy input
    arg");
    // we must suppose that the method has modified (not initialized!)
    the value
    // of a and b instances.
    now.use(a.value(), b.value())
    // are we sure here that a and b have received a value????
    // the code may be detected at run-time (a null exception)
    // or completely undetected (the method() above was called but it
    // forgot to assign a value to its referenced objects a and b, in which
    // case we are calling in fact: now.use(0, 0); with the default values
    // or a and b, assigned when they were instanciated)
    Very tricky... Hard to debug. It would be much simpler if we just used:
    int a;
    int b;
    if (some condition) {
    (a, b) = call.method(0, 1, "dummy input arg");
    now.use(a, b);
    The compiler would immediately detect the case where a and b are in fact not always initialized (possible use bere initialization), and the first invoked call.method() would not have to check if its arguments are not null, it would not compile if it forgets to return two values in some code path...
    There's no need to provide extra boxing objects in the source as well as at run-time, and there's no stress added to the VM allocator or garbage collector simply because return values are only allocated on the perand stack by the caller, directly instanciated within the callee which MUST (checked at compile-time) create such instances by using the return statement to instanciate them, and the caller now just needs to use directly the variables which were referenced before call (here a and b). Clean and mean. And it allows strong typechecking as well (so this is a real help for programmers.
    Note that the signature of the method() above is:
    class call {
    (int, int) method(int, int, String) { ... }
    id est:
    class "call", member name "method", member type "(IILjava.lang.string;)II"
    This last signature means that the method can only be called by returning the value into a pair of variables of type int, or using the return value as a pair of actual arguments for another method call such as:
    call.method(call.method("dummy input arg"), "other dummy input arg")
    This is strongly typed and convenient to write and debug and very efficient at run-time...

    Can anyone give me some real-world examples where
    multiple return values aren't better captured in a
    class that logically groups those values? I can of
    course give hundreds of examples for why it's better
    to capture method arguments as multiple values instead
    of as one "logical object", but whenever I've hankered
    for multiple return values, I end up rethinking my
    strategy and rewriting my code to be better Object
    Oriented.I'd personally say you're usually right. There's almost always a O-O way of avoiding the situation.
    Sometimes though, you really do just want to return "two ints" from a function. There's no logical object you can think of to put them in. So you end up polluting the namespace:
    public class MyUsefulClass {
    public TwoInts calculateSomething(int a, int b, int c) {
    public static class TwoInts {
        //now, do I use two public int fields here, making it
        //in essence a struct?
       //or do I make my two ints private & final, which
       //requires a constructor & two getters?
      //and while I'm at it, is it worth implementing
      //equals(), how about hashCode()? clone()?
      //readResolve() ?
    }The answer to most of the questions for something as simple as "TwoInts" is usually "no: its not worth implementing those methods", but I still have to think about them.
    More to the point, the TwoInts class looks so ugly polluting the top level namespace like that, MyUsefulClass.TwoInts is public, that I don't think I've ever actually created that class. I always find some way to avoid it, even if the workaround is just as ugly.
    For myself, I'd like to see some simple pass-by-value "Tuple" type. My fear is it'd be abused as a way for lazy programmers to avoid creating objects when they should have a logical type for readability & maintainability.
    Anyone who has maintained code where someone has passed in all their arguments as (mutable!) Maps, Collections and/or Arrays and "returned" values by mutating those structures knows what a nightmare it can be. Which I suppose is an argument that cuts both ways: on the one hand you can say: "why add Tuples which would be another easy thing to abuse", on the other: "why not add Tuples, given Arrays and the Collections framework already allow bad programmers to produce unmainable mush. One more feature isn't going to make a difference either way".
    Ho hum.

  • Accessing function's return value

    Hi there. I have created several pl/sql procedures and functions that I can run as standalone programs and I have no problem integrating them into my java code also. However I cannot access the return value of any created function from my java code. The functions appear to execute correctly because when I deliberately enter an invalid select statement I get the errors I expect to get for that instance nad if I enter a valid select statement in the function the program executes correctly but I still cannot access the function's return value. My java code where I execute the pl/sql function is as follows:
    CallableStatement p = cont.conn.prepareCall("{call ? := Hellen.FUNC}");
    p.setString(1, "z006"); //hellen.FUNC = function name
    p.execute();
    How do I access the return value of my function?
    Do I need to get a ResultSet?
    My function is as follows:
    function func
    return varchar
    is tester varchar(4);
    BEGIN
    select cfcc_code into tester from hellen.test1 where test1.cfcc_code = 'A21';
    return tester;
    END;
    Any help will be gratefully received, Joe

    You need to do something like
    p.registerOutParameter(1, java.lang.String);
    p.execute();
    String result = p.getString(1);Cheers, APC

  • JDBC - how to handle insert that returns value (bind?)

    Hi,
    I'm trying to do an insert into a table in an Oracle database with an auto-incrementing primary key (using a trigger and sequence) and I need to retrieve the value after the insert. From SQL*Plus, I'd enter:
    var id number;
    INSERT INTO mytable (name) VALUES ('foo') RETURNING id into :id;
    whereupon if I do "print id", I get the value of the id field from the newly-inserted record.
    The big question is how to achieve the same thing using JDBC. I've been flailing around all morning trying to figure it out and suspect it has something to do with using a CallableStatement instead of a PreparedStatement, but all of the examples I've seen so far only deal with calling stored procedures instead of raw SQL, and they all omit the part where some variable is bound to the resultset.
    Assuming I want to have the Java variable (int? Integer()?) "newId" set to the value being returned by the SQL statement as "id" (or ":id"?), what do I need to do between getting the connection and looking at "newId" to see what the value returned by the statement is?
    ie,
    Connection conn = db.connect();
    int newId;
    // show me what I need to do here
    System.out.println("The id of the newly-inserted record is:");
    System.out.println(newId);Thanks!

    This is untested:
    use the executeUpdate() method from the Statement. The return value will be your result from the RETURNING id portion of your SQL statement, if not then you'll probably have to do a seperate select or/and explicit return to get the value back from SQL.

  • Can "main" method return values

    Hi,
    I have a requirement of returning values to the
    command prompt from the main method. Is this possible
    to do in the first place. Is it valid.
    i.e. Can you do the following in Java,
    =======================================
    import java.io.*;
    import java.lang.Object;
    import java.util.*;
    public class P
         public static String main(String args[])
         String bye = "BYE";
         return(bye);
    =========================================
    Can "main" method in Java return values at command
    prompt.
    Can you have something like,
    public static String main(String args[])
    instead of
    public static void main(String args[])
    Help urgently needed as I need to pipe data from a
    Java program to a C++ program. One method is to
    writing to a flat file but this would cause overheads
    reading and writing to a file, hence this way.
    Any help would be greatly appreciated.
    Thanks in advance.
    Thank,s

    Hi jchak,
    Yes I am trying to pass a Java String to a C++
    application. Any insights, any help.
    OK the whole thing goes as follows,
    =========================================
    Theres a C++ application which first starts up.
    This app is then supposed to invoke a Java class file
    which does some processing. Finally the value of one
    variable in Java (actually a huge String) is to be made
    available back to C++. This could be done thru flat file
    wherein the Java outputs the string to the flat file
    and on return the C++ program can be made to read the
    same flat file to retrieve that string but this would
    surely cause some overheads (time factor) reading and
    writing files. So I wish to devise some way by means
    of which I can return the string value back to the C++
    program. Piping of data from one app to another is what I
    want to do.
    Is there some way by means of which Java can return
    back or communicate or pipe back the string back to
    C++. How can it be done without using external flat files
    or databases.
    Thansk,
    JAtin

Maybe you are looking for

  • Scripting Guys need your help

    Hello All, I have a script which is working absolutely fine in workgroup(Windows logs backup) - windows server 2012 but if i run in domain environment found error and not able to pull security logs. only pulling application and system with error. Scr

  • EBS 11.5.10.2  Integration

    Hello, I have an EBS 11.5.10.2 and I need to get some data from an other server in format of a flat file. That data is going to be treated by a PLSQL procedure in the EBS 11.5.10.2 and then used in some way in the database. What is the best way to ge

  • I am trying to reset my phone and it is asking me for my passcode

    Hi my phone is disabled locked out as I put in the incorrect pin too many times. I am trying to reset it using recovery mode and following all the instructions and after a while it says please put in your passcode to continue!! How can I put in my pa

  • Pixelation in slideshow?

    I'm having issues with a Slideshow exported MP4 having pixelation even though I have manually created all the previews to no avail. I'm not sure what I can do. The slideshow is of my son's Eagle Scout project and consists of 1250 or so pictures, 12 m

  • Smart Groups possible in Address Book for PANTHER?

    Can you tell me if "SMART GROUPS" is just something in TIGER's version of ADDRESS BOOK or do these exist in PANTHER as well? Actually, I'm not sure what they are, but someone mentioned that I should use them... Thanks very much! Regards, Steve