Rows of columns, dynamic number of rows.

Hi all

I want to do a query on a version of oracle 10.2.0.4.0 database but I can't find a way to do it.
Then I have an example of what I need to do:
account     gadget
111        iphone
111        ipad
111        nokia
111        pencil
222        hard drive
222        iphone
222        nokia
333        pencil
444        pen drive
444        nokia
I need to get the following result:
account     gadget
111        iphone|ipad|nokia|pencil
222        hard drive|iphone|nokia
333        pencil
444        pen drive|nokia
I tried the following diferent queries based on examples I tried to understand:
select account, Cursor(select gadjet from user_gadgets e2 where e2.account = user_gadgets.account)
from (select distinct account from user_gadgets ) user_gadgets;

SELECT account, CAST(MULTISET(SELECT account FROM user_gadgets  e
WHERE contrno = e.contrno) AS
varchar2_table_t) FROM user_gadgets e GROUP BY account;

select
account
,sum(case when account = 'iphone'     then 'iphone' end)  as IPHONE
from crm_user_equipments@dbl_tabsdmx
group by
account
I was unable to make the first two work and the third party cannot be applied because I have a dynamic list.

Impossible to apply options to third because both columns: account contains thousands of distinct values and gadget contains nearly 80 different objects and it is changing.

Thank you and best regards,
Ricardo Tomas

Add this function:

FUNCTION join_cursor
(
    p_cursor    sys_refcursor,
    p_delimiter VARCHAR2 := ',' -- set a default delimiter

) RETURN VARCHAR2
IS
    l_value  VARCHAR2 (32767);
    l_result VARCHAR2 (32767);

BEGIN
    LOOP
        FETCH p_cursor
         INTO l_value;

        EXIT WHEN p_cursor%NOTFOUND;

        IF l_result IS NOT NULL THEN
            l_result := l_result || p_delimiter;
        END IF;

        l_result := l_result || l_value;
    END LOOP;

    CLOSE p_cursor;

    RETURN l_result;
END join_cursor;

Run this query:

SELECT acc AS account,
       join_cursor(CURSOR (SELECT gadget FROM user_gadgets where account = acc), '|') AS gadget
  FROM (SELECT unique account AS acc
          FROM user_gadgets
       )
 ORDER BY acc

Output must be what you expected.

Published by: Starlight Rider, 29 Sep, 2010 14:02

Tags: Database

