Urgent!!! Modify column of a table having records

Dear all,
I have a table with a column VARCHAR2(12) and I need to modify this column into VARCHAR2(9) without losing any data! s there any workaround?
Thanx a lot!!

This code was posted in one of the previous Oracle magazines:
The Pl/Sql procedure to rename the column must be compiled in to the database you require to rename columns in - one note I would run this as SYS:
create or replace procedure RenameColumn
(pUserName varchar2,
pTableName varchar2,
pOldColumnName varchar2,
pNewColumnName varchar2
is
vUserName dba_users.userName%type :=
upper(ltrim(rtrim(pUserName)));
vTableName dba_tables.table_name%type :=
upper(ltrim(rtrim(pTableName)));
vOldColumnName dba_tab_columns.column_name%type :=
upper(ltrim(rtrim(pOldColumnName)));
vNewColumnName dba_tab_columns.column_name%type :=
upper(ltrim(rtrim(pNewColumnName)));
vErrorMessage varchar2(4000);
eNotAuthorizedUser exception; /* -20101 */
eInvalidUser exception; /* -20102 */
eInvalidTable exception; /* -20103 */
eInvalidOldColumn exception; /* -20104 */
eInvalidNewColumn exception; /* -20105 */
cursor csrCheckUser
(pUser dba_users.userName%type)
is
select '1'
from dba_users
where userName = pUser;
cursor csrCheckTable
(pUser dba_tables.owner%type,
pTable dba_tables.table_name%type)
is
select '1'
from dba_tables
where owner = pUser
and table_name = pTable;
cursor csrCheckExistingColumn
(pUser dba_tables.owner%type,
pTable dba_tables.table_name%type,
pColumn dba_tab_columns.column_name%type)
is
select '1'
from dba_tab_columns
where owner = pUser
and table_name = pTable
and column_name = pColumn;
vDummy char(1);
begin
if user <> 'SYS'
then
raise eNotAuthorizedUser;
end if;
/* Check the value of vUserName */
if vUserName is null
then
raise eInvalidUser;
end if;
open csrCheckUser(vUserName);
fetch csrCheckUser into vDummy;
if csrCheckUser%notfound
then
close csrCheckUser;
raise eInvalidUser;
end if;
close csrCheckUser;
/* Check the value of vTableName */
if vTableName is null
then
raise eInvalidTable;
end if;
open csrCheckTable(vUserName, vTableName);
fetch csrCheckTable into vDummy;
if csrCheckTable%notfound
then
close csrCheckTable;
raise eInvalidTable;
end if;
close csrCheckTable;
/* Check the value of vOldColumnName */
if vOldColumnName is null
then
raise eInvalidOldColumn;
end if;
open csrCheckExistingColumn(vUserName, vTableName, vOldColumnName);
fetch csrCheckExistingColumn into vDummy;
if csrCheckExistingColumn%notfound
then
close csrCheckExistingColumn;
raise eInvalidOldColumn;
end if;
close csrCheckExistingColumn;
/* Check the value of vNewColumnName */
if vNewColumnName is null
then
raise eInvalidNewColumn;
end if;
open csrCheckExistingColumn(vUserName, vTableName, vNewColumnName);
fetch csrCheckExistingColumn into vDummy;
if csrCheckExistingColumn%found
then
close csrCheckExistingColumn;
raise eInvalidNewColumn;
end if;
close csrCheckExistingColumn;
/* Update the row in col$ Oracle dictionary */
update col$
set name = vNewColumnName
where (obj#, col#) in
(select obj#,
col#
from col$
where name = vOldColumnName
and obj# = (select obj#
from obj$
where name = vTableName
and owner# = (select user_id
from dba_users
where username = vUserName)));
commit;
exception
when eNotAuthorizedUser
then
vErrorMessage := 'User ' || user ||
' is not authorized to run this procedure.';
raise_application_error(-20101, vErrorMessage);
when eInvalidUser
then
vErrorMessage := 'Invalid user name: ' ||
pUserName || '.';
raise_application_error(-20102, vErrorMessage);
when eInvalidTable
then
vErrorMessage := 'Invalid table name: ' ||
pTableName || '.';
raise_application_error(-20103, vErrorMessage);
when eInvalidOldColumn
then
vErrorMessage := 'Invalid old column name: ' ||
pOldColumnName || '.';
raise_application_error(-20104, vErrorMessage);
when eInvalidNewColumn
then
vErrorMessage := 'Invalid new column name: ' ||
pNewColumnName || '.';
raise_application_error(-20105, vErrorMessage);
end RenameColumn;
Once you have the above in and compiled okay then you can rename you column names by:
begin
RenameColumn('SCOTT', 'EMPTEST', 'SAL', 'SALARY');
end;
also while still connected as SYS, note the parameters SCOTT should be the schema owner which contains the table, EMPTEST is the table name which contains the column, SAL is the old column name and SALARY is the new column name.
Have fun.

