Trigger to concatenate two fields in a table

Hi
I am trying to concatenate two column in a table and add to the third column in the same table, all the columns are
numbers, I want to write a trigger which is after insert to do that..does anyone know how its done...
thanks a lot
Jessica

Hi, Jessica,
Welcome to the forum!
Do you really need to store this concatenation? The way you would get these results in a normalized database is to store the numbers separately, and comnbine them, when necessary, in queries and reports. You can use use a view to avoid repeating the same coiding over and over.
If you really want to store the value, use a BEFORE INSERT OR UPDATE trigger, like this:
CREATE OR REPLACE TRIGGER     table_x_biu
BEFORE     INSERT OR UPDATE
ON     table_x
FOR EACH ROW
BEGIN
     :NEW.column_3 := TO_CHAR (:NEW.column_1)
                || '-'
                || TO_CHAR (:NEW.column_2);
END;I'm confused by your exact requirements. Concatentaion can only be done to strings.
If column_1 and column_2 are NUMBERs, the trigger above will make string versions of those numbers, concatenate them together (with a hyphen between them), and put the results in the VARCHAR2 column column_3.
So after this statement:
INSERT INTO  table_x (column_1, column_2, column_3)
       VALUES          (1,     2,       '9-8');the new row will have column_3= '1-2'. (In this case, there is no point in explicitly setting column_3, because the trigger will always set the value based entirely on column_1 and column_2.)
If you need more help, post CREATE TABLE , INSERT and UPDATE statements, and who what you want the table to contain after each INSERT or UPDATE.

