Default value? Trigger?

Hi all,
I got one Oracle 10g problem here, not sure you can help me or not.
If a table has a column which has "default value" setup.
Example
CREATE TABLE KENTEMP
refno number(10),
user_create varchar2(30) Default USER not null
And it also has a trigger with following contents:
If :new.user_create is Null then
:new.user_create := 'TEST';
end if;
If I going insert a record with null value on user_create column.
In some Oracle database, the create_user will become USER, some will become "TEST".
Do you understand why?
Thanks

In some Oracle database, the create_user will become USER, some will become "TEST". Are you running the same INSERT statement on all these databases? Because the default value gets applied before the trigger fires, and I would expect that to be consistent across all databases.
SQL>  create table defval (col1 number, col2 varchar2(30) default user)
  2  /
Table created.
SQL> insert into defval (col1) values (1)
  2  /
1 row created.
SQL> select * from defval
  2  /
      COL1 COL2
         1 APC
SQL> create trigger defval_trg before insert on defval for each row
  2  begin
  3    if :new.col2 is null then
  4       :new.col2 := 'TEST';
  5    end if;
  6  end;
  7  /
Trigger created.
SQL> insert into defval (col1) values (2)
  2  /
1 row created.
SQL> select * from defval
  2  /
      COL1 COL2
         1 APC
         2 APC
SQL> insert into defval (col1,col2) values (3, null)
  2  /
1 row created.
SQL> select * from defval
  2  /
      COL1 COL2
         1 APC
         2 APC
         3 TEST
SQL> Cheers, APC
Blog : http://radiofreetooting.blogspot.com/