Similar Messages

  • Getting errors when updating a column on a table having a primary key

    Hi,
    I have an application on Oracle APEX that raises the following error after an attempt (through the application) to update a column with no specific constraint on it:
    ORA-06550: line 1, column 17: PL/SQL: ORA-00936: missing expression ORA-06550: line 1, column 9: PL/SQL: SQL Statement ignoredUnable to fetch row.
    The involved table has a primary key conatraint and the corresponding column can be populated by a sequence (but there is no trigger to manipulate the sequence).
    The sequence is mentioned in the involved page definition for populating the primary key.
    If I disable the primry key and set to null the corresponding value for the primary of the record to be updated, then it is possible to update that record (thus the above column) through the application.
    Did someone encountered this situation before?
    If yes, what was then your workaround/solution?
    Kind Regards.

    Dear user8058501 ,
    Firstly) Did you check
    Auto Row Fetch (After upgrade to 4.0.1)
    Automated Row Fetch on Table with Synonym causes ORA-00936: missing expr.
    Secondly) If the problem is not resolved, Would you provide a sample on apex.oracle.com with workspace/developer account to be able to help you
    Please, if this solves your question, mark it as Correct. Otherwise as helpful.
    Best Regards
    Mahmoud

  • ORA-30036 when modifying column in large table

    Oracle version 10.2.0.4
    Afternoon everyone!
    I have a large table that I need to modify a column in - increasing from CHAR(3) to CHAR(6)
    On altering the table I'm getting an ORA-30036: unable to extend segment but 8 in undo tablespace
    Increasing undo tbs size isn't really an option, and I don't really want to go copying the table elsewhere either - again due to space limitations.
    Is there a way to avoid this undo exhaustion? Will disabling logging for this table solve my issue? Or is there another way similar to the 'checkpoint' clause you can use when dropping columns?
    Many thanks!
    Adam M

    Just in case nothing better appears and you can't increase the UNDO ...
    1. Create a new table with the correct datatype
    2. Insert data from the old table to the new table, in batches if necessary. Divide the data by key values if possible or get a range of rowids to process or something
    3. Make sure dependent objects are created for the new table
    4. drop the old table
    5. rename the old table to the new table

  • Modifying datatype of columns across multiple tables

    Hi,
    I have a requirement where-in I have to modify the datatypes of columns across multiple tables. Is there any direct way to do this? I mean does oracle has any function or in-built functionality to achieve this.
    Example;
    Table1 -> col1 datatype needs to be changed to varchar2(10)
    Table2 -> col2 datatype needs to be changed to varchar2(30)
    Table3 -> col3 datatype needs to be changed to number.
    and so on....
    Do we have such functionality?
    Thanks,
    Ishan

    Hi Aman,
    Seeing the replies, I think I was unclear in the requirements. But I guess you understood it fully, but still I would like to restate my question once again, just to be 100% sure.
    What I actually want is that in one shot, I would be able to modify columns of multible tables.
    eg, table1-> col1 changed to varchar2(20);
    table2->col2 changed to varchar2(10)
    table3-> col3 changed to number;
    I know how to do it individually, but just wanted to check, if only one command can modify the datatypes of multiple tables/.
    If not, I have already written half the script, but just for knowledge sake wanted to check if some feature is available in oracle for that.
    Regards,
    Ishan

  • How can I modify this to process 80,000 records at a time until finish.

    Hello it's me again -
    Without using a rownum limit in my cursor declare my record-set is around 10 million records. This causes problems within our environment. Is there a way I can loop the following code and only do 80,000 at a time.
    1 process 80,000
    2. process next 80,000.
    How would I redeclare the cursor in a loop and grab the next 80,000?
    Thanks again
    Steve
    SET SERVEROUTPUT ON
    DECLARE
    CURSOR vt_mlr_cursor IS Select master_key, tn, user2 from vt_mlr Where user2 is not null and rownum < 80001;
    USERFIELD VARCHAR2(100);
    R_count NUMBER := 0;
    Field1 VARCHAR2(20);
    Field2 VARCHAR2(20);
    key VARCHAR2(10);
    phone VARCHAR2(11);
    BEGIN
    FOR vt_mlr_record IN vt_mlr_cursor
    LOOP
    BEGIN
         key := vt_mlr_record.master_key;
         phone     := vt_mlr_record.tn;
         USERFIELD := vt_mlr_record.user2;
         Field1 := SUBSTR(vt_mlr_record.user2,12,4);
         Field2 := SUBSTR(vt_mlr_record.user2,28,4);
              UPDATE vt_mlr
              SET
              line_medr = Field1,
              line_aidr = Field2
              WHERE
              master_key = vt_mlr_record.master_key;
              R_count := R_count + 1;
         EXCEPTION
         when others then
         Insert into temp_reject (REJECT_KEY, REJECT_TN, REJECT_VALUE) VALUES
         (key, phone, 'USER2 ' || USERFIELD );
         R_count := R_count - 1;
    END;
    END LOOP;
         commit;
         EXCEPTION
         when others then
         DBMS_OUTPUT.PUT_LINE('Error code ' || sqlcode || ' Error desc' || SUBSTR(sqlerrm,1,200));
    END;

    Add a "last_update" or "modified" column to your table.
    Then do this:
    declare
    CURSOR vt_mlr_cursor IS
       select master_key, tn, user2
       from vt_mlr
       where user2 is not null and rownum < 80001
             and modified != 'Y'
    (or)
             and last_update < begin_date ;
       begin_date constant date := sysdate ;
    begin
      update vt_mlr
         set line_medr = Field1,
             line_aidr = Field2,
             modified = 'Y'
    (or)
             last_update = sysdate

  • How can I modify one column of current and next record depending of some criteria?

    Having DDL
    CREATE TABLE #ServiceChange(
    [ID] [int] identity(1,1),
    [SHCOMP] [char](2) NOT NULL,
    [SHCRTD] [numeric](8, 0) NOT NULL,
    [SHCUST] [numeric](7, 0) NOT NULL,
    [SHDESC] [char](35) NOT NULL,
    [SHTYPE] [char](1) NOT NULL,
    [SHAMT] [numeric](9, 2) NOT NULL,
    [CBLNAM] [char](30) NOT NULL,
    [GROUPID] [char](2) NULL
    And original and desire data in below link
    https://www.dropbox.com/sh/bpapxquaae9aa13/AADnan31ZASublDjN7sa2Vvza
    I would like to know how can I modify one column of current and next record depending of some criteria using SQL2012?
    The criteria is:
    Type should always flow F->T
    if current abs(amount)> next abs(amount) then groupid = 'PD'
    if current abs(amount)< next abs(amount) then groupid = 'PI'
    there is no case when those amounts will be equals
    where current(custid) = next(custid) and current(service) = next(service) and groupid is null
    Any help will be really apreciated.
    Thank you

    I tried that and got this error
    'LAG' is not a recognized built-in function name.
    You said you were using SQL 2012, but apparently you are not. The LAG function was added in SQL 2012. This solution works on SQL 2005 and SQL 2008:
    ; WITH numbering AS (
       SELECT groupid,
              rowno = row_number()  OVER (PARTITION BY custid, service ORDER BY date, id)
       FROM   #ServiceChange
    ), CTE AS (
       SELECT a.groupid,
              CASE WHEN abs(a.amount) < abs(b.amount) THEN 'PD'
                   WHEN abs(a.amount) > abs(b.amount) THEN 'PI'
              END AS newgroupid
       FROM  numbering a
       JOIN  numbering b ON b.custid  = a.custid
                        AND b.service = a.service
                        AND b.rowno   = a.rowno - 1
    UPDATE CTE
    SET   groupid = newgroupid
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Records repeat in some column of final table

    In my final table Some records are repeated in some columns .
    I have tried sorting and delete adjacent syntax.
    cant avoid repeating entries.
    Please give me some hint.
    <<Moved from MM forum to ABAP forum>>
    Edited by: Csaba Szommer on Feb 9, 2011 9:30 AM

    hi all
    LOOP AT IT_FINAL.
          IF IT_FINAL-BLART = 'AA'.
            IF SY-SUBRC = 0.
              MOVE-CORRESPONDING IT_FINAL TO IT_AA.
              APPEND IT_AA.
            ENDIF.
            READ TABLE IT_AA WITH KEY BELNR = IT_FINAL-BELNR
                                      GJAHR = IT_FINAL-GJAHR
                                      BUKRS = IT_FINAL-BUKRS
                                      WERKS = IT_FINAL-WERKS
                                      HKONT = IT_FINAL-HKONT
                                      TXT50 = IT_FINAL-TXT50
                                      PSWBT = IT_FINAL-PSWBT TRANSPORTING PSWBT.
            IF SY-SUBRC = 0.
              IT_FINAL-PSWBT1 = IT_AA-PSWBT.
              MODIFY IT_FINAL TRANSPORTING PSWBT1 WHERE BLART = IT_AA-BLART
                                                    AND BELNR = IT_AA-BELNR
                                                    AND GJAHR = IT_AA-GJAHR
                                                    AND BUKRS = IT_AA-BUKRS
                                                    AND WERKS = IT_AA-WERKS
                                                    AND HKONT = IT_AA-HKONT
                                                    AND TXT50 = IT_AA-TXT50
                                                    AND PSWBT = IT_AA-PSWBT.
            ENDIF.
          ENDIF.
    same logic i used for other doc types.
    SORT IT_FINAL_NEW BY
    HKONT WERKS PSWBT1  PSWBT2  PSWBT3  PSWBT4  PSWBT5  PSWBT6  PSWBT7  PSWBT8  PSWBT9  PSWBT10
                                 PSWBT11 PSWBT12 PSWBT13 PSWBT14 PSWBT15 PSWBT16 PSWBT17 PSWBT18 PSWBT19 PSWBT20
                                 PSWBT21 PSWBT22 PSWBT23 PSWBT24 PSWBT25 PSWBT26 PSWBT27 PSWBT28 PSWBT29 PSWBT30
                                 PSWBT31 PSWBT32 PSWBT33 PSWBT34 PSWBT35 PSWBT36 PSWBT37 PSWBT38 PSWBT39 PSWBT40
                                 PSWBT41 PSWBT42 PSWBT43 PSWBT44 PSWBT45 PSWBT46 PSWBT47 PSWBT48 PSWBT49 PSWBT50
                                 PSWBT51.
      DELETE ADJACENT DUPLICATES FROM IT_FINAL_NEW COMPARING
                HKONT WERKS PSWBT1  PSWBT2  PSWBT3  PSWBT4  PSWBT5  PSWBT6  PSWBT7  PSWBT8  PSWBT9  PSWBT10
                                 PSWBT11 PSWBT12 PSWBT13 PSWBT14 PSWBT15 PSWBT16 PSWBT17 PSWBT18 PSWBT19 PSWBT20
                                 PSWBT21 PSWBT22 PSWBT23 PSWBT24 PSWBT25 PSWBT26 PSWBT27 PSWBT28 PSWBT29 PSWBT30
                                 PSWBT31 PSWBT32 PSWBT33 PSWBT34 PSWBT35 PSWBT36 PSWBT37 PSWBT38 PSWBT39 PSWBT40
                                 PSWBT41 PSWBT42 PSWBT43 PSWBT44 PSWBT45 PSWBT46 PSWBT47 PSWBT48 PSWBT49 PSWBT50
                                 PSWBT51.
    But not solved the problem.

  • Duplicate records in a column of a table

    Hi,
    Can someone tell me how to get the duplicate records in a column of a table
    what is the sql query.
    Can anyone pls give an example

    Can someone tell me how to get the duplicate records in a column of a table select your_column, count(*)
    from your_table
    group by your_column
    having count(*) > 1;

  • Compare two records column by column in same table

    Hi All,
    I have an address table with ID as the PK but there can be more than one ID. I need to take the latest address record and first see if that same ID has a previous address record and if so, compare each column to see if the data has changed. I only need to compare the latest record with the next latest record.
    I cannot figure this out at all. I can of course use the MAX function to get the latest address records but do not know how I can pull the next latest address record that matches the ID and compare each column.
    Sample table:
    ID street city state zip effective_date
    1 123 main chicago IL 60111 3-7-2012
    2 34 N 13th new york NY 18374 3-7-2012
    3 15 N main Dallas TX 47389 3-7-2012
    1 89 N main chicago IL 60111 1-5-2012
    1 16 East St columbus OH 47382 12-10-2011
    2 34 N 13th new york NY 18374 10-7-2011
    2 15 S Elm new york NY 18374 09-1-2011
    3 15 N main Dallas TX 47389 10-4-2011
    SO...in the table above using today as the latest record date, based of my criteria I would only want to pull record ID 1 and 2 since the next most recent record for those IDs have had at least one of their address data change. ID 3 has exactly the same address data so I would not consider that in my criteria.
    Can i do this with SQL only or will i need to create a procedure or function?
    Any help is appreciated
    Ben

    Ben C wrote:
    Hi All,
    I have an address table with ID as the PK but there can be more than one ID. You mean there can be more than one row with tha same ID, right? (There can be more than one ID, also.)
    I need to take the latest address record and first see if that same ID has a previous address record and if so, compare each column to see if the data has changed. I only need to compare the latest record with the next latest record.
    ... Sample table:Whenever you have a problem, please post CREATE TABLE and INSERT statements for the sample data, and the exact results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.
    Can i do this with SQL only or will i need to create a procedure or function?You don't need PL/SQL, if I understand your requirements. You can do something like this:
    WITH     got_analytics     AS
         SELECT     id, street, city, state, zip, effective_date
         ,     COUNT (*)     OVER ( PARTITION BY  id )          AS cnt
         ,     ROW_NUMBER () OVER ( PARTITION BY  id
                                   ORDER BY          effective_date     DESC
                           )                           AS r_num
         FROM    table_x
    --     WHERE     ...     -- If you need any filtering, put it here
    SELECT    id, street, city, state, zip, effective_date
    FROM       got_analytics
    WHERE       cnt     > 1
    AND       r_num     <= 2
    ORDER BY  id
    ,            effective_date
    ;This will show the most recent 2 rows for each id that has 2 (or more) rows.
    You can modify it to only include ids where there was some change in street, city, state or zip between those 2 rows.
    WITH     got_analytics     AS
         SELECT     id, street, city, state, zip, effective_date
         ,     COUNT (*)     OVER ( PARTITION BY  id )          AS cnt
         ,     ROW_NUMBER () OVER ( PARTITION BY  id
                                   ORDER BY          effective_date     DESC
                           )                           AS r_num
         FROM    table_x
    --     WHERE     ...     -- If you need any filtering, put it here
    ,     got_unique_cnts     AS
         SELECT     id, street, city, state, zip, effective_date
         ,     COUNT (DISTINCT '~' || street) OVER (PARTITION BY id)     AS street_cnt
         ,     COUNT (DISTINCT '~' || city)   OVER (PARTITION BY id)     AS city_cnt
         ,     COUNT (DISTINCT '~' || state)  OVER (PARTITION BY id)     AS state_cnt
         ,     COUNT (DISTINCT '~' || zip)    OVER (PARTITION BY id)     AS zip_cnt
         FROM       got_analytics
         WHERE       cnt     > 1
         AND       r_num     <= 2
    SELECT    id, street, city, state, zip, effective_date
    FROM       got_unique_cnts
    WHERE       street_cnt     > 1
    OR       city_cnt     > 1
    OR       state_cnt     > 1
    OR       zip_cnt     > 1
    ORDER BY  id
    ,            effective_date
    ;This assumes that street, city, state and zip are all VARCHAR2s. If any of those columns is NULL on one row, and not NULL on the other row for that ID, that counts as a difference.
    Edited by: Frank Kulash on Mar 7, 2012 3:37 PM
    Edited by: Frank Kulash on Mar 7, 2012 3:41 PM

  • How to get the rows from a table having some column has any letter

    Hi All,
    suppose i have a table having columns id(number), code(varchar).
    code has alphanumeric characters (ex. ABC123, 67B56 etc).
    some codes are only numbers (2344, 7898 etc).
    how can i get the rows which have alphabets in the code.
    ex:
    id code
    1 AB45
    2 456
    3 890
    4 67B7
    how can i write a query such that it should give me the ids 1 and 4 (as they have alphabets in code)
    thanks in advance to all

    Thanks to one and all.
    i am gettig my required output.
    But i have a doubt in the operator.
    If i add or remove '[]' in the operator, i am getting different ouputs.
    There is a count difference in the result of the operators used.
    REGEXP_LIKE(<column>,'[[:lower:]]')
    REGEXP_LIKE(<column>,'[[[:lower:]]]')
    REGEXP_LIKE(<column>,'[:lower:]')
    Can anybody please explain what is the difference in using '[]', in the operator?
    What is the correct syntax, whether i have to use two '[]'s or one '[]'.
    Also, can i use REGEXP_LIKE() in oracle 8i version.( I am unable to use the operator in 8i)?
    Any query to get the required output in 8i version?
    Thanks in advance to all.

  • How to make a particular record in a particular column in a table as a link

    Hi All,
    I have a table in which the data is getting populated from the response of the BAPI.
    I have a column in this table which is not related to the BAPI response. I am binding the column with locally created attribute which is related to the custom controller also.
    The name of this column is LINK. The records for this column is "click to view".
    According to the requirement,I have two webservices which I am suppose to use in the same table.
    So the "click to view" should be enbled for the records from one webservice and should be disabled for the other.
    Now I have successfully added the column LINK and the record for it is also"click to view" as i have set it.But its not acting as a link.
    So kindly help me out.Looking forward to you.
    Regards
    DK

    Hi Dipendra,
    You can dynamically change TableCellEditor as you want a LINK at one time and no LINK(i.e. TextView ) at other time.
    You can get the handle for your table with IWDTable interface and then get handle for your table column with IWDTableColumn. Once you get these you can change the TableCellEditor for that column at runtime.
    I would sugesst you to read <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7f531207-0301-0010-5f9c-8652a3232ae0">this</a> document for further details on how to set TableCellEditor at runtime etc.
    Hope this helps,
    Regards,
    Mausam

  • Need help for SQL SELECT query to fetch XML records from Oracle tables having CLOB field

    Hello,
    I have a scenario wherein i need to fetch records from several oracle tables having CLOB fields(which is holding XML) and then merge them logically to form a hierarchy XML. All these tables are related with PK-FK relationship. This XML hierarchy is having 'OP' as top-most root node and ‘DE’ as it’s bottom-most node with One-To-Many relationship. Hence, Each OP can have multiple GM, Each GM can have multiple DM and so on.
    Table structures are mentioned below:
    OP:
    Name                             Null                    Type        
    OP_NBR                    NOT NULL      NUMBER(4)    (Primary Key)
    OP_DESC                                        VARCHAR2(50)
    OP_PAYLOD_XML                           CLOB       
    GM:
    Name                          Null                   Type        
    GM_NBR                  NOT NULL       NUMBER(4)    (Primary Key)
    GM_DESC                                       VARCHAR2(40)
    OP_NBR               NOT NULL          NUMBER(4)    (Foreign Key)
    GM_PAYLOD_XML                          CLOB   
    DM:
    Name                          Null                    Type        
    DM_NBR                  NOT NULL         NUMBER(4)    (Primary Key)
    DM_DESC                                         VARCHAR2(40)
    GM_NBR                  NOT NULL         NUMBER(4)    (Foreign Key)
    DM_PAYLOD_XML                            CLOB       
    DE:
    Name                          Null                    Type        
    DE_NBR                     NOT NULL           NUMBER(4)    (Primary Key)
    DE_DESC                   NOT NULL           VARCHAR2(40)
    DM_NBR                    NOT NULL           NUMBER(4)    (Foreign Key)
    DE_PAYLOD_XML                                CLOB    
    +++++++++++++++++++++++++++++++++++++++++++++++++++++
    SELECT
    j.op_nbr||'||'||j.op_desc||'||'||j.op_paylod_xml AS op_paylod_xml,
    i.gm_nbr||'||'||i.gm_desc||'||'||i.gm_paylod_xml AS gm_paylod_xml,
    h.dm_nbr||'||'||h.dm_desc||'||'||h.dm_paylod_xml AS dm_paylod_xml,
    g.de_nbr||'||'||g.de_desc||'||'||g.de_paylod_xml AS de_paylod_xml,
    FROM
    DE g, DM h, GM i, OP j
    WHERE
    h.dm_nbr = g.dm_nbr(+) and
    i.gm_nbr = h.gm_nbr(+) and
    j.op_nbr = i.op_nbr(+)
    +++++++++++++++++++++++++++++++++++++++++++++++++++++
    I am using above SQL select statement for fetching the XML records and this gives me all related xmls for each entity in a single record(OP, GM, DM. DE). Output of this SQL query is as below:
    Current O/P:
    <resultSet>
         <Record1>
              <OP_PAYLOD_XML1>
              <GM_PAYLOD_XML1>
              <DM_PAYLOD_XML1>
              <DE_PAYLOD_XML1>
         </Record1>
         <Record2>
              <OP_PAYLOD_XML2>
              <GM_PAYLOD_XML2>
              <DM_PAYLOD_XML2>
              <DE_PAYLOD_XML2>
         </Record2>
         <RecordN>
              <OP_PAYLOD_XMLN>
              <GM_PAYLOD_XMLN>
              <DM_PAYLOD_XMLN>
              <DE_PAYLOD_XMLN>
         </RecordN>
    </resultSet>
    Now i want to change my SQL query so that i get following output structure:
    <resultSet>
         <Record>
              <OP_PAYLOD_XML1>
              <GM_PAYLOD_XML1>
              <GM_PAYLOD_XML2> .......
              <GM_PAYLOD_XMLN>
              <DM_PAYLOD_XML1>
              <DM_PAYLOD_XML2> .......
              <DM_PAYLOD_XMLN>
              <DE_PAYLOD_XML1>
              <DE_PAYLOD_XML2> .......
              <DE_PAYLOD_XMLN>
         </Record>
         <Record>
              <OP_PAYLOD_XML2>
              <GM_PAYLOD_XML1'>
              <GM_PAYLOD_XML2'> .......
              <GM_PAYLOD_XMLN'>
              <DM_PAYLOD_XML1'>
              <DM_PAYLOD_XML2'> .......
              <DM_PAYLOD_XMLN'>
              <DE_PAYLOD_XML1'>
              <DE_PAYLOD_XML2'> .......
              <DE_PAYLOD_XMLN'>
         </Record>
    <resultSet>
    Appreciate your help in this regard!

    Hi,
    A few questions :
    How's your first query supposed to give you an XML output like you show ?
    Is there something you're not telling us?
    What's the content of, for example, <OP_PAYLOD_XML1> ?
    I don't think it's a good idea to embed the node level in the tag name, it would make much sense to expose that as an attribute.
    What's the db version BTW?

  • To modify a field in a database table based record identification by primar

    hi
    i want to to modify a field in a database table based record identification by primary key filed and two more fields
    ie customer (primary key
    i want to modify record from intenal table the record existing with primary key field customer
    the status field needs to be mofied as " value rolled"
    the below code is happening
    loop at it_record into wa_Record
    wa_inv-customer (primary key) = wa_Record=custome
    wa_inv-date = wa_Record-date
    ...so one
    append wa_inv to it_invest
    clear wa_inv
    endloop.
    if not it_invest  is initial
    modify TABle1 ( this table is data base table which needs to be mofified) based on the primary key field
    and also date field and status field which is not primary key.
    regards
    arora

    Hi there.
    Your requirement is to update a Z Database table from your internal table, right? You have several options:
    LOOP AT it_invest INTO wa_inv.
      UPDATE dbtable
         SET date = wa_inv-date
       WHERE prim_key = wa_inv-prim_key
         AND any_field = wa_inv-any_field.
    ENDLOOP.
    or
    LOOP AT it_invest INTO wa_inv.
      UPDATE dbtable FROM wa_inv. "if wa_inv of same type of dbtable
    ENDLOOP.
    In the first example, I wrote any field because you can update dbase table, filtering for fields that don't belong to the primary key. However, remember that you will change all records that respect the key you used (so, in your case, use the primary key).
    Regards.
    Valter Oliveira.

  • Inserting sequence value in a created column already table having some rows

    i have a table emp whish has already having rows in that table
    now i added one more column to that table with alter command and also i created sequence
    now i want to insert the value in that newly created column with sequencename.nextval??????

    insert into employees values (employees_seq.nextval);
    commit;
    Here employees_seq is the name of the sequence.
    Regards
    Asif Kabir
    17 (17 unresolved)
    -- Mark your answer as correct/helpful
    Edited by: asifkabirdba on Dec 22, 2009 3:39 PM

  • Error in CodeFirst Seed with migrations : Modifying a column with the 'Identity' pattern is not supported. Column: 'CreatedAt'. Table: 'CodeFirstDatabaseSchema.Category'.

    Hi,
    I have activated migrations on my Azure Mobile Services project. I filled the new seed function Inside the Configuration.cs class of the migrations. If the tables are empty, the seed function is going without any problems. When my AddorUpdate tries to update
    the first object I get the error in the inner exception : "Modifying a column with the 'Identity' pattern is not supported. Column: 'CreatedAt'. Table: 'CodeFirstDatabaseSchema.Category'."
    Part of my code is as follows:
    context.categories.AddOrUpdate(
    new Category { Id="1", Code="GEN", Text="General"},
    new Category { Id="2", Code="POL", Text="Politics"},
    new Category { Id="3", Code="FAS", Text="Fashion"},
    new Category { Id="4", Code="PEO", Text="People"},
    new Category { Id="5", Code="TEC", Text="Technology"},
    new Category { Id="6", Code="SPO", Text="Sport"},
    new Category { Id="7", Code="LIV", Text="Living"}
    Any help is welcomed. Thanks.
    Faical SAID Highwave Creations

    This occurred to me because I changed my POCO models to inherit from EntityData after I had already created my database without the extra Azure Mobile Service properties (UpdatedAt, CreatedAt, Deleted). The only way I fixed it was to drop the database and
    start over with my classes inheriting from EntityData from the beginning. If you can't do that then I would create a new table with EntityData models and see how that database is created and manually update your tables to match those. Here's an image of one
    of my tables from the management console on Azure. You can see that CreatedAt is an index.

Maybe you are looking for

  • Calling a delegate on the UI thread from a work thread inside a child class.

    Hi All, I've run into a snag developing a WPF multithreaded app where I need to call a method on the UI thread from my work thread, where the work thread is running a different class. Currently I am trying to use a delegate and an event in the 2nd cl

  • Field AWKEY in BKPF not working due to case sensitive

    Hi, I have reference key as cpv8852MLTD2013, but when i enter this in AWKEY field in BKPF it gets converted to upper case as "CPV8852MLTD2013". Due to this it is not working, and data is not executing.. Please help.. Durga

  • Loss photos while updated 4s

    Contacts are good, but apps and photos r not appearing. iCloud not showing anything and theres no recent back up

  • Dreamweaver crashes with ASP

    I am unable to edit any ASP files in Dreamweaver (CS3 and 8). Whenever I select anything, code or objects, the program hangs. This does not only happen on my computer but on other people's computers as well. If the file extension is changed to .aspx

  • How To Make a Used Graphics Workstation More Attractive?

    I'm in the process of upgrading to a more powerful workstation, and once I switch over I'll be putting the one I am using now (a Dell Precision T5400) up for sale on eBay. My current machine is no slouch.  It a dual quad core system and even by moder