Similar Messages

  • What is needed for sorting on two fields in a table control

    Hi Everybody
    I am going to certification in a couple of days. I need some help and was hopeing that you  guys could help.
    What is needed for sorting on two fields in a table control?
         One sorted table and two processing blocks
         Two standard tables and one processing blocks
         Two standard tables and two processing
    Which one is corret??
    //Script

    Hi Kimallan
    I am not sure what is meant by a "processing block". However, it seems the question wants the original table order to be preserved. If so; as far as I understood the problem we need:
    itab_proxy[] = itab_main[] .
    "two standard tables"
    SORT itab_proxy BY field1 field2 .
    If we have a sorted table, then it is always sorted by its keys. So, the question seems to become obsolete for that option.
    Hope I've understood correct...
    Regards
    *--Serdar
    [email protected]

  • Concatenate Two Fields Using EQL

    I am trying to concatenate two fields my company has in Endeca and am not being able to accomplish this. I have a Call_Num field and a Task_Num field. I would like to combine these fields with a hyphen in between. In the SQL queries I have written, I've been able to do this by typing: Call_Num || '-' || Task_Num. I tried this in EQL and am told that it doesn't recognize the ||. I tried using the keyword Concat (like you do in Excel) - CONCAT(Call_Num, '-', Task_Num), and it didn't recognize that either. I spoke to someone else in my company who uses Endeca and they told me that I need to convert Call_Num and Task_Num to integers (both fields are currently formatted as text - which is what I want, because Task_Num usually starts with a 0), multiply them by 1000 and then add them together. That isn't what I'm looking for either.
    I feel like I'm banging my head against a brick wall. I've been working on this simple task for about an hour now and have not met with any success.
    Any assistance you can provide would be greatly appreciated.

    EQL is for run-time querying, whereas you want the index to contain this as a concatenated property. Either generate this property as a concatenated version in your data feed to Endeca, or add a Record Manipulator to your pipeline of:
    <EXPRESSION TYPE="VOID" NAME="CREATE">
    <EXPRNODE NAME="PROP_NAME" VALUE="_YourConcatenatedAttribute"/>
    <EXPRESSION TYPE="STRING" NAME="CONCAT">
    <EXPRESSION TYPE="PROPERTY" NAME="IDENTITY">
    <EXPRNODE NAME="PROP_NAME" VALUE="Call_Num"/>
    </EXPRESSION>
    <EXPRESSION TYPE="STRING" NAME="CONST">
    <EXPRNODE NAME="VALUE" VALUE="-"/>
    </EXPRESSION>
    <EXPRESSION TYPE="PROPERTY" NAME="IDENTITY">
    <EXPRNODE NAME="PROP_NAME" VALUE="Task_Num"/>
    </EXPRESSION>
    </EXPRESSION>
    </EXPRESSION>
    Define a property in your pipeline and then map "\_YourConcatenatedAttribute" to this (the "_" prefix just reminds you that the source attribute is programmatically generated rather than being the name of a property in your source data). You can then use this concatenated property for any sorting, filtering etc. you want to do.
    Michael

  • Compare two fields of one table in selection.

    Dear Experts,
    I want to compare two fields of a table and make selection according to this.
    Ex: simply i want to select the rows from table mard where mard-labst>mard-insme. Could you write me the code to make this selection.

    Yes, Thomas,
    Its working:
    Sample code:
    data: begin of itab occurs 0,
          matnr type matnr,
          ernam type ernam,
          end of itab.
    select matnr ernam
           into table itab
           from mara where brgew > mara~ntgew.
    loop at itab.
      write: itab-matnr.
    endloop.
    Or,
    Try with inner join once.
    Its working: Sample code.
    data: begin of itab occurs 0,
          matnr type matnr,
          ernam type ernam,
          end of itab.
    select p~matnr q~ernam
           into table itab
           from mara as p
           inner join mara as q
           on p~brgew > q~ntgew.
    loop at itab.
      write: itab-matnr.
    endloop.
    Thanks,
    Naveen.I

  • How to concatenate two fields CSKS-KOSTL & CSKT-LTXT in BEx Query?

    Hi,
    I have a requirement to concatenate two fields CSKS-KOSTL (Cost Center) and CSKT-LTXT (Cost Center Text) and show them as one field in the BEx query.
    I do not know what to do, so please help me out.
    Thanks in advance.
    Regards
    Harman

    Hi Harman,
    If cost center is a masterdata, it can have its own text..i doubt why do u have 2 different fileds..
    Anyways if its a masterdata object maitaining its own text, then in the query properties under Display tab select Key&Text option this give you both key and text values in the output.
    If its two different fileds then its better to use concatenate in the transformation.
    Regards,
    Geetha

  • Concatenate a field in internal table without loopat.

    In an internal table,
    I need to update one field (all rows) concatenate that field with a value say '999'.
    Is it possible to do this in a single MODIFY statement without using loopat condition or any other best possible way to do it?

    yes, it is possible without LOOP:
    MODIFY itab FROM workarea WHERE condition TRANSPORTING field.
    workarea has to like a single line of the internal table and has to contain the value you want to transfer
    after TRANSPORTING you name the field you want to change
    you can check the complete syntax (with examples) in SAPHelp

  • Concatenate two fields

    Hi,
      Can anyone let me know how to concatenate the following two fields and use it in the select statement::
    BKPF-AWKEY = MKPF-BELNR + MKPF-MJAHR.
    Please reply at your earliest convenience.
    Thanks,
    Amit.

    hi
    good
    check this example and use accordingly
    DATA: c1(10) TYPE c VALUE  'Sum',
          c2(3)  TYPE c VALUE  'mer',
          c3(5)  TYPE c VALUE  'holi ',
          c4(10) TYPE c VALUE  'day',
          c1 (30) TYPE c,
          sep(3) TYPE c VALUE ' - '.
    CONCATENATE c1 c2 c3 c4 INTO c5.
    WRITE c5.
    CONCATENATE c1 c2 c3 c4 INTO c5 SEPARATED BY sep.
    WRITE / c5.
    The output looks like this:
    Summerholiday
    Sum - mer - holi - day
    In c1 to c5, the trailing blanks are ignored. The separator sep retains them.
    thanks
    mrutyun^

  • Two Fields in AFKO Table...

    Hi Friends,
    Could you please tell me what is the difference between the 2 fields in AFKO Table.
    those two fieds are: <b>PLNBEZ and STLBEZ.</b>
    My question is: how do we know which field to use and when to use it appropriately.
    thnx for the help..

    Hi Dev,
    Please note that in AFKO tabke
    Please check MRP Controller and Planner group AFKO-PLNNR'.
    If PLANNR is not maintained entry will bein STLBEZ
    Other wise in PLNBEZ.
    Hope this will help you.
    Lanka
    Message was edited by: Lanka Murthy

  • Why is the trigger triggering on all fields in a table?

    I have a trigger and the text is as follows. The trigger should just write the emplid to the table PS_DM_ADDR_CHG_EMP whenever there is an update to the fields
    STREET1,STREET2 ,STREET3 ,CITY ,STATE ,ZIP ,COUNTRY in PS_PERSONAL_DATA. But some how it is writing emplid to the PS_DM_ADDR_CHG_EMP when any updateis done on any field on the 50 plus fields of the PS_PERSONAL_DATA table. Is there any reason why this happens. I looked at all other triggers and none of them writes any thing to this table though I found one more trigger on PS_PERSONAL_DATA for any insert or update or delete on any field and it uses insert in some other table. I did not see any other triggers related to the PS_PERSONAL_DATA table. So how to diagonize the issue of finding what is causing to write the data to this custom table.
    CREATE OR REPLACE TRIGGER HT0P.PERSDATA_RAU
    AFTER UPDATE OF STREET1,STREET2 ,STREET3 ,CITY ,STATE ,ZIP ,COUNTRY
    ON PS_PERSONAL_DATA
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    v_Emplid ps_personal_data.emplid%type; -- Used for storing EMPLID
    BEGIN
    v_Emplid := :old.emplid;
    UPDATE ps_dm_addr_chg_emp a
    SET a.emplid = v_Emplid
    WHERE (((a.emplid = v_Emplid) and length(v_emplid) = 3)
    or ((substr(a.emplid, 1, 3) = substr(v_Emplid, 1, 3)) and length(v_emplid) = 4 and substr(v_emplid, -1, 1) in('B', 'C', 'J', 'K', 'P', 'U'))
    or ((a.emplid = v_Emplid) and length(v_emplid) = 4)
    or ((substr(a.emplid, 1, 4) = substr(v_Emplid, 1, 4)) and length(v_emplid) = 5 and substr(v_emplid, -1, 1) in('B', 'C', 'J', 'K', 'P', 'U'))
    or ((a.emplid = v_Emplid) and length(v_emplid) = 5)
    or ((substr(a.emplid, 1, 5) = substr(v_Emplid, 1, 5)) and length(v_emplid) = 6 and substr(v_emplid, -1, 1) in('B', 'C', 'J', 'K', 'P', 'U'))
    or ((a.emplid = v_Emplid) and length(v_emplid) = 6)
    or ((substr(a.emplid, 1, 6) = substr(v_Emplid, 1, 6)) and length(v_emplid) = 7 and substr(v_emplid, -1, 1) in('B', 'C', 'J', 'K', 'P', 'U')));
    IF SQL%NOTFOUND THEN
    INSERT INTO ps_dm_addr_chg_emp (emplid)
    VALUES (v_Emplid);
    END IF;
    END;

    Hi,
    It would be helpful if you could post formated code using tags. Learn more from FAQ
    To test your trigger - You may want to create a temparory table and have an insert statement for the temp table in your trigger and test it by updating other columns of your main table.
    Also you may want to ensure it is not the UPDATE statement which is causing the trouble for you by updating some unintended rows...
    Regards,
    Rakesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to Concatenate two rows of same table

    Hi Friends
    I have table
    No Name Id
    1 Raju 6
    2 Dhanshree 7
    3 Shital 6
    4 Priya 7
    I want the query that should display
    Raju Dhanshree.
    Shital Priya
    That Means whenever 6,7 number come the query should Concatenate The name colume

    1 150 IEEE TRANSA CTIONS ON MICR O W A V E THEOR Y AND TECHNIQ UES, V OL. 50, NO. 1, J ANU AR Y 2002
    Times-Roman 4
    2 A Miniaturized MMIC Analog Phase Shifter Using
    Times-Roman 16
    3 T w o Quarter-W a v e-Length T ransmission Lines
    Times-Roman 16
    4 Hitoshi Hayashi
    Times-Roman 7
    5 , Member , IEEE
    Times-Italic 7
    6 , T adao Nakaga w a
    Times-Roman 7
    7 , Member , IEEE
    Times-Italic 7
    8 , and Katsuhik o Araki
    Times-Roman 7
    9 Abstract—
    Times-BoldItalic 6
    10 This paper describes a miniaturized monolithic-mi-
    Times-Bold 6
    11 cr o w a v e integrated-cir cuit (MMIC) analog phase shifter using tw o
    Times-Bold 6
    12 quarter-wa v e-length transmission lines. A con v entional analog
    Times-Bold 6
    13 phase shifter employs an analog phase-shifter topology using a
    Times-Bold 6
    14 3-dB 90
    Times-Bold 6
    15 branch-line h ybrid r equiring f our quarter-wa v e-length
    Times-Bold 6
    16 transmission lines. Thus, in the f irst stage of our study , w e
    Times-Bold 6
    17 pr esent a new analog phase-shifter topology using only tw o
    Times-Bold 6
    18 quarter-wa v e-length transmission lines. The phase shifter her e
    Times-Bold 6
    19 has only one-half as many transmission lines as a con v entional
    Times-Bold 6
    20 analog phase shifter using a 3-dB 90
    Times-Bold 6
    21 branch-line h ybrid, and the
    Times-Bold 6
    22 cir cuit can be miniaturized to less than one-f ourth as compar ed to
    Times-Bold 6
    23 the con v entional analog phase shifter . Furthermor e, we sho w that
    Times-Bold 6
    24 the operating fr equency range of the phase shifter is v ery wide and
    Times-Bold 6
    25 can obtain lar ge phase v ariation with small capacitance v ariation.
    Times-Bold 6
    26 Next, an experimental
    Times-Bold 6
    27 -band MMIC analog phase shifter is
    Times-Bold 6
    28 pr esented. A phase shift of mor e than 180
    Times-Bold 6
    29 and an insertion loss
    Times-Bold 6
    30 of 3.6
    Times-Bold 6
    31 1.1 dB ar e obtained at the fr equency range fr om 12 to
    Times-Bold 6
    32 14 GHz. The chip size of the experimental MMIC phase shifter is
    Times-Bold 6
    33 less than 3.0 mm
    Times-Bold 6
    34
    How will use on this data

  • How to compare the two same fields of different tables

    Hi can any one let me know the logic for compare the two fields of different tables.

    hi
    good
    IF it_1[] = it_2[].
       " Tables contents are the same
    ELSE.
       " Tables contents are different
    ENDIF.
    If they have different structure, you probably must loop one of the tables, and inside read the other, then compare field by field.
    Or if you don't need the contents (just comparing) you can do this, for example:
    LOOP AT it_1 INTO wa_1.
       READ TABLE it_2 WITH KEY field2 = wa_1-field2
                                field5 = wa_1-field5
                       TRANSPORTING NO FIELDS.
       IF sy-subrc = 0.
          " Record is on both tables (field2 and field5 are the fields in common for both tables).
       ENDIF.
    ENDLOOP.
    thanks
    mrutyun^

  • Joining Two Fields Into One Field for a View

    I am trying to create a view based off of multiple tables.
    I have all of the joins and everything done nicely and working properly.
    However, when I get to this one step, that's when I start running into problems.
    I just want to join (or concatenate) two fields together with a period character in between them.
    For example, if I take FirstName and LastName, then I want them to become one field called Name, appearing as "JOHN.DOE"
    When I try to join them together, the problem comes up with the period character.
    A sample code of what I have done is here:
    BEGIN
    EXECUTE IMMEDIATE 'create view VIEW_LALALA
    as SELECT t1.FirstName + '.' + t2.LastName as Name, t1.something as Something, t2.ooo as OOO
    FROM (tableFirstNames t1 inner join tableLastNames t2 on t1.nameID = t2.nameID)
    END;

    832667 wrote:
    I am trying to create a view based off of multiple tables.
    I have all of the joins and everything done nicely and working properly.
    However, when I get to this one step, that's when I start running into problems.
    I just want to join (or concatenate) two fields together with a period character in between them.
    For example, if I take FirstName and LastName, then I want them to become one field called Name, appearing as "JOHN.DOE"
    When I try to join them together, the problem comes up with the period character.
    A sample code of what I have done is here:
    BEGIN
    EXECUTE IMMEDIATE 'create view VIEW_LALALA
    as SELECT t1.FirstName + '.' + t2.LastName as Name, t1.something as Something, t2.ooo as OOO
    FROM (tableFirstNames t1 inner join tableLastNames t2 on t1.nameID = t2.nameID)
    END;to concatenate two string together do not use "+", but "||"
    SELECT FIRST_NAME||'.'||LAST_NAME FROM EMP;

  • Updation of Custom Fields in AFRU table Using Customerexit

    Hi all,
    I added two fields in CO11n Tcode using SCREEN EXIT - CONFPP07 and iam trying to update these two fields in AFRU table
    using CONFPP05.  But iam unable to update these two field .
    see this code in CONFPP05
      LOOP AT afrud_tab.
        afrud_tab-zzshift = wa_afrud-zzshift1 .
        afrud_tab-zzoperator = wa_afrud-zzoperator1 .
        MODIFY afrud_tab.
      ENDLOOP.
    Plz help me regarding this..

    Thanks for reply
    Ya i added two fields in confpp07 .
    see the code :
    *&  Include           ZXCOFTOP
    tables : afrud.
    DATA : WA_AFRUD TYPE AFRUD,
            IT_AFRUD TYPE TABLE OF AFRUD.
    Include           ZXCOFU24
    MOVE afrud-zzshift1 TO wa_afrud-zzshift1.
    MOVE afrud-zzoperator1 TO wa_afrud-zzoperator1.
    Even though it is not updating . except these two fields.
    Regards,
    Srinivas

  • Concatenate two columns in Obiee 11g

    Hi,
    I am trying to concatenate two columns from same table in OBIEE 11G , i tried all below syntax
    cast("Period"."Year" as Varchar)|| cast ("Period"." Month Name" as Varchar)
    cast("Period"."Year" as char)|| cast ("Period"." Month Name" as char)
    contact(cast("Period"."Year" as char), cast ("Period"." Month Namer" as char))
    I am getting this error as - Invalid Alias Format : Table_name.Column_name require . Plz Help me Guys
    Thanks
    Edited by: Neha on Apr 16, 2012 3:41 PM

    Column forumal example based on vanilla usage tracking RPD:
    cast("Query Time"."Year" as varchar(4)) || "Query Time"."Month"BTW: "Month Name" implies a string already so I doubt you'll need to cast it as one...
    C.

  • F4 help for two fields in screen

    hello,
    I have two fields in my table control which need F4 help in the screen.
    But one F4 search exit is implemented, but it populates only one field.
    but, on clicking f4 for one field, it should populate both the fields together.
    do help me with this issue...
    Can POH in the screen populate up two fields together???

    Hi Krithika ,
    In addition to checking up the export parameters for the Search healp you will have to define the Search Help attachment also. I'll paste the SAP Help Text below but in Simple terms
    You Define a structure with the fields to be returned and define the screen elements based on that structure . So on selection the structure is returned with all values and the screen elements are in referance to structure so all values get posted in screen.
    Here is the SAP HELP part
    "" From SAP HELP
    A search help attachment is an assignment of a search help to a table, structure or data element, causing the corresponding search help to be automatically used to describe the input help process at this field when an ABAP Dictionary field is used in a screen.
    You can attach a search help as follows:
    1. Attach a search help to a structure or table field: The attached search help is available for all screen fields that refer to the table or structure field. There must be an assignment between the interface parameters of the search help and the fields of the table or structure for this type of attachment. In the input help process, this assignment results in a value transport between the corresponding fields (if they are known at least to the module pool of the screen) and the search help parameters. As for the foreign key definition, you can assign nothing, a constant or any other field (which is then sought in the module pool) to indivdiual search help parameters.
    2. Attach a search help to a table: The assigned search help is available for all screen fields for which the table is a check table. There must also be an assignment between the search help parameters and the key fields of the table for this type of assignment.
    3. Attach a search help to a data element: The attached search help is available for all screen fields that refer to the data element. If the search help is attached to a data element, an export parameter of the search help must be assigned to the data element. If the user chooses a row of the hit list in the input help, the contents of this parameter are returned in the corresponding screen field. More than one value is not returned when a search help is attached to a data element.
    The described attachments only take effect if the field was not yet assigned an input help in the screen definition. Such an assignment can be made with the mechanism PROCESS ON VALUE-REQUEST in the flow logic or by attaching a search help to the screen field in the attribute maintenance screen. A F4 help can also be assigned to the field in the flow logic by using VALUES or SELECT. In the latter case, the input help here behaves as if the table specified under SELECT were assigned to the field as check table.
    If more than one of the described mechanisms compete in defining the input help method of a screen field, the first one named will take effect. If none of the described mechanisms is available, the domain fixed values of the field will be used for the input help if necessary. If the domain of the field has no fixed values but has data type DATS or TIMS, the input helps that are assigned to these types are used for the input help. Otherwise there will be no input help available for the field.
    A search help attachment always belongs to the definition of the object to which the attachment is made (structure, table or data element). It is also maintained in the maintenance transaction for this object and transported with this object.
    <b>REWARD IF USEFUL. It Works for me here..get back if any doubts.</b>