Similar Messages

  • I need to pass null as a default value for a parameter in Before Trigger

    Hi All,
    I am using Before trigger function in calculation tab which has some set of parameters.So, I accept some parameters which are passed to this Before Trigger function and need these parameters default value as null.
    To be clear I want to set the Default value for a parameter in workbook to be NULL and pass the same to the calling Function.
    please help me.
    Thanks in advance

    Hi All,
    I am using Before trigger function in calculation tab which has some set of parameters.So, I accept some parameters which are passed to this Before Trigger function and need these parameters default value as null.
    To be clear I want to set the Default value for a parameter in workbook to be NULL and pass the same to the calling Function.
    please help me.
    Thanks in advance

  • How can I make one entity attribute change trigger another's default value?

    Guys and Gals,
    Using JDev 11.1.2.1.0
    I have an order form which has a LOV (Customers) and an address field. The address field should contain the default address associated with the selected key in the LOV.
    To do this, I have an entity (Order) with two attributes (CustomerID & Address). Address has its default value set to "adf.object.getDefaultAddress" which returns the default address for the CustomerID. This only works on initial load.
    How would I make this adf.object.getDefaultAddress trigger when I select a different LOV CustomerID in the View Object?
    I've tried various things but am a little confused. Is there something akin to partial triggers for entity objects?
    I can provide pictures, code, etc.
    Thanks,
    Will

    you can try this.
    go the the setter method in your EntityImpl class for the LOV attribute
    public void setCustomerID(Number value) {
            setAttributeInternal(CustomerID, value);
            //here call the setAddress() method
        }in your page, set the customerID autosubmit to true and make the Address field PPR the customer Id.
    <af:selectOneChoice value="#{bindings.CustomerID.inputValue}"
                               id="soc1"
                               autoSubmit="true">
            </af:selectOneChoice>
            <af:inputText value="#{bindings.Address.inputValue}"
                                   partialTriggers="soc1">
            </af:inputText>

  • Using a trigger to set default values

    Hi
    Does anyone know of a way to set a default value of a column in Oracle trigger code? I am trying to write an on Update trigger to set the default value of a column in a relationship when the parent is updated.
    Thanks
    Mike

    Solution :
    Suppose you have 2 tables, Emp and Dept,
    In this case Dept is parent and emp
    is child.
    So if you update parent (change deptno
    from 20 to 21 , then you want the same
    to be reflected in emp table i-e all the
    record in emp table having the deptno as 20
    now should have 21.
    Create trigger upd_emp
    after update on dept
    begin
    update emp
    set deptno = :new.deptno
    where deptno = :old.deptno;
    end;
    Hope this helps
    Naresh
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Mike D ([email protected]):
    Hi
    Does anyone know of a way to set a default value of a column in Oracle trigger code? I am trying to write an on Update trigger to set the default value of a column in a relationship when the parent is updated.
    Thanks
    Mike<HR></BLOCKQUOTE>
    null

  • Default Values

    It's important to remember that DEFAULT values are only used when a column isn't specified in an INSERT or MERGE, or when the DEFAULT keyword is used. If you don't explicitly declare a DEFAULT value, Oracle implicitly defines the default value to be NULL, and the DEFAULT keyword will even work with such.
    Does say this, does the possibility Exist to for example insert a default value 0 in a column (datatype number) (Default value 0) without using trigger and column is specified (e.g. I don't know from front-end if is specified)?
    Thanks in advance to all

    I don't know a lot about Forms, but if it will generate in insert statement like this:
    SQL> CREATE TABLE t(a NUMBER, b NUMBER DEFAULT 0 NOT NULL);
    Table created.
    SQL> INSERT INTO t VALUES (1,NULL);
    INSERT INTO t VALUES (1,NULL)
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("OPS$ORACLE"."T"."B")then yes, unless you can control the insert statement, you will need to use a trigger. The explicit NULL in the VALUES list will override the default.
    John

  • Current month as default value in a parameter porlet

    Hello,
    i need to pass month as a parameter to a discoverer worksheet that i've added to my page in portal.
    i'd been doing this with a single parameter form setting the default value manually while testing page.
    now i'd need to set the default value as the current month to put the page in "production".
    i think it's not possible to get the date from the system (sysdate) in a single parameter form but maybe this can be done with an omniportet.
    thanks for helping,
    dani

    If you are using a datatemplate , you can have a beforereport trigger that will have a package call.
    In the package spec, define a date variable and also define the function beforereporttrigger that retruns boolean.
    In the body, define the beforereporttrigger function with
    begin
    select sysdate into specvariable from dual
    return(true);
    end;
    You can then use the variable in the datatemplate as :variable.
    Hope this helps.
    - Vasu -

  • Unable to populate the default value  using form personalization

    Hi, I need to default a value in order managemnt for waybill number
    shipping -- transaction - delivery - detail --
    In Order management
    Shipping - Transactions
    Source system -- Order management
    From Order number - Any ordernumber
    say find
    I want to default this Detail ( xxxxx) as Way bill
    value of :DLVB.DETAIL_LABEL
    I have put the following condition on form personalization
    Condition tab
    Triger event
    When new record instance
    Trigger object
    dlvy_s
    Processing mode both
    Actions tab
    Property
    Object type Item
    Target Object DLVY_S.WAYBILL
    Property name Value
    Value
    :DLVB.DETAIL_LABEL
    but it is not defaulting... Appreciate if any one has idea what is wrong in this.
    Edited by: 885022 on Oct 3, 2011 11:31 AM
    Edited by: 885022 on Oct 3, 2011 11:33 AM

    yes Srini
    as we dont have any option via personalization to set the default values ,it can be done through controller extension ,
    in processRequest method of extended controllere get the control for that particular field where u want to set the default value and set the value using fieldbean.setValue(pagecontext,value);
    in case of any particular case ,please post in the forum
    thanx
    Pratap

  • Field with a default value from another field

    I need to populate a field as the default value from another field that the user inputs. I've tried the scripting that I found from the below Topic in the Archived Forums, but I'm not able to make it work. I've tried numerous variations and still to no avail. I tried to make the scripting work in Acrobat 6 and then decided that maybe I needed to upgrade, so I'm now trying it in Acrobat 8 with no results. Can anyone help?
    Topic
    Acrobat 5 - field with default value of another field
    Ben PF - 03:31am Mar 23, 2007 Pacific
    How can I have a field date2 which has the default value of field date1, but which can be edited by the user if necessary without changing the value of date1.
    I've tried, but I just can't figure it out!
    Any help much appreciated.
    Ben
    | Back to Topic List | Bookmark | Subscribe
    To start a NEW discussion click on the Back to Topic List link and select Add Topic.
    If you are in an archive forum please go up to the main topic list (archives are read only).
    Messages
    2 messages. Displaying 1 through 2.
    First Previous Next Last Show All Messages
    Gene Dianoski - 5:22am Mar 23, 07 PST (#1 of 2)
    This, or some variation of this, should work:
    if(this.getField("date2").value == ""{
    this.getField("date2").value = this.getField("date1).value;
    | Bookmark back to top
    Ben PF - 6:49am Mar 23, 07 PST (#2 of 2)
    Thanks very much.
    I put it in at document level to start, but it didn't run the script automatically when date1 was first filled in, so I have put it in as a mouse exit action in date1 and it works a treat.
    Thanks for your help.
    Ben

    Okay forget what I posted above and lets start over. Go to your first field and under Properties -> Actions Tab -> Select Trigger -> On Blur Run A JavaScript.
    Put this:
    this.getField("myField2").value = event.target.value;
    Make sure that you replace ("myField2") with the actual name of your second field. I just tested this and it works for Acrobat version 6.
    I haven't been doing as much javascripting as I used to, so sometimes I too make some basic mistakes.

  • Set Radio Group Default Value Based on a Select List Change Event

    Apex 4.2
    I have a radio group that is source is below. It returns 3 radio group item All,Miv,Courier
    SELECT type d, code r FROM vw_lov_depot
      WHERE svc_name = :P320_DEPOT
      ORDER BY 1
    The radio group is only populated when :P320_DEPOT gets a value, this is a select list.
    I am trying to set the radio group to  default to this value Miv it would use the statement
    SELECT type d, code r FROM vw_lov_depot
      WHERE svc_name = :P320_DEPOT
      and type ='Miv'
      ORDER BY 1
    I have tried creating a dynamic action on Select list change to populate the default value of the radio group...no joy I also tried a computation. how can I set this default value on when list changed.
    Thanks
    I have got the default Radio Group Selection working by doing a computation before region on the radio group and calling its select statement and setting the value. But the problem is now I cannot change the radtio group as I do it fire the before region trigger and sets it back to the default value....any help?

    Hi,
    Could you please create example to apex.oracle.com?
    Regards,
    Jari

  • Created by and creation date default values on form

    Hi Friends,
    I am a form newbie. I am creating a simple form.
    I have non-display column/fields:
    a.) CREATED_BY - how do I put the default value of the user login ID upon inserting record?
    b.) CREATION_DATE - how do I put the SYSDATE upon inserting the record?
    c.) UPDATED_BY - how do I put the default value of the user login ID when updating the record?
    d.) UPDATE_DATE - how do I put the SYSDATE when updating the record?
    Thanks a lot in advance

    Hi,
    In the PRE-INSERT trigger, write,
         :CREATED_BY    := GET_APPLICATION_PROPERTY(USERNAME);
         :CREATION_DATE := DATE;And in the PRE-UPDATE trigger, write,
         :UPDATED_BY  := GET_APPLICATION_PROPERTY(USERNAME);
         :UPDATE_DATE := DATE;Then your issue will be solved.
    Regards,
    Manu.
    If my response or the response of another was helpful, please mark it accordingly

  • ALV Grid default values for new rows added with Add/Insert buttons

    Hi!
    Help, please,  to find a way how to set default values for new rows added with Add/Insert buttons in
    ALV Grid.

    I have found salution:
    ALV Grid u2013 Insert row function
    Sometimes we need to assign some default values when we create a new row in a grid using standard ALV Append row button. In our scenario we will see how to assign default values to Airline Code (CARRID), Flight Connection Number (CONNID) and Flight date (FLDATE) when a new row is created. To do that we need to handle DATA_CHANGED event in the program like mentioned below.
    Definition of a class:
    Code:
          CLASS lcl_event_receiver DEFINITION
    CLASS LCL_EVENT_RECEIVER DEFINITION.
      PUBLIC SECTION.
    METHODS:
         handle_data_changed
         FOR EVENT data_changed OF cl_gui_alv_grid
         IMPORTING er_data_changed
                           e_ucomm.
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    Implementation of a class:
    Code:
    CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
      METHOD HANDLE_DATA_CHANGED.
        DATA: dl_ins_row TYPE lvc_s_moce.   " Insert Row
          FIELD-SYMBOLS: <fs> TYPE table.    " Output table
    Loop at the inserted rows table and assign default values
        LOOP AT er_data_changed->mt_inserted_rows INTO dl_ins_row.
          ASSIGN er_data_changed->mp_mod_rows->* TO <fs>.
          loop at <fs> into ls_outtab.
            ls_outtab-carrid  = 'LH'.
            ls_outtab-connid  = '400'.
            ls_outtab-fldate  = sy-datum.
            MODIFY <fs> FROM ls_outtab INDEX sy-tabix.
          endloop.
        endloop.
      ENDMETHOD.                    "handle_data_changed
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
    Register the events to trigger DATA_CHANGED event when a new row is created.
    Code:
        CALL METHOD OBJ_GRID->REGISTER_EDIT_EVENT
          EXPORTING
            I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.
        CALL METHOD OBJ_GRID->REGISTER_EDIT_EVENT
          EXPORTING
            I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.

  • Query mode & default values

    Hi,
    When a block is put into QUERY MODE all the
    fields in it are blanked.
    I am looking for a way to put in default
    values in some of my fields when in
    query mode.
    Is this possible.
    Any help is appreciated.
    Regards,
    Klas Malmstrom
    [email protected]

    You could try the When-New-Record-Instance trigger for the block and assign values to items when the :SYSTEM.MODE = 'ENTER-QUERY'. Users may be able to change these default values.
    To have hidden default values use the default where property of the block and either set on the property sheet or dynamically in the PRE-QUERY trigger; or assign values to database items in the PRE-QUERY trigger.

  • Default values on insert

    This has probably been asked and answered, but I couldn't find the answer
    when searching the newsgroups. On most of my database tables, there is a
    date column to store the date when a row was added (it is never changed
    after insert). Without Kodo JDO, we would just set the default value for
    the column in the database. What is the easiest solution for this with
    Kodo?

    Is the only way to do what I want is to use InstanceCallbacks?Yeah, I would recommend using jdoPreStore() to set it to the current
    date.
    The other option is to have a trigger in the database itself override
    the value of the "date_created" field to the current time upon insert.
    In article <[email protected]>, Frank Riley wrote:
    Tom Davies <[email protected]> wrote in
    news:b5o7dg$gak$[email protected]:
    Frank Riley wrote:
    This has probably been asked and answered, but I couldn't find the
    answer when searching the newsgroups. On most of my database tables,
    there is a date column to store the date when a row was added (it is
    never changed after insert). Without Kodo JDO, we would just set the
    default value for the column in the database. What is the easiest
    solution for this with Kodo?You can set a default in the constructor of your persistent class:
    class Foo {
    public Foo(String v)
    if (v == null)
    v = "xyz";
    private String v;
    }But, for what I'm doing, this would set the field to the time the object
    was created, not the time the object was persisted to the database. Is
    the only way to do what I want is to use InstanceCallbacks?--
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • How to assign a default value on a Tabular Report?

    version 3.2.1
    I have a column in a Tabular Report (SQL Query (updateable report) ) that I would like to default to a value every time that the Add Rows button is clicked. This column needs to have the same value for every row.
    How do I set a default value on the column?
    Thanks,
    Joe

    I've run into the same problem. The 'Default' value isn't even appearing in the form, let alone getting stored.
    I'm not 100% certain (I'm still new to Apex too), but I think that the 'Default Type' and 'Default' value fields of the 'Tabular Form Element' might only apply to new records, ie when using the Tabular Form to create new records.
    In my case, I'm displaying existing records and I've been trying to enter a default new value for a particular field, ie change the value in the field for existing records from null to today's date. I couldn't get it to work and the more I think about it the more I realise that it is probably not the right way to do it.
    One alternative would be to put the SYSDATE into the source SQL (noting that changing an existing tabular form definition would cause an error, so I would have to create a new tabular form). But another (and I think preferable for me) option is to create a trigger that will put the SYSDATE into the field as each record is updated.
    Regards,
    Peter

  • Default values OM infotypes (actions)

    Hi Experts,
    anybody knows how to set default values in OM infotype when running OM actions?
    I do this in PA component through dynamic actions, but they're not applicable in OM.
    Thank you very much!

    Hi Ema,
    I think you can use a exit or badi which will trigger a workflow on saving a record. In this you have to also take into cosideration the functionality of locking record.
    Once the approval is obtained then only, your logic should actully create the valid positions.
    Thanks!
    Regards,
    Chetan

Maybe you are looking for