Returning index of selected comp... jComboBox that is editing a jTable cell

so, i'm using an array to populate the choices of a combobox
    public String[] progCodes = new String[]{"Standard","Restricted","Combined","Special"};which i'm using to edit a cell in a jtable
baseCatTable.getColumnModel().getColumn(4).setCellEditor(new DefaultCellEditor(new JComboBox(progCodes)));and when i get the value
System.out.println(baseCatTable.getValueAt(0, 4))i'd like to return the index of the selected item in the combo box instead of the text:
Standard
any suggestions?
Edited by: hansbig on Jan 24, 2008 5:04 PM

sorry, but i'm using an IDE and it generates a lot of fluffy code.
* ProblemView.java
package problem;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.DefaultCellEditor;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
* The application's main frame.
public class ProblemView extends FrameView {
    public ProblemView(SingleFrameApplication app) {
        super(app);
        initComponents();
        edit = new JComboBox(words);
        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);
        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = ProblemApp.getApplication().getMainFrame();
            aboutBox = new ProblemAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        ProblemApp.getApplication().show(aboutBox);
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
        mainPanel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        mainPanel.setName("mainPanel"); // NOI18N
        jScrollPane1.setName("jScrollPane1"); // NOI18N
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null}
            new String [] {
                "Title 1"
        jTable1.setColumnSelectionAllowed(true);
        jTable1.setName("jTable1"); // NOI18N
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jTable1.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(edit));
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(problem.ProblemApp.class).getContext().getResourceMap(ProblemView.class);
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addGap(46, 46, 46)
                        .addComponent(jButton1)))
                .addContainerGap(12, Short.MAX_VALUE))
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addContainerGap(18, Short.MAX_VALUE))
        menuBar.setName("menuBar"); // NOI18N
        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N
        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(problem.ProblemApp.class).getContext().getActionMap(ProblemView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);
        menuBar.add(fileMenu);
        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N
        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);
        menuBar.add(helpMenu);
        statusPanel.setName("statusPanel"); // NOI18N
        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N
        statusMessageLabel.setName("statusMessageLabel"); // NOI18N
        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N
        progressBar.setName("progressBar"); // NOI18N
        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(statusMessageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(statusAnimationLabel)
                .addContainerGap())
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusMessageLabel)
                    .addComponent(statusAnimationLabel)
                    .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(3, 3, 3))
        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        System.out.println(jTable1.getValueAt(0, 0));
        System.out.println(edit.getSelectedIndex());
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    // End of variables declaration
    public String[] words = new String[]{"one","two"};
    public JComboBox edit;
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;
* ProblemApp.java
package problem;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;
* The main class of the application.
public class ProblemApp extends SingleFrameApplication {
     * At startup create and show the main frame of the application.
    @Override protected void startup() {
        show(new ProblemView(this));
     * This method is to initialize the specified window by injecting resources.
     * Windows shown in our application come fully initialized from the GUI
     * builder, so this additional configuration is not needed.
    @Override protected void configureWindow(java.awt.Window root) {
     * A convenient static getter for the application instance.
     * @return the instance of ProblemApp
    public static ProblemApp getApplication() {
        return Application.getInstance(ProblemApp.class);
     * Main method launching the application.
    public static void main(String[] args) {
        launch(ProblemApp.class, args);
}i'm getting:
init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\1\My Documents\NetBeansProjects\problem\build\classes
compile:
run:
Jan 24, 2008 7:58:36 PM org.jdesktop.application.Application$1 run
SEVERE: Application class problem.ProblemApp failed to launch
java.lang.NullPointerException
at javax.swing.DefaultCellEditor.<init>(DefaultCellEditor.java:117)
at problem.ProblemView.initComponents(ProblemView.java:136)
at problem.ProblemView.<init>(ProblemView.java:29)
at problem.ProblemApp.startup(ProblemApp.java:19)
at org.jdesktop.application.Application$1.run(Application.java:171)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Exception in thread "AWT-EventQueue-0" java.lang.Error: Application class problem.ProblemApp failed to launch
at org.jdesktop.application.Application$1.run(Application.java:177)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: java.lang.NullPointerException
at javax.swing.DefaultCellEditor.<init>(DefaultCellEditor.java:117)
at problem.ProblemView.initComponents(ProblemView.java:136)
at problem.ProblemView.<init>(ProblemView.java:29)
at problem.ProblemApp.startup(ProblemApp.java:19)
at org.jdesktop.application.Application$1.run(Application.java:171)
... 8 more
BUILD SUCCESSFUL (total time: 2 seconds)
also, I made a zip file of the project and put it up here:
http://www.geocities.com/hansbigtree/problem.zip
thanks.

Similar Messages

  • How do you set new items within a JComboBox that is within a JTable

    I have searched and searched for the answer to this and do not thing there is one. I have a JTable that has 5 columns. 2 of the columns use DefaultCellRenderers where a JComboBox is used. One of the columns has a value of different football positions. The other has a value of the different players. When a user enters a particular position such as Kickers I want all the Kickers to be showin within the Players JComboBox within the table.
    The problem is that I ONLY want the cell to be modified within that row and column that the position was changed. I have found ways to modify the component but it modifies it for the whole Column. I only want it to be modified for the player cell within the row that the Position was modified. Bottom line is that I just want to modify the JComboBox's components.
    If anyone has had this challenge before please advise.

    I'm not sure I fully understood what you wanted. Does the following little program help you?import javax.swing.*;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableColumnModel;
    import java.awt.*;
    * User: weebib
    * Date: 29 janv. 2005
    * Time: 23:37:57
    public class FootballTable extends JPanel {
         private static final String[] COLUMN_NAMES = {"Position", "Name"};
         private static final String[] POSITIONS = {"goal", "arriere", "milieu", "avant"};
         private static final String[] GOALS = {"goal1", "goal2", "goal3"};
         private static final String[] ARRIERES = {"arriere1", "arriere2", "arriere3"};
         private static final String[] MILIEUX = {"milieu1", "milieu2", "milieu3"};
         private static final String[] AVANTS = {"avant1", "avant2", "avant3"};
         public FootballTable() {
              super(new BorderLayout());
              DefaultTableModel model = new DefaultTableModel(COLUMN_NAMES, 10);
              final JTable table = new JTable(model);
              TableColumnModel columnModel = table.getColumnModel();
              columnModel.getColumn(0).setCellEditor(new DefaultCellEditor(new JComboBox(POSITIONS)));
              columnModel.getColumn(1).setCellEditor(new DefaultCellEditor(new JComboBox()) {
                   public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
                        JComboBox nameComboBox = (JComboBox)super.getTableCellEditorComponent(table, value, isSelected, row, column);
                        Object position = table.getValueAt(row, 0);
                        if (position == null) {
                             nameComboBox.setModel(new DefaultComboBoxModel());
                        } else if (position.equals("goal")) {
                             nameComboBox.setModel(new DefaultComboBoxModel(GOALS));
                        } else if (position.equals("arriere")) {
                             nameComboBox.setModel(new DefaultComboBoxModel(ARRIERES));
                        } else if (position.equals("milieu")) {
                             nameComboBox.setModel(new DefaultComboBoxModel(MILIEUX));
                        } else if (position.equals("avant")) {
                             nameComboBox.setModel(new DefaultComboBoxModel(AVANTS));
                        } else {
                             nameComboBox.setModel(new DefaultComboBoxModel());
                        return nameComboBox;
              add(new JScrollPane(table), BorderLayout.CENTER);
         public static void main(String[] args) {
              try {
                   UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
              } catch (Exception e) {
                   e.printStackTrace();
              final JFrame frame = new JFrame(FootballTable.class.getName());
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setContentPane(new FootballTable());
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        frame.setSize(400, 300);
                        frame.show();
    }Sorry for the French words, I have no idea how they are called in english (and too lazy to search).
    There is another solution. You also can override the table's prepareEditor method and add the relevant code before returning the Component.

  • Select for update that doesn't return any rows

    Are there any odd side-effects that may occur if a select for update that returns no results is never committed? I wouldn't think there are, but I'm not sure if there would be some kind of overhead or unforeseen consequences. This isn't a terribly important question, but it's come up in some coding I've done and I've not been able to find any documentation addressing it.

    A select for update only locks rows that meet the predicate specified in the where clause. So, if the query returns no rows, no rows are locked.
    session1> SELECT * FROM t;
            ID DESCR
             1 Un
             5 One
             2 THIS IS WA
    session1> SELECT * FROM t
      2  WHERE id = 11 FOR UPDATE;
    no rows selectedA second session can update rows in the table
    session2> UPDATE t
      2  SET descr = 'One'
      3  WHERE id = 1;
    1 row updated.John
    Edited by: John Spencer on Jan 7, 2009 1:36 PM
    I just realized that, although you can do updates on the table after the select fo update that returns no rows, you cannot do DDL operations liike a truncate. Unless the session that does the select for update either ends the transaction (i.e. commit or rollback) or ends the session DDL operations will fail.

  • How to utilize index in selection statement

    hi
    how to utilize index in selection statement and how is it reduces performance whether another alternative is there to reduce performance .
    thanks

    Hi Suresh,
    For each SQL statement, the database optimizer determines the strategy for accessing data records. Access can be with database indexes (index access), or without database indexes (full table scan).The cost-based database optimizer determines the access strategy on the basis of:
    *Conditions in the WHERE clause of the SQL statement
    *Database indexes of the table(s) affected
    *Selectivity of the table fields contained in the database indexes
    *Size of the table(s) affected
    *The table and index statistics supply information about the selectivity of table fields, the selectivity of combinations of table fields, and table size.     Before a database access is performed, the database optimizer cannot calculate the exact cost of a database access. It uses the information described above to estimate the cost of the database access.The optimization calculation is the amount by which the data blocks to be read (logical read accesses) can be reduced. Data blocks show the level of detail in which data is written to the hard disk or read from the hard disk.
    <b>Inroduction to Database Indexes</b>
    When you create a database table in the ABAP Dictionary, you must specify the combination of fields that enable an entry within the table to be clearly identified. Position these fields at the top of the table field list, and define them as key fields.
    After activating the table, an index is created (for Oracle, Informix, DB2) that consists of all key fields. This index is called a primary index. The primary index is unique by definition. As well as the primary index, you can define one or more secondary indexes for a table in the ABAP Dictionary, and create them on the database. Secondary indexes can be unique or non-unique. Index records and table records are organized in data blocks.
    If you dispatch an SQL statement from an ABAP program to the database, the program searches for the data records requested either in the database table itself (full table scan) or by using an index (index unique scan or index range scan). If all fields requested are found in the index using an index scan, the table records do not need to be accessed.
    A data block shows the level of detail in which data is written to the hard disk or read from the hard disk. Data blocks may contain multiple data records, but a single data record may be spread across several data blocks.
    Data blocks can be index blocks or table blocks. The database organizes the index blocks in the form of a multi-level B* tree. There is a single index block at root level, which contains pointers to the index blocks at branch level. The branch blocks contain either some of the index fields and pointers to index blocks at leaf level, or all index fields and a pointer to the table records organized in table blocks. The index blocks at leaf level contain all index fields and pointers to the table records from the table blocks.
    The pointer that identifies one or more table records has a specific name. It is called, for example, ROWID for Oracle databases. The ROWID consists of the number of the database file, the number of the table block, and the row number within the table block.
    The index records are stored in the index tree and sorted according to index field. This enables accelerated access using the index. The table records in the table blocks are not sorted.
    An index should not consist of too many fields. Having a few very selective fields increases the chance of reusability, and reduces the chance of the database optimizer selecting an unsuitable access path.
    <b>Index Unique Scan</b>
    If, for all fields in a unique index (primary index or unique secondary index), WHERE conditions are specified with '=' in the WHERE clause, the database optimizer selects the access strategy index unique scan.
    For the index unique scan access strategy, the database usually needs to read a maximum of four data blocks (three index blocks and one table block) to access the table record.
    <b><i>select * from VVBAK here vbeln = '00123' ......end select.</i></b>
    In the SELECT statement shown above, the table VVBAK is accessed. The fields MANDT and VBELN form the primary key, and are specified with '=' in the WHERE clause. The database optimizer therefore selects the index unique scan access strategy, and only needs to read four data blocks to find the table record requested.
    <b>Index Range Scan</b>
    <b><i>select * from VVBAP here vbeln = '00123' ......end select.</i></b>
    In the example above, not all fields in the primary index of the table VVBAP (key fields MANDT, VBELN, POSNR) are specified with '=' in the WHERE clause. The database optimizer checks a range of index records and deduces the table records from these index records. This access strategy is called an index range scan.
    To execute the SQL statement, the DBMS first reads a root block (1) and a branch block (2). The branch block contains pointers to two leaf blocks (3 and 4). In order to find the index records that fulfill the criteria in the WHERE clause of the SQL statement, the DBMS searches through these leaf blocks sequentially. The index records found point to the table records within the table blocks (5 and 6).
    If index records from different index blocks point to the same table block, this table block must be read more than once. In the example above, an index record from index block 3 and an index record from index block 4 point to table records in table block 5. This table block must therefore be read twice. In total, seven data blocks (four index blocks and three table blocks) are read.
    The index search string is determined by the concatenation of the WHERE conditions for the fields contained in the index. To ensure that as few index blocks as possible are checked, the index search string should be specified starting from the left, without placeholders ('_' or %). Because the index is stored and sorted according to the index fields, a connected range of index records can be checked, and fewer index blocks need to be read.
    All index blocks and table blocks read during an index range scan are stored in the data buffer at the top of a LRU (least recently used) list. This can lead to many other data blocks being forced out of the data buffer. Consequently, more physical read accesses become necessary when other SQL statements are executed
    <b>DB Indexex :Concatenation</b>
         In the concatenation access strategy, one index is reused. Therefore, various index search strings also exist. An index unique scan or an index range scan can be performed for the various index search strings. Duplicate entries in the results set are filtered out when the search results are concatenated.
    <i><b>Select * from vvbap where vbeln in ('00123', '00133', '00134').
    endselect.</b></i>
    In the SQL statement above, a WHERE condition with an IN operation is specified over field VBELN. The fields MANDT and VBELN are shown on the left of the primary index. Various index search strings are created, and an index range scan is performed over the primary index for each index search string. Finally, the result is concatenated.
    <b>Full Table Scan</b>
    <b><i>select * from vvbap where matnr = '00015'.
    endselect</i></b>
    If the database optimizer selects the full table scan access strategy, the table is read sequentially. Index blocks do not need to be read.
    For a full table scan, the read table blocks are added to the end of an LRU list. Therefore, no data blocks are forced out of the data buffer. As a result, in order to process a full table scan, comparatively little memory space is required within the data buffer.
    The full table scan access strategy is very effective if a large part of a table (for example, 5% of all table records) needs to be read. In the example above, a full table scan is more efficient than access using the primary index.
    <i><b>In Brief</b></i>
    <i>Index unique scan:</i> The index selected is unique (primary index or unique secondary index) and fully specified. One or no table record is returned. This type of access is very effective, because a maximum of four data blocks needs to be read.
    <i>Index range scan:</i> The index selected is unique or non-unique. For a non-unique index, this means that not all index fields are specified in the WHERE clause. A range of the index is read and checked. An index range scan may not be as effective as a full table scan. The table records returned can range from none to all.
    <i>Full table scan:</i> The whole table is read sequentially. Each table block is read once. Since no index is used, no index blocks are read. The table records returned can range from none to all.
    <i>Concatenation:</i> An index is used more than once. Various areas of the index are read and checked. To ensure that the application receives each table record only once, the search results are concatenated to eliminate duplicate entries. The table records returned can range from none to all.
    Regards,
    Balaji Reddy G
    ***Rewards if answers are helpful

  • Which system field returns the number of records returned after a select?

    Which system field returns the number of records returned after a select?
    a) sy-index
    b) sy-recno
    c) sy-lncnt
    d) sy-dbcnt
    e) sy-tabix

    Hi,
       SY-DBCNT
    Regards,
    Prashant

  • How to get all the index of "selected rows" in table control?

    Hi Gurus,
    I have a table control, wherein I need to get selected row so that I can get its respective TABIX.
    I know that the event for capturing selected row is in PAI.
    I also ensure that the w/ selColumn name in my screenpainter is exactly the same as my declaration in ABAP.
    TOP INCLUDE
    YPES: BEGIN OF Y_ZQID_CHECK,
            IDNUM           TYPE ZQID_CHECK-IDNUM,
            WERKS           TYPE ZQID_CHECK-WERKS,
            MATNR           TYPE ZQID_CHECK-MATNR,
            LICHA           TYPE ZQID_CHECK-LICHA,
            LIFNR           TYPE ZQID_CHECK-LIFNR,
            ECOA_S          TYPE ZQID_CHECK-ECOA_S,
            ID_STAT         TYPE ZQID_CHECK-ID_STAT,
            ID_DATE         TYPE ZQID_CHECK-ID_DATE,
            FLAG_MAILCOA(1) TYPE C,
            MARK(1)         TYPE C, "Name of w/ SelColumn in ScreenPainter: T_ZQIDCHECK_DISCH-MARK
           END   OF Y_ZQID_CHECK.
    DATA: T_ZQIDCHECK_DISCH TYPE STANDARD TABLE OF Y_ZQID_CHECK WITH HEADER LINE.
    PAI
    PROCESS AFTER INPUT.
    * MODULE USER_COMMAND_9004.
    LOOP AT T_ZQIDCHECK_DISCH.
      MODULE READ_TC_DISCH .
    ENDLOOP.
    module READ_TC_DISCH input.
      DATA: W_LINE_SEL TYPE SY-STEPL,
                  W_TABIX    LIKE SY-TABIX.
      GET CURSOR LINE W_LINE_SEL.
      W_TABIX = TC_ID_ONLY-TOP_LINE + w_LINE_SEL - 1.
      MODIFY T_ZQIDCHECK_DISCH INDEX TC_ID_ONLY-current_line.
    If I am selecting single row, I can properly get the selected index via debug.
    BUG:
    When I'm selecting multiple rows in table control, only the last row is always being read inside the loop of my table control.
    Please see the screenshot.
    [url]http://img268.imageshack.us/img268/5739/tcselectedrows.jpg[url]
    Notice in the debug screenshot, even if it's just in the 1st loop of table control, it automatically gets the 4th table control index, instead of the 2nd one.
    Helpful inputs will be appreciated.
    Thanks.
    Jaime
    Edited by: Jaime Cabanban on Dec 9, 2009 3:16 PM

    Hi,
    Are you sure that you have selected multiple line for tablecontrol in the property window of the tablecontrol.
    Flowlogic.
    LOOP WITH CONTROL TC_01.
         Module Get_Marked.
    ENDLOOP.
    Module Pool
    Module Get_Marked.
    read the data from the internal table where mark  = 'X'.
    this should give you only selected records.
    Endmodule.
    Kindly check the tablecontrol property.
    Regards,
    Ranjith Nambiar

  • How can I limit the number of rows returned by a select stat

    How can I limit the number of rows returned by a select
    statement. I have a query where I return the number of stores
    that are located in a given area.. I only want to return the
    first twenty-five stores. In some instances there may be over
    200 stores in a given location.
    I know is SQL 7 that I can set the pagesize to be 25....
    Anything similiar in Oracle 8i?
    null

    Debbie (guest) wrote:
    : Chad Nale (guest) wrote:
    : : How can I limit the number of rows returned by a select
    : : statement. I have a query where I return the number of
    : stores
    : : that are located in a given area.. I only want to return the
    : : first twenty-five stores. In some instances there may be
    : over
    : : 200 stores in a given location.
    : : I know is SQL 7 that I can set the pagesize to be 25....
    : : Anything similiar in Oracle 8i?
    : If you are in Sql*Plus, you could add the statement
    : WHERE rownum <= 25
    : Used together with an appropriate ORDER BY you
    : could get the first 25 stores.
    Watch out. ROWNUM is run before ORDER BY so this would only
    order the 25 selected
    null

  • How to get the index of selected values in SelectManyChoice...

    How to get the index of selected values in SelectManyChoice... the value which i get is coming when i submit the value second time

    By using the given code i get the value of the selected indices, but problem here is i get the value when it get submits at the second time... First time the length of that int array is 0.
    Second time it shows the value two times (i.e) First time submitted value and the second time submitted value. After that it works fine.. I have problem while clicking first time only..
    The Following error also raises.. One multiselect is dependent on other multiselect.
    DF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase PROCESS_VALIDATIONS 3
    java.lang.ArrayIndexOutOfBoundsException: 6
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlListBinding.findObjectFromIndex(FacesCtrlListBinding.java:334)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlListBinding.getInputValue(FacesCtrlListBinding.java:199)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.internalGet(JUCtrlValueBinding.java:2416)
         at oracle.jbo.uicli.binding.JUCtrlListBinding.internalGet(JUCtrlListBinding.java:3717)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlListBinding.internalGet(FacesCtrlListBinding.java:500)
         at oracle.adf.model.binding.DCControlBinding.get(DCControlBinding.java:749)
         at javax.el.MapELResolver.getValue(MapELResolver.java:164)
         at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
         at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
         at com.sun.el.parser.AstValue.getValue(Unknown Source)
         at com.sun.el.ValueExpressionImpl.getValue(Unknown Source)

  • Oracle insists on using particular index in SELECT -- HELP!!!

    Here's the situation:  Back in November, I wrote a report program that contained the following SELECT statement on SAP table FMIFIIT:
    * Get data from the FMIFIIT table.
      SELECT trbtr
             fmbelnr
             fmbuzei
             fonds
             fistl
             farea
             measure
             fipex
             zhldt
             sgtxt
             grant_nbr
        FROM fmifiit
        INTO TABLE it_fmifiit_data
       WHERE zhldt >= p_bpdte                            AND
             zhldt <= p_epdte                            AND
             fistl IN r_fndctr                           AND
             fistl BETWEEN '4011000000' AND '4013999999' AND
             fonds IN r_fund                             AND
             fipex BETWEEN '500000' AND '599999'         AND
             measure <> 'GRANT RELEVANT'                 AND
             measure IN s_rio                            AND
             wrttp NOT IN ('51','60','81')               AND
             stats = ' '.
    I ran into time-out issues with this statement, so a new index ("Z5") was created on the following fields:  ZHLDT, FISTL, FONDS, and FIPEX.  This was the 11th custom index added to the table.  The program was re-run, the statement picked up the new index, and it ran much faster.  Problem solved.
    Fast-forward to this week.  I wrote a new report program that used a SELECT statement virtually identical to the one above.  It looks like this:
    * Get FMIFIIT data.
      SELECT gjahr
             knbelnr
             knbuzei
             measure
             trbtr
             fmbelnr
             fmbuzei
             fonds
             fistl
             farea
             fipex
             zhldt
             sgtxt
          FROM fmifiit
          INTO TABLE it_fmifiit
       WHERE zhldt >= p_bpdte                    AND
             zhldt <= p_epdte                    AND
             fistl IN r_fndctr                   AND
             fonds IN r_fund                     AND
             fipex BETWEEN '500000' AND '599999' AND
             measure <> 'GRANT RELEVANT'         AND
             measure IN s_rio                    AND
             wrttp NOT IN ('51','60','81')       AND
             stats = ' '.
    Again, the program began running into time-out issues on this statement.  I did a trace using ST05, and I found that the system was choose index "3" (FONDS, FIPEX, FIPOS) instead of the obviously-better "Z5" index created a few months ago.
    I tried all kinds of things to figure out why it was choosing "3" to no avail.  Basis even re-ran statistics on the FMIFIIT table, but that didn't work.  Right now, my only option is to add an Oracle hint to the SELECT statement to force it to use index "Z5".  In our DEV system, I've used SE30 to verify that this definitely improves the timing bottleneck that occurs when "3" is used.
    I've only been an ABAP programmer for a few years now, and this one is technically beyond my knowledge.  I don't know what else to try, and I don't know how to determine why the system keeps choosing the index it does.  It's especially frustrating when the SELECT statement is so similar to the one from above, and in that case, it DOES pick up the "Z5" index.
    Does anyone have any information/strategies/suggestions?  At this point, I'm all ears.
    Thanks so much!
    Dave

    Hi Dave,
    based on the query I cannot share your view that there is an obvious choice.
    In fact the best index choice depends on what your data looks like and how are the In-lists filled.
    Maybe the range conditions are very useful, maybe the in-lists are the most selective criteria.
    As a detailed analysis of this is a bit heavy to be done via this forum, why don't you just implement the hint and live happily with it?
    Since you find your index sensible and have proven that it leads to better performance, you obviously know more about your data than Oracle does by the statistics.
    Now you can either try and learn how the Oracle CBO works (there are notes and books available on this topic) or you just use your workaround although you may not exactly understand the reasons for the problem.
    In general - if this would be a support message - I would ask you to ensure that all parameter recommendations are implemented and all CBO patches are installed.
    Then I'd use the sql-statement data collection script (there's a sap note containing this script - just search for 'sql_id') to gather much of the relevant data.
    And then I'd have to look into the data and figure out what's behind the CBOs decision.
    As you wrote that you're rather on the ABAP side of live this effort may not necessarily be worthwhile when you have a proven workaround at hand.
    regards,
    Lars

  • How to get index of selected image??

    hi all
    I have a set of images that is displayed for the user and when he choose one image click on it and it will do sime action ... these images are stored in an array of images . How can i know the index of selected image ??

    i woul like to append an array of images in the screen and whenever i choose one of this images it link me to the class

  • Random selection of rows from a 2D array then subset both the rows that were selected and those that were not. Please see message below.

    For example, I have a 2D array with 46 rows and 400 columns. I would like to randomly select 46 data rows from the 2D array. By doing the random selection it means that not all individual 46 rows will be selected some rows may appear more than once as there may be some duplicates or triplicates in the random selection. The importan thing is that we will have randomly selected 46 rows of data (no matter that some rows appear more than once). Then I would like to subset these randomly selected 46 data rows (some which will be duplicated, or triplicated, etc.) and then also find and subset the rows that were not selected. Does this make sense? Then i would like to do this say 10 times for this data set. So that then I will have 2 by 10 data sets: the first 10 each with 46 rows and the other 10 with n rows depending on how many WERE NOT randomly selected. i hope that my explanation is clear. I am relatively new to Labview. It is really great so I am getting better! If anyone can help me with this problems it will be great. RVR

    Start by generating randon #s between 0 and 45. Run a for loop X times and in it use the random function, multiply the result by X and round down (-infinity). You can make this into a subVI, which you can reuse later. In the same loop, or in a different one, use Index Array to extract the rows which were selected (wiring the result out of the loop with auto indexing causes it to be rebuilt into a 2D array).
    One possible solution for the second part would be to go over the array of randomly generated numbers in a for loop and use Search 1D Array to find each of the numbers (i). If you get -1, it means the row wasn't selected and you can extract it.
    I hope this puts you on the right path. If not, don't be afraid to ask more.
    To learn more about LV, I suggest you read the LabVIEW user manual. Also, try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
    In addition, I suggest you read the LabVIEW style guide.
    Try to take over the world!

  • UPPER Indexes cause select ERROR!

    I downloaded Oracle 10g and installed it on a windows 2003 server. When I created UPPER indexes on a table, and the table has many rows, SELECT statement failed.
    for example:
    DROP TABLE TestTab;
    CREATE     TABLE     TestTab(
         id          NUMBER(9)     DEFAULT 1 NULL,
         name          VARCHAR2(32)     NULL,
         address          VARCHAR2(64)     NULL,
         PRIMARY     KEY     (id)
    DROP INDEX TestTab_01;
    CREATE     INDEX     TestTab_01 ON TestTab(UPPER(name));
    DROP INDEX TestTab_02;
    CREATE     INDEX     TestTab_02 ON TestTab(UPPER(address));
    create or replace procedure ADDDATA
    IS
    lCount     NUMBER;
    BEGIN
    lCount := 1;
    LOOP
    INSERT INTO TESTTAB VALUES(lCount, TO_CHAR(lCount, '00000'), TO_CHAR(lCount, '00000'));
    lCount := lCount + 1;
    IF lCount >= 80000 THEN
    EXIT;
    END IF;
    END LOOP;
    COMMIT;
    EXCEPTION
    WHEN OTHERS THEN
    ROLLBACK;
    RAISE;
    END;
    EXEC ADDDATA;
    SELECT COUNT(*) FROM TestTab;
    SELECT id FROM TestTab WHERE (UPPER(name) = ' 00100' OR UPPER(name) = ' 00101' OR UPPER(name) = ' 00102'
    OR UPPER(address) = ' 00105' OR UPPER(address) = ' 00106') ORDER BY id;
    ID
    100
    101
    102
    SELECT id FROM TestTab WHERE (UPPER(address) = ' 00105' OR UPPER(address) = ' 00106' OR UPPER(name) = ' 00100' OR UPPER(name) = ' 00101' OR UPPER(name) = ' 00102') ORDER BY id;
    ID
    105
    106
    It looks like that the first index could be used and the second index couldn't be used and indexes caused select errors.

    indexes caused select errors. Which errors ? I did exactly what you posted, and these are the results :
    TEST@db102 SQL> SELECT id FROM TestTab WHERE (UPPER(name) = ' 00100' OR UPPER(name) = ' 00101' OR UPPER(name) = ' 00102'
    OR UPPER(address) = ' 00105' OR UPPER(address) = ' 00106') ORDER BY id;  2
                 ID
                100
                101
                102
                105
                106
    TEST@db102 SQL> SELECT id FROM TestTab WHERE (UPPER(address) = ' 00105' OR UPPER(address) = ' 00106' OR UPPER(name) = ' 00100'
    OR UPPER(name) = ' 00101' OR UPPER(name) = ' 00102') ORDER BY id;
                 ID
                100
                101
                102
                105
                106
    TEST@db102 SQL> select count(*) from testtab;
           COUNT(*)
              79999
    TEST@db102 SQL>                                                                                    

  • How do you select and move more than one bookmark at a time? Shift+Click does not select multiple items that are next to one another in a list because the item

    How do you select and move more than one bookmark at a time?
    Shift+Click does not select multiple items that are next to one another in a list because the items open in firefox before this happens.

    Use the bookmarks library. You may use Shift +Click, and Ctrl + Click to create groupings of selected bookmarks to drag and drop.
    * one method of opening the bookmarks library is keyboard shortcut <br /> Ctrl+Shift+B (Windows)
    *see also [[How to use bookmarks to save and organize your favorite websites]]
    *and [[Use bookmark folders to organize your bookmarks]]

  • How can I change (or select) what is being being used when I share, as the file cover. When I Share lets say "Master File" i want to select a frame that is used as the file cover. So when its on my desktop I see this image as the file icon.

    How can I change (or select) what is being being used when I share, as the file cover. When I Share lets say "Master File" i want to select a frame that is used as the file cover. So when its on my desktop I see this image as the file icon.

    I don't think Finder does this (I've tried).
    iTunes does though. Where you can set artwork or the "poster frame"...
    This may not be what you want but if it helps, I know 2 ways  do this is
    Open the video in QuicktimePlayer7 | View | Set Poster Frame (even then, you might need to save it as .mov (ie in a 'mov container').
    Drag the file into iTunes and set the artwork (as in http://www.dummies.com/how-to/content/adding-album-cover-art-or-images-in-itunes .html)
    From there, iTunes will use that frame as the "poster frame" ie the photo/frame that shows when you browse your videos. Which is what you want, but limited to iTunes.
    When I do either of these above, the frame I set does not show when exploring files in "Finder" (or in the other Explorer tool I use called "Pathfinder").
    So it maybe, that exactly what you want, is not possible.

  • I'm trying to install an update to itunes that downloaded but can't complete installation as its trying to install onto D: drive. I don't have a D drive and i'm not given option of selecting the drive to install on. How can i select the drive that i want

    I'm trying to install itunes but can't complete installation as its trying to install onto F: drive. I don't have a F drive and I'm not given option of selecting the drive to install on. How can I select the drive that i want to install on?

    Hi,
    How do you connect the printer to the XP machine ? If USB, you need to make that machine as a Print server. Please try this:
       http://techtips.salon.com/make-windows-computer-pr​int-server-11914.html
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

Maybe you are looking for

  • IPhone 6 Plus 64 - Facetime Problem

    I bought iPhone 6 plus few days ago in Dubai - UAE. I couldn't make facetime work. Actually I couldn't find it. Is there anyway to make it work?

  • Passing values to a JSP file

    Help! This is a very trivial and simple problem but stupid me couldn't figure out. I am developing a web interface with a database. I retrieved some records with a recordset. Now I am passing the id value to the next jsp file. This is what my code lo

  • Since I downloaded the free upadted version,I cannot cut and paste

    I know that my mouse is working. but this happened since Friday. I tried to change the setting on the mouse but I still am unablea to cut and pasteed

  • Where can I find the font files on my computer?

    I am looking to find where my font files are so that I can use my own fonts for an animation in Blender

  • Creating client

    can anybody tell me the procedure to create another client with the same user in IDES SYSTEM. sapuser-800, sapuser-810? my mail id is [email protected]