Insert value into a column based on value of another column

Hi,
I am trying to insert a value into a record based on a column in
the record, using a trigger. The complication arises because
the new value is selected from the same table. For example:
SELECT COL1, COL2, COL3, COL4 from TABLE1
I want to set COL2 and COL3 based on the value of COL4. And to
get the value of COL2 and COL3, I will go back to TABLE1 and set
the condition to TABLE1.COL1 = :NEW.COL4
I cannot seem to execute the trigger as I get the message "ORA-
04091: table SYSTEM.TABLE1 is mutating, trigger/function may not
see it" everytime.
Is this the correct way to achieve what I wanted? Or is there
another way?
Appreciate your feedback. Thank you in advance.

Hi,
I am trying to insert a value into a record based on a column in
the record, using a trigger. The complication arises because
the new value is selected from the same table. For example:
SELECT COL1, COL2, COL3, COL4 from TABLE1
I want to set COL2 and COL3 based on the value of COL4. And to
get the value of COL2 and COL3, I will go back to TABLE1 and set
the condition to TABLE1.COL1 = :NEW.COL4
I cannot seem to execute the trigger as I get the message "ORA-
04091: table SYSTEM.TABLE1 is mutating, trigger/function may not
see it" everytime.
Is this the correct way to achieve what I wanted? Or is there
another way?
Appreciate your feedback. Thank you in advance. I'm not sure what you mean when you insert a value into a
record, but if you are setting a value in a column of the same
record using a trigger, then it's easy.
:new.COL2 := ....:new.COL4...
:new.COL3 := ....:new.COL4...
The trigger must be 'INSERT or UPDATE' and 'FOR EACH RECORD'.
If you are setting a different record in the same table, the
solution is much more difficult.

