Order By Columns in a Row

Hi,
I'm struggling to solve a problem. I want to sort the values of fields in each row.
RDBMS : 11.2.0.3
CREATE TABLE test_order
  (a NUMBER, b NUMBER ,c NUMBER ,d NUMBER
REM INSERTING into test_order
Insert into "test_order" (A,B,C,D) values ('18','29','14','21');
Insert into "test_order" (A,B,C,D) values ('40','11','29','12');
Insert into "test_order" (A,B,C,D) values ('22','20','19','24');
select * from test_order
         A          B          C          D
        18         29         14         21
        40         11         29         12
        22         20         19         24 I'm trying get result in order as shown below DOES NOT matter column name.
Each row ordered by its own columns.
         A          B          C          D
        14         18         21         29
        11         12         29         40
        19         20         22         24 Note: my real table have more than one million records.
Any helps is welcome.

Seeing as Frank is also having fun with this, and I'm bored watching a data pump import ticking over partition by partition, I thought about creating a SQL data type called TSortedNumbers - allowing you to create/store a set of numbers as a sorted list, and providing a method for returning a specific item in the set.
As PL/SQL code needs to be used to override the default constructor, I decided to use a PL/SQL quicksort on the number list - as oppose to an expensive context switch to SQL to have SQL doing the sort for you. No idea what (if any) performance improvements there are using a PL/SQL quicksort.
However, this does demonstrate the really kewl and awesome functionality Oracle provides by enabling one to define custom SQL types.
// TNumbers is an array/collection of numbers
SQL> create or replace type TNumbers as table of number;
  2  /
Type created.
// package Lib, implements the well-known Quick Sort algorithm - and sorts an
// array of numbers, where the array is of data type TNumbers
SQL> create or replace package Lib is
  2          procedure QuickSort( array in out nocopy TNumbers );
  3  end;
  4  /
Package created.
SQL>
SQL> create or replace package body Lib is
  2          procedure SwapPivots( array in out nocopy TNumbers, pivot1 number, pivot2 number ) is
  3                  pivotValue      number;
  4          begin
  5                  pivotValue := array(pivot1);
  6                  array(pivot1) := array(pivot2);
  7                  array(pivot2) := pivotValue;
  8          end;
  9
10          procedure  Partition( array in out nocopy TNumbers, left number, right number, pivotIndex number, storeIndex out number ) is
11                  pivotValue      number;
12          begin
13                  pivotValue := array(pivotIndex);
14                  SwapPivots( array, pivotIndex, right );
15                  storeIndex := left;
16                  for i in left..right - 1 loop
17                          if array(i) < pivotValue then
18                                  SwapPivots( array, i, storeIndex );
19                                  storeIndex := storeIndex + 1;
20                          end if;
21                  end loop;
22                  SwapPivots( array, storeIndex, right );
23          end;
24
25          procedure QuickSort( array in out nocopy TNumbers, left number, right number ) is
26                  pivotIndex      number;
27                  pivotNewIndex   number;
28          begin
29                  if left < right then
30                          pivotIndex := trunc( DBMS_RANDOM.value( left, right ) );
31
32                          Partition( array, left, right, pivotIndex, pivotNewIndex );
33                          QuickSort( array, left, pivotNewIndex-1 );
34                          QuickSort( array, pivotNewIndex+1, right );
35                  end if;
36          end;
37
38          procedure QuickSort( array in out nocopy TNumbers ) is
39          begin
40                   QuickSort( array, 1, array.Count );
41          end;
42
43  end;
44  /
Package body created.
// We define a a custom SQL data type that contains a single property called n,
// where n is of type TNumber.
// The default constructor for this type is: TSortedNumbers ( <array-of-numbers )
// We create a custom constructor with the same signature, in order to override
// the default constructor.
SQL> create or replace type TSortedNumbers is object(
  2          n       TNumbers,
  3
  4          constructor function TSortedNumbers(n TNumbers) return self as result,
  5          member function Get(i integer) return number
  6  );
  7  /
Type created.
// Using our custom constructor, we accept the array-of-numbers parameter,
// assign it to our  TSortedNumbers property n, and quick sort our property so
// that the array-of-numbers is in ascending values.
// We also provide a method called Get(), that allows the caller to get a value
// from our sorted array, by index number.
SQL> create or replace type body TSortedNumbers as
  2          constructor function TSortedNumbers(n TNumbers) return self as result is
  3          begin
  4                  self.n := n;
  5                  Lib.QuickSort(self.n);
  6                  return;
  7          end;
  8
  9          member function Get(i integer) return number is
10          begin
11                  return( self.n(i) );
12          end;
13
14  end;
15  /
Type body created.
// Create sample table and populate it with data
SQL> create table testtab( a number, b number, c number, d number );
Table created.
SQL>
SQL> insert into testtab (A,B,C,D) values ('18','29','14','21');
1 row created.
SQL> insert into testtab (A,B,C,D) values ('40','11','29','12');
1 row created.
SQL> insert into testtab (A,B,C,D) values ('22','20','19','24');
1 row created.
// To create an array of numbers, we use the TNumbers() data type. Its
// constructor  is TNumbers( num1, num2, .., numn ). We pass the columns of
// the rows as parameters into this constructor and it creates an array of our
// column values. As we now have an array-of-numbers, we can instantiate a
// TSortedNumbers object. Its constructor required an array-of-numbers
// parameter. Which is what we have created using our row's columns.
// As the TSortedNumbers object contains a sorted array-of-numbers of our
// columns, we can display the numbers in the array using the Get() method
// and index position in the array of the number we want to display.
SQL> with results as(
  2  select
  3          rownum,
  4          t.*,
  5          TSortedNumbers( TNumbers(a,b,c,d) ) as NUMBER_SET
  6  from       testtab t
  7  )
  8  select
  9          r.number_set.Get(1)     as "1",
10          r.number_set.Get(2)     as "2",
11          r.number_set.Get(3)     as "3",
12          r.number_set.Get(4)     as "4"
13  from       results r
14  /
         1          2          3          4
        14         18         21         29
        11         12         29         40
        19         20         22         24
SQL>
Edited by: Billy  Verreynne  on Apr 13, 2013 6:04 PM. (Added comments to example)

Similar Messages

  • How to remove gaps/null values from set of columns in a row

    Im trying to implement a solution for removing null value columns from a row.
    Basically in below example i have five codes and corresponding id's for that codes.What im trying to achive here is if
    i have a null code then i have to move next not null code and id into its new location.
    Example:
    'A1'cd1,'A2'cd2,null cd3,'A4'cd4,null cd5,'i1'id1,'i2'id2,null id3,'i4' id4,null id5 So here cd4 and id4 should take positions of cd3 and id3.
    Output should look like this
    cd1 cd2 cd3 cd4 cd5     id1 id2 id3 id4 id5
    A1  A2   A4              i1  i2  i4Any help would be highly appreciated for below example:
    with temp_table as
    (select 'A1'cd1,'A2'cd2,null cd3,'A4'cd4,null cd5,'i1'id1,'i2'id2,null id3,'i4' id4,null id5 from dual union all
    select 'A11',null,null,'A44','A55','id11',null,null, 'id44','id55' from dual union all
    select null,'A111',null,null,'A555',null,'id111',null, null,'id555' from dual union all
    select 'A',null,null,'A1111','E55','id11',null,null, 'id111','id1111' from dual )
    select * from temp_table;Edited by: GVR on Dec 1, 2010 8:27 AM

    I like case expression B-)
    The same question of my homepage http://www.geocities.jp/oraclesqlpuzzle/7-81.html
    with temp_table(cd1,cd2,cd3,cd4,cd5,id1,id2,id3,id4,id5) as(
    select 'A1' ,'A2' ,null,'A4'   ,null  ,'i1'  ,'i2'   ,null,'i4'   ,null     from dual union all
    select 'A11',null ,null,'A44'  ,'A55' ,'id11',null   ,null,'id44' ,'id55'   from dual union all
    select null,'A111',null,null   ,'A555',null  ,'id111',null,null   ,'id555'  from dual union all
    select 'A'  ,null ,null,'A1111','E55' ,'id11',null   ,null,'id111','id1111' from dual)
    select
    case when SumCD1 = 1 then CD1
         when SumCD1+SumCD2 = 1 then CD2
         when SumCD1+SumCD2+SumCD3 = 1 then CD3
         when SumCD1+SumCD2+SumCD3+SumCD4 = 1 then CD4
         when SumCD1+SumCD2+SumCD3+SumCD4+SumCD5 = 1 then CD5 end as CD1,
    case when SumCD1+SumCD2 = 2 then CD2
         when SumCD1+SumCD2+SumCD3 = 2 then CD3
         when SumCD1+SumCD2+SumCD3+SumCD4 = 2 then CD4
         when SumCD1+SumCD2+SumCD3+SumCD4+SumCD5 = 2 then CD5 end as CD2,
    case when SumCD1+SumCD2+SumCD3 = 3 then CD3
         when SumCD1+SumCD2+SumCD3+SumCD4 = 3 then CD4
         when SumCD1+SumCD2+SumCD3+SumCD4+SumCD5 = 3 then CD5 end as CD3,
    case when SumCD1+SumCD2+SumCD3+SumCD4 = 4 then CD4
         when SumCD1+SumCD2+SumCD3+SumCD4+SumCD5 = 4 then CD5 end as CD4,
    case when SumCD1+SumCD2+SumCD3+SumCD4+SumCD5 = 5 then CD5 end as CD5,
    case when SumID1 = 1 then ID1
         when SumID1+SumID2 = 1 then ID2
         when SumID1+SumID2+SumID3 = 1 then ID3
         when SumID1+SumID2+SumID3+SumID4 = 1 then ID4
         when SumID1+SumID2+SumID3+SumID4+SumID5 = 1 then ID5 end as ID1,
    case when SumID1+SumID2 = 2 then ID2
         when SumID1+SumID2+SumID3 = 2 then ID3
         when SumID1+SumID2+SumID3+SumID4 = 2 then ID4
         when SumID1+SumID2+SumID3+SumID4+SumID5 = 2 then ID5 end as ID2,
    case when SumID1+SumID2+SumID3 = 3 then ID3
         when SumID1+SumID2+SumID3+SumID4 = 3 then ID4
         when SumID1+SumID2+SumID3+SumID4+SumID5 = 3 then ID5 end as ID3,
    case when SumID1+SumID2+SumID3+SumID4 = 4 then ID4
         when SumID1+SumID2+SumID3+SumID4+SumID5 = 4 then ID5 end as ID4,
    case when SumID1+SumID2+SumID3+SumID4+SumID5 = 5 then ID5 end as ID5
    from (select cd1,cd2,cd3,cd4,cd5,id1,id2,id3,id4,id5,
          nvl2(cd1,1,0) as SumCD1,
          nvl2(cd2,1,0) as SumCD2,
          nvl2(cd3,1,0) as SumCD3,
          nvl2(cd4,1,0) as SumCD4,
          nvl2(cd5,1,0) as SumCD5,
          nvl2(id1,1,0) as SumID1,
          nvl2(id2,1,0) as SumID2,
          nvl2(id3,1,0) as SumID3,
          nvl2(id4,1,0) as SumID4,
          nvl2(id5,1,0) as SumID5
          from temp_table)
    order by cd1,cd2,cd3,cd4,cd5;
    CD1   CD2    CD3   CD4   CD5   ID1    ID2    ID3     ID4   ID5
    A     A1111  E55   null  null  id11   id111  id1111  null  null
    A1    A2     A4    null  null  i1     i2     i4      null  null
    A11   A44    A55   null  null  id11   id44   id55    null  null
    A111  A555   null  null  null  id111  id555  null    null  nullMy SQL articles of OTN-Japan
    http://www.oracle.com/technology/global/jp/pub/jp/ace/sql_image/1/otnj-sql-image1.html
    http://www.oracle.com/technology/global/jp/pub/jp/ace/sql_image/2/otnj-sql-image2.html

  • Interactive report: Can I exclude a particular column from single row view?

    Hi -- I posted on this yesterday (Possible to exclude interactive report column from single row display?
    a bit anxious for suggestions, I guess!
    I've added a column with edit-link functionality to my interactive report query (that is, the link
    is not attached to the database data... it's an additional column and shows an icon). It's also
    in addition to the default single row view link. (We need both.)
    Unfortunately, the Edit link column shows up in the single row view. I've pared it down as much
    as I can: the label is empty, and the null value shows as "-". But an extra row with "-" is pretty
    ugly. Is there a way to always, completely exclude this column from the single row view?
    I know I could put the edit link on a data column, but:
    1) I want the link to always be to the left of the data (and the user can re-order columns)
    2) when the user doesn't have edit privileges, the link will need to be disabled or just not
    be displayed, and I think that would be a problem if the link were on the data. (true?)
    Thanks,
    Carol

    Please disregard this thread, and the one it refers back to. I see a flaw in the design of what I was attempting to do! Creating the link for Editing as a column means the user could inadvertently not display it, or move it, or... any number of problematic scenarios.
    Thanks,
    Carol

  • Interactive Report Column Headings and Row Height

    I am using the div style="width:350px;" method to control the width of columns in various interactive reports. That works fine except for the following:
    1. When creating filters, the <div...> stuff shows up along with the actual column heading, thus confusing some end users
    2. Even when I uncheck the "Use same text for single row view" checkbox and then provide a simple single row view label, the <div> stuff still shows up on the single row view
    Does anyone have a better solution?
    Also, does anyone know of a way to limit the row height within an interactive report row? I have some columns of data that contain a large amount of HTML data and I'd like to be able to limit the number of rows that show on the report.
    Is Oracle planning to provide some better control over the Interactive Report columns in another version? The Interactive Report is such a huge improvement in usability in APEX - it would be great to take it to another level by providing some better control over column width and row height.
    Edited by: DaleB on Jun 18, 2009 8:54 AM
    Edited by: DaleB on Jun 18, 2009 8:54 AM

    Dale,
    Unfortunately we don't have much we can use to do what you would like. I would have said it's impossible until version 4 but you could actually do something similar to what Roel has done. His trick is in the edit button. He changed the edit button to use an "onload" call to a JavaScript process. You could do the same but call a process that goes across the rows and styles each column. Now because you don't have a way to identify the column (can't use the order because the end user could change it) you'll have to write the code to look at the top row first and then style the appropriate column. As far as I can tell, this would be quite difficult and inefficient. Having said that if you need it that bad and would like some help with it, put up an example application on apex.oracle.com and provide the workspace/username/password and I'll take a look.
    Regards,
    Dan
    http://danielmcghan.us
    http://sourceforge.net/projects/tapigen
    You can reward this reply by marking it as either Helpful or Correct ;-)

  • How can can i subtract the value of the column in each row ?

    I want to subtract  the value  of the column in each row if the row is not enough then continue to next row.
    For example 
    ID             QTY
    A               20
    B               40       
    C               60
    I want to update this table by subtract  the value  of the column (QTY) out 70 so the result i want will be 
    ID              QTY
    A                20 - 70 = -50 -->  0 this row will be updated to 0 and 50 will continue to next row   
    B                40 - 50  = -10 -->  0   this row will be updated to 0 and 10 will continue to next row
    C                60 - 10  = 50  -->  Stop loop
    How can i write the sql query for this operation , Thanks

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. You have no idea,
    do you? Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. What did you try on your own before posting? I will bet that you did nothing! You expect other people to do your job or homework for you. 
    >> I want to subtract the value of the column in each row if the row is not enough then continue to next row. <<
    This makes no sense. Rows have no ordering; that is a spreadsheet. There is no such thing as a generic “id” in RDBMS. And an identifier is not a sequence which would have an ordering. 
    CREATE TABLE Foobar
    (something_seq INTEGER NOT NULL PRIMARY KEY,
     onhand_qty INTEGER NOT NULL);
    Learn how to use the SUM()OVER() and LAG() aggregate functions, post what you tried for yourself and then we will help you. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Is there any performance difference in the order of columns referencing index?

    I wish to find out if there is any performance difference or efficiency in specifying those columns referencing index(es) first in the WHERE clause of SQL statements. That is, whether the order of columns referencing the index is important???.
    E.g. id is the column that is indexed
    SELECT * FROM a where a.id='1' and a.name='John';
    SELECT * FROM a where a.name='John' and a.id='1';
    Is there any differences in terms of efficiency of the 2 statements??
    Please advise. Thanks.

    There is no difference between the two statements under either the RBO or the CBO.
    sql>create table a as select * from all_objects;
    Table created.
    sql>create index a_index on a(object_id);
    Index created.
    sql>analyze table a compute statistics;
    Table analyzed.
    sql>select count(*)
      2    from a
      3   where object_id = 1
      4     and object_name = 'x';
    COUNT(*)
            0
    1 row selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=29)
       1    0   SORT (AGGREGATE)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'A' (Cost=1 Card=1 Bytes=29)
       3    2       INDEX (RANGE SCAN) OF 'A_INDEX' (NON-UNIQUE) (Cost=1 Card=1)
    sql>select count(*)
      2    from a
      3   where object_name = 'x'   
      4     and object_id = 1;
    COUNT(*)
            0
    1 row selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=29)
       1    0   SORT (AGGREGATE)
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'A' (Cost=1 Card=1 Bytes=29)
       3    2       INDEX (RANGE SCAN) OF 'A_INDEX' (NON-UNIQUE) (Cost=1 Card=1)

  • Select a column in a rows

    I want to select a column in a row.
    suppose,
    empno
    1
    2
    3
    4
    5
    I want op like,
    1 2 3 4 5

    Like this...
    SQL> ed
    Wrote file afiedt.buf
      1  select max(decode(rn, 1, empno)) as emp1
      2        ,max(decode(rn, 2, empno)) as emp2
      3        ,max(decode(rn, 3, empno)) as emp3
      4        ,max(decode(rn, 4, empno)) as emp4
      5        ,max(decode(rn, 5, empno)) as emp5
      6        ,max(decode(rn, 6, empno)) as emp6
      7        ,max(decode(rn, 7, empno)) as emp7
      8        ,max(decode(rn, 8, empno)) as emp8
      9        ,max(decode(rn, 9, empno)) as emp9
    10        ,max(decode(rn, 10, empno)) as emp10
    11        ,max(decode(rn, 11, empno)) as emp11
    12        ,max(decode(rn, 12, empno)) as emp12
    13        ,max(decode(rn, 13, empno)) as emp13
    14        ,max(decode(rn, 14, empno)) as emp14
    15        ,max(decode(rn, 15, empno)) as emp15
    16        ,max(decode(rn, 16, empno)) as emp16
    17        ,max(decode(rn, 17, empno)) as emp17
    18        ,max(decode(rn, 18, empno)) as emp18
    19        ,max(decode(rn, 19, empno)) as emp19
    20        ,max(decode(rn, 20, empno)) as emp20
    21  from (
    22        select empno, row_number() over (order by empno) as rn from emp
    23*      )
    SQL> /
          EMP1       EMP2       EMP3       EMP4       EMP5       EMP6       EMP7       EMP8       EMP9   EMP10         EMP11      EMP12      EMP13      EMP14      EMP15      EMP16      EMP17      EMP18      EMP19      EMP20
          7369       7499       7521       7566       7654       7698       7782       7788       7839    7844          7876       7900       7902       7934
    SQL>

  • Upload a file where no. of columns for each row is not fixed...

    Hi All,,
    I have to upload a file......
    number of columns for each rows are not fixed ....
    e.g.
    Posting Date     Company Code     Currency     Header Text     Cost Center     Internal Order     Ref 1     Ref 2     Line Text     Account no.     Amount     Account no.     Amount     Account no.     Amount     Account no.     Amount     Account no.     Amount     Account no.     Amount     Account no.     Amount
    31-05-09     1000     EUR     PAYROLL 05/2009     1234     123456     123456     seaman     RU     999999     9,999.99                                                            
    31-08-09     1000     EUR     PAYROLL 05/2009     678     98765     98765     officer     GB     600015     4,560.00      600035     2,125.50      600020     1,325.40      600025     245.75      600030     300.00      280010     1,000.00      281091     6,000.00
    its in tab delimited txt file.....
    how to upload this type of file..
    Plz suggest....
    thnx
    rahul

    Hi,
    Define your internal table like this.
         TYPES: BEGIN OF upload_type,
           upload(330),
           END OF upload_type.
    DATA: itab_upload TYPE STANDARD TABLE OF upload_type,
           wa_upload TYPE upload_type.
    Data: file type string.
    file = 'C:/test.txt'.
      CALL FUNCTION 'GUI_UPLOAD'
           EXPORTING
                filename                = file
                filetype                = 'ASC'
               HAS_FIELD_SEPARATOR = 'X'
           TABLES
                data_tab                = itab_upload
           EXCEPTIONS
                file_open_error         = 1
                file_read_error         = 2
                no_batch                = 3
                gui_refuse_filetransfer = 4
                invalid_type            = 5
                no_authority            = 6
                unknown_error           = 7
                bad_data_format         = 8
                header_not_allowed      = 9
                separator_not_allowed   = 10
                header_too_long         = 11
                unknown_dp_error        = 12
                access_denied           = 13
                dp_out_of_memory        = 14
                disk_full               = 15
                dp_timeout              = 16
                OTHERS                  = 17.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Use the sring operations to identify your coloumns.
    Regards,
    Satish

  • Columns converted into rows.

    Hello-
    I have a table with 5 columns contains distinct rows.
    Example:
    COL_A     COL_B     COL_C     COL_D     COL_E
    1051     25000     7/17/2009     7/20/2009     190409949A
    1051     V4581     12/9/2009     12/11/2009     407829924A
    1051     78659     7/21/2010     7/25/2010     403021811A
    1051     72400     8/21/2009     8/31/2009     407381779M
    1051     73300     2/6/2010     2/13/2010     403506467A
    1051     5849     3/23/2010     3/30/2010     402442165A
    1051     6827     9/16/2009     9/23/2009     400245360W
    1051     4254     3/11/2009     3/19/2009     404824298A
    1051     2768     10/16/2009     10/17/2009     401987971A
    1051     53081     12/23/2009     12/27/2009     406889222Aso on
    Now I want to convert this 10 rows into one column like :
    1051 2009717250200972090409949 10512009129452009121190409949 1051201072178201072503021811 1051 200982120097002009 83107381779 ......so on
    ie first 10 records will become one column and so on......
    So for every 10 records I have to make it one column as above results. and there are two spaces after 1051(means first column and after last column col_E there are 6 spaces then second row will start.
    Can you please help me out how can we do it.
    Thanks in advance!
    Thanks
    Nick
    Edited by: user12020842 on Apr 21, 2011 12:23 PM

    Try this,
    SELECT REPLACE ( MAX (SYS_CONNECT_BY_PATH ( str, '@#')), '@#')
      FROM (SELECT col_a || ' ' || col_b || col_c || col_D || col_e || '      ' str,
                   CEIL (ROWNUM / 10) lvl,
                   ROW_NUMBER () OVER (PARTITION BY CEIL (ROWNUM / 10) ORDER BY col_a) rn
              FROM Table_name)
    START WITH rn = 1
    CONNECT BY PRIOR rn + 1 = rn
           AND PRIOR lvl = lvl
    GROUP BY lvlG.

  • SQL Query to re-order the columns

    Hello All,
    I want to know if it is possible to re-order the columns of a table once the rows has been inserted in all the columns.
    So for e.g I have initially a table containing 3 columns COL1, COL2 & COL3.
    Now after data has been inserted into the table, I want to re-order the columns like COL3, COL2, COl1 or may be COL2, COL1, COL3 etc keeping the data intact.
    Cheers,
    Parag

    Parag Kalra wrote:
    I want to know if it is possible to re-order the columns of a table once the rows has been inserted in all the columns.
    So for e.g I have initially a table containing 3 columns COL1, COL2 & COL3.
    Now after data has been inserted into the table, I want to re-order the columns like COL3, COL2, COl1 or may be COL2, COL1, COL3 etc keeping the data intact.Why? What is your reason for wanting to do this? What do you want to achieve by it? If we understand the actual problem, then we may be able to provide some usable suggestions.
    The reason why your request makes very little sense is that the physical sequence of columns in a row in a datablock, has no impact on you as developer writing code.
    Why? Because you control the order in which you want to select columns. You control the order in which you insert columns. You control the order in which you update columns.
    SQL allows you the programmer to specify the sequence of columns, and subset of columns, that you want to use in your SQL.
    Why would you want to change the physical table definition, and rewrite the entire table on disk (using very expensive I/O) to reorder the physical column sequence?

  • 2.1.0.62: Bug editing text columns in multiple rows using editor-window

    Hello Forum,
    I hope this is not a double post, but I did not come up with the right keywords to search for.
    So here is the bug/strange annoying behavior:
    When I edit multiple rows of a table using the extra edit-window, it shows the text of the previous row I edited and not the text of the actual row.
    Well, sounds quit complicated so I'll give an example:
    Suppose you have a table with two columns and two rows. One column is of type varchar2. Say it contains the values "one" and "two".
    Now I click into the row containing "one", open the extra-edit-window and change the value to "one-1".
    Then I click into the second row and also open the extra-edit-window. The window shows "one-1" instead of "two" as it should.
    This is very annoying because I don't have autocommit activated and when I edit a couple of clob fields, the editor just shows the text of the previous field. I have to say commit for every row in order not to scramble the contents of multiple fields. I have to use the edit-window because the inplace editor is not very useful when editing large texts.
    I observed this bug with varchar2 and clob fields but it may not be restricted to those.
    I run Windows XP and conect to Oracle 10.2.0.4
    Regards,
    dhalek

    Hello -K-,
    setting "Post edits on row change" indeed does prevent this bug, but leads to another problem:
    When I click the rollback-button, the table data is not reverted to its original state. In fact the changes are not commited, but rolling back, does not give the old data back. I can enter "rollback;" into the worksheet and then refresh the table data to show the old values but internally SQL Developer still thinks it has uncommitted changes in the table.
    I, for now, uncheck "Post edits on row change" and use the inplace editor wherever possible. That has some strange cursor bugs (sometimes puts the cursor to the end making it impossible to enter text in the middle of the field) but that does not affect other rows.
    Regards,
    dhalek
    Edited by: dhalek on 30.10.2009 15:08

  • Coinciding columns on multiple rows with GridBadLayout

    I was trying to figure out why I could not initially accomplish the following with a GridBagLayout:
    Row0: 0000011111
    Row1:      1111122222
    Row2:           2222233333 The above is supposed to be 3 JLabels on three different rows:
    The 1st row has a single JLabel starting in column 0 with a width of 2, extending it to column 1.
    The 2nd row has a single JLabel starting in column 1 with a width of 2, extending it to column 2.
    The 3rd row has a single JLabel starting in column 2 with a width of 2, extending it to column 3.
    The entire grid is 4 columns and 3 rows total.
    Below I have two examples where I attempted the above. Only the 2nd example produces the desired effect. The 1st code example ends up putting both the Row 0 and Row 1 JLabel in the same column. This was surprising because I thought the GridBagLayout would give each column contained by a control enough weight to actually make those columns exist.
    Here is what my first code example below produces:
    Row0: 0000011111
    Row1: 1111122222
    Row2:           2222233333 The first two JLabels, 0000011111 and 1111122222, appear in the same column, and the 3rd JLabel appears in the seemingly 2nd column. This was confusing to me which is the point of this whole post.
    In order to gain the desired effect, I had to place 4 blank dummy empty JLabel components in a non-visible Row 0 of the grid. I did this for all 4 columns of that invisible row 0. The row is non-visible because the JLabel have no text or output. After adding this non-visible Row 0, all of the original mentioned Rows 0 through 2 become Rows 1 through 2 respectively.
    For example:
    Row0: iiiiiIIIIIiiiiiIIIII
    Row1: 0000011111
    Row2:      1111122222
    Row3:           2222233333 The above shows an inserted Row 0 with invisible labels that are not seen, but they seem to give weight to each column, allowing each to exist. Without doing this, as mentioned, the first code example (shown below) fails. The second example (also below) works, so it appears that putting the invisible controls into the first row, one in each column, somehow gives enough weight to each column to "establish" the column more so than otherwise.
    The big question I have is why didn't the first example work?
    I mean, in that example, I'm giving each JLabel equal weight, and each one takes up a width of 2 columns, so why doesn't the JLabel in the second row end up in column 1? Instead, both the original row 0 and row 1 JLabels appear in what looks like column 0, the same column. Does anyone know why this happened?
    The invisible control solution is fine but I'm just curious why it wasn't as intuitive as it should have been. The only thing I can come up with is that the weight of the 1st and 2nd JLabel (row 0 and 1) got combined in some fashion which combined them into column 1 which end up looking like column 0 since 0 somehow looses all weight. (???)
    ****************** THE FOLLOWING DOES NOT PRODUCE THE RIGHT EFFECTS ******************
    public class TestCoincidingColumns1 extends javax.swing.JFrame {
        /** Creates new form TestCoincidingColumns1 */
        public TestCoincidingColumns1() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
            java.awt.GridBagConstraints gridBagConstraints;
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            getContentPane().setLayout(new java.awt.GridBagLayout());
            jLabel1.setText("LabelRow0Col0Wid2");
            jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 255, 255)));
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.gridx = 0;
            gridBagConstraints.gridy = 0;
            gridBagConstraints.gridwidth = 2;
            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
            getContentPane().add(jLabel1, gridBagConstraints);
            jLabel2.setText("LabelRow1Col1Wid2");
            jLabel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 0, 0)));
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.gridx = 1;
            gridBagConstraints.gridy = 1;
            gridBagConstraints.gridwidth = 2;
            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
            getContentPane().add(jLabel2, gridBagConstraints);
            jLabel3.setText("LabelRow2Col2Wid2");
            jLabel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 255, 0)));
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.gridx = 2;
            gridBagConstraints.gridy = 2;
            gridBagConstraints.gridwidth = 2;
            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
            getContentPane().add(jLabel3, gridBagConstraints);
            pack();
        }// </editor-fold>
        * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new TestCoincidingColumns1().setVisible(true);
        // Variables declaration - do not modify
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        // End of variables declaration
    ****************** THE FOLLOWING WORKS ******************
    public class TestCoincidingColumns1WithFix extends javax.swing.JFrame {
        /** Creates new form TestCoincidingColumns1WithFix */
        public TestCoincidingColumns1WithFix() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
        private void initComponents() {
            java.awt.GridBagConstraints gridBagConstraints;
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jLabel3 = new javax.swing.JLabel();
            DummyRow0Col0 = new javax.swing.JLabel();
            DummyRow0Col1 = new javax.swing.JLabel();
            DummyRow0Col2 = new javax.swing.JLabel();
            DummyRow0Col3 = new javax.swing.JLabel();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            getContentPane().setLayout(new java.awt.GridBagLayout());
            jLabel1.setText("LabelRow0Col0Wid2");
            jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 255, 255)));
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.gridx = 0;
            gridBagConstraints.gridy = 1;
            gridBagConstraints.gridwidth = 2;
            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
            gridBagConstraints.weightx = 1.0;
            getContentPane().add(jLabel1, gridBagConstraints);
            jLabel2.setText("LabelRow1Col1Wid2");
            jLabel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 0, 0)));
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.gridx = 1;
            gridBagConstraints.gridy = 2;
            gridBagConstraints.gridwidth = 2;
            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
            gridBagConstraints.weightx = 1.0;
            getContentPane().add(jLabel2, gridBagConstraints);
            jLabel3.setText("LabelRow2Col2Wid2");
            jLabel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 255, 0)));
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.gridx = 2;
            gridBagConstraints.gridy = 3;
            gridBagConstraints.gridwidth = 2;
            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
            gridBagConstraints.weightx = 1.0;
            getContentPane().add(jLabel3, gridBagConstraints);
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.gridx = 0;
            gridBagConstraints.gridy = 0;
            gridBagConstraints.weightx = 1.0;
            getContentPane().add(DummyRow0Col0, gridBagConstraints);
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.gridx = 1;
            gridBagConstraints.gridy = 0;
            gridBagConstraints.weightx = 1.0;
            getContentPane().add(DummyRow0Col1, gridBagConstraints);
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.gridx = 2;
            gridBagConstraints.gridy = 0;
            gridBagConstraints.weightx = 1.0;
            getContentPane().add(DummyRow0Col2, gridBagConstraints);
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.gridx = 3;
            gridBagConstraints.gridy = 0;
            gridBagConstraints.weightx = 1.0;
            getContentPane().add(DummyRow0Col3, gridBagConstraints);
            pack();
        }// </editor-fold>                        
        * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new TestCoincidingColumns1WithFix().setVisible(true);
        // Variables declaration - do not modify                     
        private javax.swing.JLabel DummyRow0Col0;
        private javax.swing.JLabel DummyRow0Col1;
        private javax.swing.JLabel DummyRow0Col2;
        private javax.swing.JLabel DummyRow0Col3;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        // End of variables declaration                   
    }

    gridwidth=1 will produce something like the following:
    Row0: 00000
    Row1:      11111
    Row2:           22222where each component has its own column which is not the effect I was looking for. The effect is where a component appears halfway, or partway into the middle of the prior row's component's column. See original post for example.
    See URL in my prior post for a different thread with a post containing details as to why it's not possible to do what I want to do with GridBagLayout unless I use hidden columns to define each column that I want. When I do that, I can place a component midway into what appears to be the column for the prior row's component.
    Thanks for trying though.

  • Reversing Order in columns.

    Having entered details in a spreadsheet 3 columns x 1000 rows, I found I need to reverse the order of the columns. I need to do this without sorting them, as the listed items are not in numerical or alphabetical order. eg.
    change this...
    Header 1
    Header 2
    Header 3
    663344
    Dave
    3 River Close
    766542
    Fred
    11 Stream Street
    42205
    Andy
    7 Canal Road
    907
    Ben
    5 Brook Lane
    to this...
    Header 1
    Header 2
    Header 3
    907
    Ben
    5 Brook Lane
    42205
    Andy
    7 Canal Road
    766542
    Fred
    11 Stream Street
    663344
    Dave
    3 River Close
    Is there any way to do this? The sort panel only appears to give me the option to sort in numerical or alphabetical order.

    Hi Clive,
    "I found the new column needed to be inserted as column A (at the begining) so that all the following columns were changed, as this process doesn't change columns before the inserted column."
    I'm not sure I understand what you're saying here. The new column can be inserted anywhere. Numbers always sorts Rows, based on the content of one or more columns. Here's a copy of your original table (Table 1), with four duplicates, to each of which a single column has been added.
    After adding the column and finning in the numbers, each of the copies was sorted descending on its added column. As can be seen, the results were the same for each table.
    Regards,
    Barry

  • Converting Column Header to Rows Value in SQL Query

    Dear Guys,find blew the table from A1_30 to YetToDue columns. I need from A1_30 to A356 columns convert into row values and that values column head name like Abstract. A1_30 A31_60 A61_90 A91_120 A121_180A181_365A365 BalArr NoOfLoanLoanOS YetToDue
    0 0 0 101 0 0 0 909 66730 909 3637
    0 40 0 0 0 0 0 1818 66681 1818 3637
    0 56 0 0 0 0 0 1818 70210 1818 5455
    0 0 66 0 0 0 0 909 73735 909 7273
    0 35 0 0 0 0 0 2727 73327 2727 7273
    0 0 66 0 0 0 0 909 73353 909 7273
    0 40 0 0 0 0 0 909 66778 909 3637
    0 40 0 0 0 0 0 1818 66744 1818 3637
    0 0 0 101 0 0 0 909 66787 909 3637
    0 40 0 0 0 0 0 1818 66671 1818 3637
    0 56 0 0 0 0 0 1818 70201 1818 5455
    0 56 0 0 0 0 0 1818 70204 1818 5455
    0 0 66 0 0 0 0 909 73331 909 7273
    0 40 0 0 0 0 0 1818 66726 1818 3637
    0 40 0 0 0 0 0 2727 66798 2727 3637
    0 40 0 0 0 0 0 909 66676 909 3637
    0 40 0 0 0 0 0 1818 66685 1818 3637
    0 56 0 0 0 0 0 1818 70209 1818 5455
    0 57 0 0 0 0 0 1818 70226 1818 5455
    0 35 0 0 0 0 0 2727 73762 2727 7273
    0 0 66 0 0 0 0 909 73333 909 7273
    0 40 0 0 0 0 0 1818 66759 1818 3637
    0 40 0 0 0 0 0 882 66597 882 8826
    0 40 0 0 0 0 0 2727 66789 2727 3637
    0 40 0 0 0 0 0 2646 66609 2646 8826
    0 40 0 0 0 0 0 2646 66641 2646 8826
    0 57 0 0 0 0 0 1818 70193 1818 5455
    0 56 0 0 0 0 0 1818 70202 1818 5455
    0 35 0 0 0 0 0 2727 73757 2727 7273
    0 0 66 0 0 0 0 909 73345 909
    7273
    I expecting the results:
    Abstract BalArr NoOfLoan LoanOS YetToDue
    A0_30 0 0 0 0
    A31_60 45261 1579445 45261 122852
    A61_90 4545 367097 4545 36365
    A91_120 1818 133517 1818 7274
    A121_180 0 0 0 0
    A181_365 0 0 0 0
    A365 0 0 0 0
    pls help I really appreciate ..

    Dear Partrck Hurst.I have facing struggle with my store procedure , It work very slow performance when i pass the entryPlease go through my store procedure and let me advice if i wrote the script wrongly .ALTER PROCEDURE [dbo].[MFDB_GenerateDCBCollection]
    @i_BranchId INT,
    @i_SHGId INT,
    @p_SHGMemberId INT,
    @i_LoanNumber INT,
    @i_DayOpenDate DATETIME,
    @o_ErrorStatus INT Output
    ) AS
    --WITH ENCRYPTION AS
    DECLARE @p_DayOpenDate AS DATETIME
    DECLARE @p_BranchId AS INT
    DECLARE @D_FromDate AS DATE
    DECLARE @D_ToDate AS DATE
    DECLARE @E_ToDate AS DATE
    DECLARE @p_RecordCounter AS INT
    DECLARE @p_RecordCount AS INT
    DECLARE @p_TempCollectionId AS INT
    DECLARE @p_TempStateId AS INT
    DECLARE @p_TempRegionId AS INT
    DECLARE @p_TempBranchId AS INT
    DECLARE @p_TempSHGId AS INT
    DECLARE @p_TempSHGName AS VARCHAR(75)
    DECLARE @p_TempSHGMemberId AS INT
    DECLARE @p_TempMemberId AS INT
    DECLARE @p_TempMemberName AS VARCHAR(75)
    DECLARE @p_TempVillageName AS VARCHAR(100)
    DECLARE @p_TempPanchayatName AS VARCHAR(100)
    DECLARE @p_TempPanchayatId AS INT
    DECLARE @p_TempVillageId AS INT
    DECLARE @p_TempInstNumber AS INT
    DECLARE @p_TempLoanNumber AS INT
    DECLARE @p_TempDisbursedDate AS DATE
    DECLARE @p_TempStatus AS INT
    DECLARE @p_TempLoanSchemeId AS INT
    DECLARE @p_TempLCategoryId AS INT
    DECLARE @p_TempLActivityId AS INT
    DECLARE @p_TempLActSpecId AS INT
    DECLARE @p_TempLoanAmount AS NUMERIC(18,2)
    DECLARE @p_TempApprovalStatus AS INT
    DECLARE @p_TempFundingAgencyId AS INT
    DECLARE @p_TempOpenBalPrin AS NUMERIC(18,2)
    DECLARE @p_TempOpenBalInt AS NUMERIC(18,2)
    DECLARE @p_TempStdPrin AS NUMERIC(18,2)
    DECLARE @p_TempStdInt AS NUMERIC(18,2)
    DECLARE @p_TempCollPrin AS NUMERIC(18,2)
    DECLARE @p_TempCollInt AS NUMERIC(18,2)
    DECLARE @p_TempAdvancePrin AS NUMERIC(18,2)
    DECLARE @p_TempAdvanceInt AS NUMERIC(18,2)
    DECLARE @p_TempArrearPrin AS NUMERIC(18,2)
    DECLARE @p_TempArrearInt AS NUMERIC(18,2)
    DECLARE @p_TempBalancePrin AS NUMERIC(18,2)
    DECLARE @p_TempBalanceInt AS NUMERIC(18,2)
    DECLARE @p_TempDemandDate AS DATE
    DECLARE @p_TempCollectionDate AS DATE
    DECLARE @p_TempLStatus AS INT
    DECLARE @p_TempLSourceId AS INT
    DECLARE @p_TempVoucherName AS VARCHAR(75)
    DECLARE @p_TempInsurance AS NUMERIC(18,2)
    DECLARE @p_TempUpFrontFess AS NUMERIC(18,2)
    DECLARE @p_TempDocumentFees AS NUMERIC(18,2)
    DECLARE @p_TotalInterest AS NUMERIC(18,2)
    DECLARE @i_Month AS INT = 1
    DECLARE @p_Year AS INT = 2015
    DECLARE @i_SHGMemberId AS INT
    BEGIN TRANSACTION DCBGenerated
    BEGIN
    Set @o_ErrorStatus = 0
    SELECT @D_FromDate = DATEADD(MONTH, @i_Month - 1, DATEADD(YEAR, @p_Year - 1900, 0)) --as [START DATE]
    SELECT @D_ToDate = DATEADD(MONTH, @i_Month, DATEADD(YEAR, @p_Year - 1900, -1)) --as [EMD DATE]
    SELECT @i_SHGMemberId = MFDB_SHGMemberId FROM MFDB_SHGMEMBER_MASTER WHERE MFDB_SHGId = @i_SHGId AND MFDB_MemberId = @p_SHGMemberId
    SELECT @p_TempVillageName = MFDB_VillageName,
    @p_TempVillageId = MFDB_VillageId ,
    @p_TempPanchayatId = MFDB_PanchayatId ,
    @p_TempPanchayatName = MFDB_PanchayatName
    FROM MFDB_SHG_MASTER WHERE MFDB_SHGId = @i_SHGId
    /* Drop and Create TempCollection Table. This table has all installments for a given member */
    CREATE TABLE #TEMPDCBCOLLECTION
    [MFDB_LedgerNumber] [int] IDENTITY(1,1) NOT NULL,
    [MFDB_StateId] [int] NOT NULL,
    [MFDB_RegionId] [int] NOT NULL,
    [MFDB_BranchId] [int] NOT NULL,
    [MFDB_SHGId] [int] NOT NULL,
    [MFDB_SHGName] [varchar](75) NOT NULL,
    [MFDB_ShgMemberId] [int] NOT NULL,
    [MFDB_MemberName] [varchar](50) NOT NULL,
    [MFDB_LoanNumber] [int] NOT NULL,
    [MFDB_LoanAmount] [int] NOT NULL
    ) ON [PRIMARY]
    /* Drop and Create TempCollection Table. This table has all installments for a given member */
    ;WITH CTE_1 AS
    SELECT CT.MFDB_StateId AS StateId,
    CT.MFDB_RegionId AS RegionId,
    CT.MFDB_BranchId AS BranchId,
    CT.MFDB_SHGId AS ShgId,
    SM.MFDB_SHGName AS ShgName,
    CT.MFDB_SHGMemberId AS SHGMemberId,
    SMM.MFDB_MemberName AS MemberName,
    CT.MFDB_LoanNumber AS LoanNumber,
    LM.MFDB_LoanAmount AS LoanAmount
    FROM dbo.MFDB_COLLECTION_TXN CT
    LEFT JOIN dbo.MFDB_COLLECTION_AUDIT CA
    On CT.MFDB_SHGId = CA.MFDB_SHGId
    And CT.MFDB_MemberId = CA.MFDB_MemberId
    And CT.MFDB_LoanNumber = CA.MFDB_LoanNumber
    And CT.MFDB_CollectionId = CA.MFDB_CollectionId
    And CT.MFDB_LSourceId = CA.MFDB_LSourceId
    INNER JOIN dbo.MFDB_SHG_MASTER SM
    On CT.MFDB_SHGId = SM.MFDB_SHGId
    INNER JOIN dbo.MFDB_SHGMEMBER_MASTER SMM
    On CT.MFDB_SHGId = SMM.MFDB_SHGId
    And CT.MFDB_SHGMemberId = SMM.MFDB_SHGMemberId
    INNER JOIN dbo.MFDB_LOANAPPLICATION_MASTER LM
    ON LM.MFDB_SHGId = CT.MFDB_SHGId
    AND LM.MFDB_ShgMemberId = CT.MFDB_ShgMemberId
    AND LM.MFDB_LoanNumber = CT.MFDB_LoanNumber
    Where DATEDIFF(DAY,MFDB_CollectionDate,@i_DayOpenDate) = 0
    And CT.MFDB_CollectionAmount > 0
    And CT.MFDB_CollApprovedBy IS NULL
    AND CT.MFDB_BranchId = @i_BranchId
    AND CT.MFDB_SHGId = @i_SHGId
    AND CT.MFDB_ShgMemberId = @i_SHGMemberId
    AND CT.MFDB_LoanNumber = @i_LoanNumber
    CTE_2 AS
    SELECT DISTINCT
    StateId,
    RegionId,
    BranchId,
    ShgId,
    ShgName,
    SHGMemberId,
    MemberName,
    LoanNumber,
    LoanAmount
    FROM CTE_1
    INSERT INTO #TEMPDCBCOLLECTION ([MFDB_StateId],[MFDB_RegionId],[MFDB_BranchId],[MFDB_SHGId],[MFDB_SHGName],[MFDB_ShgMemberId],[MFDB_MemberName],[MFDB_LoanNumber],[MFDB_LoanAmount])
    SELECT StateId,
    RegionId,
    BranchId,
    ShgId,
    ShgName,
    SHGMemberId,
    MemberName,
    LoanNumber,
    LoanAmount
    FROM CTE_2
    DECLARE DCBMonthCursor CURSOR FOR
    SELECT [MFDB_StateId],
    [MFDB_RegionId],
    [MFDB_BranchId],
    [MFDB_SHGId],
    [MFDB_SHGName],
    [MFDB_ShgMemberId],
    [MFDB_MemberName],
    [MFDB_LoanNumber],
    [MFDB_LoanAmount]
    FROM #TEMPDCBCOLLECTION
    OPEN DCBMonthCursor
    FETCH NEXT FROM DCBMonthCursor
    INTO @p_TempStateId ,
    @p_TempRegionId ,
    @p_TempBranchId ,
    @p_TempSHGId ,
    @p_TempSHGName ,
    @p_TempSHGMemberId ,
    @p_TempMemberName ,
    @p_TempLoanNumber ,
    @p_TempLoanAmount
    WHILE (@@FETCH_STATUS = 0)
    BEGIN
    Set @p_TotalInterest = 0
    Select @p_TotalInterest = SUM(MFDB_StdInterest) From MFDB_LOAN_DISBURSEMENT Where MFDB_SHGId = @p_TempSHGId And MFDB_ShgMemberId = @p_TempSHGMemberId And MFDB_LoanNumber = @p_TempLoanNumber
    ;With
    CTE_1 AS
    SELECT LM.MFDB_StateId AS StateId ,
    LM.MFDB_RegionId AS RegionId,
    LM.MFDB_BranchId AS BranchId,
    LM.MFDB_SHGId AS SHGId,
    SM.MFDB_SHGName AS SHGName,
    LM.MFDB_ShgMemberId AS SHGMemId,
    LM.MFDB_MemberName AS MemberName,
    SM.MFDB_VillageId AS VillageId,
    LM.MFDB_LoanNumber AS LoanNo,
    LM.MFDB_LoanAmount AS LoanAmount,
    LM.MFDB_DisburseDate AS DisbursedDate,
    ISNULL((SELECT LD.MFDB_DemandDate
    FROM dbo.MFDB_LOAN_DISBURSEMENT LD
    Where LD.MFDB_SHGId = LM.MFDB_SHGId
    And LD.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    And LD.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,LD.MFDB_DemandDate,@i_DayOpenDate) = 0
    And LD.MFDB_ApprovalStatus = 1 ),NULL) AS DemandDate,
    ISNULL((SELECT TOP 1 CT.MFDB_CollectionDate
    FROM dbo.MFDB_COLLECTION_TXN CT
    Inner Join dbo.MFDB_COLLECTION_AUDIT CA
    On CT.MFDB_SHGId = CA.MFDB_SHGId
    And CT.MFDB_ShgMemberId = CA.MFDB_ShgMemberId
    And CT.MFDB_LoanNumber = CA.MFDB_LoanNumber
    And CT.MFDB_LSourceId = CA.MFDB_LSourceId
    And CT.MFDB_CollectionId = CA.MFDB_CollectionId
    WHERE CT.MFDB_SHGId = LM.MFDB_SHGId
    AND CT.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND CT.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,CT.MFDB_CollectionDate,@i_DayOpenDate) = 0
    ORDER BY CA.MFDB_CollectionId DESC),NULL) AS CollectionDate,
    ISNULL((SELECT TOP 1 CA.MFDB_InstallmentNumber
    FROM dbo.MFDB_COLLECTION_AUDIT CA
    Inner Join dbo.MFDB_COLLECTION_TXN CT
    On CT.MFDB_SHGId = CA.MFDB_SHGId
    And CT.MFDB_ShgMemberId = CA.MFDB_ShgMemberId
    And CT.MFDB_LoanNumber = CA.MFDB_LoanNumber
    And CT.MFDB_LSourceId = CA.MFDB_LSourceId
    And CT.MFDB_CollectionId = CA.MFDB_CollectionId
    WHERE CA.MFDB_SHGId = LM.MFDB_SHGId
    AND CA.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND CA.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,CT.MFDB_CollectionDate,@i_DayOpenDate) = 0
    ORDER BY CA.MFDB_CollectionId DESC),
    ISNULL((SELECT LD.MFDB_InstallmentNumber
    FROM dbo.MFDB_LOAN_DISBURSEMENT LD
    Where LD.MFDB_SHGId = LM.MFDB_SHGId
    And LD.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    And LD.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,LD.MFDB_DemandDate,@i_DayOpenDate) = 0
    And LD.MFDB_ApprovalStatus = 1 ),0)) AS IntallNo,
    ISNULL(CAST((SELECT TOP 1 NR.MFDB_BalancePrincipal
    FROM dbo.MFDB_NEW_DCB_REPORT NR
    WHERE NR.MFDB_SHGId = LM.MFDB_SHGId
    AND NR.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND NR.MFDB_LoanNumber = LM.MFDB_LoanNumber
    ORDER BY NR.MFDB_LedgerNumber DESC) AS NUMERIC(18,0)),0) AS ArrPrincipal,
    ISNULL(CAST((SELECT TOP 1 NR.MFDB_BalanceInterest
    FROM dbo.MFDB_NEW_DCB_REPORT NR
    WHERE NR.MFDB_SHGId = LM.MFDB_SHGId
    AND NR.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND NR.MFDB_LoanNumber = LM.MFDB_LoanNumber
    ORDER BY NR.MFDB_LedgerNumber DESC) AS NUMERIC(18,0)),0) AS ArrInterest,
    0 AS CurrDemandPrin,
    0 AS CurrDemandInt,
    ISNULL((SELECT CAST(SUM(ISNULL(CA.MFDB_CollectedPrincipal,0) +
    ISNULL(CA.MFDB_AdvancePrincipal,0) +
    ISNULL(CA.MFDB_ArrearPrincipal,0)) AS NUMERIC(18,0))
    FROM dbo.MFDB_COLLECTION_AUDIT CA
    Inner Join dbo.MFDB_COLLECTION_TXN CT
    On CT.MFDB_SHGId = CA.MFDB_SHGId
    And CT.MFDB_ShgMemberId = CA.MFDB_ShgMemberId
    And CT.MFDB_LoanNumber = CA.MFDB_LoanNumber
    And CT.MFDB_LSourceId = CA.MFDB_LSourceId
    And CT.MFDB_CollectionId = CA.MFDB_CollectionId
    WHERE CA.MFDB_SHGId = LM.MFDB_SHGId
    AND CA.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND CA.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,CT.MFDB_CollectionDate,@i_DayOpenDate) = 0
    ),0) AS CurrCollPri,
    ISNULL((SELECT CAST(SUM(ISNULL(CA.MFDB_CollectedInterest,0) +
    ISNULL(CA.MFDB_AdvanceInterest,0) +
    ISNULL(CA.MFDB_ArrearInterest,0)) AS NUMERIC(18,0))
    FROM dbo.MFDB_COLLECTION_AUDIT CA
    Inner Join dbo.MFDB_COLLECTION_TXN CT
    On CT.MFDB_SHGId = CA.MFDB_SHGId
    And CT.MFDB_ShgMemberId = CA.MFDB_ShgMemberId
    And CT.MFDB_LoanNumber = CA.MFDB_LoanNumber
    And CT.MFDB_LSourceId = CA.MFDB_LSourceId
    And CT.MFDB_CollectionId = CA.MFDB_CollectionId
    WHERE CA.MFDB_SHGId = LM.MFDB_SHGId
    AND CA.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND CA.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,CT.MFDB_CollectionDate,@i_DayOpenDate) = 0
    ),0) AS CurrCollInt,
    ISNULL(CAST((SELECT TOP 1 NR.MFDB_AdvCBPrincipal
    FROM dbo.MFDB_NEW_DCB_REPORT NR
    WHERE NR.MFDB_SHGId = LM.MFDB_SHGId
    AND NR.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND NR.MFDB_LoanNumber = LM.MFDB_LoanNumber
    ORDER BY NR.MFDB_LedgerNumber DESC) AS NUMERIC(18,0)),0) AS AdvOBPri,
    ISNULL(CAST((SELECT TOP 1 NR.MFDB_AdvCBInterest
    FROM dbo.MFDB_NEW_DCB_REPORT NR
    WHERE NR.MFDB_SHGId = LM.MFDB_SHGId
    AND NR.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND NR.MFDB_LoanNumber = LM.MFDB_LoanNumber
    ORDER BY NR.MFDB_LedgerNumber DESC) AS NUMERIC(18,0)),0) AS AdvOBInt,
    0 AS AdvCBPri,
    0 AS AdvCBInt,
    0 AS BalancePri,
    0 AS BalanceInt,
    ISNULL((SELECT CAST(SUM(ISNULL(CA.MFDB_CollectedPrincipal,0) +
    ISNULL(CA.MFDB_AdvancePrincipal,0) +
    ISNULL(CA.MFDB_ArrearPrincipal,0)) AS NUMERIC(18,0))
    FROM dbo.MFDB_COLLECTION_AUDIT CA
    Inner Join dbo.MFDB_COLLECTION_TXN CT
    On CT.MFDB_SHGId = CA.MFDB_SHGId
    And CT.MFDB_ShgMemberId = CA.MFDB_ShgMemberId
    And CT.MFDB_LoanNumber = CA.MFDB_LoanNumber
    And CT.MFDB_LSourceId = CA.MFDB_LSourceId
    And CT.MFDB_CollectionId = CA.MFDB_CollectionId
    WHERE CA.MFDB_SHGId = LM.MFDB_SHGId
    AND CA.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND CA.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,CT.MFDB_CollectionDate,@i_DayOpenDate) >= 0
    ),0) AS OS_Pri,
    ISNULL((SELECT CAST(SUM(ISNULL(CA.MFDB_CollectedInterest,0) +
    ISNULL(CA.MFDB_AdvanceInterest,0) +
    ISNULL(CA.MFDB_ArrearInterest,0)) AS NUMERIC(18,0))
    FROM dbo.MFDB_COLLECTION_AUDIT CA
    Inner Join dbo.MFDB_COLLECTION_TXN CT
    On CT.MFDB_SHGId = CA.MFDB_SHGId
    And CT.MFDB_ShgMemberId = CA.MFDB_ShgMemberId
    And CT.MFDB_LoanNumber = CA.MFDB_LoanNumber
    And CT.MFDB_LSourceId = CA.MFDB_LSourceId
    And CT.MFDB_CollectionId = CA.MFDB_CollectionId
    WHERE CA.MFDB_SHGId = LM.MFDB_SHGId
    AND CA.MFDB_ShgMemberId = LM.MFDB_ShgMemberId
    AND CA.MFDB_LoanNumber = LM.MFDB_LoanNumber
    And DATEDIFF(DAY,CT.MFDB_CollectionDate,@i_DayOpenDate) >= 0
    ),0) AS OS_Int,
    0 AS RepaymentPercentage,
    LM.MFDB_LoanSchemeId AS LoanProduct,
    LM.MFDB_LActivityId AS LoanActivity,
    LM.MFDB_LActSpecId AS LoanSubActivity,
    LM.MFDB_FundingAgencyId AS FundAgencyId,
    LM.MFDB_LSourceId AS SourceId
    FROM dbo.MFDB_LOANAPPLICATION_MASTER LM
    Left Join dbo.MFDB_SHG_MASTER SM
    On SM.MFDB_ShgId = LM.MFDB_ShgId
    WHERE LM.MFDB_ApprovalStatus= 3
    AND LM.MFDB_DisburseDate IS NOT NULL
    AND LM.MFDB_StateId = @p_TempStateId
    AND LM.MFDB_RegionId = @p_TempRegionId
    AND LM.MFDB_BranchId = @p_TempBranchId
    AND LM.MFDB_SHGId = @p_TempSHGId
    AND LM.MFDB_ShgMemberId = @p_TempSHGMemberId
    AND LM.MFDB_LoanNumber = @p_TempLoanNumber
    CTE_2 AS
    SELECT StateId, RegionId, BranchId, SHGId, SHGName, SHGMemId, MemberName, VillageId , LoanNo, LoanAmount, DisbursedDate,DemandDate, CollectionDate, IntallNo,
    ArrPrincipal,
    ArrInterest,
    CurrDemandPrin,
    CurrDemandInt,
    ISNULL(ISNULL(ArrPrincipal,0) + ISNULL(CurrDemandPrin,0),0) AS TotDemandPri,
    ISNULL(ISNULL(ArrInterest,0) + ISNULL(CurrDemandInt,0),0) AS TotDemandInt,
    AdvOBPri,
    AdvOBInt,
    CurrCollPri,
    CurrCollInt,
    AdvCBPri,
    AdvCBInt,
    BalancePri,
    BalanceInt,
    ISNULL(ISNULL(LoanAmount,0) - ISNULL(OS_Pri,0),0) AS OS_Pri,
    ISNULL(ISNULL(@p_TotalInterest,0) - ISNULL(OS_Int,0),0) OS_Int,
    CONVERT(INT,RepaymentPercentage) AS RepaymentPercentage,
    LoanProduct,
    LoanActivity,
    LoanSubActivity,
    FundAgencyId,
    SourceId
    FROM CTE_1
    CTE_3 AS
    SELECT StateId, RegionId, BranchId, SHGId, SHGName, SHGMemId, MemberName, VillageId , LoanNo, LoanAmount, DisbursedDate,DemandDate, CollectionDate, IntallNo,
    ArrPrincipal,
    ArrInterest,
    CurrDemandPrin,
    CurrDemandInt,
    TotDemandPri,
    TotDemandInt,
    CASE WHEN AdvOBPri < 0 THEN AdvOBPri * -1 ELSE AdvOBPri END AS AdvOBPri,
    CASE WHEN AdvOBInt < 0 THEN AdvOBInt * -1 ELSE AdvOBInt END AS AdvOBInt,
    CurrCollPri,
    CurrCollInt,
    CASE WHEN ISNULL(TotDemandPri,0) = 0 THEN ISNULL((CurrCollPri + AdvOBPri),0)
    WHEN ISNULL(TotDemandPri,0) > 0 AND ISNULL(CurrCollPri + AdvOBPri,0) > ISNULL(TotDemandPri,0) THEN ISNULL(ISNULL(CurrCollPri + AdvOBPri,0) - ISNULL(TotDemandPri,0),0)
    WHEN ISNULL(TotDemandPri,0) > 0 AND ISNULL(CurrCollPri + AdvOBPri,0) < ISNULL(TotDemandPri,0) THEN 0
    WHEN ISNULL(CurrCollPri + AdvOBPri,0) = ISNULL(TotDemandPri,0) THEN 0
    ELSE 0 END AS AdvCBPri,
    CASE WHEN ISNULL(TotDemandInt,0) = 0 THEN ISNULL((CurrCollInt + AdvOBInt),0)
    WHEN ISNULL(TotDemandInt,0) > 0 AND ISNULL(CurrCollInt + AdvOBInt,0) > ISNULL(TotDemandInt,0) THEN ISNULL(ISNULL(CurrCollInt + AdvOBInt,0) - ISNULL(TotDemandInt,0),0)
    WHEN ISNULL(TotDemandInt,0) > 0 AND ISNULL(CurrCollInt + AdvOBInt,0) < ISNULL(TotDemandInt,0) THEN 0
    WHEN ISNULL(CurrCollInt + AdvOBInt,0) = ISNULL(TotDemandInt,0) THEN 0
    ELSE 0 END AS AdvCBInt,
    0 AS BalancePri,
    0 AS BalanceInt,
    OS_Pri,
    OS_Int,
    0 AS Repayment,
    LoanProduct,
    LoanActivity,
    LoanSubActivity,
    FundAgencyId,
    SourceId,
    CONVERT(CHAR(3), @i_DayOpenDate, 0) + ' - ' + RIGHT(CONVERT(CHAR(4), YEAR(@i_DayOpenDate)),2) AS Months
    FROM CTE_2
    INSERT INTO dbo.MFDB_NEW_DCB_REPORT
    ( [MFDB_TxnDate]
    ,[MFDB_StateId]
    ,[MFDB_RegionId]
    ,[MFDB_BranchId]
    ,[MFDB_SHGId]
    ,[MFDB_SHGName]
    ,[MFDB_ShgMemberId]
    ,[MFDB_MemberName]
    ,[MFDB_VillageId]
    ,[MFDB_LoanNumber]
    ,[MFDB_LoanAmount]
    ,[MFDB_DisbursedDate]
    ,[MFDB_DemandDate]
    ,[MFDB_CollectionDate]
    ,[MFDB_InstallmentNumber]
    ,[MFDB_ArrearPrincipal]
    ,[MFDB_ArrearInterest]
    ,[MFDB_DemandPrincipal]
    ,[MFDB_DemandInterest]
    ,[MFDB_TotDemandPrincipal]
    ,[MFDB_TotDemandInterest]
    ,[MFDB_AdvOBPrincipal]
    ,[MFDB_AdvOBInterest]
    ,[MFDB_CollectedPrincipal]
    ,[MFDB_CollectedInterest]
    ,[MFDB_AdvCBPrincipal]
    ,[MFDB_AdvCBInterest]
    ,[MFDB_BalancePrincipal]
    ,[MFDB_BalanceInterest]
    ,[MFDB_OS_Pri]
    ,[MFDB_OS_Int]
    ,[MFDB_RepaymentPercentage]
    ,[MFDB_LoanSchemeId]
    ,[MFDB_LActivityId]
    ,[MFDB_LActSpecId]
    ,[MFDB_FundAgencyId]
    ,[MFDB_LSourceId]
    ,[MFDB_Months]
    ,[MFDB_PanchayatId]
    ,[MFDB_PanchayatName]
    ,[MFDB_VillageName]
    SELECT @i_DayOpenDate ,StateId, RegionId, BranchId, SHGId, SHGName, SHGMemId, MemberName, VillageId , LoanNo, LoanAmount, DisbursedDate,DemandDate,CollectionDate,IntallNo,
    ArrPrincipal,ArrInterest,CurrDemandPrin,CurrDemandInt,TotDemandPri,TotDemandInt,AdvOBPri,AdvOBInt,CurrCollPri,CurrCollInt,
    CASE WHEN AdvCBPri < 0 THEN 0 ELSE AdvCBPri END,
    CASE WHEN AdvCBInt < 0 THEN 0 ELSE AdvCBInt END,
    CASE WHEN ISNULL(TotDemandPri,0) = 0 THEN 0
    WHEN ISNULL(TotDemandPri,0) > 0 AND ISNULL(CurrCollPri + AdvOBPri,0) > ISNULL(TotDemandPri,0) THEN 0
    WHEN ISNULL(TotDemandPri,0) > 0 AND ISNULL(CurrCollPri + AdvOBPri,0) < ISNULL(TotDemandPri,0) THEN ABS(ISNULL(ISNULL(CurrCollPri + AdvOBPri,0) - ISNULL(TotDemandPri,0),0) * -1)
    WHEN ISNULL(CurrCollPri + AdvOBPri,0) = ISNULL(TotDemandPri,0) THEN 0
    ELSE 0 END AS BalancePri,
    CASE WHEN ISNULL(TotDemandInt,0) = 0 THEN 0
    WHEN ISNULL(TotDemandInt,0) > 0 AND ISNULL(CurrCollInt + AdvOBInt,0) > ISNULL(TotDemandInt,0) THEN 0
    WHEN ISNULL(TotDemandInt,0) > 0 AND ISNULL(CurrCollInt + AdvOBInt,0) < ISNULL(TotDemandInt,0) THEN ABS(ISNULL(ISNULL(CurrCollInt + AdvOBInt,0) - ISNULL(TotDemandInt,0),0) * -1)
    WHEN ISNULL(CurrCollInt + AdvOBInt,0) = ISNULL(TotDemandInt,0) THEN 0
    ELSE 0 END AS BalanceInt,
    OS_Pri,
    OS_Int,
    0 AS Repayment,
    LoanProduct,LoanActivity,LoanSubActivity,FundAgencyId,SourceId,Months,@p_TempPanchayatId,@p_TempPanchayatName,@p_TempVillageName
    FROM CTE_3
    If @@Error != 0
    Begin
    Set @o_ErrorStatus = 1
    ROLLBACK TRANSACTION DCBGenerated
    RETURN
    End
    FETCH NEXT FROM DCBMonthCursor
    INTO @p_TempStateId ,
    @p_TempRegionId ,
    @p_TempBranchId ,
    @p_TempSHGId ,
    @p_TempSHGName ,
    @p_TempSHGMemberId ,
    @p_TempMemberName ,
    @p_TempLoanNumber ,
    @p_TempLoanAmount
    END
    CLOSE DCBMonthCursor
    DEALLOCATE DCBMonthCursor
    DELETE FROM #TEMPDCBCOLLECTION
    If @@Error != 0
    Begin
    Set @o_ErrorStatus = 1
    ROLLBACK TRANSACTION DCBGenerated
    RETURN
    End
    END
    COMMIT TRANSACTION DCBGenerated

  • Bad practice to assume ordering of columns using *  ??

    I am using Pro*C -- embedded sql
    I have a table with 60 columns and it is partitioned by datetime. It is constantly getting new rows via an array insert, inserting 10 to 100 million rows a day depending on the installation.
    I am currently using select * for the querying.
    I am inserting an array:
    exec sql for :cnt insert into x values (...);
    Is it more efficient or bad practice to assume the ordering of columns. Is it better to list the columns explicitly in the select/insert?
    thanks, lisa

    Yes.
    Imagine if you have added a new column to the table and that column has a default value assigned for older applications (only newer applications will use this added column, old applications should still work), you do not have to re-visit the old application code to change all those insert statements. Only new applications will need to care about what value to put into this newly added column.
    This helps avoid unnecessary changes to existing applications if the new column(s) is added to support new applications only.

Maybe you are looking for

  • How to preset the order of rows in the outer query of a correlated query ?

    Good morning, I have the following simple query: select empno,        ename,        sal,        sum(case              when rn = 1 then sal              else -sal            end) over (order by sal, empno) as running_diff    from (          select emp

  • Oracle ADF application - broswer cancel / retry error message

    Hi We have developed an application on Oracle ADF11g and targetted client browser to run on IE7. We have no issues during our development and test environment, whereas while we moved the same to customers beta & then to live environment, the user exp

  • Using same bind variable multiple times in Dynamic sql

    Hi; I have a query which uses same variable multiple times, is there a way I could use only one time that variable and it will take multiple times. Query is; execute immediate 'SELECT count(*) FROM x WHERE MONTH_ID = :VOMNTH_ID UNION SELECT count(*)

  • Mass idoc mail has been sent to many users

    Dears,   recently many user got lots of mail with title 'EDI: Incorrect status for inbound IDoc' in their inbox .   i have checked these standard inbound idocs , and the process code has been linked to one task, such as TS00008068. Via we19 i have cr

  • JCo and HR Minimaster

    Hi, For our application integration with SAP I created an  application client to the SAP test system using JCo . Using "RFC_FUNCTION_SEARCH" I got a list of BAPI's and I used the BAPI "BAPI_CC1_DNLOAD_MINIMASTER" to get the HRMinimaster data. But I d