Maybe you are looking for

  • Windows Vista Home Prem SP1, iTunes 76, after install, refuses to launch

    I have just resinstalled Windows Vista Home Premium to a 1 yr old Acer 5610 laptop. Installed Vista SP1. Downloaded and installed latest (v7.6.something) iTunes and let it do the full, all apple media installation. It seemed OK, showed his music, let

  • Design Patterns/Best Practices etc...

    fellow WLI gurus, I am looking for design patterns/best practices especially in EAI / WLI. Books ? Links ? With patterns/best practices I mean f.i. * When to use asynchronous/synchronous application view calls * where to do validation (if your connec

  • Garage Band 6.0.5 update - (Mac 10.6.8) Snow leopard.

    Hi folks, Garage band ceased to load on my mac - previous to updating to my current Snow Leopard..  To try and solve the problem I updated to Snow Leopard - no resolution.  I then updated to Garage Band 6.0.5 -  still the same problem as before I upd

  • Tabular form template

    Hi all, I'm looking for a special template on tabular forms. It should provide different form elements only for a row that is in edit mode or in input mode. The other rows should be display_only_html. has someone done this before? thanks franz

  • Hot and Controversial - Colour Management

    Ok, having spent weeks, if not months, trying to get my head around 'colour management' (not easy at my age), I wonder if the entire subject has been overly complicated by the *experts* in this field and whether it really is as important as it is mad