Alternate rows with different number of columns in JTable or similar

Hi Guys,
I have tried searching google and these forums, but have not been able to find what I am looking for.
Looking for ideas, on how to do the following
I have a swing application, that I would like to have alternate rows
eg.
1st row has 10 columns
2nd row has 1 column, that expands all 10 columns of the 1st row
and keeps alternating like this for the rest of the records in the table.
Is there a special JTable that can do this for me, or has anyone had to do this before.
Thanks,
Mac

an example of merging cells is here
[http://www.crionics.com/products/opensource/faq/swing_ex/JTableExamples4.html]
scroll down to 'Multi-Span Cell'
run the program, highlight some cells, click combine.
if that's the type of thing you're after, modify your code per what's in 'combine'
note: the original code (now) produces a stack overflow error (don't know if it's been fixed in the above link),
but if you get that error, in AttributiveCellTableModel's setDataVector( Vector newData, Vector columnNames )
change
setColumnIdentifiers(columnNames);
to
columnIdentifiers = columnNames;

Similar Messages

  • How to load data from file contains rows with different number of columns

    hi all,
    a data file contains assets data ordered like this(location_id
    serial_number , quantity
    serial_number , quantity
    single column rows represents location, and two columns rows represents asset details for that location
    123
    12345 ,1
    32145 ,1
    124
    12348 ,12
    41239 ,22
    54189 ,2
    254
    22419 ,1
    I want to use sql loader to load these data after merging locations with thieir assets,like this order(location_id,serial number,quantity)
    123 ,12345 ,1
    123 ,25413 ,1
    123 ,32145 ,1
    124 ,12348 ,12
    124 ,41239 ,22
    124 ,54189 ,2
    254 ,22419 ,1
    Can one help me in that?
    thank you,

    Create external table and code sql query to do it.
    :p

  • Can we create JTable with multiple rows with varying number of columns ?

    Hi All,
    I came across a very typical problem related to JTable. My requirement is that cells should be added dynamically to the JTable. I create a JTable with initial size of 1,7 (row, columns) size. Once the 7 columns are filled with data, a new row should be created. But the requirement is, the new row i.e. second row should have only one cell in it initially. The number of cells should increase dynamically as the data is entered. The table is automatically taking the size of its previous row when new row is added. I tried by using setColumnCount() to change the number of columns to '1' for the second row but the same is getting applied to the first row also.
    So can you please help me out in this regard ? Is it possible to create a JTable of uneven size i.e. multiple rows with varying number of columns in each row ?
    Thanks in Advance.

    Well a JTable is always going to paint the same number of columns for each row. Anything is possible if you want to rewrite the JTable UI to do this, but I wouldn't recommend it. (I certainly don't know how to do it).
    A simpler solution might be to override the isCellEditable(...) method of JTable and prevent editing of column 2 until data in column 1 has been entered etc., etc. You may also want to provide a custom renderer that renderers the empty column differently, maybe with a grey color instead of a white color.

  • Query result Alternate row with different color   

    hello
    can anyone help me on a query result.
    i wish to have a :
    query result Alternate row with different color .
    ex.
    first row light grey
    second row darker grey.
    and repeats itself up to the last record/row.
    thanks

    <tr> <!------------------------------I replaced with
    <tr bgcolor="<cfif currentrow mod
    2>##D3D3D3<cfelse>##F5F5F5</cfif>">
    <td>
    #MYARRAY[x][2].CNO#
    </td>
    <td align="center">
    #MYARRAY[x][2].CDCDTt#
    </td>
    <td>
    #MYARRAY[x][2].PADESC#
    </td>
    <td align="center">
    #MYARRAY[x][2].INc#
    </td>
    <td align="center">
    #MYARRAY[x][2].Exp#
    </td>
    <cfset thirdArray = MYARRAY[x][3]>
    <cfif NOT arraylen(thirdArray)>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
    <cfelse>
    <cfloop index="z" from="1" to="3">
    <cfif z GT arraylen(thirdArray)>
    <td> </td>
    <td> </td>
    <cfelse>
    <td>
    #thirdArray[z][2]# 
    </td>
    <td>
    #thirdArray[z][3]# 
    </td>
    </cfif>
    </cfloop>
    <cfif arrayLen(thirdArray) gt 3>
    <td nowrap="nowrap">
    <cfloop index="z" from="4" to="#arraylen(thirdArray)#">
    #thirdArray[z][2]# - #thirdArray[z][3]#<BR />
    </cfloop>
    </td>
    </cfif>
    </cfif>
    </tr>
    I got this error.
    Variable CURRENTROW is undefined

  • JTable with different number of columns (packets)

    Hi experts,
    is it possible to draw a single JTable which have different number of columns in each row
    if yes good
    if no my project is to build a comperhensive packet sniffer what is the most appropriate swing component to repersent a packets (data,Ack,...) which have different number of fields and when i select one packet it is highlighted with different color
    Best Regards

    AHDK wrote:
    is it possible to draw a single JTable which have different number of columns in each rowThis is about how to make a cell span multiple cells: [http://www.codeguru.com/java/articles/139.shtml]
    The code is a little buggy. I used it in a practical example, and removed the bugs:
    [http://forum.byte-welt.net/attachment.php?attachmentid=132&d=1249675825] (source code is included in the jar file)

  • LSMW uploading excel with different number of columns

    Dear Expert,
    I am trying to build a lsmw to upload data sometime the number of columns are different. For example, a standard excel has 5 columns but sometime it only has 4 columns with the input screen of 4 fields. I am wondering what is the APAB code I could put in may LSMW field mapping say if the value from the excel is "/" then this field should be skiped from reading. Then my LSWM will generate a batch input filed with 4 columns of input data to fit in the input screen with for fields only, If the value from the excel does not have "/' then all field would be read. So my LSMW will generate a batch input with 5 columns of input data to fit in the input screen of 5 fields.
    If you may share the coding.
    Thank you

    Hi,
    In this step, click on the target field and then click on the button "Rule"
    IN the next screen select the radio button "ABAP Code"
    Then put the code as below:-
    IF NOT <Source Field> IS INITIAL.
    <Target Field> = <Source Field>.
    ENDIF.
    (Insteac of <Source Field> and <Target Field>, put your actual value in your LSMW.)
    Regards,
    Gaurav

  • Make Concatenation with different number of columns in Sequence

    I have the folowing query
    select dated,sum(substr(hrs,1,2)) ||':'|| sum(substr(hrs,4,5)) hrs,dpt,reason
    from dpr.stp_00_00
    group by dated,dpt,reason
    order by dated
    and the output of this query is this
    DATED     HRS     DPT     REASON
    10/14/2011     2:5     Mechanical     Boiler tubes damaged & less availability of steam due to only one boiler operation
    10/14/2011     0:20     Mechanical     Breakage of link of bagasse carrier # 1 and surplus carrier
    10/14/2011     1:0     Mechanical     Choke at belt conveyor
    10/15/2011     0:10     Mechanical     Boiler pressure dropped
    10/16/2011     1:30     Electrical     Power failure / 505 governor card damaged of turbine # 2
    10/16/2011     0:10     Mechanical     3rd mill taken in line
    10/16/2011     0:30     Mechanical     Raw juice line before primary heaters busted
    10/16/2011     1:0     Mechanical     Raw juice pump at mill house NRV body got busted
    I have grouped the rows with reason column but due to that the reason is different for each dept and also and for different in each date there fore i want to do that the reason in all dates should be concatenated in single rows in Reason column In other words all reasons in all dates should be shown in single column with grouped date and Department and after the output of data should be like bellow
    DATED     HRS     DPT     REASON
    10/14/2011     2:5     Mechanical     Boiler tubes damaged & less availability of steam due to only one boiler operation - Breakage of link of bagasse carrier # 1 and surplus -Mechanical     Breakage of link of bagasse carrier # 1 and surplus carriercarrier - Mechanical     Choke at belt conveyor

    How about this:
    WITH t AS
    (SELECT TO_DATE('10/14/2011', 'MM-DD-YYYY') dated, 'Mechanical' dpt, 'Boiler tubes damaged and less availability of steam due to only one boiler operation' reason FROM dual UNION ALL
    SELECT TO_DATE('10/14/2011', 'MM-DD-YYYY') dated, 'Mechanical' dpt, 'Breakage of link of bagasse carrier # 1 and surplus carrier' reason FROM dual UNION ALL
    SELECT TO_DATE('10/14/2011', 'MM-DD-YYYY') dated, 'Mechanical' dpt, 'Choke at belt conveyor ' reason FROM dual UNION ALL
    SELECT TO_DATE('10/15/2011', 'MM-DD-YYYY') dated, 'Mechanical' dpt, 'Boiler pressure dropped' reason FROM dual UNION ALL
    SELECT TO_DATE('10/16/2011', 'MM-DD-YYYY') dated, 'Electrical' dpt, 'Power failure / 505 governor card damaged of turbine # 2 ' reason FROM dual UNION ALL
    SELECT TO_DATE('10/16/2011', 'MM-DD-YYYY') dated, 'Mechanical' dpt, '3rd mill taken in line' reason FROM dual UNION ALL
    SELECT TO_DATE('10/16/2011', 'MM-DD-YYYY') dated, 'Mechanical' dpt, 'Raw juice line before primary heaters busted' reason FROM dual UNION ALL
    SELECT TO_DATE('10/16/2011', 'MM-DD-YYYY') dated, 'Mechanical' dpt, 'Raw juice pump at mill house NRV body got busted' reason FROM dual)
    SELECT   dated,
             dpt,
             RTRIM(XMLAGG(XMLELEMENT(c, reason||' - ')).extract ('//text()'), ' - ') reasons
    FROM     t
    GROUP BY dated,
             dpt

  • Csv input adapter - read rows with different # of columns

    I have a csv file which includes rows with different number of columns. I want to read all the rows( of different # of cols)  into ONE stream only and then split into separate streams afterwards.
    I saw that CSV File Input Adapter does not add missing columns with nulls by default. Is it possible somehow? How can I generate a workaround?
    Thanks.

    Hello,
    The CSV Input Adapter expects to find a fixed number of fields.  If you attach the input adapter to a stream/window with 3 fields, it will always try to read three fields.  You can have missing data and this will be read into a column as a NULL value but the delimiters must still be there.  For example:
    1,1,1
    2,2,2
    3,3,3
    4,,4
    5,5,5
    CREATE INPUT WINDOW inWindow SCHEMA (c1 integer, c2 integer, c3 integer) PRIMARY KEY (c1);
    ATTACH INPUT ADAPTER File_Hadoop_CSV_Input2 TYPE toolkit_file_csv_input TO inWindow PROPERTIES csvExpectStreamNameOpcode = FALSE ,
      dir = 'c:/temp' ,
      file = 'test.csv' ,
      csvDelimiter = ',' ;
    A workaround you might consider is reading an entire line from your file into a stream with a single string column.  The trick is that you have to choose a character for the column delimiter that you are certain will never show up in your data.  Than once you have read that line into a stream, you can use the string functions to parse out the columns as needed:
    CREATE INPUT STREAM csv_instream SCHEMA (
      log_line_message string
    // Choose a character that is certain to never show up in the data in order to read the entire line
    // from the CSV file into a single column
    ATTACH INPUT ADAPTER File_Hadoop_CSV_Input1 TYPE toolkit_file_csv_input TO csv_instream PROPERTIES
      csvExpectStreamNameOpcode = FALSE ,
      dir = 'C:/temp' ,
      file = 'error_log' ,
      csvDelimiter = '@' ;
    // Parse out the individual columns
    CREATE OUTPUT STREAM csv_outstream SCHEMA (
      log_datetime timestamp ,
      debug_level string ,
      host string ,
      message string ) AS SELECT
      to_timestamp(substr(CI.log_line_message, 1, 24), 'DY MON DD HH24:MI:SS YYYY') as log_datetime,
      substr(CI.log_line_message, patindex(CI.log_line_message, '[', 2)+1, (patindex(CI.log_line_message, ']', 2) - patindex(CI.log_line_message, '[', 2))-1) AS debug_level,
      replace(substr(CI.log_line_message, patindex(CI.log_line_message, '[', 3)+1, (patindex(CI.log_line_message, ']', 3) - patindex(CI.log_line_message, '[', 3))-1), 'client ', '') AS host,
      substr(CI.log_line_message, patindex(CI.log_line_message, ']', 3)+1, 500) AS message
      FROM csv_instream CI
      WHERE CI.log_line_message IS NOT NULL;
    Thanks,
    Neal

  • Not able to color different rows with different colors in a column of table

    Hi,
    I am trying to to display different rows with different colors in a column of the table based on some decode condition.
    I have gone through the following threads :
    Can we colour the rows in the column of a table
    Changing Color of a value in a column
    This is what i have done :
    1.Added the following code to custom.xss(changed the name to Custom.xss as suggested in one of the above threads) --- in path ---- jdev\myhtml\OA_HTML\cabo\styles
    <style selector=".1">
    <includeStyle name="DefaultFontFamily"/>
    <property name="font-size">11pt</property>
    <property name="font-weight">Bolder</property>
    <property name="color">#008000</property>
    <property name="text-indent">3px</property>
    </style>
    <style selector=".2">
    <includeStyle name="DefaultFontFamily"/>
    <property name="font-size">11pt</property>
    <property name="font-weight">Bolder</property>
    <property name="color">#FFFF00</property>
    <property name="text-indent">3px</property>
    </style>
    2. Sql query of the VO is :
    select comments,role ,decode(role,'REQUESTER','1','2') Colorattr from xxat_sars_action_history where request_id = :1 and event_name = :2 and action_code <> 'PENDING'
    order by sequence_num desc
    3. Coded the following in the process request of the controller:
    OATableBean table = (OATableBean)webBean.findIndexedChildRecursive("CommentsTB");
    OAMessageStyledTextBean roleBN = (OAMessageStyledTextBean)webBean.findIndexedChildRecursive("role");
    OADataBoundValueViewObject cssjob = new OADataBoundValueViewObject(roleBN,"Colorattr");
    roleBN.setAttributeValue(oracle.cabo.ui.UIConstants.STYLE_CLASS_ATTR, cssjob);
    where 1 and 2 form the colors ( i have even tried with 'Red' and 'Yellow'...as it was not working replaced with 1 and 2)
    4.The query returns data fine with corresponding 1 and 2 values.
    But different colors are not getting reflecting on to the UI.
    I am testing this on my local jdev.
    Please do let me know if i am missing something.
    Thanks ,
    Sushma.

    Any Clues please.....
    Thanks,
    Sushma.

  • Table with varying number of columns

    Hello experts,
    my issue:
    I need to print a table with varying number of columns. Depending on if all cells of a certain column are initial the
    whole column should disappear. Hiding is not enough.
    If this columns is in the middle of the table the following columns should move left to fill the gap.
    my approach: (maybe there is an easier one)
    There are 4 different possible situations. My approach was to create 4 different tables with different amount of
    columns. In the interface I fill the table that is really needed from the source table data and fill a flag that characteristics
    the situation, possible values (1,2,3,4).
    In the form I'd like to print the appropriate table depending on the situations.
    my problem:
    How to place all 4 possible tables lying upon each other in the form and print only the needed one depending on the flag value?
    my question:
    Is my approach ok? Or is there an easier one?
    If it is ok. How can I solve the problem regarding printing the right table.
    Thanks in advance!
    Heinz

    Hi Heinz,
    You can handle it with FormCalc Script at initialization.
    Suppose you have a table with name TABLE having a header HEADER and data row DATA:
    TABLE-->HEADER(Cell1...Cell2...Cell3...Cell4)
              --->DATA(Cell1...Cell2...Cell3...Cell4)
    Suppose you want to hide Cell3 for null values, then write below code at initialization of DATA:
    if(DATA[*].Cell3.rawValue eq null)
    then
    DATA[*].Cell3.presence = "hidden"
    HEADER.Cell3.presence = "hidden"
    else
    DATA[*].Cell3.presence = "visible"
    HEADER.Cell3.presence = "visible"
    endif
    Hope it would help.
    Regards,
    Vaibhav

  • How to create a table with varied number of columns?

    I am trying to create a balance table. The colunms should include years between the start year and end year the user will input at run time. The rows will be the customers with outstanding balance in those years.
    If the user input years 2000 and 2002, the table should have columns 2000, 2001, 2002. But if the user input 2000 and 2001, the table will only have columns 2000 and 2001.
    Can I do it? How? Thanka a lot.

    Why did you create a new thread for this?
    How to create a table with varied number of columns?

  • SQL to convert rows with more than one columns to columns

    Hi All,
    I have a typical question here. As must have been in most of the recent databases, the attributes of a master table are put in a child table. So an SQL query will return multiple rows with each row having each attribute.
    Eg: Object OBJ has 5 attributes - A, B, C, D, E. The tables would be
    TABLE OBJ
    ======
    OBJ_ID (PK) (Say ID1)
    OBJ_COL1
    OBJ_COL2
    TABLE OBJ_CHILD
    ========
    OBJ_CHILD_ID (PK)
    OBJ_ID(FK)
    ATTRIBUTE (The data will be A,B,C,D,E for each OBJ_ID)
    ATTRIBUTE_VALUE (Value for each attribute. say 1,2,3,4,5)
    Query : SELECT OBJ_ID, ATTRIBUTE, ATTRIBUTE_VALUE FROM OBJ < OBJ_CHILD where OBJ.OBJ_ID = OBJ_CHILD.OBJ_ID
    This will return 5 rows as :
    OBJ ATTRIBUTE ATTRIBUTE_VALUE
    === ======== =============
    ID1 A 1
    ID1 B 2
    ID1 C 3
    ID1 D 4
    ID1 E 5
    I need to return rows as follows:
    ID1 A 1 B 2 C 3 D 4 E 5
    Is this thing possible in SQL? Even with a function ? (Its a transpose but with two columns in every row)
    Thanks,
    Midhun.
    P.S. I am on Oracle 10g.

    Hi
    user8830587 wrote:
    ... I need to return rows as follows:
    ID1 A 1 B 2 C 3 D 4 E 5How many columns is that?
    If it's 11 or 12 separate columns, then look for Pivot .
    If it's 2 or 3 columns (where the last one is all the data from obj_child concatenated together), then look for String Aggregation .
    Either can be done with any number of columns.
    If you have a choice, you'll probably want to do string aggregation rather than pivot.
    If you'd like help, post a little sample data (CREATE TABLE and INSERT statements) for both tables.
    Also post the results you want from that data, clearly formatted to show the columns. When you post formatted text on this site, type these 6 characters:
    \(all small letters, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    Edited by: Frank Kulash on May 14, 2010 6:26 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Displaying tables with dynamic number of columns

    Hello,
    I'm pretty new to JSF. Currently I'm working on a project where I have to select a table from a list, and then make it browsable/editable. The problem I have is that the different tables also have a different number of columns.
    I have no problem displaying different tables if the number of coulumns stays the same (using h:datatable) but when it's dynamic, I don't know how I can have my JSP to adjust to support the varying number of columns.
    Has anyone got an example of dynamic datatable or maybe someone can point me in the right direction.
    Brimborian

    Hi daniel,
    1. There is an INDEPENDENT FORM
      whose inputs are FIELD LIST
      and from those, it consructs dynamic table.
    2. Here is the program.
    the dynamic table name will be
    <DYNTABLE>.
    3. U can use this program (FORM in this program)
    to generate any kind of internal table
    by specifying some inputs (ie. field list)
    4.
    REPORT abc.
    COMPULSORY
    FIELD-SYMBOLS: <dyntable> TYPE ANY TABLE.
    FIELD-SYMBOLS: <dynline> TYPE ANY.
    DATA: lt TYPE lvc_t_fcat.
    DATA: ls TYPE lvc_s_fcat.
    FIELD-SYMBOLS: <fld> TYPE ANY.
    DATA : fldname(50) TYPE c.
    PARAMETERS : infty(4) TYPE c OBLIGATORY.
    DATA : iname LIKE dd02l-tabname.
    START-OF-SELECTION.
    GET INFO
    CONCATENATE 'P' infty INTO iname.
    DATA : ddfields LIKE ddfield OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'DD_NAMETAB_TO_DDFIELDS'
    EXPORTING
    tabname = iname
    TABLES
    ddfields = ddfields.
    CONSTRUCT FIELD LIST
    LOOP AT ddfields.
    ls-fieldname = ddfields-fieldname.
    APPEND ls TO lt.
    ENDLOOP.
    PERFORM
    PERFORM mydyntable USING lt.
    BREAK-POINT.
    INDEPENDENT FORM
    FORM mydyntable USING lt TYPE lvc_t_fcat .
    Create Dyn Table From FC
    FIELD-SYMBOLS: <fs_data> TYPE REF TO data.
    FIELD-SYMBOLS: <fs_1>.
    FIELD-SYMBOLS: <fs_2> TYPE ANY TABLE.
    DATA: lt_data TYPE REF TO data.
    ASSIGN lt_data TO <fs_data>.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = lt
    IMPORTING
    ep_table = <fs_data>
    EXCEPTIONS
    generate_subpool_dir_full = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    ENDIF.
    Assign Dyn Table To Field Sumbol
    ASSIGN <fs_data>->* TO <fs_1>.
    ASSIGN <fs_1> TO <fs_2>.
    ASSIGN <fs_1> TO <dyntable>.
    ENDFORM. "MYDYNTABLE
    regards,
    amit m.

  • DB view with flexible number of columns?

    In my Oracle 10 I have these tables
    Customer table:
    id      customer
    1       John
    2       Bob
    Item table
    id      item_name
    1       itemA
    2       itemB
    3       itemC
    4       itemD
    Purchase table:
    id      item_id date    customer_id
    1       3       070202  2
    2       6       070203  5
    ...I'd like to create a view like this:
            itemA   itemB   itemC   itemD   ...
    John    3       4       0       0       ...
    Bob     0       3       0       0       ...
    ...The view showed John purchased itemA 3 times, item B 4 times. Bob purchased itemB 3 times. This assume each customer only by one item at a time, which is a reasonable simplification of my situation.
    Such a view (with variable number of columns) is needed not in our web application but also provide an understandable data source for non IT professional to use report software. If my approach of solving this problem is completely wrong, I'd also like to know what's the common practice. Thank you very much in advance!
    Message was edited by:
    user609663

    I have tried to ask the question in a way that greatly simplify current problem to make it easy for others to understand without having to explain a lot of background information and 'the situation'; it seems I over-simplified the issue to make it even not worth solving or a wrong question being asked. So here I explain the complete problem and look for advice again (be prepared, pretty long description following:). I am a purchased customer of Oracle 10 DB and I reasonably expect being considered as Oracle user looking for help rather than students trying to play smart with assigned data normalization course exercises.
    We are working on a system that collects data from interview results. The questionnaires for the interviews are formatted with a coded question, followed by user's answer to the question, like the following:
         Question Code   Question content   Answer
         H001            ...                123
         H002            ...                45
         H003            ...                33
         H004            ...                66
         H005            ...                4,66
         ...             ...                ...The users answer question with a digit, for some special questions, e.g. H005, they are allowed to answer with a set of digits. There are thousands of interviews each year, the simplest solution to collect the interview answers is to use such a db table:
    simple_db_table:
    id   H001  H002  H003  H004  H005  H006  H007
    1    123   45    33    66    4     82    9
    ...This solution have two problems:
    1. It doesn't properly store answers to questions that requre a set of digits, like H005.
    2. The number of questions and their codes change from one survey to another, but the table have fixed number of columns and column names.
    And two benefit:
    1. With such simple table, people who use report software that directly access oracle db can creat their reports on easy-to-understand data presentation;
    2. calculation based on questionnaire data is simple, e.g. get the average of H007/H009 for questionnaires that have H002 > H003 * 600 would be:
    SELECT SUM(H007) / SUM(H009) FROM simple_db_table WHERE H002 > H003 * 600;Next solution we have normalized tables:
    questionnaire_entry_table:
    id                 NUMBER
    questionnaire_name CHARquestionnaire_definition_table:
    id                 NUMBER
    questionnaire_id   NUMBER
    question_code      CHAR
    question_content   VARHCARinterview_table:
    id                 NUMBER
    questionnaire_id   NUMBER
    date               DATEquestionnaire data table: itv_data
    id                 NUMBER
    interview_id       NUMBER
    question_code      CHAR
    answer             NUMBERWith the new structure, it just turn the problems of simple_db_table to its benefit and simple_db_table's benefit become the problem:
    1. Personnel who use report creation software feel too confused to make report based on such tables, because they do not understand the normalized modeling. In our case, effective training is difficult because there will be many geographically distributed people make reports based on this structure and they have lower IT knowledge than database administrators. These personnel can make reports based on simple_db_table.
    2. calculation based on questionnaire data is very difficult.
    To explain 2, let's take the same example, we still wish to get the average of H007/H009 for questionnaires that have H002 > H003 * 600, my method is:
    setp 1: create a view with by using:
           CREATE VIEW v (id, H002, H003) AS
           SELECT a.itv_id, a.H002, b.H003
             FROM itv_data a, itv_data b
           WHERE a.interviewee_id=b.interviewee_id
             AND a.question_code='H002' AND b.question_code='H003';step 2: create a stored procedure to get the calculation result:
           CREATE OR REPLACE PROCEDURE get_result (result OUT NUMBER) IS
             sh007 NUMBER := 0;
             sh009 NUMBER := 0;
           BEGIN
             SELECT SUM(H007) INTO sh007 FROM itv_data
               WHERE itv_id in (SELECT id FROM v WHERE H002 > H003 * 683);
             SELECT SUM(H009) INTO sh009 FROM itv_data
               WHERE itv_id in (SELECT id FROM v WHERE H002 > H003 * 683);
             idc := sh007/sh009;
           END get_idc;As you can see the calculation become much more complex and might involve overhead.
    There might be better way to calculate the result that I don't know yet. We have some 100 different formulas to calculate different results, so it's important to get them right and efficiently.
    The best solution seems to me is that to create such a view from itv_data and other tables so that to reflect the same structure of simple_db_table. So here comes the question I originally asked how is it possible to create a view with flexible number of columns. I made the very simple example in my original posted message wishing to get an idea of this is possible or the way to go.
    I may be taking a completely wrong approach to attack the problem, e.g. perhaps there is a simpler way to get_result from itv_table and for report creation users I should use a metadata layer on top of the normalized table structure (e.g. by using Metadata Query Language from Pentaho BI). But anyway I'd like to get some insightful ideas from the forum. Again thanks for help in advance.

  • Display of text of different rows with different color - JTable

    Hi all !
    I have struck in a problem. I have to display the different rows with different color in the JTable. I have created an arraylist in the model class, which stores color of all the rows. Now in renderer class, I am just picking up color from the arraylist, taking rowIndex as index for arraylist. I used to set foreground color for each row in the renderer class. The problem is that it is not showing all the rows properly, sometimes it show all the rows correctly, but as i resize the window/panel, it starts behaving abnormally, some text is painted properly, but other aren't.
    Does anybody have any solution regarding this problem.
    One thing i want to mention is that in getTableCellRendererComponent() method, i used to retrive the color everytime, and setting the foreground color of the text. Is this a right approach or some other technique have to be followed.
    here is code of renderer class ---
    import java.awt.*;
    import javax.swing.*;
    * Renderer to plot stage record table.
    public class ExStageCellRenderer extends javax.swing.table.DefaultTableCellRenderer
        Color curColor;
         * returns component to be painted, overridding this method from
         * DefaultCellRenderer
         * @param table
         *            table whose component has to be plotted
         * @param value
         *            value of that particular cell
         * @param isSelected
         *            is Cell selected
         * @param hasFocus
         *            has the cell got focus
         * @param row
         *            row of the cell
         * @param column
         *            column of the cell
         * @return painted component
        public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row,
                int column)
            Component component = super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column);
            ExStageDataModel model = (ExStageDataModel)table.getModel ();       
            if (curColor instanceof Color) {
                    curColor = model.getColor(row);
                } else {
                    // If color unknown, use table's foreground color
                    curColor = table.getForeground();
            String tooltip = "";
            StringBuffer stringBuffer = new StringBuffer ();
            for (int i = 0; i < table.getColumnCount (); i++)
                    Object Value = table.getValueAt (row, i);
                    if (Value == null) continue;
                    stringBuffer.append (Value.toString () + "    ");
            tooltip += stringBuffer.toString ();
            tooltip = tooltip.trim ();
            ((JComponent) component).setToolTipText (tooltip);
            if (column == 1)
                this.setHorizontalAlignment (SwingConstants.CENTER);
            else if (column == 0 || column == 4 || column == 5)
                this.setHorizontalAlignment (SwingConstants.LEFT);
            else
                this.setHorizontalAlignment (SwingConstants.RIGHT);
            // LOOK!! should turn tip off if there is none !!
            component.setForeground (this.curColor);
            //System.out.println("render : " + component.getBounds ());
            //component.validate ();
            component.update (component.getGraphics ());
            return component;
    Waiting for reply....
    Code snooker

    Hmm, why are you doing the curColor instanceof? What does this accomplish? I don't see any reason to ask what it was before; all you should be interested in here is what you want it to be now.
    All you should have to do is say:
    this.setForeground(model.getColor(row));I also don't see why you're doing the update() -- JTable is going to do that for you at the appropriate time, you have no idea if now is the right time to do it or not. In fact it probably isn't, you're probably updating the previously-drawn cell with your new color and alignment, which may be the strange behavior you're seeing.
    Also, I don't see why you're doing the super. All that's going to do is return "this", so why not just use "this"?
    Well, without knowing your larger code or exactly what you're trying to accomplish, maybe I'm just missing something.
    I've just recently been working on a program where I had some similar requirements -- different foreground and background colors and alignment -- and I found it much cleaner to create a class to hold all this data, and then create a default renderer for that class. Then I made some constructors for this "attribute" class that let me set whatever I need, like
    public CellAttrib(String s,Color c,int alignment,Border border)
      this.s=s;
      this.c=c;
      this.border=border;
    // with suitable defaults ...
    pubic CellAtrtrib(String s)
      this.s=s;
      this.c=Color.BLACK;
      this.border=null;
    }Then the renderer just queried the cell-attributes class, as in:
    setForeground(value.getColor());
    setHorizontalAlignment(value.getAlignment());
    setBorder(value.getBorder);

Maybe you are looking for

  • Automatic deletion of Line item at GR level

    Hi All, I have a requirement, The client will hire security service from the vendor, they will create service PO with 12line item and each line item cost will distribute to 5 cost center. they want a report which shows the pending quantity month wise

  • InDesign CS3 Crashes on Save (PC)

    The other day i tried to save a file in Photoshop CS3 and suddenly on clicking save the program froze. Thru the forums i learned i could resolve this issue by turning off CUE, this fixed the problem but the next day i experienced the same problem wit

  • ITEM detail for Transaction

    hellow gurus i'm workin on environment BW 3.5 and CRm 4.0 now i have to create datasource for some Extra fields for that i have used followin tables CRMD_ORDERADM_H CRMD_INDEX but after using this in BW report i'm not able to get the item( Product ) 

  • How to install/upgrade Ultrasearch for AS Middle Tier 10.1.2.0.2?  DB 9208.

    Hi, I am trying to understand the Ultrasearch from the point of view of my 10.1.2.0.2 middle tier. Here is my environment: Our Metadata Repository and Portal Repository (Customer) databases are version 9.2.0.8. Recently patched to 9.2.0.8 from 9.2.0.

  • Web Site Display Language - Allowing the user to chose the language

    I have created a web site that allows the user to display the page in the language of the users choice. Windows Internet Explorer and FireFox both allow the user to select a language option, and the web page will display the text in that language. Sa