Similar Messages

  • Validate list column based on entry from another column

    Hi there
    I would like to ensure that a value is entered in list column B, if there is a value of 'Yes' in list column A.
    I assume this formula is entered in the Validation settings of the list, but cannot work out what is required.
    Is it something like?     =IF([Col-A]="Yes",IF(LEN([Col-B]<1,TRUE,FALSE),TRUE)
    Thanks
    Asher
    Fast, Cheap, Good. Choose any Two!

    Ahh, found a solution:
    =IF([Col-A]="Yes",IF([Col-B]<>"",TRUE,FALSE),TRUE)
    Now i need to do the same for other fields in the list, and these formulas must go together in the validation settings of the list, which is going to look messy.
    If i want to do the same with columns C and D, how would i append this to the formula?
    =IF([Col-C]="Yes",IF([Col-D]<>"",TRUE,FALSE),TRUE)
    Thanks
    Asher
    Fast, Cheap, Good. Choose any Two!

  • Inserting paragraphs into a report based on a certain condition

    Hi, I need some advice on the best method to insert paragraphs of text into a report.
    I have +/- 100 paragraphs which are in text format, I need to insert these into the report based on certain conditions.
    I have tried entering them into the trailer section one after the other and using conditional formatting to display them if the the condition is met. This works well but I ran out of space in the trailer section.
    I then thought of saving the paragraphs somewhere on the server as seperate txt files and inserting them into the report using file links,
    or I could put these paragraphs into a table and then insert them from there, some of these paragraphs are longer than 4000 characters,
    Please advise on the best method
    Thank you
    Michael

    Hi,
    If the button and the textfield are on in the same subform then this code should work in the click event of the button
    (This is JavaScript code so make sure the code is set to JavaScript and Client on the drop downs in the script window)
    (assuming the name of the textfield is TextField1)
    TextField1.rawValue = "some value";
    If they are in different subforms then you have 2 options
    Please note in both these options it is easier if the subforms have names ( I am assuming this to keep samples simple)
    option 1 -
    use the parent object to move up the tree till you are at the same level as that of the subform that contains the textfield
    e.g. 
    (Click Event of the button)
    this.parent.subformname.TextField1.rawValue = "some value";
    option 2 -
    Use the resolve node to make your way down from the top level of the form
    xfa.resolveNode ("form1.subformname.TextField1").rawValue = "some value";
    Hope this helps
    Malcolm
    p.s. I am making assumptions as the image/file you attached did not appear for me.

  • Can I assign a task based on information from another column?

    For example:
    Let's say I have a column called "Question Type" and this column has multiple checkbox choice, those being:
         Math
         Science
         History
         English
         Other
    I want to allow users to be able to select multpile catagories for the question, like making one both math and science (which right now is completely possible)
    I then want another column that says who the problem is assigned to. Bob is good at math, Joe at science, Jill at histroy, Jenn at English, and Billy handles everything else.
    1) Is there a way that the task can be automatically assigned to my math expert Bob when I specify that the item I am adding is a math problem?
    2) If I make a problem both math and science, can the task be assigned to both Bob and Joe?
    Thanks in advance!

    Hi,
    According to your post, my understanding is that you wanted to assign a task based on information from another column.
    To assign task to multiple users, you need to:
    Create a workflow and add action: Start Approval Process.
    Click these user, select the Group, change One or a time(serial) to
    All at onec(paralle).
    Right click the action, select Properties, click ExpandGroups, change No to
    Yes.
    Then you can assign task to each member of the group.
    I recommend to follow the steps as below to achieve what you want:
    Create a custom list, add columns: Question Type(Choice); Assigned to(Person or Group).
    Create a workflow associated the list.
    Add conditions and action as below:
    Then the task can be automatically assigned to 123 when the item is a math problem.
    In addition, if you make a problem both math and science, the task can be assigned to both 456 and 789.
    You can add other conditions to satisfy all the requirements.
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Is it possible to create a Column with Conditional Mandatory with another Column?

    Is it possible to create a Column with Conditional Mandatory with another Column?
    For example
    In a Table we have column A, B, C.
    A is Primary Column.
    B is Optional
    C is Conditional Mandatory.
    A B
    C
    12345 ABC
    OK
    12346 NULL
    NULL
    12347 ABC
    OK
    Only if the B Column has the value then only C column should be mandatory

    I guess you can't create a condtional mandatory column directly. However, you can use check constraint to on the column
    create table YourTable
      A int primary key,
      B char(3),
      C int,
      constraint ch_con check(
                                B
    is not null
    or C is null

  • Update/Insert into two fields based on value of one.

    How would I do the following in ADDT.
    Example:
    I have a database about dogs. When user completes form they make a selection from a recordset feed drop down box of breeds. Lets say they select "PUG" based on the selection two fields are populated from the same recordset size="small" and color="brown".
    I hope I've explained this well enough
    Thanks!
    Rich

    >>
    I think I understand. I'm using two forms One to select the item from a list. I'm passing that items value to the next page where I'm placing that value into a query which will give me the options available based on the query results?
    >>
    what I meant, is first have the user insert the new record and let him specify the desired "breed" already there -- the following page(s) will need to make sure that he´s going to update the newly inserted record with additional values, that´s why you should use the "SELECT dog_id FROM dog_table ORDER BY id DESC LIMIT 1" - query on page 2. However, once this new record had been clearly identified "by id", you can add whatever options available in the secondary table which are related to the "dog_id" (breed) that has been stored when inserting the new record. Maybe *I* don´t get it, lol ;-)
    >>
    I currently do this the dropdown value to a case statement that takes the value of the dropdown and determines the correct values for the database update
    >>
    OK, but when each dog just has one option
    (thought it were two ones: "color" and "size"), isn´t your existing dependant dropdown enough for specifying that "based on breed" option without having to use a hidden field at all ? Ah well, have you ever used ADDT´s / Kollections "dependant drop-down" wizard -- that should do it for one option
    >>
    hidden field that I need to update value based on what the value is above
    >>
    humm -- updating the value of a hidden field in the very same page then ? Never heard of this being possible apart from using some hand-made javascript.
    Guess I gotta ask my dog what it thinks about all that :-)
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Custom table column based on value scale

    I want to custom table column based on the vaules.
    I understood I need to to /1000000 in the column definition and custom ###,###,###M.
    But sometimes it can be Kilos and sometimes Billions.
    I don't want to display 0.02M or 200000M.
    How can I define conditional custom according to the current value?

    Try doing what I said here and see if it works for you...
    Re: Represent numbers in thousands

  • Insert data into sql database where the values are in an array

    Hello Experts,
    using vbscript i want to store data in MS SQL. i have prepared a script which works fine when i provide the static value but in actual i get the values in an array and now want to store values from there.
    Below is not complete code but the block in question.
    oRecordset_Working.Open "INSERT INTO tbl_work (release, version, state, Arch)" & _
    "VALUES ('5.2', '11.25' , 'Active', 'XYZ')", _
    oConnection, adOpenStatic, adLockOptimistic
    i verified the database and can see the information is feeded.
    What i really want to make work is:
    for i=0 to UBound (arrValues)
    oRecordset_Working.Open "INSERT INTO tbl_work (release, version, state, Arch)" & _
    "VALUES ('arrValues(i)')", _
    oConnection, adOpenStatic, adLockOptimistic
    Next
    logically it is incorrect as INSERT query comes inside the loop but then how can someone make it work?
    can someone help me with this?
    -KAKA-

    Here is the preferred method of inserting multiple values into multiple fields.  It is very fast and very easy to set up.
    Const adBSTR = 8
    Const adInput = 1
    Const CONNECTION_STRING = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\temp\test.mdb;Persist Security Info=False"
    Const SQL_INSERT = "INSERT INTO Table1(ID, Name, Notes) VALUES(?, ?, ?)"
    Set conn = CreateObject("ADODB.Connection")
    conn.Open(CONNECTION_STRING)
    Set cmd = CreateObject("ADODB.Command")
    With cmd
    .ActiveConnection = conn
    .CommandText = SQL_INSERT
    .Prepared = True
    ' create parameter object and assign to command object
    .Parameters.Append .CreateParameter("ID", adBSTR, adInput)
    .Parameters.Append .CreateParameter("Name", adBSTR, adInput)
    .Parameters.Append .CreateParameter("Notes", adBSTR, adInput)
    End With
    ' bind and insert values
    For i = 2 To 10
    cmd.Parameters("ID") = "ID" & i
    cmd.Parameters("Name") = "Joe" & i
    cmd.Parameters("Notes") = "My notes"
    cmd.Execute
    Next
    conn.Close
    ¯\_(ツ)_/¯

  • Filter column based on values in second column

    I have a 7 columns (A-G). I want to add a filter to return rows if the value in column D exists anywhere in column C (values in column D and C do not necessarily match).
    Is this possible? I tried creating a filter for column D based on column C using the 'Filter based on results of another request' functionality, but it did not work.
    Create/Edit Filter>Filter based on results of another request
    Column: column D
    Relationship: is equal to any
    Saved Request: same request
    Use values in Column: column C

    Okay, it looks like you are using the same query for both the main and subquery. That won't work.
    1) Create a query with one column, column D. Name it and save it.
    2) Now build your main report with all the columns you desire and on column C, apply the filter "based on results..." and have it point to column D of the subquery in step 1.

  • Color a column based on value in another column in tableview

    I am using a tableview iterator to display data in a bsp page. I want to color a cell in particular column (column 4), when a value in another column (column 2) on that same row is greater than 20. I can color the cell in column 2 but am not able to color the cell in column 4. How can I accomplish this?
    This is what I have. Looks like val1 is losing it's value.
    CASE p_column_index.
        WHEN 2.
          ASSIGN p_row_data_ref->* TO <row>.
          ASSIGN COMPONENT 'ZTGT' OF STRUCTURE <row> TO <col>.
          VAL = <col>.
          IF VAL GT '20'.
            val1 = p_row_index.
            p_style = 'celldesign:CRITICALVALUE_DARK'.
          ENDIF.
        WHEN 4.
            if p_row_index = val1.
              p_style = 'celldesign:CRITICALVALUE_DARK'.
            endif.
        WHEN OTHERS.
    do nothing
      ENDCASE.

    The reason val1 is "loosing its' value" is presumably because you have defined it in the method as a local variable. So each time you call the RENDER_CELL_START method it is is newly initialised. So if you make this an instance attribute it will retain its' contents across method calls.
    Cheers
    Graham Robbo

  • Why does insertion location into GridLayout differ based on inputs?

    Hello,
    I wrote a loop that inserts a run-time determined number of checkboxes into a GridLayout.
    For instance, if the user wants 5 checkboxes (decided at run-time), then the program creates 5 new checkboxes and inserts them into a (5 rows, 1 col) grid.
    The checkboxes appear correctly as 5 rows and 1 column.
    However, if the user wants a lot of checkboxes, (ex: user wants 10 checkboxes), then the program inserts the checkboxes in the wrong order.
    Instead of
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    It inserts like this:
    1 2
    3 4
    5 6
    7 8
    9 10
    Notice how the checkboxes appear in a (5 row x 2 column) grid.
    I dont know why the exact same lines of code [code that generates a (user defined number of rows x 1 column)] create two different layouts based on the size of the input.
    I ONLY want to have ONE column, no matter how many lines of input. I put a JScrollPane on the panel that has the GridLayout because the i know that a lot of checkboxes wont be able to fit entirely on that one little section that has the GridLayout panel.
    Can anyone explain why the output differs based on the input?

    The following quote from the API documentation for GridLayout may help you understand what's happening:
    "When both the number of rows and the number of columns have been set to non-zero values, either by a constructor or by the setRows and setColumns methods, the number of columns specified is ignored. Instead, the number of columns is determined from the specified number or rows and the total number of components in the layout. So, for example, if three rows and two columns have been specified and nine components are added to the layout, then they will be displayed as three rows of three columns. Specifying the number of columns affects the layout only when the number of rows is set to zero."

  • Deriving 1 Value from 2 Fields Based on Values in Fields

    I have a query that needs to return 1 of my values based on the values from 2 fields from 2 tables. However, the value should only be returned in 1 field and one of the fields should be evaluated first. If this first evaluated field has a certain value ('Y') then the other field is ignored.
    To be more clear, per the normal query below, what I want is to somehow, if possible, combine the case t2.el_contr and case t1.contr_type statements so that one field, say: mbr_contr_type_desc returns a value.
    So that if the value of t2.el_contr is 'Y' then 'SUB CHILD' is returned. It is important that this field should be evaluated first (If the value of it is 'Y' then the other field evaluation can be ignored). If this is not 'Y', then t1.contr_type should be evaluated and the values as listed below also returned to mbr_contr_type_desc.
    I know the following isn't correct, but it might better illustrate what I'm trying to do (the normal query is below this)
    case t2.el_contr
    when 'Y' then 'SUB CHILD'
    case t1.contr_type
    when 'A' then '1 PARTY MALE SUB'
    when 'B' then '1 PARTY FEMALE SUB'
    when 'C' then '2 PARTY MALE SUB'
    when 'D' then '2 PARTY FEMALE SUB'
    when 'F' then 'FAMILY MALE SUB'
    when 'G' then 'FAMILY FEMALE SUB'
    end as mbr_contr_type_desc
    In an Access query I would do the following in a column:
    iif([el_contr]='Y',"SUB CHILD',SWITCH([contr_type]="A","1 PARTY MALE SUB",[contr_type]="B" etc.))
    *NORMAL QUERY*
    select t1.ssn
    t1.type,
    t1.grp_id,
    t1.contr_type,
    t2.el_contr,
    case t2.el_contr
    when 'Y' then 'SUB CHILD'
    end as mbr_contr_type_desc_2,
    case t1.contr_type
    when 'A' then '1 PARTY MALE SUB'
    when 'B' then '1 PARTY FEMALE SUB'
    when 'C' then '2 PARTY MALE SUB'
    when 'D' then '2 PARTY FEMALE SUB'
    when 'F' then 'FAMILY MALE SUB'
    when 'G' then 'FAMILY FEMALE SUB'
    end as mbr_contr_type_desc_1
    from member_elig t1
    inner join grp_master t2 on
    t1.grp_id = t2.grp_id

    Perfect!
    Thanks, didn't know that existed. Still learning my way around pl/sql..
    One other (unrelated) question..when i hit the CTRL+LEFT ARROW* button in my SQL window, it will not tab back. This is really annoying! I have looked through PREFERENCES-EDITOR and can't seem to find any setting that will allow this. Do you know of any way to change this so I can tab backwards/fowards through code in the SQL window?
    Thanks for any suggestions!
    *Or CTRL+RIGHT ARROW for that matter..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Assigning a Numeric Value in a Cell Based on Text in Another Cell

    In advance, thanks for your assistance. I'm trying, in vain, to assign a numeric value in a cell based on text (from a dropdown menu) in another cell. For example, in cell A5 I have a dropdown list that includes the options "blue", "red", "white", and "gold." I want cell C15 to be 2 if A5="blue"; I want C15 to be 0 if A5="red"; I want C15 to be 2 if A5="white"; and, I want C15 to be 1 if A5="gold."

    Tippet,
    This is a job for LOOKUP.
    The expression for the Result cell is: =LOOKUP(A2, Lookup :: A1:A4, Lookup :: B1:B4)
    The aux. table contains the matches that you assign for the colors.
    Regards,
    Jerry

  • Populate f4 values of a field based on value of other field

    Hi,
    I have created select options using WDR_SELECT_OPTIONS.For one of the fields ,f4 values should be based on value of another field in the screen.
    How will i achceive this requirement.
    I got a link about the same but that is not using WDR_SELECT_OPTIONS
    http://www.sdn.sap.com/irj/scn/logon?redirect=/irj/scn/wiki?path=/display/WDABAP/Using%20Search%20help%20attachments%20for%20WebDynpro%20ABAP
    I got another link
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/606288d6-04c6-2c10-b5ae-a240304c88ea?quicklink=index&overridelayout=true
    which I am going to try
    Thanks
    Bala Duvvuri
    Edited by: Bala Duvvuri on Jun 22, 2011 6:49 AM

    Hi,
    Using OVS you can achieve this.,  In OVS Event Handler read the value based on which you  want to display F4 for other field and populate the values based on the first field.
    this link is fine., go through this: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/606288d6-04c6-2c10-b5ae-a240304c88ea?quicklink=index&overridelayout=true
    hope this helps u.,
    Thanks & Regards,
    Kiran

  • Hide column based on condition on other column in table

    hi,
    am using BIP 10.1.3.2 to generate reports.In the template i need to hide one column based on condition on other.am using SQL query as my data source type.can anybody help me ?

    Use <?if:?> condition in the RTF, but its mainly for the rows not column. You can work around this by handeling in backend. Or take two separate tables, one with the column which you want to hide and another table without that column and before calling that table use IF condition.
    Regards,
    Amit D
    Persistent Systems Ltd.

Maybe you are looking for

  • Remote App from Ipad return "Failed to parse authorization Challange"

    Hi, I have set up a Remote App infrastructure on Windows 2012 server , I have publish some apps , I have publish my server on internet opening port 443 and 3389 for RDP with a public rapid SSL wildcard certificate  ... everything works on pcs but whe

  • Overwrite data in the Planning Cube

    Hi Gurus, I am new to BPS, I have created a simple Manual planning layout for my users where they could enter their plan data for either plan or forecast version. As you all know the cube is always additive and cannot overwrite the Keyfigures directl

  • How do you schedule an email to be sent at a later time?  Also, canned messaging shortcuts in Apple Mail?

    I have heard rumors that this is doable using Automator and iCal.  I have also heard rumors that Apple Scripts are the way to go and I have found a few online (likely from 17 year olds in their basements) -- I must admit, I'm a little leary about cop

  • Errors in Job Queue for Timesheet

    I am having errors in my Job Queue when i fill the timesheet (fill+send+approve) and also when i delete the timesheet from Manage Timesheet or from Delete Enterprise object. Following is the error description; 1. For Timesheet Fill and submision: Job

  • ABAP Editor

    hello experts, i m working in ecc 6.0 i have new front end abap editor .. in that suppose i have + form xyz |   - |    some code +end form i want to collapse and decollapse that <b>+</b> sign by any short cut.. ctrl + / or something like that so can