Query to display tablespace (PSAPBTABD) table

Experts,
We need to take the list of tables only in "PSAPBTABD" tablespace with following requirements.
NUM_ROWS,
AVG_ROW_LEN ROWLEN,
BLOCKS,
We have query but it downloads common for tables.
SELECT * FROM
( SELECT
    SUBSTR(TABLE_NAME, 1, 21) TABLE_NAME,
    NUM_ROWS,
    AVG_ROW_LEN ROWLEN,
    BLOCKS,
    ROUND((AVG_ROW_LEN + 1) * NUM_ROWS / 1000000, 0)
NET_MB,
    ROUND(BLOCKS * (8000 - 23 * INI_TRANS) *
      (1 - PCT_FREE / 100) / 1000000, 0) GROSS_MB,
    ROUND((BLOCKS * (8000 - 23 * INI_TRANS) * (1 - PCT_FREE/ 100) -
      (AVG_ROW_LEN + 1) * NUM_ROWS) / 1000000) "WASTED_MB"
  FROM DBA_TABLES
  WHERE
    NUM_ROWS IS NOT NULL AND
    PARTITIONED = 'NO' AND
    (IOT_TYPE != 'IOT' OR IOT_TYPE IS NULL)
  ORDER BY 7 DESC)
WHERE ROWNUM <= 10;
Please let us know how to query a particular tablespace table only
Thanks
Malai

Hi,
I do not know where you copy your query, but you may try to understand it and then you would find your answer.
The documentation is your friend
SELECT * FROM
( SELECT
"BBABLABLA"
FROM
                                      DBA_TABLES
WHERE
NUM_ROWS IS NOT NULL AND
PARTITIONED = 'NO' AND
(IOT_TYPE != 'IOT' OR IOT_TYPE IS NULL)
ORDER BY 7 DESC)
WHERE ROWNUM <= 10;
you are selecting from DBA_TABLES
what are the columns of this view? clue, look at the documentation
There is a column called "TABLESPACE_NAME" ....
Then you can put a condition very easily to show ONLY one tablespace