Similar Questions

  • How to have a dynamic number of tables where new rows can be added

    Hello
    I'm new to ADF and have a task where I on a single page should I show that a dynamic number of tables and each table below should show some fields and create a button to create new lines in the table. To be more precise each table show an education for the individual and the rows of the table shows the meanders of specific education.
    I thought to use a treetable but don't think it's the right way to go because of the new line add feature - I'm not sure of the combination of having a dynamic number of tables and the ability to create new lines of each table.
    If you know where I can find a model similar to the one above or just give me your opinion on how to solve it, it would be much appreciated.
    I get the data from a Web service.

    This is a small sample.
    It could be improved for more information.
    work for you?

    Class Education
    public class {education
    private string ID;
    description of the private channel;
    private list class ArrayList = new();
    Public Education() {}
    }

    {} public void setId (String id)
    This.ID = id;
    }

    public String getId() {}
    return the id;
    }

    {} public void setDescription (description of the chain)
    This.Description = description;
    }

    public String getDescription() {}
    return description;
    }

    public void setCourses (list of courses of ) {}
    This.courses = run;
    }

    public getCourses() {list
    return of the course;
    }
    }

    classroom

    public class {course
    private string ID;
    description of the private channel;
    teaching of teaching private;
    public Course() {}
    }

    {} public void setId (String id)
    This.ID = id;
    }

    public String getId() {}
    return the id;
    }

    {} public void setDescription (description of the chain)
    This.Description = description;
    }

    public String getDescription() {}
    return description;
    }

    {} public void setEducation (education)
    This.Education = education;
    }

    Public Education getEducation() {}
    return of education;
    }
    }
    Managed Bean

    public class {Manage
    private list of educations of ;
    selectedEducation of teaching private;
    selectedCourse of course private;

    public Manage() {}
    educations = new ArrayList ();
    for (int x = 1; x)<= 10="" ;="" x++="" )="">
    E education = new Education();
    e.setId(""+x);
    e.setDescription ("education" + x);
    for (int i = 1; i)< 3;="">
    Class c = new Course();
    c.setId (e.getId () +'.) » + i) ;
    c.setDescription (e.getDescription () +": courses"+ i);
    e.getCourses () .add (c);
    }
    This.Educations.Add (e);
    }

    }
    public String actionAdd() {}
    Add the code in the event here...
    TODO invoke the web service proxy to add courses
    Class c = new Course();
    c.setId (this.selectedEducation.getId () +'.) (' + (this.selectedEducation.getCourses () .size () + 1));
    c.setDescription (this.selectedEducation.getDescription () +": courses"(this.selectedEducation.getCourses () .size () + 1));
    this.selectedEducation.getCourses () .add (c);
    Returns a null value.
    }

    public String actionQuit() {}
    Add the code in the event here...
    TODO invoke the proxy web service to stop the course of education
    int index = this.selectedEducation.getCourses () .indexOf (this.selectedCourse);
    this.selectedEducation.getCourses () .remove (index);
    Returns a null value.
    }
    public void setEducations (list of educations ) {}
    This.Educations = educations;
    }

    public getEducations() {list
    TODO invoke the web service proxy to get educations
    return of the educations;
    }

    {} public void setSelectedEducation (selectedEducation education)
    this.selectedEducation = selectedEducation;
    }

    Public Education getSelectedEducation() {}
    Return selectedEducation;
    }

    {} public void setSelectedCourse (course selectedCourse)
    this.selectedCourse = selectedCourse;
    }

    public class getSelectedCourse() {}
    Return selectedCourse;
    }
    }

    JSPX



    xmlns:h = "http://java.sun.com/jsf/html".
    xmlns:f = "http://java.sun.com/jsf/core".
    xmlns:afh = "http://xmlns.oracle.com/adf/faces/html".
    xmlns:af = "http://xmlns.oracle.com/adf/faces" >

    DOCTYPE system = "http://www.w3.org/TR/html4/loose.dtd".
    doctype-public = ""-/ / W3C / / DTD HTML 4.01 Transitional / / IN "/ >"





    Content = text/html"; charset = windows-1252 "/ >"








    var value = "#{Education.courses}" = "course" rows = "5" "
    strips = "row" bandingInterval = "1" >












    to = "#{Manage.selectedEducation}" / >





    to = "#{Manage.selectedEducation}" / >

    to = "#{Manage.selectedCourse}" / >











    faces config xml


    "- //Sun Microsystems, Inc.//DTD JavaServer Faces 1.1 Config / / IN".
    "http://java.sun.com/dtd/web-facesconfig_1_1.dtd" >


    manage
    com.test.Manage
    session


    Oracle.ADF.Core

  • Dynamic number of columns in the table

    Hello

    I use JDev 10.1.3.3.0 with ADF. I just want to create a table, with a dynamic number of columns in the table. The background is that a user of my webapplication can create and submit a sql query. Now, I have to show him the results. My idea was, I have save the result in a bean managed (ResultTable), which is stored in the session context and map at my table in my page.

    If I search the Forum and don't get only one useful thread: {: identifier of the thread = 971888}, but I don't exactly understand. What is the CollectionModel? Do I need this?

    I'm trying to report on the following:

    ResultTable
    public class ResultTable {
    
        public static final String SESSION_NAME = "ResultTable";
        private ArrayList<ResultColumn> columnList; 
        private CollectionModel collectionModel;
    
        public ResultTable() {
        }
    
        public ArrayList<ResultColumn> getColumnList() {
            return columnList;
        }
    
        public void setColumnList(ArrayList<ResultColumn> columnList) {
            this.columnList = columnList;
        }
    }
    ResultColumn
    public class ResultColumn {
        
        private ArrayList<ResultRow> rowList;
        private String name;
    
        public ResultColumn() {
        }
    
        public ArrayList<ResultRow> getRowList() {
            return rowList;
        }
    
        public void setRowList(ArrayList<ResultRow> rowList) {
            this.rowList = rowList;
        }
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    }
    ResultTable
    public class ResultRow {
        
        private String value;
    
        public ResultRow() {
        }
    
        public String getValue() {
            return value;
        }
    
        public void setValue(String value) {
            this.value = value;
        }
    }
    My showResult.jspx
    <af:table emptyText="No items were found"
              value="ResultTable.columnList"
              var="column"
              varStatus="colStatus"
              id="table1">
      <af:forEach items="#{column.rowList}" var="row" varStatus="rowStatus">
        <af:column sortable="false" headerText="#{column.name}" 
                   id="column#{colStatus.index}">
          <af:outputText value="#{row.value}"
                         id="outputText#{rowStatus.index}"/>
        </af:column>
      </af:forEach>
    </af:table>
    The ResultTable was filled with data, but the Board is not filled. So, I think, it must be rejected to the data binding.

    I get warnings and errors to run too. But I don't know if they are the result or cause of my problem.
    27.10.2009 10:15:41 oracle.adfinternal.view.faces.renderkit.core.xhtml.TableRenderer renderTableWithoutColumns
    WARNUNG: Table with id: form1:table1 has no visible columns!
    27.10.2009 10:15:41 oracle.adfinternal.view.faces.io.HtmlResponseWriter endElement
    SCHWERWIEGEND: Element End name:span does not match start name:div
    27.10.2009 10:15:41 oracle.adfinternal.view.faces.io.HtmlResponseWriter endElement
    SCHWERWIEGEND: Element End name:span does not match start name:div
    27.10.2009 10:15:41 oracle.adfinternal.view.faces.io.HtmlResponseWriter endElement
    SCHWERWIEGEND: Element End name:form does not match start name:span
    27.10.2009 10:15:41 oracle.adfinternal.view.faces.io.HtmlResponseWriter endElement
    SCHWERWIEGEND: Element End name:body does not match start name:form
    27.10.2009 10:15:41 oracle.adfinternal.view.faces.io.HtmlResponseWriter endElement
    SCHWERWIEGEND: Element End name:html does not match start name:body
    Concerning

    Majo

    Hi Mario,.

    
      
        
          
        
      
    
    

    Note that your JSPX snippet above has serious shortcomings:

  • 'ResultTable.rowList' is not an EL expression, but the value attribute of the af: table must refer to an EL expression
  • Items AF:foreach = "#{row.cellList}"-you don't have to store information about the columns of all rows, more it won't work as af:forEach tag may not see the value of the expression of EL #{line} (or any component EL expression created). " See the tagdoc here: http://www.oracle.com/technology/products/jdev/htdocs/partners/addins/exchange/jsf/doc/tagdoc/core/forEach.html
  • "ID =" Column #{cellStatus.index} "and id =" outputText #{rowStatus.index} "are invalid and that they don't compile even as id attributes cannot contain EL expressions.

    .

    I think to solve your problem, you need three things:

  • List of columns (for example the list If you need to store only the names of column or list If you need additional information),.
  • list of lines,
  • a line can be a map (with the name of the column - cell data mapping; card e.g.) or a list (with columns indexed; for examplelist).

    Example with the lines of the map:

    JSPX snippet:

    
      
        
          
        
      
    
    

    The ResultTable bean:

    public class ResultTable {
    
        private List columnList;
        private List> rowList; 
    
        public ResultTable() {
        }
    
        public List getColumnList() {
            return columnList;
        }
    
        public void setColumnList(List columnList) {
            this.columnList = columnList;
        }
    
        public List> getRowList() {
            return rowList;
        }
    
        public void setColumnList(List> rowList) {
            this.rowList= rowList;
        }
    
    }
    

    Type ResultColumn:

    public class ResultColumn {
    
        // additional fields if needed...
        private String name;
    
        public ResultColumn() {
        }
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    }
    

    AF:table display correctly after the initialization of the values in your beans properly filled ResultTalbe (e.g. to fill the list of rank with the lines).

    Hope this helps,
    Patrik

  • Need help to display columns dynamically

    Hi all

    I have a requirement to display columns dynamically for query below
    ====================================================
    1. SELECT * FROM
    2 (SELECT jrgm.resource_name, fu.email_address,
    JRG.group_name 3,.
    4 max (decode (frv.responsibility_name, 'Customer Support Specialist_PRD', 'Y', ' don't)) Cust_Suppo
    5 max (decode (frv.responsibility_name, 'Internet Expenses_US', 'Y', ' don't)) Internet_Expenses_US,.
    6 max (decode (frv.responsibility_name, 'Internet Procurement_US', 'Y', ' don't)) Internet_Procureme
    7 max (decode (frv.responsibility_name, 'Email Center Console Agent', 'Y', ' don't)) Email_Center_Ag
    8 max (decode (frv.responsibility_name, 'Email Center Agent_PRD', 'Y', ' don't)) Email_Center_Agent_
    9 max (decode (frv.responsibility_name, 'Customers online CS User_PRD', 'Y', ' don't)) Customers_Onl
    10 max (decode (frv.responsibility_name, 'Email component Message Center', 'Y', ' don't)) Email_Cente
    Jtf_rs_group_members_vl jrgm 11,
    12 jtf_rs_groups_vl jrg,
    13 jtf_rs_defresources_vl jrdv,
    14 fnd_user_resp_groups furg,
    15 fnd_responsibility_vl LIF,
    16 apps.fnd_user fu
    17. WHERE the jrgm. GROUP_ID = jrg. GROUP_ID
    18 AND jrdv.resource_id = jrgm.resource_id
    19 AND jrdv.user_id = fu.user_id
    20 AND fu.user_id = furg.user_id
    21 AND furg.responsibility_id = frv.responsibility_id
    22 AND furg.responsibility_application_id = frv.application_id
    23 AND (fu.end_date IS NULL or TRUNC (fu.end_date) > = TRUNC (SYSDATE))
    24 AND (frv.end_date IS NULL or TRUNC (frv.end_date) > = TRUNC (SYSDATE))
    25 AND (furg.end_date IS NULL or TRUNC (furg.end_date) > = TRUNC (SYSDATE))
    26 AND jrg. GroupName like '% C '.
    27 AND jrgm.resource_name = 'Anderson, Jonathan P '.
    28 GROUP BY jrgm.resource_name, fu.email_address,.
    29 jrg.group_name)
    30 * ORDER BY 3
    ====================================================================
    above the line 4-10 I hard coded column names instead of that I need to display columns dynamically
    I have to write something like...
    Max (decode (frv.responsibility_name, (select fcl.meaning from fnd_common_lookups where fcl.meaning = frv.responsibility_name fcl), 'Y',' don't)) fcl.meaning
    Could you please suggest me a solution for this...

    Thank you
    GRISSA
  • get the names of the columns dynamically

    Hi gurus,
    I have the list item filled with lots of names of a table schema.
    I did grid in oracle 10g and I want to fill in the grid with the data that should come at least four/more columns.
    I want to get the trigger list change when whenever any name a table is selected/changed.

    How can I get the names of the columns dynamically
    Please give me the step by step process
    for the filling of the grid...

    Hello

    If you want to get the details of the column, and then use the USER_TAB_COLUMNSview.

    SELECT COLUMN_NAME, DATA_TYPE FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 
    

    Kind regards

    Manu.

  • Dynamic number of pages

    Hello
    I need to create a RTF model with dynamic number of pages.
    Let me explain:
    I have a (my_page_number) page number recorded on the database and I want to start my model with a page number that is

    my_page_number + PAG

    Number of automatic page in MSWORD designating PAG.

    Can someone help me?

    Thank you!
    Good bye
    Daniela

    Hello Daniela,

    using the query, it search in the report.

    You use the following syntax

     in your rtf to make the report to start from page number.
    
    If Your xml looks like
    
    51
    ....
    ...
    ...
    
     
    
  • grouping data with a dynamic number of levels

    Is it possible to do something like:

    < cfloop... >
    < cfoutput group =... >
    ...
    < / cfloop >

    < cfoutput >
    ...
    < / cfoutput >

    < cfloop... >
    < / cfoutput >
    < / cfloop >

    I tried but it doesn't seem to work. I would like to consolidate data from several levels deep, with a dynamic number of levels. I don't know it in advance. Is it possible to do?

    Thank you

    Roman

    Hello

    You cannot place the tag inside a it will throw an error...

    Why don't you do the grouping at the query level?...

  • ADF trigger dynamic number of components

    I have an addiction to view object class three levels-> category-> subclass and want to create a dynamic form with the following logic:
    When the user selects a category drop down, page is updated with a number of drop-down lists of class with all subclasses - that is, I have a dynamic number of components selectOneChoice depending on the category selection. Dependence of the class category is implemented with valueChangeListener category Classes of queries with the category Id, class subclass is simple link display / tree of the value binding. Value of subclass for backing bean binding is done with a hash table.

    ADF faces framework let me recreate the elements of the actual page with partial-page rendering (or some other mechanism)?
    Should I completely re - generate all the components of selectOneChoice inside forEach whenever the user changes category.


    My components in the page:


    < af:selectOneChoice value = "#{bbean.category} '"
    label = "category".
    autoSubmit = 'true' immediate = "true".
    ID = 'category' valuePassThru = 'true '.
    valueChangeListener = "#{bbean.categoryChanged}" >
    < f: selectItems value = "#{bindings." Categories.Items} "/ >"
    < / af:selectOneChoice >


    < af:forEach var = 'class' items = "#{bindings." Classes.Children} ">"
    < af:selectOneChoice value = "#{bbean.subclass [class.id]}" "
    label = "#{Class.Name} '"
    partialTriggers = "category".
    ID = "class" valuePassThru = "true" >
    < af:forEach var = "subclass" items = "#{class.children}" >
    < af:selectItem label = "#{subclass.name}" value = "#{subclass.id}" / > "
    < / af:forEach >
    < / af:selectOneChoice >
    < / af:forEach >



    The above code is a development of earlier less complex UI. For everything I tried I can't get to the desired effect. When I change the category it does not affect sub-drop downs somehow. If I activate the valueChangeListener category, category change cause the validation phase null property exceptions:

    2.9.2008 14:05:40 com.sun.faces.lifecycle.ProcessValidationsPhase run
    SEVERE: Error test 'null' property at the bean of type my.project.view.managed.Search$ 1
    javax.faces.el.PropertyNotFoundException: error test 'null' property at the bean of type my.project.view.managed.Search$ 1
    ...

    Erik,

    Instead of making components selectOneChoice have 'category' as their partial triggers, what happens if you set partialTriggers = 'category' on a parent of these selectOneChoices component?

    John

  • Covert rows to columns dynamically

    Hi Experts,

    I use oracle 10g and do not have access ' t create/write on it so I can't create a view/procedure I want to achieve the next thing with a single query.

    I have the table like this

    Name of the value ID

    1 - ONE - AS
    1 - B - ACE
    2 - C - BN
    2 - D - BN
    2 - E - NL
    3-F - CV
    3 - G - CV

    and want to have result as below

    ID -- AS -- BN -- CV
    1 -- A,B --- --- --- ---
    2-- --- -- -- C,D,E --
    3 --- --- -- -- -- -- F,G

    Here I used '-' for the space.

    I was able to achieve this result by using the following question

    SELECT id,
    MAX (DECODE (NAME, 'LIKE', VALUE, NULL)) AS «DO»,
    MAX (DECODE (NAME, 'NL', VALUE, NULL)) AS 'BN ',.
    MAX (DECODE (NAME, 'CV', VALUE, NULL)) AS 'CV '.
    (SELECT ID,
    RTRIM)
    XMLAGG (XMLELEMENT (e, VALUE |)) ',')). EXTRACT ('/ / text()').
    ',')
    VALUE,
    name
    TEMP
    Doc_rno, name)
    GROUP BY id

    But here I am hardcoding 'THAT', 'NL', 'CV' column name so that could generate the result.i wants to reach without hard-code the name of the column because I'm having dynamic value in the name column.

    for example

    for A database its going to be W, R, T
    for database B its going to be C, K, L, P

    even I do not know the values in the name column

    could someone help pls it's very urgent.
    DROP TABLE T;
    CREATE TABLE T(TID, TNAME, TVALUE)
    AS SELECT 1, 'Name_' || LEVEL, 'Value ' || LEVEL
    FROM DUAL CONNECT BY LEVEL <= 3;
    
    VARIABLE V_REFCUR REFCURSOR;
    
    DECLARE
    L_SQL VARCHAR2(4000);
    BEGIN
    FOR REC IN (
      SELECT 'select TID ' sql_text FROM DUAL
      UNION ALL
      SELECT ', max(decode(tname,'''||TNAME||''',tvalue)) "' || TNAME || '"'
      FROM (SELECT DISTINCT TNAME FROM T ORDER BY 1)
      UNION ALL
      SELECT ' from t group by tid' FROM DUAL
    ) LOOP
      l_sql := l_sql || rec.sql_text;
    END LOOP;
    open :v_refcur for l_sql;
    END;
    /
    print :v_refcur;
    

    Most of each language can handle a REF CURSOR. Execute the foregoing as an anonymous block.

  • Selection of column dynamic Collection

    Hi gurus,

    I have a little problem with a collection.

    I have a collection with a type of pins. The selected cell may contain 28, 29,..., 33.

    Later, I want to count the lines of the following collection, where (in this example) c033 is not null. The variable is then used as a string, not a column.

    How can I use the variable as a column in the 'where' - clause?

    Here is my sql query:

    declare
    l_type_position varchar2 (4);  -content will be: c033
    l_types number (3.0)

    Start

    -Select the dynamic column for the next newsletter

    Select 'c0 ' | (c009) - c009 = 33
    in l_type_position
    of apex_collections

    where collection_name = "UPLOAD_HEAD";

    Select count (l_type_position)
    in l_types
    of apex_collections

    where collection_name = "SPREADSHEET_CONTENT."
    -folowing line error occurse

    and l_type_position is not null;   -= and c033 is not null;

    end;

    Thanks for help.

    This can be done using lexical replacement and dynamic SQL (as always, check for possible code SQL injection):

    declare
    
      l_type_position varchar2(4);  --content will be: c033
      l_types number(3,0);
    
    begin
    
      -- select the dynamic column for the next statement
      select 'c0'||(c009)   -- c009 = 33
      into l_type_position
      from apex_collections
      where  collection_name = 'UPLOAD_HEAD';
    
      -- check for SQL injection
      l_type_position := dbms_assert.simple_sql_name(l_type_position);
    
      -- count collection rows
      execute immediate q'{
          select count(}' || l_type_position || q'{)
          from apex_collections
          where  collection_name = 'SPREADSHEET_CONTENT'}'
        into
          l_types;
       ...
      end;
    

    However, it is possible that it is a question of XY. If further information on the nature of the obligation provided that it might be possible to identify a clearer and more secure solution using SQL static.

  • Create columns dynamically

    Hello

    I'm writing an application that contains a table to display data from a file. I want to know the number of columns of data in the file, because it can vary. However, it seems that I might have a problem with the creation of methods setter/getter for properties of column as I don't know before hand the number of columns and what called I make use of PropertyValueFactory class of convenience because it uses a channel set for a parameter.

    Any suggestions?

    Thanks in advance

    You can use a list<> or ObservableList<> data for each line of the table type (thus table.getItems () will look like ObservableList<>>.) You will not be able to use a PropertyValueFactory: you define a CellValueFactory custom columns to be indexed in the correct column.

    Here is an example that reads a tabs-delimited text file and populates the table on the fly. Eventually, it reads the first line as "header values" (i.e. of the column titles) and then each line. If a row has more columns that are currently in the table, it adds additional columns. Analysis of tabs is not intended to be the quality of the production (without tab quotes are supported, etc.).

    Enter the URL of a tabs-delimited text file and press ENTER to see work. (If you have a folder on your file system, use file:///absolute.path.to.file.txt.)

    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.net.URL;
    import java.net.URLConnection;
    
    import javafx.application.Application;
    import javafx.application.Platform;
    import javafx.beans.property.SimpleStringProperty;
    import javafx.beans.property.StringProperty;
    import javafx.beans.value.ObservableValue;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.concurrent.Task;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.CheckBox;
    import javafx.scene.control.Label;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableView;
    import javafx.scene.control.TextField;
    import javafx.scene.control.TableColumn.CellDataFeatures;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.layout.HBox;
    import javafx.scene.layout.Priority;
    import javafx.stage.Stage;
    import javafx.util.Callback;
    
    public class DynamicTable extends Application {
    
      @Override
      public void start(Stage primaryStage) {
        final BorderPane root = new BorderPane();
        final TableView> table = new TableView<>();
        final TextField urlTextEntry = new TextField();
        urlTextEntry.setPromptText("Enter URL of tab delimited file");
        final CheckBox headerCheckBox = new CheckBox("Data has header line");
        urlTextEntry.setOnAction(new EventHandler() {
          @Override
          public void handle(ActionEvent event) {
            populateTable(table, urlTextEntry.getText(),
                headerCheckBox.isSelected());
          }
        });
        HBox controls = new HBox();
        controls.getChildren().addAll(urlTextEntry, headerCheckBox);
        HBox.setHgrow(urlTextEntry, Priority.ALWAYS);
        HBox.setHgrow(headerCheckBox, Priority.NEVER);
        root.setTop(controls);
        root.setCenter(table);
        Scene scene = new Scene(root, 600, 400);
        primaryStage.setScene(scene);
        primaryStage.show();
      }
    
      private void populateTable(
          final TableView> table,
          final String urlSpec, final boolean hasHeader) {
        table.getItems().clear();
        table.getColumns().clear();
        table.setPlaceholder(new Label("Loading..."));
        Task task = new Task() {
          @Override
          protected Void call() throws Exception {
            BufferedReader in = getReaderFromUrl(urlSpec);
            // Header line
            if (hasHeader) {
              final String headerLine = in.readLine();
              final String[] headerValues = headerLine.split("\t");
              Platform.runLater(new Runnable() {
                @Override
                public void run() {
                  for (int column = 0; column < headerValues.length; column++) {
                    table.getColumns().add(
                        createColumn(column, headerValues[column]));
                  }
                }
              });
            }
    
            // Data:
    
            String dataLine;
            while ((dataLine = in.readLine()) != null) {
              final String[] dataValues = dataLine.split("\t");
              Platform.runLater(new Runnable() {
                @Override
                public void run() {
                  // Add additional columns if necessary:
                  for (int columnIndex = table.getColumns().size(); columnIndex < dataValues.length; columnIndex++) {
                    table.getColumns().add(createColumn(columnIndex, ""));
                  }
                  // Add data to table:
                  ObservableList data = FXCollections
                      .observableArrayList();
                  for (String value : dataValues) {
                    data.add(new SimpleStringProperty(value));
                  }
                  table.getItems().add(data);
                }
              });
            }
            return null;
          }
        };
        Thread thread = new Thread(task);
        thread.setDaemon(true);
        thread.start();
      }
    
      private TableColumn, String> createColumn(
          final int columnIndex, String columnTitle) {
        TableColumn, String> column = new TableColumn<>();
        String title;
        if (columnTitle == null || columnTitle.trim().length() == 0) {
          title = "Column " + (columnIndex + 1);
        } else {
          title = columnTitle;
        }
        column.setText(title);
        column
            .setCellValueFactory(new Callback, String>, ObservableValue>() {
              @Override
              public ObservableValue call(
                  CellDataFeatures, String> cellDataFeatures) {
                ObservableList values = cellDataFeatures.getValue();
                if (columnIndex >= values.size()) {
                  return new SimpleStringProperty("");
                } else {
                  return cellDataFeatures.getValue().get(columnIndex);
                }
              }
            });
        return column;
      }
    
      private BufferedReader getReaderFromUrl(String urlSpec) throws Exception {
        URL url = new URL(urlSpec);
        URLConnection connection = url.openConnection();
        InputStream in = connection.getInputStream();
        return new BufferedReader(new InputStreamReader(in));
      }
    
      public static void main(String[] args) {
        launch(args);
      }
    }
    
  • Create a column of number starting at a variable

    I want to create a column on a report that will number the lines sequentially starting at an input variable.

    Production is expected to be something like the following if 100 was entered as a variable starting:

    100 first line details
    101 second line details
    102 third line details


    The variable should be entered as a parameter.

    Hello
    In case the solution given by Rod does not work, perhaps because of sorting you can try this:

    1. create a calculated item, say called BASEVALUE and enter 1 for the calculation

    2. create this second calculation:

    * Sum (BASEVALUE) (ORDER BY sorting your items LINES UNBOUNDED PRECEDING) + variable departure*, so if your sort were growing sorted POINTS and MYDATE down with a 500 starting point it would be as follows:

    SUM (BASEVALUE) OVER (ORDER BY ASC, DESC MYDATE ROWS UNBOUNDED PRECEDING ELEMENTS) + 500

    3. remove the spreadsheet BASEVALUE so that it does not appear

    Best wishes
    Michael

  • Dynamic number of panelBoxes in panelDashboard

    Hello

    I had a scenario where I need to display a series of images in a particular order as a string. When the length of the string is greater than 5, he can display them in the rank, but only in the order of the string, and also the number of images is decided during execution.

    So I thought with the use of the panelDashboard with panelBoxes inside, which can be organized running using the columns: 5 of the panelDashboard . But I'm not able to use the af: forEach inside the panelDashboard. This prevents me from doing a dynamic creation of the panelBoxes.

    So somebody please give me a way to do it... or a better way to meet the requirements

    Hello

    Have you tried to run the page regardless of the error? Just tried with

                    
                    
                        
                            
                        
                        
                    
    

    And be able to see 5 panelBoxes inside panelDashboard.

    Arun-

  • How to set the page dynamically number in a URL?

    Hi, I would like to know how to dynamically set the number of pages in one URL. I have a report that shows me a list of options, and each option has a specific associated page number. I would like to redirect the user to a specific page, depending on the option, click it. (The values of the elements of the report, comes from a table that has two columns: opinion on, page_name)

    Thank you

    Just do the report column a link (in the attributes report > column attributes) and change the target to a url. The url should be something like

    f? p = 1: #MYPAGENUMBERCOLUMN #:Session:Request:Debug:Clearcache:itemname:itemvalue:printerfreindly

  • Ability to pass dynamic number of entries to a procedure using native SQL?

    Hello

    We have end users to do things like this:

    var x refcursor;

    exec some_proc (1234,: x);

    print x;

    Now, they want to use dynamic multiple entries like this:

    var x refcursor;

    exec some_proc (1234 5678, 9011,: x);

    print x;

    Yes I know you could do something like this:

    Create the type t_num is table of number;

    declare

    v_nums t_num: = t_num (123,456,789,234);

    v_result sys_refcursor;

    Start

    some_proc (v_nums, v_result)

    end;

    But they have some old piece of middleware simplifying procedure calls which it can handle data types and cursors.  So I was wondering if there is a way to fill a cursor using native sql to succeed in a procedure?  Yes I am assuming that the answer will be no, but I wanted to just make sure.

    But they have some old piece of middleware simplifying procedure calls which it can handle data types and cursors.

    Too old to take a string delimited as input?  Then cut the string and fill it with v_nums in some_proc?  Does not seem a lot of work.

Maybe you are looking for

  • Firefox will not complete download. It just stops.

    I had to do a system restore and when I try to re-download firefox I get as much as the run button and when I click it nothing happens. I'm under System 7. Norton tells me that the Downloader is new and questionable, but does not stop the download. H

  • Mail in Mac OS Server 5.1 Server (El Capitan)

    Hello. A question on the mail server. I want to NO limit single size email (with attachments). Default seems to be 10 MB max... For my needs it is not enough Now, when someone send a bulk email to a single account on the server, receives this message

  • Satellite L300D - spare chips No.

    I have a laptop L300D I try to go there, the first problem was the PSU died, also replaced a fuse on the main Board smd, but he also destroyed a here on this Board can t read the chip so that his breath out only info I did the part no screen printing

  • El capitan and slower computer

    What would cause my macbook pro to run more slowly since the installation of el capitan? I am very frustrated and unhappy. I've upgraded only because it was held for the last update of itunes - I need for ipad new pro.  It is significantly slower in

  • Halo 3 microphone

    My new xbox 360 microphone seems to work very well at first. When I start talking about the symbol of the broadcast shows, but when I'm done talking he stays on the screen. I even put it on the floor without background noise, and the symbol is still