Problem to give default value in entity object using query

hi,
i have one entity object and i want to set default value of attribute like division which is based on employee code.
entity object based on table leavedetail and using refrence table employee_hdr(empcode ,division).
so how can i set default value of division attribute which is based on empcode attribute using SQL

well,
yes user, fetish nailed correctly.
make some viewlink.
something like says as example.
department vo
employee vo
make viewlinks between those vo's
important thing: exposed then source and destination accesor.
use groovy :
go to employee vo - create Department name field ( as transiest)
use this statement default value expersion type.
DepartmentView1.DepartmentName
it will get the value. check over.
so this example well suits to your scenario.
i hope this will helps you.
well create is an video. to get the value using groovy.
http://www.youtube.com/watch?v=mpHV4x89a_A
Edited by: ADF7 on Apr 14, 2012 5:46 AM

Similar Messages

  • Default value in Entity Object for SYSDATE   ??

    hi ,
    I have a database table which has a DATE column and default value for this column is SYSDATE.
    I want to set default value for this attribute in my EO as I am doing for all other attributes .
    What will be the value of Default Property of entity Object for SYSDATE ??
    Thanx,
    Prasoon

    Hi,
    I succesfully implemented a default systimestamp value.
    I suppose that the same implies for a default sysdate.
    In the DB:
    t_created TIMESTAMP default systimestamp NOT NULL
    In the Entity Object:
    Attribute: TCreated
    Type: Timestamp => in your case Date
    Persistent: yes
    Updateable: never
    Refresh: after insert
    Database column: T_CREATED type TIMESTAMP => in your case DATE
    You could have problems if you leave access to the attribute (updateable flag != never), in this case I suppose the framework adds the Field in the sql insert statement and that would overwrite the default value definition.
    Regards
    Fred
    PS I'm not from Oracle

  • Problem while setting new value to entity object attribute in doDML meathod

    Hi all,
    I am overriding the entity objects doDML method for generating the value of Sequence Number just before insert .
    For this puropose i am using doDML method. I am fetching the maximum value for the sequence number feild from the table by a prepared statement
    and then incrementing that value by one.
        protected void doDML(int operation, TransactionEvent e) {
            if (operation == DML_INSERT) {
                // code for getting the max+1 of sequence number before insert
                //command executes.
                try {
                    System.out.println("Inside doDML Method");
                    String sql =
                        "select nvl(max(seq_no),0)+1  from WF_LEAVE_HDR where org_unit_code = " +
                        this.getOrgUnitCode();
                    PreparedStatement pstmt =
                        getDBTransaction().createPreparedStatement(sql, 0);
                    ResultSet rs = pstmt.executeQuery();
                    rs.next();
                    Integer newSeqNo =rs.getInt(1); //(Number)rs.getString(0);
                    //this.setSeqNo(new Number(newSeqNo));
                    setAttributeInternal("SeqNo",new Number(newSeqNo));
                    System.out.println("Value of new seq no is -->>"+getSeqNo());
                } catch (Exception excpt) {
                    System.out.println("Inside catch block ");
                    excpt.printStackTrace();
            super.doDML(operation, e);
        }i am getting the value correct by using the sql statement but while i am using setAttributeInternal("SeqNo",new Number(newSeqNo));
    it is giving an error and value for new sequence no is not passed to the seq no feild of the entity object. I have tried this.setSeqNo(new Number(newSeqNo))
    but it is also not wotrking .
    Any one please help , I am using Jdeveloper 10.1.3
    Thanks all in advance.

    iloveoracle,
    Sigh... in addition to doing this in doDML (which Dimitar points out is the wrong place to do this)... you are making a huge huge mistake.
    select nvl(max(seq_no),0)+1  from WF_LEAVE_HDRWhat happens when two people do this at around the same time? You don't do any locking, so you will get two rows with the same SeqNo. This is absolutely the wrong way of doing sequence numbers. The best way of doing this would be to use real sequence numbers (an Oracle sequence) and ignore the fact that there will be gaps. If you insist on using your approach, you MUST LOCK THE ENTIRE TABLE before you try to do your little max() + 1 trick, otherwise you run the very real risk of getting duplicate SeqNos. OK, I see that you are trying to do sequences by org_unit_code, so you don't have to lock the whole table, but you do have to have some way of holding a lock. You must also write some code to be able to handle an "unable to get the lock because someone else already holds it" type of situation.
    <rant>
    I have seen so many people try to do this little max() + 1 trick. It DOES NOT, WILL NOT work until you handle locking properly. One question that I often ask when I interview database developers is about generating "gapless" sequences; unless the job is for a brand-new-with-absolutely-no-experience trainee, answering "select max() + 1" without any mention of concurrency issues would be grounds for an immediate rejection of the candidate. Seriously. Have a run over to http://asktom.oracle.com and search for "gapless" if you'd like to see a more strongly worded rant.
    </rant>
    Bottom line, just use an Oracle sequence if it's at all possible; otherwise, be prepared to write some bunches of code to deal with locking.
    John

  • Setting dynamic values to entity object

    Is there any way to set bean values (dynamic values) to Entity Object while commit the record, and how can i set these values using Groovy language
    Thanks in advance

    You need to give more information about the version of Jdev you use and your use case. read more -
    https://forums.oracle.com/forums/ann.jspa?annID=56

  • Default value at Account Object Field setup

    Hi,
    How to give default value as ‘On Demand’ for the Source field at the time of Account creation and also we need to bypass this default value if the channel is web service and data import. This default should only effect if it is being done from OD UI.
    I added below expression in DefaultValue
    ([<IndexedPick5>] = LookupValue("OCC_INDEX_CUST_LOV_ACCOUNT_5","On Demand")) AND (ExcludeChannel(‘Web Services’)) AND (ExcludeChannel(‘Import’))
    but it giving an error as below when clicking New button in Account Object:
    1] An error occurred calculating the default value for field 'Indexed Pick 5' in business component
    'Account'.(SBL-DAT-00412) [2] Could not evaluate expression 'Expr: 'LookupValue([<IndexedPick5>],"On Demand") OR (ExcludeChannel(‘Web Services’))'' for field 'Indexed Pick 5' in business component 'Account'.(SBL-DAT-00394) [3] CSSString doesn't support operator 'OR'(SBL-DAT-00479)
    Thanks
    Bob

    Try the following.
    IIf(ExcludeChannel(‘Web Services’) or ExcludeChannel(‘Import’), 'On Demand', '')
    Cheers!
    Shilei G

  • How to set the Default values for Info Objects in Data Selection of InfoPac

    Hi All,
    Flat file Extracion:
    How to set the Default values for Info Objects in Data Selection Tab  for Info Package
    ex: Fiscal Year Variant  Info Object having values 'K4' 'Y2' etc  in Flat file
    Initially  default value(not constant)  for this info Object value should be 'K4'  in Info Package
    If I set data selection value for this info object K4 it will retreive records with this selection only? how to handle
    Rgds,
    CV

    Hi,
    suppose as your ex. if you are having fiscalyear variant in the dataselection tab then specify K4 in the from column, again the ficalyearvariant row and click on insert duplicate row at the bottom . you will get another row . In that enter Y2 in the from column. now you can extract K4, y2 values .
    haritha

  • Not allows to assign default value to input field using values in datastore

    Hi Masters,
    Consider that I have one input field in a form. I should assign default value to it. I should assign to it, the value which i have stored in a datastore. When i run the application, if i give default value as 123 ,then it is working fine i.e., it is showing 123 in the textfield in form , but if i give the default value as STORE@ProductId, then it is not displaying that value in the form.
    Please help me out.
    Thanks & Regards,
    Kaushik Sreeram

    Hi,
    i faced this problem and here's what i concluded:
    There's no way you can set default value for input field dynamicly, since the default value of input control is caculated only once (i think on initializing of the iView). The input control and the data store are initialized at the same time, STORE@productID is empty that time...
    If you don't need to recieve value through the input field you're trying to initialize, but just to display the value from the store - I suggest you try using another control - Expression Box. It's value is calculated continiously, just like the Label's, and you can refere to it later.
    Regards,
    Yulia

  • How to set default value of a table using sequence number

    Dear all,
    Does any body know that how to set default value of a table
    using sequence number.
    But I don't want to use trigger to do that.
    Please help!!!!
    Eldon

    Andrew is essentially correct. You can get around the trigger,
    but not the sequence, if (and this may be a very big if) you can
    guarantee that every time an insert is done into the table, from
    whatever source, the statement looks something like
    INSERT INTO tbl VALUES (sequence.nextval,other_columns_values)

  • Unable to set up the default value in custom object 10,related item section

    Hi,
    Please help me out for the below issue
    Custom Object 10 we renamed to Quarterly Broker Review .In Quarterly Broker Review there is a related item section 'Activity'.
    In Quarterly Broker Review ,Activity related Section ,After clicking on The 'New Task' button 'Account Name' field in Quarterly Broker Review(Parent ) should be prefilled in the Activity Section(Related Item Section) in Account Name Field
    'Account Name' field is a Picklist Read Only field.
    Since it is a picklist read only field i couldn't write the expression in the 'Activity' Related section under 'Account Name' field
    you can also help me by reaching at '[email protected]'
    Thanks,
    Srinivas Merugu

    Hi Srinivas,
    As you know, you can refer to a field in a different object by using JoinFieldValue function. But this function is not available for all the object references. If you refer online help for JoinFieldValue function you would notice that from activity only CustomObjects 1,2 an 3 can be referenced using this function.
    If this is possible for the activity and CustomObject 10 then you go to the field named Account Id in Activity object and set a default value. I guess in the parent object "CustomObject10" Account Id will also be stored in "Account: Integration ID". So this field value can be copied into the Account Id field of Activity.
    Instead you could write a web service program to achieve this.
    Thanks
    Naren

  • Customizing Entity Object SQL Query prior to Insert?

    I am using an ADF BC Entity Object to store values from a multi-page form input process.
    At the end of the process, I plan to call a method that will programmatically take the values from the Entity Object and insert a new row to the database. I need to customize the query to add an encryption function to the insert for one of the fields. For example, instead of 'INSERT password' I need the SQL to be 'INSERT encrypt_fct(password)'.
    Is this possible and if so how?
    thanks

    Hi javaX
    Easiest way of achieving this in ADF BC is overriding the doDML method in your underlying EO's EntityImpl class. The following gives an example, assuming a table called users with username & password columns, where you wish to encrypt the password column with a SQL function named encrypt_fc:
    protected void doDML(int operation, TransactionEvent transactionEvent) {
      if (operation == DML_INSERT) {
        CallableStatement statement = null;
        String insertDML =
          "INSERT INTO users (username, password) VALUES (?,encrypt_fc(?))";
        statement =
          getDBTransaction().createCallableStatement(insertDML, 1);
        try {
          // Bind the statement parameters and execute the statement
          statement.setString(1, getUsername().toString());
          statement.setString(2, getPassword().toString());
          statement.execute();
        } catch (Exception ex) {
          throw new oracle.jbo.JboException(ex);
        } finally {
          try {
            statement.close();
          } catch (Exception nex) {
            /* Ignore */
      } else // operation == DML_UPDATE || DML_DELETE
        super.doDML(operation, transactionEvent);
    }Another way is to include the code for your encrypt function in your ADF model project. By this I mean convert the encrypt function to Java, then add it as a piece of code to your EntityImpl or a more generic library if needed elsewhere. This way you don't have to modify the doDML, but rather the EO setter routine to call your encyption function, and the unencrypted password isn't passed between ADF and the DB.
    Hope this helps.
    CM.

  • How to change default value in a table using ALTER TABLE

    Hi,
    How to change default value in a table
    I have a table TEST which has 2 fields CODE of Datatype VARCHAR2(10) and Indicator as VARCHAR2(1).
    I want to change the default value using ALTER TABLE TEST of field Indicator to 'I'.
    Any help will be needful for me
    Thanks and Regards

    user598986 wrote:
    Hi,
    How to change default value in a table
    I have a table TEST which has 2 fields CODE of Datatype VARCHAR2(10) and Indicator as VARCHAR2(1).
    I want to change the default value using ALTER TABLE TEST of field Indicator to 'I'.
    ALTER TABLE  test
    MODIFY (indicator DEFAULT 'I'); 
    Incidentally, INDICATOR is a keyword in Oracle, so you may have problems using it as a column name. If so, you'll have to enclose the column name in double-quotes, and be careful to use capital letters inside the quotes.
    Edited by: Frank Kulash on Aug 26, 2009 11:42 AM

  • How to set default value and after that , use it as control

    Hello,
    Currently i am making motor driver from labview, and i am facing one problem.
    When i connect to my board via labview, it will relay last position to global variable. After that, i have to go to loop, where i can send back  modified position to my motor control board
    In short, i have to control number, but that number default value should be writtem by another function when i start vi.
    any ideas how to do it ?
    Solved!
    Go to Solution.

    Let me know if any clarification is needed
    Kudos are always welcome if you got solution to some extent.
    I need my difficulties because they are necessary to enjoy my success.
    --Ranjeet
    Attachments:
    VI.vi ‏13 KB

  • Problem in populating lookup values based on the lookup query from database

    HI all
    I have problem of population look-up values based on look-up query
    I am giving the details what i am trying
    I need to populate the values from the UD_LDAP_USR table into the field of UD_USRGRPC_NisNetTriple of type lookup
    i planned to set the properties of lookup as like this
    look up query as select UD_LDAP_USR_COMMON_NAME as NisNetTriple from UD_LDAP_USR
    ColumnNames as UD_LDAP_USR_COMMON_NAME
    Column captions as UD_LDAP_USR_COMMON_NAME
    Column width as 30
    Lookup Column Name as UD_LDAP_USR_COMMON_NAME
    But when i try to add ColumnName as wht i mentioned above i m getting invalid property exception,update failed
    I am not sure about that are we able to use other Connector table prefix with UD into the another processFrom
    Let me give update on this issue
    Urgent,struck my work here
    thanks
    Nagaraj

    Thanks for the reply raghav
    I tried but it was not working
    I gave like what u specified but no use
    It is throwing exception like set look-up query for the field
    Any one help me out on this issue
    Edited by: Nagaraju Chowdary on Jan 21, 2013 3:41 AM
    Edited by: Nagaraju Chowdary on Jan 21, 2013 3:42 AM

  • How to intercept update on entity object using bc4j

    Hi all,
    I need to intercept a user from updating a particular entity object and create a new entity instead. I have a particular row in a database table that has a primary key with special meaning. If a user attempts to update this row, I want to automatically create a new row in the table with the information they entered and leave the original row unmodified. Any suggestions on how to do this at the entity layer?
    Thanks
    Mike

    Hi Sung,
    I've created 2 Entity Objects, named TestEo and OtherEo. The logic I've included is as follows: Before posting data for TestEo to the database (thus as part of the prepareForDML), I create a new instance of OtherEo, using the createBlankInstance method exposed on OtherEoDefImpl.
    However, the instance thus created ends up in a STATUS_UNMODIFIED, regardless of locking mode (I've managed to eliminate the locking mode as an issue).
    Could you give me an idea of where I'm going wrong? I've attached the prepareForDML() (with diagnostic msgs) and createBlankInstance() methods below.
    TestEoImpl.prepareForDML()
    protected void prepareForDML(int p0, TransactionEvent p1)
    switch (this.getDBTransaction().getLockingMode())
    case DBTransaction.LOCK_OPTIMISTIC:
    System.out.println("Locking mode: LOCK_OPTIMISTIC");
    break;
    case DBTransaction.LOCK_PESSIMISTIC:
    System.out.println("Locking mode: LOCK_PESSIMISTIC");
    break;
    // TODO: Override this oracle.jbo.server.EntityImpl method
    super.prepareForDML(p0, p1);
    OtherEoDefImpl otherEoDef = (OtherEoDefImpl) EntityDefImpl.findDefObject(
    "testapp.OtherEo");
    System.out.println("Entity Class: " + this.getClass().getName());
    switch (this.getEntityState())
    case EntityImpl.STATUS_DEAD:
    System.out.println("Entity State: STATUS_DEAD");
    break;
    case EntityImpl.STATUS_DELETED:
    System.out.println("Entity State: STATUS_DELETED");
    break;
    case EntityImpl.STATUS_INITIALIZED:
    System.out.println("Entity State: STATUS_INITIALIZED");
    break;
    case EntityImpl.STATUS_MODIFIED:
    System.out.println("Entity State: STATUS_MODIFIED");
    break;
    case EntityImpl.STATUS_NEW:
    System.out.println("Entity State: STATUS_NEW");
    break;
    case EntityImpl.STATUS_UNMODIFIED:
    System.out.println("Entity State: STATUS_UNMODIFIED");
    break;
    EntityImpl otherEo = otherEoDef.createBlankInstance(getDBTransaction());
    System.out.println("Entity Class: " + otherEo.getClass().getName());
    int state = otherEo.getEntityState();
    switch (state)
    case EntityImpl.STATUS_DEAD:
    System.out.println("Entity State: STATUS_DEAD - " + state);
    break;
    case EntityImpl.STATUS_DELETED:
    System.out.println("Entity State: STATUS_DELETED - " + state);
    break;
    case EntityImpl.STATUS_INITIALIZED:
    System.out.println("Entity State: STATUS_INITIALIZED - " + state);
    break;
    case EntityImpl.STATUS_MODIFIED:
    System.out.println("Entity State: STATUS_MODIFIED - " + state);
    break;
    case EntityImpl.STATUS_NEW:
    System.out.println("Entity State: STATUS_NEW - " + state);
    break;
    case EntityImpl.STATUS_UNMODIFIED:
    System.out.println("Entity State: STATUS_UNMODIFIED - " + state);
    break;
    OtherEoDefImpl.createBlankInstance()
    public EntityImpl createBlankInstance(DBTransaction p0)
    // TODO: Override this oracle.jbo.server.EntityDefImpl method
    return super.createBlankInstance(p0);
    Output - Test 1
    Locking mode: LOCK_OPTIMISTIC
    Entity Class: testapp.TestEoImpl
    Entity State: STATUS_NEW
    Entity Class: testapp.OtherEoImpl
    Entity State: STATUS_UNMODIFIED - 1
    Output - Test 2
    Locking mode: LOCK_PESSIMISTIC
    Entity Class: testapp.TestEoImpl
    Entity State: STATUS_NEW
    Entity Class: testapp.OtherEoImpl
    Entity State: STATUS_UNMODIFIED - 1

  • How to retrieve line Item values from an object using groovy

    def RevenueObject = nvl(ChildRevenue,0);
    println('revenueItems==='+revenueItems.size());
    while(RevenueObject.hasNext())
    def revenueLine = RevenueObject.next();
    revenueLine.setAttribute('Test_c', 'Hello');
    } Groovy Scripting
    Error : Getting null value for Revenue object
    Exception in expression "OpportunityEO" trigger "getRevenueItems" : groovy.lang.MissingMethodException : No signature of method: oracle.jbo.server.ViewRowSetIteratorImpl.size() is applicable for argument types: () values: [] Possible solutions: is(java.lang.Object), find(), use([Ljava.lang.Object;), with(groovy.lang.Closure), sleep(long), find(groovy.lang.Closure)
    at "OpportunityEO" trigger "getRevenueItems" line 7
    No signature of method: oracle.jbo.server.ViewRowSetIteratorImpl.size() is applicable for argument types: () values: [] Possible solutions: is(java.lang.Object), find(), use([Ljava.lang.Object;), with(groovy.lang.Closure), sleep(long), find(groovy.lang.Closure)

    Depending on the message the line number might be in one of the fields:
    MESSAGE_V1
    MESSAGE_V2
    MESSAGE_V3
    MESSAGE_V4
    Although if the message simply is not meant to include the line number, it won't be there. That's the way it is. If there is a user exit available, you may add your custom messages with the line number. In some user exits (in sales order for sure) there is a special variable (flag), which is set when the BAPI runs the transaction.

Maybe you are looking for