Similar Messages

  • Sql Except query to Display mismatched records along with Table names

    Hi
    I am using below query to display mismatch records between two tables
    SELECT * FROM table1
    EXCEPT
    SELECT * FROM table2
    UNION
    SELECT * FROM table2
    EXCEPT
    SELECT * FROM table1
    This displays mismatched records like below
    Sunil  1000  india
    Sunil 1500  india
    I would like to display even the table names in the result For ex;
    Sunil  1000  india  Table1
    Sunil 1500  india   Table2
    Can you please help us in this regard.

    cnk_gr's query should work for you. 
    One change that I would make is to use UNION ALL, not UNION.  UNION eliminates duplicate rows, which means SQL has to do additional work (sort the result and then check for duplicates). 
    So if you can have duplicates and don't want them in your result, then you would use UNION.  And if you can have duplicates and you want the duplicates in the result, you would use UNION ALL.  But in cases like this, where you know you cannot have
    duplicates (because column 1 contains 'TABLE1' for every row in the first half and column 1 contains 'TABLE2' for every row returned from the second half of the query), you should always use UNION ALL.  It will be more efficient.
    Tom

  • Data not displayed in Z-table when material code (MATNR) entered in selection screen.

    Hi Experts,
    I have a Z-table for a gatepass report which was already created by another developer. This table has many fields including plant, year, material code field. (MATNR) etc
    Now the problem is in SE11, I run the table to display the entries, when I enter plant and year and execute many entries are displayed.properly including material codes(e.g.50008536). 
    But when I execute the same entering plant, year and material code(e.g.50008536) then this message is displayed. " No table entries found for specified key"
    The same thing happens if I am writing a select query in my report to get the data of any particular material code. My internal table is not filled with the data including that particular material code.
    Some more info :
    1. The material code field in the Z-table is assigned the standard material code Data element. i.e. MATNR
    2. Even if I enter '000000000050008536' as input it is still not working. it is automatically changed to '50008536' after executing.
    So please help me where the problem is? I have spent alot of time on this but not able to find the problem..
    Thanks,
    Vishal .

    Hi Vishal,
    Hope I understand  that table content does not starts with zero for material, reply me if i am wrong.
    Use this code before where condition.
    loop at so_matnr.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
       EXPORTING
         INPUT         = so_matnr-low
      IMPORTING
        OUTPUT        = so_matnr-low.
    if so_matnr-high is NOT INITIAL.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
       EXPORTING
         INPUT         = so_matnr-high
      IMPORTING
        OUTPUT        = so_matnr-high.
    endif.
    MODIFY  so_matnr.
    endloop.
    if table content is filled with zero use  FM conversion_exit_alpha_input
    Regards,
    Venkat.

  • How do you have more than one parameterized Query to display "All"?

    hi,
    I am using:
    Jdeveloper 9.0.5.2
    Oracle Database 9.2.0.1
    Toplink
    Struts
    I have been able to create a parameterized query to display an html read only table.
    I populated a dropdown list with values from the database
    and the values I select will be the parameters to my read only table.
    The drop down list is on the same page as the read only table.
    I have all this working but I also need to hard code an option in the Drop down to "All"
    to represent all values of this parameter.
    I was able to trick the jsp page using two read only tables
    and displaying the one with the parameterized query when a parameter other than "All" was chosen
    and then display the other only when "All" was chosen.
    This does not seem the best way to do it.
    What if I had more than one parameter and I wanted to show "All"
    the values of one and a certain values for another.
    I would then need at least 4 read only tables.
    How do I accomplish this in an easier way?
    Thanks in advance.

    I am not exactly sure what you are asking... Are you having trouble with TopLink, or another part of your application?
    Peter Krogh

  • Saving a file from a form to be display on a table

    Hi i'm having some problems trying to save the filled out on the form to be displayed on the table i don't know how i am going to go about it can you please help me thanks.
    Here is the code for the form.
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.*;              //for layout managers and more
    import java.awt.event.*;        //for action events
    import java.net.URL;
    import java.text.ParseException;
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import javax.swing.JComboBox;
    public class DD extends JPanel
                                 implements ActionListener {
        private String newline = "\n";
        protected static final String textFieldString = "Name"; 
        protected static final String textFieldString1 = "Start Time";
        protected static final String textFieldString2 = "End Time";
        protected static final String textFieldString3 = "Total Time(Minutes)";
        protected static final String ftfString = "Date";
        protected static final String buttonString = "JButton";
        JFormattedTextField startTime;
        JTextField totalTime;
        protected JLabel actionLabel;
        Component[][] rowData;
        private String[] shapeName = { "Meeting", "Lunch", "Holiday", "Sickness",
                 "Preparing report", "Administrative work", "Emails", "Query" };
        public DD() {
            setLayout(new BorderLayout());
            Panel data = new Panel();
              data.setLayout(new GridLayout(7, 4));
            rowData = new Component[7][];
    //      One row
                   for (int row = 0; row < 7; row++)
                        rowData[row] = new Component[5];
                        rowData[row][0] = new TextField(10);
                        rowData[row][1] = new TextField(10);
                        ((TextField) rowData[row][1]).addActionListener(this);
                        rowData[row][2] = new JComboBox(shapeName);
                        ((JComboBox) rowData[row][2]).addActionListener(this);
    //      ((TextField)rowData[ row ][ 2 ]).addActionListener(this);
                        rowData[row][3] = new TextField(10);
                        ((TextField) rowData[row][3]).addActionListener(this);
    //      JComboBox jcboxShapeCombo;
    //      System.out.println(rowData[row][2]);
    //      jcboxShapeCombo[2] = new JComboBox (shapeName);
    //      rowData[ row ][ 3 ] = new TextField(10);
                        rowData[row][4] = new TextField(10);
                        ((TextField) rowData[row][4]).addActionListener(this);
                        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("H:mm");
                        ((TextField) rowData[row][0]).setText(sdf.format(new java.util.Date()));
                        data.add(rowData[row][0]);
                        data.add(rowData[row][1]);
                        data.add(rowData[row][2]);
                        data.add(rowData[row][3]);
                        data.add(rowData[row][4]);
            //Create a regular text field.
            JTextField textField = new JTextField(10);
            textField.setActionCommand(textFieldString);
            textField.addActionListener(this);
            java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("H:mm");
            startTime = new JFormattedTextField(sdf);
            startTime.setValue(new java.util.Date());
            startTime.setActionCommand(textFieldString1);
            startTime.addActionListener(this);
            JTextField textField2 = new JTextField(10);
            textField2.setActionCommand(textFieldString2);
            textField2.addActionListener(this);
            totalTime = new JTextField(10);
            totalTime.setActionCommand(textFieldString3);
            totalTime.addActionListener(this);
            //Create a formatted text field.
            JFormattedTextField ftf = new JFormattedTextField(
                      //java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("H:mm");
                    java.util.Calendar.getInstance().getTime());
            ftf.setActionCommand(textFieldString);
            ftf.addActionListener(this);
            //Create some labels for the fields.
            JLabel textFieldLabel = new JLabel(textFieldString + ": ");
            textFieldLabel.setLabelFor(textField);
            JLabel textFieldLabel1 = new JLabel(textFieldString1 + ": ");
            textFieldLabel1.setLabelFor(startTime);
            JLabel textFieldLabel2 = new JLabel(textFieldString2 + ": ");
            textFieldLabel2.setLabelFor(textField2);
            JLabel textFieldLabel3 = new JLabel(textFieldString3 + ": ");
            textFieldLabel3.setLabelFor(totalTime);
            JLabel ftfLabel = new JLabel(ftfString + ": ");
            ftfLabel.setLabelFor(ftf);
            //Create a label to put messages during an action event.
            actionLabel = new JLabel("Type text in a field and press Enter.");
            actionLabel.setBorder(BorderFactory.createEmptyBorder(10,0,0,0));
            //Lay out the text controls and the labels.
            JPanel textControlsPane = new JPanel();
            GridBagLayout gridbag = new GridBagLayout();
            GridBagConstraints c = new GridBagConstraints();
            textControlsPane.setLayout(gridbag);
            JLabel[]labels = {textFieldLabel, textFieldLabel1,textFieldLabel2, textFieldLabel3, ftfLabel};
            JTextField[] textFields = {textField, startTime,textField2,totalTime, ftf};
            addLabelTextRows(labels, textFields, gridbag, textControlsPane);
            c.gridwidth = GridBagConstraints.REMAINDER; //last
            c.anchor = GridBagConstraints.WEST;
            c.weightx = 1.0;
            textControlsPane.add(actionLabel, c);
            textControlsPane.setBorder(
                    BorderFactory.createCompoundBorder(
                                    BorderFactory.createTitledBorder("Text Fields"),
                                    BorderFactory.createEmptyBorder(5,5,5,5)));
            //Create a text area.
            JTextArea textArea = new JTextArea(
            textArea.setFont(new Font("Serif", Font.ITALIC, 16));
            textArea.setLineWrap(true);
            textArea.setWrapStyleWord(true);
            JScrollPane areaScrollPane = new JScrollPane(textArea);
            areaScrollPane.setVerticalScrollBarPolicy(
                            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            areaScrollPane.setPreferredSize(new Dimension(250, 250));
            areaScrollPane.setBorder(
                BorderFactory.createCompoundBorder(
                    BorderFactory.createCompoundBorder(
                                    BorderFactory.createTitledBorder("Comment"),
                                    BorderFactory.createEmptyBorder(5,5,5,5)),
                    areaScrollPane.getBorder()));
            //Create an editor pane.
            JEditorPane editorPane = createEditorPane();
            JScrollPane editorScrollPane = new JScrollPane(editorPane);
            editorScrollPane.setVerticalScrollBarPolicy(
                            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            editorScrollPane.setPreferredSize(new Dimension(250, 145));
            editorScrollPane.setMinimumSize(new Dimension(10, 10));
            String[] initString =
            { "Meeting", "Lunch", "Holiday", "Sickness",
                     "Preparing report", "Administrative work", "Emails", "Query" };
            JList listCategories = new JList(initString);
            JScrollPane editorScrollPane = new JScrollPane(listCategories);
            editorScrollPane.setVerticalScrollBarPolicy(
                            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            editorScrollPane.setPreferredSize(new Dimension(250, 145));
            editorScrollPane.setMinimumSize(new Dimension(10, 10));
            //Create a text pane.
            JTextPane textPane = createTextPane();
            JScrollPane paneScrollPane = new JScrollPane(textPane);
            paneScrollPane.setVerticalScrollBarPolicy(
                            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            paneScrollPane.setPreferredSize(new Dimension(250, 155));
            paneScrollPane.setMinimumSize(new Dimension(10, 10));
            //Put the editor pane and the text pane in a split pane.
            JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
                                                  editorScrollPane,
                                                  paneScrollPane);
            splitPane.setOneTouchExpandable(true);
            splitPane.setResizeWeight(0.5);
            JPanel rightPane = new JPanel(new GridLayout(1,0));
            rightPane.add(splitPane);
            rightPane.setBorder(BorderFactory.createCompoundBorder(
                            BorderFactory.createTitledBorder("Category of Task"),
                            BorderFactory.createEmptyBorder(5,5,5,5)));
            JPanel rightPane = new JPanel(new GridLayout(1,0));
            rightPane.add(editorScrollPane);
            //Put everything together.
            JPanel leftPane = new JPanel(new BorderLayout());
            leftPane.add(textControlsPane,
                         BorderLayout.PAGE_START);
            leftPane.add(areaScrollPane,
                         BorderLayout.CENTER);
            add(leftPane, BorderLayout.LINE_START);
            add(rightPane, BorderLayout.LINE_END);
            JButton button = new JButton("Submit");
            button.setCursor(Cursor.getDefaultCursor());
            //button.setMargin(new Insets(0,0,0,0));
            button.setActionCommand(buttonString);
            button.addActionListener(this);
            add(button, BorderLayout.SOUTH);
            button.addActionListener(new ActionListener()
                   public void actionPerformed(ActionEvent evt)
                        String toPrint = collectData();
                        newFile(toPrint);
       private String collectData()
              String toPrint = "";
              for (int i = 0; i < rowData.length; i++)
                   Component[] currentRowComps = rowData;
                   for (int j = 0; j < currentRowComps.length; j++)
                        Component currentComp = currentRowComps[j];
                        if (currentComp instanceof TextField)
                             TextField tf = (TextField) currentComp;
                             toPrint += tf.getText() + " - ";
                        else if (currentComp instanceof JComboBox)
                             JComboBox box = (JComboBox) currentComp;
                             Object selection = box.getSelectedItem();
                             if (selection != null)
                                  toPrint += selection.toString() + " - ";
                   toPrint += "\n";
              return toPrint;
         private File newFile(String data)
              File newfile = null;
              try
                   newfile = new File("I:\\ouput.doc");
                   System.out.println("DATA? - " + data);
                   FileOutputStream fos = new FileOutputStream(newfile);
                   fos.write(data.getBytes());
                   fos.close();
                   // JOptionPane.showMessageDialog(null, "Save File");
                   JOptionPane.showMessageDialog(null, "File saved.", "Success",
                   JOptionPane.INFORMATION_MESSAGE);
              catch (IOException ioexc)
                   JOptionPane.showMessageDialog(null, "Error while saving file: " + ioexc,
                   "Error", JOptionPane.ERROR_MESSAGE);
              return null;
    private void addLabelTextRows(JLabel[] labels,
    JTextField[] textFields,
    GridBagLayout gridbag,
    Container container) {
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.EAST;
    int numLabels = labels.length;
    for (int i = 0; i < numLabels; i++) {
    c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
    c.fill = GridBagConstraints.NONE; //reset to default
    c.weightx = 0.0; //reset to default
    container.add(labels[i], c);
    c.gridwidth = GridBagConstraints.REMAINDER; //end row
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    container.add(textFields[i], c);
    public void actionPerformed(ActionEvent e) {
    String prefix = "You typed \"";
    if (textFieldString2.equals(e.getActionCommand()))
    JTextField source = (JTextField)e.getSource();
    actionLabel.setText(prefix + source.getText() + "\"");
    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("H:mm");
    try {
                        java.util.Date end = sdf.parse(source.getText());
                        java.util.Date start = sdf.parse(startTime.getText());
                        long difference = (end.getTime() - start.getTime()) / 60000;
                        totalTime.setText(Long.toString(difference));
                   } catch (ParseException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
    if (textFieldString1.equals(e.getActionCommand()))     {JTextField source = (JTextField)e.getSource();
            actionLabel.setText(prefix + source.getText() + "\"");}
    if (textFieldString2.equals(e.getActionCommand()))     {JTextField source = (JTextField)e.getSource();
            actionLabel.setText(prefix + source.getText() + "\"");}
    if (textFieldString3.equals(e.getActionCommand()))     {JTextField source = (JTextField)e.getSource();
            actionLabel.setText(prefix + source.getText() + "\"");}
    else if (textFieldString.equals(e.getActionCommand())) {
    //JPasswordField source = (JPasswordField)e.getSource();
    //actionLabel.setText(prefix + new String(source.getPassword())
    //+ "\"");
    } else if (buttonString.equals(e.getActionCommand())) {
    Toolkit.getDefaultToolkit().beep();
    private JEditorPane createEditorPane() {
    JEditorPane editorPane = new JEditorPane();
    editorPane.setEditable(false);
    java.net.URL helpURL = DD.class.getResource(
    "DailyDairyDemoHelp.html");
    if (helpURL != null) {
    try {
    editorPane.setPage(helpURL);
    } catch (IOException e) {
    System.err.println("Attempted to read a bad URL: " + helpURL);
    } else {
    System.err.println("Couldn't find file: Daily Dairy.html");
    return editorPane;
         private JTextPane createTextPane() {
    String[] initString =
    { "Meeting", "Lunch", "Holiday", "Sickness",
         "Preparing report", "Administrative work", "Emails", "Query" };
    String[] initStyles =
    { "regular", "italic", "bold", "small", "large",
    "regular", "button", "regular", "icon",
    "regular"
    JTextPane textPane = new JTextPane();
    StyledDocument doc = textPane.getStyledDocument();
    addStylesToDocument(doc);
    try {
    for (int i=0; i < initString.length; i++) {
    doc.insertString(doc.getLength(), initString[i],
    doc.getStyle(initStyles[i]));
    } catch (BadLocationException ble) {
    System.err.println("Couldn't insert initial text into text pane.");
    return textPane;
    protected void addStylesToDocument(StyledDocument doc) {
    //Initialize some styles.
    Style def = StyleContext.getDefaultStyleContext().
    getStyle(StyleContext.DEFAULT_STYLE);
    Style regular = doc.addStyle("regular", def);
    StyleConstants.setFontFamily(def, "SansSerif");
    Style s = doc.addStyle("italic", regular);
    StyleConstants.setItalic(s, true);
    s = doc.addStyle("bold", regular);
    StyleConstants.setBold(s, true);
    s = doc.addStyle("small", regular);
    StyleConstants.setFontSize(s, 10);
    s = doc.addStyle("large", regular);
    StyleConstants.setFontSize(s, 16);}
    /*s = doc.addStyle("icon", regular);
    StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
    ImageIcon pigIcon = createImageIcon("images/Pig.gif",
    "a cute pig");
    if (pigIcon != null) {
    StyleConstants.setIcon(s, pigIcon);
    s = doc.addStyle("button", regular);
    StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
    ImageIcon soundIcon = createImageIcon("images/sound.gif",
    "sound icon");
    JButton button = new JButton();
    if (soundIcon != null) {
    button.setIcon(soundIcon);
    } else {
    button.setText("BEEP");
    button.setCursor(Cursor.getDefaultCursor());
    button.setMargin(new Insets(0,0,0,0));
    button.setActionCommand(buttonString);
    button.addActionListener(this);
    StyleConstants.setComponent(s, button);
    /** Returns an ImageIcon, or null if the path was invalid. */
    protected static ImageIcon createImageIcon(String path,
    String description) {
    java.net.URL imgURL = DD.class.getResource(path);
    if (imgURL != null) {
    return new ImageIcon(imgURL, description);
    } else {
    System.err.println("Couldn't find file: " + path);
    return null;
    * Create the GUI and show it. For thread safety,
    * this method should be invoked from the
    * event dispatch thread.
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("DailyDairyDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Add content to the window.
    frame.add(new DD());
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args) {
    //Schedule a job for the event dispatching thread:
    //creating and showing this application's GUI.
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    //Turn off metal's use of bold fonts
              UIManager.put("swing.boldMetal", Boolean.FALSE);
              createAndShowGUI();
    And here is the code for the table.
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.io.*;
    import java.util.Date;
    import java.sql.*;
    import java.text.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    public class DDTable extends JFrame{
         protected JTable m_table;
         protected DDTableData m_data;
         protected JLabel m_title;
         public DDTable(){
              super("DDTABLE");
              setSize(600, 300);
              UIManager.put("Table.focusCellHighlightBorder",new LineBorder(Color.black, 0));
              m_data = new DDTableData();
              m_title = new JLabel(m_data.getTitle(), SwingConstants.CENTER);
              m_title.setFont(new Font("Helvetica", Font.PLAIN, 24));
              getContentPane().add(m_title, BorderLayout.NORTH);
              m_table = new JTable();
              m_table.setAutoCreateColumnsFromModel(false);
              m_table.setModel(m_data);
              for (int k = 0; k < m_data.getColumnCount(); k++) {
                   DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
                   renderer.setHorizontalAlignment(DDTableData.m_columns[k].m_alignment);
                   TableColumn column = new TableColumn(k, DDTableData.m_columns[k].m_width, renderer, null);
                   m_table.addColumn(column);
              JTableHeader header = m_table.getTableHeader();
              header.setUpdateTableInRealTime(false);
              setJMenuBar(createMenuBar());
              JScrollPane ps = new JScrollPane();
              ps.getViewport().setBackground(m_table.getBackground());
              ps.getViewport().add(m_table);
              getContentPane().add(ps, BorderLayout.CENTER);
              protected JMenuBar createMenuBar(){
                   JMenuBar menuBar = new JMenuBar();
                   JMenu mFile = new JMenu("File");
                   mFile.setMnemonic('f');
                   Action actionNew = new AbstractAction("New Appointment"){
                        public void actionPerformed(ActionEvent e){
                             if (!promptToSave())
                                  return;
                             newDocument();
                        JMenuItem item = new JMenuItem(actionNew);
                        item.setMnemonic('n');
                        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK));
                        mFile.add(item);
                        Action actionSave = new AbstractAction("Save Appointment"){
                             public void actionPerformed(ActionEvent e){
                                  boolean m_textChanged = false;
                                  if (!m_textChanged)
                                       return;
                                  saveFile(false);
                              item = new JMenuItem(actionSave);
                             item.setMnemonic('s');
                             item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
                             mFile.add(item);
                   JMenuItem mData = new JMenuItem("Retrieve Data");
                   mData.setMnemonic('r');
                   ActionListener lstData = new ActionListener(){
                   public void actionPerformed(ActionEvent e){
                        retrieveData();
                   mData.addActionListener(lstData);
                   mFile.add(mData);
                   mFile.addSeparator();
                   JMenuItem mExit = new JMenuItem("Exit");
                   mExit.setMnemonic('x');
                   ActionListener lstExit = new ActionListener(){
                        public void actionPerformed(ActionEvent e){
                             System.exit(0);
                   mExit.addActionListener(lstExit);
                   mFile.add(mExit);
                   menuBar.add(mFile);
                   return menuBar;
              protected void saveFile(boolean b) {
                   // TODO Auto-generated method stub
              protected void newDocument() {
                     //Create and set up the window.
                 JDialog frame = new JDialog();//"DailyDairyDemo");
                 frame.setModal(true);
                 //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                 //Add content to the window.
                 frame.add(new DD());
                 //Display the window.
                 frame.pack();
                 frame.setVisible(true);
                 JOptionPane.showMessageDialog(this, "Done!");
                 //loadFile();
              protected boolean promptToSave() {
                   // TODO Auto-generated method stub
                   return true;
              public void retrieveData(){
                   Runnable updater = new Runnable(){
                        public void run(){
                             SimpleDateFormat frm = new SimpleDateFormat("MM/dd/yyyy");
                             String currentDate = frm.format(m_data.m_date);
                             String result =
                             (String)JOptionPane.showInputDialog(DDTable.this,"Please enter date in form mm/dd/yyyy:", "Input", JOptionPane.INFORMATION_MESSAGE, null, null, currentDate);
                             if (result==null)
                                  return;
                             java.util.Date date = null;
                             try{
                                  date = frm.parse(result);
                             catch (java.text.ParseException ex){
                                  date = null;
                             if (date == null){
                                  JOptionPane.showMessageDialog(DDTable.this, result+" is not a valid date", "Warning", JOptionPane.WARNING_MESSAGE);
                                  return;
                             setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                             try{
                                  m_data.retriveData(date);
                             catch (Exception ex){
                                  JOptionPane.showMessageDialog(DDTable.this,"Error retrieving data:\n"+ex.getMessage(),"Error",JOptionPane.ERROR_MESSAGE);
                             setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                             m_title.setText(m_data.getTitle());
                             m_table.tableChanged(new TableModelEvent(m_data));
                   SwingUtilities.invokeLater(updater);
         public static void main(String argv[]){
              DDTable frame = new DDTable();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setVisible(true);
       class DDData{
            public String m_name;
            public String m_date;
            public String m_startTime;
            public String m_endTime;
            public String m_totalTime;
            public String m_comment;
            public String m_category;
            public DDData(String name, String date,String startTime, String endTime, String totalTime, String comment, String category){
                 m_name = name;
                 m_date = date;
                 m_startTime = startTime;
                 m_endTime = endTime;
                 m_totalTime = totalTime;
                 m_comment = comment;
                 m_category = category;
       class ColumnData{
            public String m_title;
            public int m_width;
            public int m_alignment;
            public ColumnData(String title, int width, int alignment) {
                 m_title = title;
                 m_width = width;
                 m_alignment = alignment;
       class DDTableData extends AbstractTableModel{
         private static final long serialVersionUID = 1L;
         static final String QUERY = "SELECT symbols.name,"+"data startTime, data.endTime, data.totalTime, data.comment, data.category FROM DATA INNER JOIN SYMBOLS"
         +"ON DATA.symbol = SYMBOLS.symbol WHERE"+
         "month(data.date1)=? AND day(data.date1)=?"+
         "AND year(data.date1)=?";
         @SuppressWarnings("unchecked")
         public void retriveData(Date date)
         throws SQLException, ClassNotFoundException {
              try {
                   File f = new File("appointments.dat");
                   FileInputStream fis = new FileInputStream(f);
                ObjectInputStream ois = new ObjectInputStream(fis);
                m_vector = (Vector<DDData>) ois.readObject();
                ois.close();
                fis.close();
               } catch(ClassCastException ex) {
               } catch(FileNotFoundException ex) {
               } catch(IOException ex) {
              /*GregorianCalendar calendar = new GregorianCalendar();
              calendar.setTime(date);
              int month = calendar.get(Calendar.MONTH)+1;
              int day = calendar.get(Calendar.DAY_OF_MONTH);
              int year = calendar.get(Calendar.YEAR);
              m_date = date;
              m_vector = new Vector();
              Connection conn = null;
              PreparedStatement pst = null;
              try{
                   //Load the JDBC-ODBC bridge driver
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   conn = DriverManager.getConnection("jdbc:odbc:Market", "admin", "");
                   pst = conn.prepareStatement(QUERY);
                   pst.setInt(1, month);
                   pst.setInt(2, day);
                   pst.setInt(3, year);
                   ResultSet results = pst.executeQuery();
                   while (results.next()){
                        String name = results.getString(1);
                        String startTime = results.getString(2);
                        String endTime = results.getString(3);
                        String totalTime = results.getString(4);
                        String comment = results.getString(5);
                        String category = results.getString(6);
                        m_vector.addElement(new DDData(name, startTime, endTime, totalTime, comment, category, category));
                   sortData();
              finally{
                   if (pst != null )
                        pst.close();
                   if (conn != null)
                        conn.close();
         private void saveData() {
              try {
                   File f = new File("appointments.dat");
                   FileOutputStream fos = new FileOutputStream(f);
                ObjectOutputStream oos = new ObjectOutputStream(fos);
                oos.writeObject(m_vector);
                oos.close();
                fos.close();
               } catch(IOException ex) {
         private void sortData() {
              // TODO Auto-generated method stub
         static final public ColumnData m_columns[] = {
                 new ColumnData("Name", 100, JLabel.LEFT),
                 new ColumnData("Date", 100, JLabel.LEFT),
                 new ColumnData("Start Time", 100, JLabel.RIGHT),
                 new ColumnData("End Time", 100, JLabel.RIGHT),
                 new ColumnData("Total Time", 100, JLabel.RIGHT),
                 new ColumnData("Comment", 200, JLabel.RIGHT),
                 new ColumnData("Category", 100, JLabel.RIGHT),
            protected SimpleDateFormat m_frm;
            protected Vector<DDData> m_vector = new Vector<DDData>();
            protected Date m_date;
            public DDTableData(){
                 m_frm = new SimpleDateFormat("MM/dd/yyyy");
                 setDefaultData();
            public void setDefaultData(){
                 try{
                      m_date = m_frm.parse("07/31/2007");
                 catch (java.text.ParseException ex){
                      m_date = null;
                 m_vector.removeAllElements();
                 m_vector.addElement(new DDData("Jerome", null, "Dan", null, null, null, null));
            public int getRowCount(){
                 return m_vector==null ? 0 : m_vector.size();
            public int getColumnCount(){
                 return m_columns.length;
            public String getColumnName(int column){
                 return m_columns[column].m_title;
            public boolean isCellEditable(int nRow, int nCol){
                 return false;
            public Object getValueAt(int nRow, int nCol){
                 if (nRow < 0 || nRow>=getRowCount())
                      return "";
                 DDData row = m_vector.elementAt(nRow);
                 switch (nCol){
                 case 0: return row.m_name;
                 case 1: return row.m_date;
                 case 2: return row.m_startTime;
                 case 3: return row.m_endTime;
                 case 4: return row.m_totalTime;
                 case 5: return row.m_comment;
                 case 6: return row.m_category;
                 return "";
            public String getTitle(){
                 if (m_date==null)
                      return "Daily Dairy";
                 return "Daily Dairy at "+m_frm.format(m_date);

    here is code to collect the data pls what can i do to get the data on the form display on the JTable in the all categories as on the form pls...
    private String collectData()
              String toPrint = "";
              for (int i = 0; i < rowData.length; i++)
                   Component[] currentRowComps = rowData;
                   for (int j = 0; j < currentRowComps.length; j++)
                        Component currentComp = currentRowComps[j];
                        if (currentComp instanceof TextField)
                             TextField tf = (TextField) currentComp;
                             toPrint += tf.getText() + " - ";
                        else if (currentComp instanceof JComboBox)
                             JComboBox box = (JComboBox) currentComp;
                             Object selection = box.getSelectedItem();
                             if (selection != null)
                                  toPrint += selection.toString() + " - ";
                   toPrint += "\n";
              return toPrint;
         private File newFile(String data)
              File newfile = null;
              try
                   newfile = new File("I:\\ouput.doc");
                   System.out.println("DATA? - " + data);
                   FileOutputStream fos = new FileOutputStream(newfile);
                   fos.write(data.getBytes());
                   fos.close();
                   // JOptionPane.showMessageDialog(null, "Save File");
                   JOptionPane.showMessageDialog(null, "File saved.", "Success",
                   JOptionPane.INFORMATION_MESSAGE);
              catch (IOException ioexc)
                   JOptionPane.showMessageDialog(null, "Error while saving file: " + ioexc,
                   "Error", JOptionPane.ERROR_MESSAGE);
              return null;
    private void addLabelTextRows(JLabel[] labels,
    JTextField[] textFields,
    GridBagLayout gridbag,
    Container container) {
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.EAST;
    int numLabels = labels.length;
    for (int i = 0; i < numLabels; i++) {
    c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
    c.fill = GridBagConstraints.NONE; //reset to default
    c.weightx = 0.0; //reset to default
    container.add(labels[i], c);
    c.gridwidth = GridBagConstraints.REMAINDER; //end row
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    container.add(textFields[i], c);
    Message was edited by:
    desaint
    Message was edited by:
    desaint

  • SAP Query: Duplicte records after joining table CSKT

    Guru's,
    We have created a query in SQ02 for Z table which has fields with KOKRS and KOSTL as well.
    Ztable fields:
    PLAN_TYPE
    PLAN_PROCESS
    KOKRS
    KOSTL
    We want to display cost center description. SO joining this Z table with CSKT(KOKRS,KOSTL). We are getting duplicate records in output because CSKT has duplicate KOSTL.To solve this, we want fetch Latest KOSTL comparing DATBI  GE SY-DATUM.
    Can anybody help us how to code this logic in Query. I have gone thru most of the SDN threads but could not find the answer.
    Please help us.
    Thanks in Advace.
    Shreyansh

    Moderator message - Duplicate post locked

  • Dialog Prog to Display fields of Table or Structure in screen dynamically.

    Hello Experts ,
           I am working on a dialog programming I wish to display any given table/structure on the screen - to be very clear.
    1st screen -
        One input box which can take any SAP standard or custom tableor structure as input <-- Press enter
    2 nd screen -
        I wish to see the fields of the structure in column format dsiplayed in the screen ( Like ALV Grid in the page).
    Please tell me the logic or similar example so i can refer thanks in advance.
    Thanks,
    Sriram.

    Hello Srinivas,
      Your program looks really looks and simple but the porb is we have 4.6c here. So the syntax lines
    CREATE DATA gv_dref TYPE TABLE OF (p_table).
       is not accepted by the system if we enter as it is (error - unable to interpret table - possible cause of error or spelling) 
    but it accepts
    CREATE DATA gv_dref TYPE p_table.
    but at the time of select query its not talking it has a internal table to show data , finalltyit dumps.
    [ASSIGN gv_dref->* TO <fs_itab>.
      "Select the data
      SELECT * FROM (p_table) INTO TABLE <fs_itab> UP TO 100 ROWS.
    So my problem is to find a way to dynamically display a table or view .
    Please guide.
    Regards,
    Sriram.

  • How to display a oracle table from a java program?

    How to display a oracle table from a java program.
    Hello friends, I have written a Java program, using oracle 10g as backend.
    I want to display a oracle table as output. Im not getting how to display oracle table as a output table.. Pls help me
    Thank you

    jayanthds, you're not going to get a satisfactory
    answer to this here. it's too big a task to justbe
    quickly outlined in a forum - the reply "all youneed
    to do is to query you table and return it asJTable"
    is worthless, for example, since the solution to
    any problem can be distilled to such a
    soundbite, if need be. doesn't make the solutionany
    simpler
    essentially you're asking "how do I write adatabase
    application?". all you'll get is snippets of code
    that, when fitted together, will eventually helpyou
    do this, but you'll spend days and days comingback
    saying "right, I've done that, now what?" until
    either you or the forum gets frustrated with the
    whole affair and the process stops
    there are entire books written about this subject,
    and countless tutorials and guides on theinternet.
    you're better off going down that routehehehe.well, it's true! I used to have a manager that would outline the solution to a problem in a few lines of pseudocode, and then firmly believe that the actual solution would be just as brief and simple. shame his pseudocode included such lofty abstractions as "reformat all data"

  • Setting leadselection does not change displayed row in table

    I am using a Table element to display a list of search results.
    The first time I perform a query, the results appear and the first row is displayed. The table footer shows the total amount of rows and the buttons to navigate. So far, so good.
    The problem occurs when I perform a new query, after having navigated through the rows and the table was for example showing row number 10.
    I perform the new query (which sets the leadselection back to 0), but the table stays on row 10, or the row closest to that number. It does not jump to the first row. Or in other words, the table view does not "reset".
    Any ideas?

    You right, it will not automatically navigate to the first row.
    Set  firstVisibleRow property of the table UI element to zero everytime you execute the search.
    Abhi

  • Problem while displaying all the table names from a MS Access Data Source.

    I started preparing a small Database application. I want to display all the Table Names which are in the 'MS Access' Data Source.
    I started to executing by "Select * from Tab" as if in SQL.
    But i got an error saying that "Not able to resolve Symbol 'Tab' in the query".
    Please let me know how can i display all the table Names in the MS Access Dats Source.

    Here i am developing the application in Swing using JDBC for accessing the database.
    I want to display all the Table names from the data source in a ListBox for easy selection of tables to view their details.

  • Query to display BOMs Header and Item

    Hello SAP gurus
    I am trying to create a query to display BOMs with header and item. For that I am using tables MAST, STKO and STPO.
    The table join is:
    MAST -> STKO -> STPO
    MAST - WERKS, STLNR and STLAL
    STKO - STLNR and STPOZ
    The system dont show anything...
    Can someone help me?
    Thanks in advance.
    Adelmo Silva

    Yes, it works but...
    If I have 2 alternatives, the system show everything even if i select alternative 1 or 2.
    I am missing something... because system is showing all alternatives...
    System is showing something like this:
    Material     BOM     AltBOM     BOM St     Item     ICt     Component     Valid from     Quantity     Un
    726121012     00131075     1     01     0010     L     109219     17-12-2007     0,200     KG
    726121012     00131075     1     01     0020     L     109230     17-12-2007     0,003     KG
    726121012     00131075     1     01     0030     L     109232     17-12-2007     1,166     M2
    726121012     00131075     1     01     0040     L     726004012     17-12-2007     0,120     M3
    726121012     00131075     1     01     0010     L     109526     17-12-2007     0,200     KG
    726121012     00131075     1     01     0020     L     109232     17-12-2007     1,166     M2
    726121012     00131075     1     01     0030     L     726004012     17-12-2007     0,120     M3
    Edited by: Adelmo Silva on Jan 9, 2008 9:07 AM

  • Query to Display Settlement Receivers for Maintenance Items

    I am looking for a way to get a query/list display that shows me our maintenance plans, maintenance items and the settlement receiver.  Looked in all the obvious spots and the actual receiver is not available.  In the maintenance plan you can get the field that tells you there is a settlement rule but not the actual receiver.  In the order list display you cannot get the information either.
    Has anyone had this requirement and if so, what may have been the solution.

    Greetings Linda,
    The Settlement Rules are saved in the tables COBRA & COBRB. Get your Maintenance Plan Object Number from table MPOS and join on the field OBJNR using an SAP Query.
    (SQVI or SQ00)
    Also, note that these will be copied to the created Orders and the actual settlement only happens for the Orders. The settlement rule of the Maintenance Item is only a template, no actuals are involved.

  • Query to display one row per group based on highest value

    I have the following table and I want to be able to create a query that displays only the highest number based on a group. (see below)
    Acode
    aname
    anumber
    a
    Jim
    40
    a
    Jim
    23
    a
    Jim
    12
    b
    Sal
    42
    b
    Sal
    12
    b
    Sal
    3
    Acode
    aname
    anumber
    a
    Jim
    40
    b
    Sal
    42

    Multiple ways
    using aggregation
    SELECT Acode,aname,MAX(anumber) AS anumber
    FROM table
    GROUP BY Acode,aname
    using subquery
    SELECT Acode,aname,anumber
    FROM table t
    WHERE NOT EXISTS (
    SELECT 1
    FROM table
    WHERE Acode = t.Acode
    AND aname = t.aname
    AND anumber > t.anumber
    using analytical function
    SELECT Acode,aname,anumber
    FROM
    SELECT *,ROW_NUMBER() OVER (PARTITION BY Acode, aname ORDER BY anumber DESC) AS Rn
    FROM table
    )t
    WHERE Rn = 1
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to write sql query that display comma suppurated result using Group by

    Hi,
    I am having data like bellow ,
    Above result got from joining two tables VMTAGroupClient,VMTAipNames .
    Query i have written to display above result is,
    select vgc.VMTAGroupId,vn.VMTAName from VMTAGroupClient vgc inner join VMTAipNames vn
    on vgc.VMTAID=vn.VMTANameID group by vgc.VMTAGroupId,vn.VMTAName 
    using the VMTAGroupId column how to write query to display result result like,
    VMTAGroupID    VMTAs
       1                       VMTA1,VMTA3
       2                       VMTA2,VMTA4,VMTA5
    Regards,
    Anwar Shaik

    Satheesh,
    Here in my case data need to read from two tables VMTAGroupClient, VMTAipNames.
    VMTAGroupId is in one table and VMTAName column in some other table.Iin both the tables VMTAID is common.
    Please check the above result displayed data from two tables.
    can we write same query using join?
    Anwar Shaik

  • Very Important (Query to display the output in required format)

    CREATE TABLE TEMP(X VARCHAR2(10),Y VARCHAR2(100));
    INSERT INTO TEMP('RIDER1','2001-12;2002-32;2003-42');
    INSERT INTO TEMP('RIDER2','2001-52;2003-72');
    SELECT * FROM TEMP
    Initial Out Put in 2 columns X/Y_
    X Y
    RIDER1 2001-12;2002-32;2003-42
    RIDER2 2001-52;2003-72
    Write a Query to display the above data in the format below in 3 columns A/B/C*
    A B C
    Rider1 2001 12
    Rider1 2002 32
    Rider1 2003 42
    Rider2 2001 52
    Rider2 2003 72

    So your old version doesn't support Regular expression. It will be very easy and efficient if you could use regular expression.
    SQL> SELECT x,TRIM(REGEXP_SUBSTR(col2,'[^-]+', 1, 1)) col2,
      2           TRIM(REGEXP_SUBSTR(col2,'[^-]+', 1, 2)) col3
      3   FROM (
      4     SELECT DISTINCT x,regexp_substr (y, '[^;]+', 1, level) col2 
      5     FROM temp 
      6     CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (y, '[^;]+'))  + 1
      7     ORDER BY 1,2
      8        );
    X          COL2
    COL3
    RIDER1     2001
    12
    RIDER1     2002
    32
    RIDER1     2003
    42
    X          COL2
    COL3
    RIDER2     2001
    52
    RIDER2     2003
    72But for your version you can use something like
    SQL> /* By curtesy Frank Kulash */
    SQL> SELECT x,SUBSTR(the_value,1,INSTR(the_value,'-',1)-1) col2,
      2           SUBSTR(the_value,INSTR(the_value,'-',1)+1)col3
      3  FROM (
      4        SELECT DISTINCT x,SUBSTR(y,
      5                            DECODE(level,
      6                                   1,
      7                                   1,
      8                                   INSTR(y, ';', 1, level - 1) + 1),
      9                            DECODE(INSTR(y, ';', 1, level),
    10                                   0,
    11                                   length(y),
    12                                   instr(y, ';', 1, level) -
    13                                   DECODE(level,
    14                                          1,
    15                                          0,
    16                                          INSTR(y, ';', 1, level - 1)) - 1)) the_value
    17                FROM temp
    18              CONNECT BY level <=
    19                         LENGTH(y) - LENGTH(REPLACE(y, ';')) + 1
    20          )
    21  ORDER BY 1,2,3                     
    22       ;
    X          COL2
    COL3
    RIDER1     2001
    12
    RIDER1     2002
    32
    RIDER1     2003
    42
    X          COL2
    COL3
    RIDER2     2001
    52
    RIDER2     2003
    72
    SQL>

Maybe you are looking for

  • Remote streaming server is up for testing. Starting at 12:30pm EST Oct 31 2005

    I have router configured I believe. So have at it. Time of testing starts at 1230 hours EST or 1730 UTC on Oct 31, 2005 Time of testing ends 3 hours later at 1530 hours EST Server is at: 66.177.25.115:8080 Server software: msipvs (intervideo WinDVR v

  • Tcode in user decision step

    Dear experts, I have a user decision step. Before the approver can approve or reject the workitem i need to show a tocde screen to him. Say for example CN25. My workitem will be generated only after initiator makes changes in that tcode. I want appro

  • Adding up of amount fields in the xml payload

    HI , I have a issue on hand in mapping . I am using message mapping to map the source to the target. The issue is I have a item data in the source message which contains the Amount field . also it has some charge nodes also under it which also has a

  • How can I view emails in HTML format or at least o...

    Dear Nokia, I've recently purchased the Nokia e90 to use for email using Vodafone push email (push.vodafone.nl) however the emails are in plain text format and not even the links are accessible. I have the folowing questions: 1) is it possible to vie

  • Starting a new iTunes library?

    My old laptop with my original iTunes library broke recently. I want to transfer all my data from my iPod onto a new library without erasing ANYTHING on the iPod. I've tried doing the whole "Manually Manage" thing but it doesn't really seem to work f