Merging 2 rows into 1 row

I have a field:
=Fields!Attachment_Name.Value that returns values on 2 separate rows
Row 1 LTC 34 EARC
Row 2 LTC 34 EARC v04_13
How can I get the 2 rows to merge into 1 row to show "LTC 34 EARC" only
Thank you

How is the value coming in dataset?
Is it a single column values you're showing above as two lines or are they two separate rows? Is the question to merge multiple row data to one inside SSRS?
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • How to remove these icons in the red box, and Merge the two rows into 1?

    1. How may one remove these icons in the red box?
    2. How may one coalesce/merge the two bottom rows into one row?
    I'm running a French version of Adobe Acrobat XI version 11.0.0.

    I'm working in AA9, but it may be the same.
    The icons are in Tool Groups. The Groups are seperated by the verticle bars.
    Right Click within a toolbar group to avail options for enabling and disabling tools within a Group.
    The bars themselves can be selected with the mouse and dragged to re-order the groups.

  • Merging two rows into a single row

    Hi ,
    I wish to merge few columns of tow rows into a single row.
    if i use union it gives two rows as o/p.
    What is the exact sql statement for that?
    Thanks

    Hi Sridhar,
    This is my code for merging and i used union.
    Suggest me good solution.
    CREATE OR REPLACE VIEW INSPECTINT.INSPECT_LOC_TRACKING_RPT_VIEW AS
    SELECT
    VEN_COMPANY_NAME VEN_COMPANY_NAME,
    VEN_COMPANY_NAME_2 VEN_COMPANY_NAME_2,
    VEN_CONTACT_FIRST_NAME VEN_CONTACT_FIRST_NAME,
    VEN_CONTACT_MIDDLE_NAME VEN_CONTACT_MIDDLE_NAME,
    VEN_CONTACT_LAST_NAME VEN_CONTACT_LAST_NAME,
    VEN_ADDRESS_LINE_1 VEN_ADDRESS_LINE_1,
    VEN_ADDRESS_LINE_2 VEN_ADDRESS_LINE_2,
    VEN_CITY VEN_CITY,
    VEN_CNT_COUNTY_CODE VEN_CNT_COUNTY_CODE,
    VEN_STC_STATE_CODE VEN_STC_STATE_CODE,
    VEN_ZIP_CODE VEN_ZIP_CODE,
    VEN_PHONE_NO_1 VEN_PHONE_NO_1,
    VEN_PHONE_EXTN_1 VEN_PHONE_EXTN_1,
    VEN_PHONE_NO_2 VEN_PHONE_NO_2,
    VEN_PHONE_EXTN_2 VEN_PHONE_EXTN_2,
    VEN_FAX_NO_1 VEN_FAX_NO_1,
    VEN_VENDOR_NO VEN_VENDOR_NO,
    VEN_APV_AP_VENDOR_ID VEN_APV_AP_VENDOR_ID,
    VEN_EMAIL_ADDRESS VEN_EMAIL_ADDRESS,
    --all these should be null
    to_number(NULL) PHY_LCN_PARAMETER_ID,
    to_char(NULL) PHY_LCN_CURRENT_ADDRESS_IND,
    to_char(NULL) PHY_LCN_STATUS_CODE,
    to_char(NULL) PHY_LCN_LTY_LOCATION_TYPE,
    to_char(NULL) PHY_LCN_ADT_ADDRESS_TYPE,
    to_char(NULL) PHY_LCN_HOUSE_NO,
    to_char(NULL) PHY_LCN_ADDRESS_LINE_1,
    to_char(NULL) PHY_LCN_ADDRESS_LINE_2,
    to_char(NULL) PHY_LCN_CITY,
    to_char(NULL) PHY_LCN_STC_STATE_CODE,
    to_char(NULL) PHY_LCN_ZIP_CODE,
    to_char(NULL) PHY_LCN_CNT_COUNTY_CODE,
    to_date(NULL) PHY_END_DATE,
    to_number(NULL) PHY_LCN_VEN_VENDOR_ID_GTA,
    to_char(NULL) PHY_LCN_SUB_LOCATION_GTA,
    to_char(NULL) PHY_LCN_DIRECTION_GTA,
    ---all these should be null
    to_char(NULL) LOW_LCN_PARAMETER_ID,
    to_char(NULL) LOW_LCN_CURRENT_ADDRESS_IND,
    to_char(NULL) LOW_LCN_STATUS_CODE,
    to_char(NULL) LOW_LCN_LTY_LOCATION_TYPE,
    to_char(NULL) LOW_LCN_ADT_ADDRESS_TYPE,
    to_char(NULL) LOW_LCN_HOUSE_NO,
    to_char(NULL) LOW_LCN_ADDRESS_LINE_1,
    to_char(NULL) LOW_LCN_ADDRESS_LINE_2,
    to_char(NULL) LOW_LCN_CITY,
    to_char(NULL) LOW_LCN_STC_STATE_CODE,
    to_char(NULL) LOW_LCN_ZIP_CODE,
    to_char(NULL) LOW_LCN_CNT_COUNTY_CODE,
    to_char(NULL) LOW_LCN_LANDLORD,
    to_number(NULL) LOW_LCN_LANDLORD_PHONE,
    to_date(NULL) LOW_END_DATE,
    to_char(NULL) LOW_LCN_SUB_LOCATION_GTA,
    to_char(NULL) LOW_LCN_DIRECTION_GTA
    FROM LOCATIONS LOC , VENDORS VEN
    WHERE LOC.LCN_VEN_VENDOR_ID_GTA IS NOT NULL
    AND LOC.LCN_VEN_VENDOR_ID_GTA = VEN_VENDOR_ID
    AND LOC.LCN_LTY_LOCATION_TYPE ='AS'
    UNION ALL
    SELECT
    to_char(NULL) VEN_COMPANY_NAME,
    to_char(NULL) VEN_COMPANY_NAME_2,
    to_char(NULL) VEN_CONTACT_FIRST_NAME,
    to_char(NULL) VEN_CONTACT_MIDDLE_NAME,
    to_char(NULL) VEN_CONTACT_LAST_NAME,
    to_char(NULL) VEN_ADDRESS_LINE_1,
    to_char(NULL) VEN_ADDRESS_LINE_2,
    to_char(NULL) VEN_CITY,
    to_char(NULL) VEN_CNT_COUNTY_CODE,
    to_char(NULL) VEN_STC_STATE_CODE,
    to_char(NULL) VEN_ZIP_CODE,
    to_number(NULL) VEN_PHONE_NO_1,
    to_number(NULL) VEN_PHONE_EXTN_1,
    to_number(NULL) VEN_PHONE_NO_2,
    to_number(NULL) VEN_PHONE_EXTN_2,
    to_number(NULL) VEN_FAX_NO_1,
    to_char(NULL) VEN_VENDOR_NO,
    to_char(NULL) VEN_APV_AP_VENDOR_ID,
    to_char(NULL) VEN_EMAIL_ADDRESS,
    decode(lcn_adt_address_type,'P',to_number(LCN_PARAMETER_ID),to_number(NULL)) PHY_LCN_PARAMETER_ID,
    decode(lcn_adt_address_type,'P',LCN_CURRENT_ADDRESS_IND,to_char(NULL)) PHY_LCN_CURRENT_ADDRESS_IND,
    decode(lcn_adt_address_type,'P',LCN_STATUS_CODE,to_char(NULL)) PHY_LCN_STATUS_CODE,
    decode(lcn_adt_address_type,'P',LCN_STATUS_CODE,to_char(NULL)) PHY_LCN_LTY_LOCATION_TYPE,
    decode(lcn_adt_address_type,'P',LCN_ADT_ADDRESS_TYPE,to_char(NULL)) PHY_LCN_ADT_ADDRESS_TYPE,
    decode(lcn_adt_address_type,'P',LCN_HOUSE_NO,to_char(NULL)) PHY_LCN_HOUSE_NO,
    decode(lcn_adt_address_type,'P',LCN_ADDRESS_LINE_1,to_char(NULL)) PHY_LCN_ADDRESS_LINE_1,
    decode(lcn_adt_address_type,'P',LCN_ADDRESS_LINE_2,to_char(NULL)) PHY_LCN_ADDRESS_LINE_2,
    decode(lcn_adt_address_type,'P',LCN_CITY,to_char(NULL)) PHY_LCN_CITY,
    decode(lcn_adt_address_type,'P',LCN_STC_STATE_CODE,to_char(NULL)) PHY_LCN_STC_STATE_CODE,
    decode(lcn_adt_address_type,'P',LCN_ZIP_CODE,to_char(NULL)) PHY_LCN_ZIP_CODE,
    decode(lcn_adt_address_type,'P',LCN_CNT_COUNTY_CODE,to_char(NULL)) PHY_LCN_CNT_COUNTY_CODE,
    decode(lcn_adt_address_type,'P',END_DATE,to_char(NULL)) PHY_END_DATE,
    decode(lcn_adt_address_type,'P',LCN_VEN_VENDOR_ID_GTA,to_char(NULL)) PHY_LCN_VEN_VENDOR_ID_GTA,
    decode(lcn_adt_address_type,'P',LCN_SUB_LOCATION_GTA,to_char(NULL)) PHY_LCN_SUB_LOCATION_GTA,
    decode(lcn_adt_address_type,'P',LCN_DIRECTION_GTA,to_char(NULL)) PHY_LCN_DIRECTION_GTA,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_PARAMETER_ID,to_char(NULL)) LOW_LCN_PARAMETER_ID,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_CURRENT_ADDRESS_IND,to_char(NULL)) LOW_LCN_CURRENT_ADDRESS_IND,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_STATUS_CODE,to_char(NULL)) LOW_LCN_STATUS_CODE,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_LTY_LOCATION_TYPE,to_char(NULL)) LOW_LCN_LTY_LOCATION_TYPE,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_ADT_ADDRESS_TYPE,to_char(NULL)) LOW_LCN_ADT_ADDRESS_TYPE,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_HOUSE_NO,to_char(NULL)) LOW_LCN_HOUSE_NO,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_ADDRESS_LINE_1,to_char(NULL)) LOW_LCN_ADDRESS_LINE_1,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_ADDRESS_LINE_2,to_char(NULL)) LOW_LCN_ADDRESS_LINE_2,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_CITY,to_char(NULL)) LOW_LCN_CITY,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_STC_STATE_CODE,to_char(NULL)) LOW_LCN_STC_STATE_CODE,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_ZIP_CODE,to_char(NULL)) LOW_LCN_ZIP_CODE,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_CNT_COUNTY_CODE,to_char(NULL)) LOW_LCN_CNT_COUNTY_CODE,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_LANDLORD,to_char(NULL)) LOW_LCN_LANDLORD,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_LANDLORD_PHONE,to_char(NULL)) LOW_LCN_LANDLORD_PHONE,
    decode(LCN_ADT_ADDRESS_TYPE,'D',END_DATE,to_char(NULL)) LOW_END_DATE,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_SUB_LOCATION_GTA,to_char(NULL)) LOW_LCN_SUB_LOCATION_GTA,
    decode(LCN_ADT_ADDRESS_TYPE,'D',LCN_DIRECTION_GTA,to_char(NULL)) LOW_LCN_DIRECTION_GTA
    FROM LOCATIONS LOC
    WHERE (LCN_LTY_LOCATION_TYPE ='AS' OR LCN_ADT_ADDRESS_TYPE='D')
    AND LCN_CURRENT_ADDRESS_IND ='Y'
    thanks

  • Merge rows into a single row

    select OPRCLASS,BUSINESS_UNIT from ps_sec_bu_cls where oprclass like 'OHRL_ADA01%';
    OPRCLASS BUSINESS_UNIT
    OHRL_ADA01 ADA01
    OHRL_ADA01 PRT01
    OHRL_ADA01 STATE
    How can i merge all the BUSINESS_UNIT rows into one row with a delimiter?
    OPRCLASS BUSINESS_UNIT
    OHRL_ADA01 ADA01, PRT01, STATE

    One possible solution: STRAGG

  • Merging rows into one row but into SEPARATE Columns

    Hello Gurus,
    I have searched alot on OTN and many other places, but no where I could get the solution of how can we merge rows into one row but separate column. For example
    Consider the below scenario
    "DEPARTMENT", "EMP","NAME","SUBJECT"
    "Electronics","1","Sam","LIC"
    "Electronics","2","Pam","VLSI"
    "Electronics","3","Tom","C"
    "Mech","1","Abu","Thermo"
    "Mech","4","Lina","Machines"Now, I need the output like
    Based on Department as Group By Clause
    "DEPARTMENT", "EMP1","NAME1","SUBJECT1","EMP2","NAME2","SUBJECT2","EMP3","NAME3","SUBJECT3"
    "Electronics","1","Sam","LIC","2","Pam","VLSI","3","Tom","C"
    "Mech","1","Abu","Thermo","4","Lina","Machines"
    The row data to be loaded into separate columns. Name of the column is not an issue... can be anythingIn all the forums which I went through I could find them loading into a single column, but not into respective separate columns.
    Any help would be much appreciated.
    Thanks

    848265 wrote:
    Frank,
    I saw your name nearly n number of times, as I went through many forums today... And the link which you have just posted, I went through it today afternoon.
    Could you please explain this bit taken from your dynamic pivot post.
    SELECT     DISTINCT
         ',     COUNT (CASE WHEN job = '''
    ||     job
    ||     ''' '     AS txt1
    ,     'THEN 1 END)     AS '
    ||     job
    ||     '_CNT'     AS txt2
    FROM     scott.emp
    ORDER BY     txt1;Many Thanks.You only need that when you need column aliases based on the actual data (and you explicitly said you don't need that) or when can't put an upper bound on the number of columns to be displayed. If that doesn't apply to this problem, then don't use any kind of dynamic SQL (like the code above); it makes the job much more difficult, less efficient and less robust.
    Here's what the code above is doing.
    If you were hard-coding a query that showed the number of people in each job, and you knew that the possible jobs were 'ANALYST', 'CLERK' and 'MANAGER', then you might hard-code a query like this:
    SELECT    deptno
    ,       COUNT (CASE WHEN job = 'ANALYST'  THEN 1 END)     AS analyst
    ,       COUNT (CASE WHEN job = 'CLERK'    THEN 1 END)     AS clerk
    ,       COUNT (CASE WHEN job = 'MANAGER'  THEN 1 END)     AS manager
    FROM       scott.emp
    GROUP BY  deptno
    ;If the jobs had different names, or if there were not 3 different jobs, then you would have to change the lines in the SELECT clause that start with ", COUNT ( CASE ...".
    The code you posted is from an example of dynamic SQL, where you first run a Preliminary Query . (What you posted above is, in fact, the complete preliminary query.) The output of that preliminary query is exactly the variable part of the real query, such as:
    ,       COUNT (CASE WHEN job = 'ANALYST'  THEN 1 END)     AS analyst
    ,       COUNT (CASE WHEN job = 'CLERK'    THEN 1 END)     AS clerk
    ,       COUNT (CASE WHEN job = 'MANAGER'  THEN 1 END)     AS managerYou then use this output as part of your main query. In other words, you can write something today that will generate exacrly as many columns as you need next year, with names from the data as it is next year. How? because you're not writing the full query today. The variable part will be written by the preliminary query when it runs next year.

  • Merge multiple rows into single row (but multiple columns)

    How to merge multiple rows into single row (but multiple columns) efficiently.
    For example
    IDVal IDDesc IdNum Id_Information_Type Attribute_1 Attribute_2 Attribute_3 Attribute_4 Attribute_5
    23 asdc 1 Location USA NM ABQ Four Seasons 87106
    23 asdc 1 Stats 2300 91.7 8.2 85432
    23 asdc 1 Audit 1996 June 17 1200
    65 affc 2 Location USA TX AUS Hilton 92305
    65 affc 2 Stats 5510 42.7 46 9999
    65 affc 2 Audit 1996 July 172 1100
    where different attributes mean different thing for each Information_type.
    For example for Information_Type=Location
    Attribute_1 means Country
    Attribute_2 means State and so on.
    For example for Information_Type=Stats
    Attribute_1 means Population
    Attribute_2 means American Ethnicity percentage and so on.
    I want to create a view that shows like below:
    IDVal IDDesc IDNum Country State City Hotel ZipCode Population American% Other% Area Audit Year AuditMonth Audit Type AuditTime
    23 asdc 1 USA NM ABQ FourSeasons 87106 2300 91.7 46 85432 1996 June 17 1200
    65 affc 2 USA TX AUS Hilton 92305 5510 42.7 46 9999 1996 July 172 1100
    Thanks

    Hi,
    That's called Pivoting . The forum FAQ has a section on this subject: {message:id=9360005}
    I hope this answers your question.
    If not, post your best attempt, along with a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data. (You did post the results you wanted, but they're very hard to read because they're not formatted. Use \ tags, as described in the forum FAQ, below.)
    Explain, using specific examples, how you get the results you want from the data given.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).  This is always important, but especially so with pivots.
    See the forum FAQ {message:id=9360002}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Merging 2 rows into one

    Greedings,
    I have the following output
    1       A       null     null
    2      null      B         CHow is it possible to merge it into one line?
    CREATE TABLE test_g
    a VARCHAR2(1),
    b VARCHAR2(1),
    c VARCHAR2(1)
    INSERT INTO test_g
    VALUES (null,'B','C');
    INSERT INTO test_g
    VALUES ('A',null,null);

    what you are asking of is a kind of Grouping?
    If yes, you need to have a Grouping Trait, that stays common across the rows to be grouped.
    Extending your example:
    create table test_t (grp varchar2(5), col_a varchar2(5), col_b varchar2(5), col_c varchar2(5));
    insert into test_t values ('A', 'A', null, null);
    insert into test_t values ('A', null, 'B', null);
    insert into test_t values ('A', null, null, 'C');
    insert into test_t values ('B', 'B', null, null);
    insert into test_t values ('B', null, null, 'D');
    select grp, max(col_a), max(col_b), max(col_c)
      from test_t
    group by grp;
    GRP   MAX(COL_A) MAX(COL_B) MAX(COL_C)
    A     A          B          C         
    B     B                     D          If you do not have a Grouping Trait, then you can still simply merge the rows. To do this, remove the GRP column from Select and group by from above query; which I think answers your original question. However, would you want to club the data of entire table into a Single row? If not then you need a Grouping column (as demonstrated above).

  • Want to merge data into a table containing 10 million rows

    Can somebody suggest me a fast and optimized way to merge data into the table.The source table contains 1 million data.

    Hi,
    use merge!
    Another option, create a new table as CTAS from target and source.
    Herald ten Dam
    http://htendam.wordpress.com

  • Problem with merge using package (row)variable

    We're doing an ETL project, where we have to validate data coming from staging tables before inserting / updating them in our data tables.
    We use a validate function for this, in which we 'test' our mappings and business logic, and returns 'OK' if no errors were occured.This function is called in the WHERE clause, and populates a package row variable. From this variable, values are read in the insert / update statement, using a get function.
    The problem is that sometimes, with a data set with NO duplicate keys, we get an ORA-00001 error, and sometimes not.
    Does anyone have any idea why this error could occur ? We're on Oracle 9.2.0.5.0.
    For the demo mentioned below, the following statement fails , while it succeeds if we add 'and rownum < 11' to the where clause :
    merge into target_tab t
    using (select st.* from source_tab st where demo_pack.assign_var(st.attrib_1, st.attrib_2, st.attrib_3) = 'OK') s
    on (t.attrib_1 = s.attrib_1 and
    t.attrib_2 = s.attrib_2)
    when matched then update
    set t.attrib_3 = demo_pack.get_attrib('ATTRIB_3')
    when not matched then
    insert(attrib_1, attrib_2, attrib_3)
    values (demo_pack.get_attrib('ATTRIB_1'), demo_pack.get_attrib('ATTRIB_2'), demo_pack.get_attrib('ATTRIB_3'));
    Can anyone explain to me why this statement sometimes fails, and other times not ?
    Thanks in advance .
    demo tables / packages :
    create table source_tab
    attrib_1 varchar2(30),
    attrib_2 varchar2(30),
    attrib_3 varchar2(200)
    create table target_tab
    attrib_1 varchar2(30) not null,
    attrib_2 varchar2(30) not null,
    attrib_3 varchar2(200),
    constraint pk_target_tab primary key(attrib_1, attrib_2)
    insert into source_tab
    select table_name, column_name, data_type
    from user_tab_columns;
    commit;
    create or replace package demo_pack as
    function assign_var(p_attrib_1 in target_tab.attrib_1%type,
    p_attrib_2 in target_tab.attrib_2%type,
    p_attrib_3 in target_tab.attrib_3%type) return varchar2;
    function get_attrib(p_name in varchar2) return varchar2;
    end;
    create or replace package body demo_pack as
    g_rec target_tab%rowtype;
    function assign_var(p_attrib_1 in target_tab.attrib_1%type,
    p_attrib_2 in target_tab.attrib_2%type,
    p_attrib_3 in target_tab.attrib_3%type) return varchar2 is
    begin
    g_rec.attrib_1 := p_attrib_1;
    g_rec.attrib_2 := p_attrib_2;
    g_rec.attrib_3 := p_attrib_3;
    return 'OK';
    end;
    function get_attrib(p_name in varchar2) return varchar2 is
    l_return varchar2(200);
    begin
    if p_name = 'ATTRIB_1' then
    l_return := g_rec.attrib_1;
    elsif p_name = 'ATTRIB_2' then
    l_return := g_rec.attrib_2;
    elsif p_name = 'ATTRIB_3' then
    l_return := g_rec.attrib_3;
    end if;
    return l_return;
    end;
    end;
    /

    It's not necessarily that the problem is within your package code. As long as UNIQUE constraint exists on DEST table, any MERGE statement may fail with ORA-00001 due to concurrent updates and inserts taking place.
    Of course, it's just my guess but consider the following scenario (three sessions modify DEST table in parallel – and to keep this example clear, I put their commands in chronological order):
    S#1>  create table dest(x primary key, y) as
      2   select rownum, rownum
      3     from dual
      4  connect by level <= 5;
    Table created.
    S#1>  create table src(x, y) as
      2   select rownum + 1, rownum + 1
      3     from dual
      4  connect by level <= 5;
    Table created.
    S#1> select * from src;
             X          Y
             2          2
             3          3
             4          4
             5          5
             6          6
    S#1> select * from dest;
             X          Y
             1          1
             2          2
             3          3
             4          4
             5          5
    S#2> -- Now, session #2 will update one row in DEST table
    S#2> update dest
      2     set y = 40
      3   where x = 4;
    1 row updated.
    S#2> select * from dest;
             X          Y
             1          1
             2          2
             3          3
             4         40
             5          5
    S#1> -- Session #1 issues the following MERGE:
    S#1> merge into dest d
      2  using (select * from src) s
      3     on (s.x = d.x)
      4   when matched then update set d.y = s.y
      5   when not matched then insert (d.x, d.y)
      6        values (s.x, s.y);
    -- At this point, session #1 becomes blocked as it can not modify row locked by session #2
    S#3> -- Now, session #3 inserts new row into DEST and commits.
    S#3> -- MERGE in session #1 is still blocked.
    S#3> insert into dest values (6, 6);
    1 row created.
    S#3> select * from dest;
             X          Y
             1          1
             2          2
             3          3
             4          4
             5          5
             6          6
    6 rows selected.
    S#3> commit;
    Commit complete.
    S#2> -- Session #2 rolls back its UPDATE.
    S#2> rollback;
    Rollback complete.
    -- Finally, session #1 is getting unblocked, but...
    merge into dest d
    ERROR at line 1:
    ORA-00001: unique constraint (MAX.SYS_C0032125) violated
    S#1>Hope this helps,
    Andrew.

  • Merge inserting duplicate rows

    Hi,
    I first check if a particular dept_no exists in the table, if not insert into the table. I am getting duplicate rows inserted.
    This is the table data before Merge.
       CUST_ID FIRST_NAME           LAST_NAME               DEPT_NO     SALARY
             1 Dan                  Morgan                       10     100000
             2 Jack                 Cline                        20     100000
             3 Helen                Lofstrom                     20      50000This is the table data after Merge.
    3 rows merged.
       CUST_ID FIRST_NAME           LAST_NAME               DEPT_NO     SALARY
             1 Dan                  Morgan                       10     100000
             2 Jack                 Cline                        20     100000
             3 Helen                Lofstrom                     20      50000
             4 Ram                  Bharad                       30       2000
             4 Ram                  Bharad                       30       2000
             4 Ram                  Bharad                       30       2000
    6 rows selected.This is the code to merge
    MERGE INTO customer c
    USING ( SELECT cust_id,
                   first_name,
                   last_name,
                   dept_no,
                   salary
            FROM customer ) e
    ON ( c.dept_no = 30 )
    WHEN MATCHED THEN
        UPDATE SET
               c.cust_id    = 4,
               c.first_name = 'Ram',
               c.last_name  = 'Bharad',
               c.salary     = 2000
    WHEN NOT MATCHED THEN
        INSERT
        (c.cust_id,c.first_name, c.last_name,c.dept_no,c.salary)
        VALUES
        (4,'Ram','Bharad',30,2000);Shouldn't the above code insert once, and update twice?
    Thanks

    You have done it wrong...
    Try like this
    SQL> create table customer(cust_id number,first_name varchar2(20), last_name varchar2(20), dept_no number, salary number)
      2  /
    Table created.
    SQL> insert into customer
      2  select 1, 'Dan','Morgan',10,100000 from dual
      3  union all
      4  select 2, 'Jack','Cline',20,100000 from dual
      5  union all
      6  select 3, 'Helen','Lofstrom',20,50000 from dual
      7  /
    3 rows created.
    SQL> commit
      2  /
    Commit complete.
    SQL> select * from customer
      2  /
       CUST_ID FIRST_NAME           LAST_NAME               DEPT_NO     SALARY
             1 Dan                  Morgan                       10     100000
             2 Jack                 Cline                        20     100000
             3 Helen                Lofstrom                     20      50000
    SQL> MERGE INTO customer c
      2  USING ( SELECT 4 cust_id,
      3                 'Ram' first_name,
      4                 'Bharad' last_name,
      5                 30 dept_no,
      6                 2000 salary
      7          FROM dual ) e
      8  ON ( c.dept_no = e.dept_no )
      9  WHEN MATCHED THEN
    10      UPDATE SET
    11             c.cust_id    = e.cust_id,
    12             c.first_name = e.first_name,
    13             c.last_name  = e.last_name,
    14             c.salary     = e.salary
    15  WHEN NOT MATCHED THEN
    16      INSERT
    17      (c.cust_id,c.first_name, c.last_name,c.dept_no,c.salary)
    18      VALUES
    19      (e.cust_id,e.first_name, e.last_name,e.dept_no,e.salary);
    1 row merged.
    SQL> select * from customer
      2  /
       CUST_ID FIRST_NAME           LAST_NAME               DEPT_NO     SALARY
             1 Dan                  Morgan                       10     100000
             2 Jack                 Cline                        20     100000
             3 Helen                Lofstrom                     20      50000
             4 Ram                  Bharad                       30       2000but beware of the fact that you are joining based on dept_no so multiple rows can get updated with same cust_id. see below.
    SQL> rollback
      2  /
    Rollback complete.
    SQL>  MERGE INTO customer c
      2   USING ( SELECT 4 cust_id,
      3             'Ram' first_name,
      4             'Bharad' last_name,
      5             20 dept_no,
      6             2000 salary
      7      FROM dual ) e
      8   ON ( c.dept_no = e.dept_no )
      9   WHEN MATCHED THEN
    10       UPDATE SET
    11         c.cust_id    = e.cust_id,
    12         c.first_name = e.first_name,
    13         c.last_name  = e.last_name,
    14         c.salary     = e.salary
    15   WHEN NOT MATCHED THEN
    16       INSERT
    17       (c.cust_id,c.first_name, c.last_name,c.dept_no,c.salary)
    18       VALUES
    19       (e.cust_id,e.first_name, e.last_name,e.dept_no,e.salary);
    2 rows merged.
    SQL> select * from customer
      2  /
       CUST_ID FIRST_NAME           LAST_NAME               DEPT_NO     SALARY
             1 Dan                  Morgan                       10     100000
             4 Ram                  Bharad                       20       2000
             4 Ram                  Bharad                       20       2000Thanks,
    Karthick.

  • Merge only one row out of multiple rows

    I need to prepare a merge statement which merge only one row in to a table. Below is the table definition, sample data and merge statement i used.
          CREATE TABLE Mob_Attr (NAME VARCHAR2(20), ATTR_1 VARCHAR2(20), ATTR_2 VARCHAR2(20), ATTR_3 VARCHAR2(20));
          CREATE TABLE Mob_Desc (NAME VARCHAR2(50), ATTR_1 VARCHAR2(20), ID NUMBER(20));     
          CREATE TABLE Mob_Main (NAME VARCHAR2(20), ATTR VARCHAR2(20), ID VARCHAR2(10));     
          insert into Mob_Attr(name, attr_1, attr_2,attr_3) values ('n1','aa',null,null);
          insert into Mob_Attr(name, attr_1, attr_2,attr_3) values ('n2','bb',null,null);
          insert into Mob_Attr(name, attr_1, attr_2,attr_3) values ('n3','cc',null,null);
          insert into Mob_Attr(name, attr_1, attr_2,attr_3) values ('n4','dd',null,null);
          insert into Mob_Desc (NAME,ATTR_1,ID) values ('n1','aa',10);
          insert into Mob_Desc (NAME,ATTR_1,ID) values ('n1','aa',15);
          insert into Mob_Desc (NAME,ATTR_1,ID) values ('n1','aa',123);
          insert into Mob_Desc (NAME,ATTR_1,ID) values ('n1','aa',1455);
          insert into Mob_Desc (NAME,ATTR_1,ID) values ('n2','bb',455);
          insert into Mob_Desc (NAME,ATTR_1,ID) values ('n2','bb',135);
          insert into Mob_Desc (NAME,ATTR_1,ID) values ('n3','cc',15);
          insert into Mob_Desc (NAME,ATTR_1,ID) values ('n3','cc',52);
          insert into Mob_Desc (NAME,ATTR_1,ID) values ('n4','dd',1455);
          merge into Mob_Main ma using
          (select d.name, d.attr_1,d.id from Mob_Attr a, Mob_Desc d
          where a.name = d.name and a.attr_1 = d.attr_1
          ) q on (ma.name=q.name and ma.attr=q.attr_1)
          when not matched then
          insert (NAME,ATTR,ID)
          values (q.name,q.attr_1,q.ID);
          Above merge statement will actually merge entire data . But i want the first row will only get inserted to the base table (Mob_Main). If we take name 'n1' first row from table Mob_Desc with ID as '10' only should get inserted. I can go for a cursor to do this as i have huge data volume i prefer merge instead.

    MERGE INTO Mob_Main ma
         USING (SELECT d.name, d.attr_1, d.id
                  FROM Mob_Attr a, Mob_Desc d
                 WHERE a.name = d.name AND a.attr_1 = d.attr_1 AND id = 10
                UNION
                SELECT d.name, d.attr_1, d.id
                  FROM Mob_Attr a, Mob_Desc d
                 WHERE a.name = d.name AND a.attr_1 = d.attr_1 AND id != 10
                       AND NOT EXISTS
                                  (SELECT 1
                                     FROM Mob_Desc d1
                                    WHERE     d.name = d1.name
                                          AND d.attr_1 = d1.attr_1
                                          AND d1.id = 10)) q
            ON (ma.name = q.name AND ma.attr = q.attr_1)
    WHEN NOT MATCHED
    THEN
       INSERT     (NAME, ATTR, ID)
           VALUES (q.name, q.attr_1, q.ID);
    COMMIT;
    select *
    from Mob_Main
    order by name, id;
    NAME                 ATTR                 ID       
    n1                   aa                   10       
    n2                   bb                   135      
    n2                   bb                   455      
    n3                   cc                   15       
    n3                   cc                   52       
    n4                   dd                   1455     
    6 rows selected.

  • How To Concatenate Column Values from Multiple Rows into a Single Column?

    How do I create a SQL query that will concatenate column values from multiple rows into a single column?
    Last First Code
    Lesand Danny 1
    Lesand Danny 2
    Lesand Danny 3
    Benedi Eric 7
    Benedi Eric 14
    Result should look like:
    Last First Codes
    Lesand Danny 1,2,3
    Benedi Eric 7,14
    Thanks,
    David Johnson

    Starting with Oracle 9i
    select last, first, substr(max(sys_connect_by_path(code,',')),2) codes
    from
    (select last, first, code, row_number() over(partition by last, first order by code) rn
    from a)
    connect by last = prior last and first = prior first and prior rn = rn -1
    start with rn = 1
    group by last, first
    LAST       FIRST      CODES                                                                                                                                                                                                  
    Lesand         Danny          1,2,3
    Benedi         Eric           7,14Regards
    Dmytro

  • Need help with turning multiple rows into a single row

    Hello.
    I've come across a situation that is somewhat beyond my knowledge base. I could use a little help with figuring this out.
    My situation:
    I am attempting to do some reporting from a JIRA database. What I am doing is getting the dates and times for specific step points of a ticket. This is resulting in many rows per ticket. What I need to do is return one row per ticket with a calculation of time between each step. But one issue is that if a ticket is re-opened, I want to ignore all data beyond the first close date. Also, not all tickets are in a closed state. I am attaching code and a sample list of the results. If I am not quite clear, please ask for information and I will attempt to provide more. The database is 10.2.0.4
    select jiraissue.id, pkey, reporter, summary
    ,changegroup.created change_dt
    ,dbms_lob.substr(changeitem.newstring,15,1) change_type
    ,row_number() OVER ( PARTITION BY jiraissue.id ORDER BY changegroup.created ASC ) AS order_row
    from jiraissue
    ,changeitem, changegroup
    ,(select * from customfieldvalue where customfield = 10591 and stringvalue = 'Support') phaseinfo
    where jiraissue.project = 10110
    and jiraissue.issuetype = 51
    and dbms_lob.substr(changeitem.newstring,15,1) in ('Blocked','Closed','Testing','Open')
    and phaseinfo.issue = jiraissue.id
    and changeitem.groupid = changegroup.id
    and changegroup.issueid = jiraissue.id
    order by jiraissue.id,change_dt
    Results:
    1     21191     QCS-91     Error running the Earliest-deadlines flight interface request/response message     2008-07-16 9:30:38 AM     Open     1
    2     21191     QCS-91     Error running the Earliest-deadlines flight interface request/response message     2008-07-16 11:37:02 AM     Testing     2
    3     21191     QCS-91     Error running the Earliest-deadlines flight interface request/response message     2010-06-08 9:14:52 AM     Closed     3
    4     21191     QCS-91     Error running the Earliest-deadlines flight interface request/response message     2010-09-02 11:29:37 AM     Open     4
    5     21191     QCS-91     Error running the Earliest-deadlines flight interface request/response message     2010-09-02 11:29:42 AM     Open     5
    6     21191     QCS-91     Error running the Earliest-deadlines flight interface request/response message     2010-09-02 11:29:50 AM     Testing     6
    7     21191     QCS-91     Error running the Earliest-deadlines flight interface request/response message     2010-09-02 11:29:53 AM     Closed     7
    8     23234     QCS-208     System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role      2008-10-03 10:26:21 AM     Open     1
    9     23234     QCS-208     System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role      2008-11-17 9:39:39 AM     Testing     2
    10     23234     QCS-208     System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role      2011-02-02 6:18:02 AM     Closed     3
    11     23977     QCS-311     Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks     2008-09-29 2:44:54 PM     Open     1
    12     23977     QCS-311     Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks     2010-05-29 4:47:37 PM     Blocked     2
    13     23977     QCS-311     Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks     2011-02-02 6:14:57 AM     Open     3
    14     23977     QCS-311     Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks     2011-02-02 6:15:32 AM     Testing     4
    15     23977     QCS-311     Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks     2011-02-02 6:15:47 AM     Closed     5

    Hi,
    Welcome to the forum!
    StblJmpr wrote:
    ... I am attempting to do some reporting from a JIRA database. What is a JIRA database?
    I am attaching code and a sample list of the results. If I am not quite clear, please ask for information and I will attempt to provide more. Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and the results you want from that data.
    Simplify the problem as much as possible. For example, if the part you don't know how to do only involves 2 tables, then jsut post a question involving those 2 tables. So you might just post this much data:
    CREATE TABLE     changegroup
    (      issueid          NUMBER
    ,      created          DATE
    ,      id          NUMBER
    INSERT INTO changegroup (issueid, created, id) VALUES (21191,  TO_DATE ('2008-07-16 09:30:38 AM', 'YYYY-MM-DD HH:MI:SS AM'),  10);
    INSERT INTO changegroup (issueid, created, id) VALUES (21191,  TO_DATE ('2008-07-16 11:37:02 AM', 'YYYY-MM-DD HH:MI:SS AM'),  20);
    INSERT INTO changegroup (issueid, created, id) VALUES (21191,  TO_DATE ('2010-06-08 09:14:52 AM', 'YYYY-MM-DD HH:MI:SS AM'),  90);
    INSERT INTO changegroup (issueid, created, id) VALUES (21191,  TO_DATE ('2010-09-02 11:29:37 AM', 'YYYY-MM-DD HH:MI:SS AM'),  10);
    INSERT INTO changegroup (issueid, created, id) VALUES (21191,  TO_DATE ('2010-09-02 11:29:42 AM', 'YYYY-MM-DD HH:MI:SS AM'),  10);
    INSERT INTO changegroup (issueid, created, id) VALUES (21191,  TO_DATE ('2010-09-02 11:29:50 AM', 'YYYY-MM-DD HH:MI:SS AM'),  20);
    INSERT INTO changegroup (issueid, created, id) VALUES (21191,  TO_DATE ('2010-09-02 11:29:53 AM', 'YYYY-MM-DD HH:MI:SS AM'),  90);
    INSERT INTO changegroup (issueid, created, id) VALUES (23234,  TO_DATE ('2008-10-03 10:26:21 AM', 'YYYY-MM-DD HH:MI:SS AM'),  10);
    INSERT INTO changegroup (issueid, created, id) VALUES (23234,  TO_DATE ('2008-11-17 09:39:39 AM', 'YYYY-MM-DD HH:MI:SS AM'),  20);
    INSERT INTO changegroup (issueid, created, id) VALUES (23234,  TO_DATE ('2011-02-02 06:18:02 AM', 'YYYY-MM-DD HH:MI:SS AM'),  90);
    INSERT INTO changegroup (issueid, created, id) VALUES (23977,  TO_DATE ('2008-09-29 02:44:54 PM', 'YYYY-MM-DD HH:MI:SS AM'),  10);
    INSERT INTO changegroup (issueid, created, id) VALUES (23977,  TO_DATE ('2010-05-29 04:47:37 PM', 'YYYY-MM-DD HH:MI:SS AM'),  30);
    INSERT INTO changegroup (issueid, created, id) VALUES (23977,  TO_DATE ('2011-02-02 06:14:57 AM', 'YYYY-MM-DD HH:MI:SS AM'),  10);
    INSERT INTO changegroup (issueid, created, id) VALUES (23977,  TO_DATE ('2011-02-02 06:15:32 AM', 'YYYY-MM-DD HH:MI:SS AM'),  20);
    INSERT INTO changegroup (issueid, created, id) VALUES (23977,  TO_DATE ('2011-02-02 06:15:47 AM', 'YYYY-MM-DD HH:MI:SS AM'),  90);
    CREATE TABLE     changeitem
    (      groupid          NUMBER
    ,      newstring     VARCHAR2 (10)
    INSERT INTO changeitem (groupid, newstring) VALUES (10, 'Open');
    INSERT INTO changeitem (groupid, newstring) VALUES (20, 'Testing');
    INSERT INTO changeitem (groupid, newstring) VALUES (30, 'Blocked');
    INSERT INTO changeitem (groupid, newstring) VALUES (90, 'Closed');Then post the results you want to get from that data, like this:
    ISSUEID HISTORY
      21191 Open (0) >> Testing (692) >> Closed
      23234 Open (45) >> Testing (807) >> Closed
      23977 Open (607) >> Blocked (249) >> Open (0) >> Testing (0) >> ClosedExplain how you get those results from that data. For example:
    "The output contains one row per issueid. The HISTORY coloumn shows the different states that the issue went through, in order by created, starting with the earliest one and continuing up until the first 'Closed' state, if there is one. Take the first row, issueid=21191, for example. It started as 'Open' on July 16, 2008, then, on the same day (that is, 0 days later) changed to 'Testing', and then, on June 8, 2010, (692 days later), it became 'Closed'. That same issue opened again later, on September 2, 2010, but I don't want to see any activity after the first 'Closed'."
    The database is 10.2.0.4That's very important. Always post your version, like you did.
    Here's one way to get those results from that data:
    WITH     got_order_row     AS
         SELECT     cg.issueid
         ,     LEAD (cg.created) OVER ( PARTITION BY  cg.issueid
                                          ORDER BY      cg.created
                  - cg.created            AS days_in_stage
         ,       ROW_NUMBER ()     OVER ( PARTITION BY  cg.issueid
                                          ORDER BY      cg.created
                               )    AS order_row
         ,     ci.newstring                     AS change_type
         FROM    changegroup     cg
         JOIN     changeitem     ci  ON   cg.id     = ci.groupid
         WHERE     ci.newstring     IN ( 'Blocked'
                           , 'Closed'
                           , 'Testing'
                           , 'Open'
    --     AND     ...          -- any other filtering goes here
    SELECT       issueid
    ,       SUBSTR ( SYS_CONNECT_BY_PATH ( change_type || CASE
                                                             WHEN  CONNECT_BY_ISLEAF = 0
                                           THEN  ' ('
                                              || ROUND (days_in_stage)
                                              || ')'
                                                         END
                                    , ' >> '
               , 5
               )     AS history
    FROM       got_order_row
    WHERE       CONNECT_BY_ISLEAF     = 1
    START WITH     order_row          = 1
    CONNECT BY     order_row          = PRIOR order_row + 1
         AND     issueid               = PRIOR issueid
         AND     PRIOR change_type     != 'Closed'
    ORDER BY  issueid
    ;Combining data from several rows into one big delimited VARCHAR2 column on one row is call String Aggregation .
    I hope this answers your question, but I guessed at so many things, I won't be surprised if it doesn't. If that's the case, point out where this is wrong, post what the results should be in those places, and explain how you get those results. Post new data, if necessary.

  • Merging multiple rows in to a single row (when rows meet merging criteria)

    Hi 
    I have a scenario to merge multiple rows in to a single rows when the data in those rows fall in merge criteria .Below is how my data is 
    Now the merging logic for the above rows is , we need to combine multiple rows in to a single row when the data in those rows permits us to do in that way. Simply saying , its like sandwich where we combine multiple things to a single piece.The output for
    the above rows should be
    Here  we combined Row 1 ,2, 3 in to a single row as the data in those rows permits to merge in to single row. But the row 4 cannot be combined to any of those rows because the data in those rows doesn't permits us do a merge ( As the value of the column
    JobSource for the row 4 is different from the other rows ) .
    My original data has 56 columns , but for readability i kept only 9 columns. 
    can you please throw some idea on how to achieve this scenario. I know we need to use CTE for achieving this, but i am not able succeed in doing an iteration on multiple rows.
    Appreciate your response .

    Thanks for your reply .
    Rule for merging is simple . First of all there is no unique row identifier for each row , the fact table is not having an identity column in the database . I called row 1 , row 2  etc in my post above only to make better explanation of my scenario.
    The rule for merge is below. 
    1) we can combine only when the data in a column for one row is null & the data in same column for the other row is not null . It should also satisfy the condition where the data in other columns should conflict each other.
    2) Data for all columns for the merging rows should not be conflicting (i.e. we should not merge the rows when the data in a column is not equal to the same column in the other row
    ,considering not null value)
    Steps in merging the above source data :
    1) Consider the case of row 1 and row 2 in the source, we can combine these rows as the data is satisfying the rule 1 for columns (Jobsource,Flight, Package,Update,Iscancelled
    ,Result, Severity) and columns (JobID and RuleName ) fall under rule 2.  we merge these two rows in to a single row and keep in that in the table.
    2) Then the resulting row is again merged with the second row which is present above by applying the rule 1 and rule 2 . Below would be output of merge operation.
    Now there would be only two rows in the output . But these rows cannot be merged as the data doesn't satisfy the merge rules 2 . As Jobsource for the row 1 in the above output is "PresubmissionSource" which is not equal
    to "PostSubmission" jobSource which is in row 2. So these two rows are left unmerged .So the above two rows would be the output of merge operation on my source data.
    This process has to be repeated for all the rows in the table. As of now my table as 92 Million rows with 56 columns which need to be considered for merging rows. I replicated my scenario in 9 columns and 4 rows to understand better.

  • Problem in displaying the data of columns into rows in sap script

    hi,
    i am working on a sap script and i have to display the dat which is displayed in column into rows but it is not displaying it properly.
    eg, C
        12.1
        Si
        5.5
    it is displaying the data right now like this but i want to display the  data like this:-
    eg, C      Si
        12.1   5.5
    plzzprovide me guidelines how to solve this problem.

    hi,
    i am using this code to display the data:-
    plzz provide me guidelines where i am getting wrong?
    TOPparCOMPONENT DESP,,,,,, INS. LOT #, , , , , , MIC,,,,,,,,,, MIC VALUEparENDTOPparFINAL
    PROTECT
    IF &I_FINAL-PRUEFLOS& NE '000000000000'
    &I_FINAL-MAKTX(23)&&i_final-prueflos(12Z)&
    &I_FINAL-kurztext(25)&
    &I_FINAL-original_input(8)&
    ELSE
    &I_FINAL-MAKTX(23)&     
    &I_FINAL-kurztext(25)&
    &I_FINAL-original_input(8)&
    ENDIF
    ENDPROTECT
    ITEMHEAD
    POSITION WINDOW
    SIZE WIDTH +0 . 4 CH HEIGHT +1 LN
    BOX FRAME 10 TW
    BOX HEIGHT '1.35' LN INTENSITY 20
    IF &PAGE& = '1'
    BOX XPOS '0' CH YPOS '0' CM WIDTH '0' CM HEIGHT '43' LN FRAME '10' TW
    For horizontal line at top
    BOX XPOS '0' CH YPOS '0' CM WIDTH '75' CH HEIGHT '0' LN FRAME '10' TW
    COLUMN LINES...
    END OF COLUMN LINES...
    BOX XPOS '0' CH YPOS '43' LN WIDTH '75' CH HEIGHT '0' LN FRAME '10'TW
    BOX XPOS '75' CH YPOS '0' LN WIDTH '0' CH HEIGHT '43' LN FRAME '10'TW
    ELSE
    COLUMN LINES...
    END OF COLUMN LINES...
    BOX XPOS '0' CH YPOS '0' CM WIDTH '0' CM HEIGHT '47' LN FRAME '10' TW
    BOX XPOS '0' CH YPOS '0' CM WIDTH '75' CH HEIGHT '0' LN FRAME '10' TW
    BOX XPOS '0' CH YPOS '0' CM WIDTH '45' CM HEIGHT '0' LN FRAME '10' TW
    BOX XPOS '20' CH YPOS '0' CM WIDTH '0' CM HEIGHT '47' LN FRAME '10' TW
    BOX XPOS '0' CH YPOS '47' LN WIDTH '75' CH HEIGHT '0' LN FRAME '10'TW
    BOX XPOS '75' CH YPOS '0' LN WIDTH '0' CH HEIGHT '47' LN FRAME '10'TW
    ENDIF
    LINEFEED
    NEWPAGE
    NEW-PAGE
    provide me guidelines to solve this problem.
    Edited by: ricx .s on Mar 13, 2009 5:58 AM

  • Error inserting a row into a table with identity column using cfgrid on change

    I got an error on trying to insert a row into a table with identity column using cfgrid on change see below
    also i would like to use cfstoreproc instead of cfquery but which argument i need to pass and how to use it usually i use stored procedure
    update table (xxx,xxx,xxx)
    values (uu,uuu,uu)
         My component
    <!--- Edit a Media Type  --->
        <cffunction name="cfn_MediaType_Update" access="remote">
            <cfargument name="gridaction" type="string" required="yes">
            <cfargument name="gridrow" type="struct" required="yes">
            <cfargument name="gridchanged" type="struct" required="yes">
            <!--- Local variables --->
            <cfset var colname="">
            <cfset var value="">
            <!--- Process gridaction --->
            <cfswitch expression="#ARGUMENTS.gridaction#">
                <!--- Process updates --->
                <cfcase value="U">
                    <!--- Get column name and value --->
                    <cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
                    <cfset value=ARGUMENTS.gridchanged[colname]>
                    <!--- Perform actual update --->
                    <cfquery datasource="#application.dsn#">
                    UPDATE SP.MediaType
                    SET #colname# = '#value#'
                    WHERE MediaTypeID = #ARGUMENTS.gridrow.MediaTypeID#
                    </cfquery>
                </cfcase>
                <!--- Process deletes --->
                <cfcase value="D">
                    <!--- Perform actual delete --->
                    <cfquery datasource="#application.dsn#">
                    update SP.MediaType
                    set Deleted=1
                    WHERE MediaTypeID = #ARGUMENTS.gridrow.MediaTypeID#
                    </cfquery>
                </cfcase>
                <cfcase value="I">
                    <!--- Get column name and value --->
                    <cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
                    <cfset value=ARGUMENTS.gridchanged[colname]>
                    <!--- Perform actual update --->
                   <cfquery datasource="#application.dsn#">
                    insert into  SP.MediaType (#colname#)
                    Values ('#value#')              
                    </cfquery>
                </cfcase>
            </cfswitch>
        </cffunction>
    my table
    mediatype:
    mediatypeid primary key,identity
    mediatypename
    my code is
    <cfform method="post" name="GridExampleForm">
            <cfgrid format="html" name="grid_Tables2" pagesize="3"  selectmode="edit" width="800px" 
            delete="yes"
            insert="yes"
                  bind="cfc:sp3.testing.MediaType.cfn_MediaType_All
                                                                ({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})"
                  onchange="cfc:sp3.testing.MediaType.cfn_MediaType_Update({cfgridaction},
                                                {cfgridrow},
                                                {cfgridchanged})">
                <cfgridcolumn name="MediaTypeID" header="ID"  display="no"/>
                <cfgridcolumn name="MediaTypeName" header="Media Type" />
            </cfgrid>
    </cfform>
    on insert I get the following error message ajax logging error message
    http: Error invoking xxxxxxx/MediaType.cfc : Element '' is undefined in a CFML structure referenced as part of an expression.
    {"gridaction":"I","gridrow":{"MEDIATYPEID":"","MEDIATYPENAME":"uuuuuu","CFGRIDROWINDEX":4} ,"gridchanged":{}}
    Thanks

    Is this with the Travel database or another database?
    If it's another database then make sure your columns
    allow nulls. To check this in the Server Navigator, expand
    your DataSource down to the column.
    Select the column and view the Is Nullable property
    in the Property Sheet
    If still no luck, check out a tutorial, like Performing Inserts, ...
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/index.jsp
    John

Maybe you are looking for