Idx column

The index on a table is on three columns - Column 1, 2 and 3.
If I am querying the records from the table using only column 2 in the where clause,
is search done using the index??
select * from table
where col2 = 'x';
will there be a change (or decrease in query time) if i create another index on column 2 alone? I am using 9i.

Hi !
I think that ( but not sure ) so call skip scan is available in later versions and not in 9i.
Creating an index on col2 should increase performance , but it's not necesary.
You should investigate execution plan .. for example
SQL>
SQL> set autotrace traceonly explain
SQL>
SQL>
SQL> select empno,ename from emp;
Execution Plan
Plan hash value: 3956160932
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT  |      |    14 |   140 |     3   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| EMP  |    14 |   140 |     3   (0)| 00:00:01 |
SQL> Only from the execution plan , you can see which index if any , is used
T

Similar Messages

  • Meaning of IDX column, and how to get rid of it

    This may be a dumb question, as I've just downloaded Kodo, but I'm puzzled
    why Kodo looks for an IDX column when I have an existing schema. I can't
    find any reference to this column in the spec.
    package.jdo looks like this:
    <jdo>
    <package name="">
    <class name="Seat" >
    <extension vendor-name="tt" key="table" value="SEAT"/>
    <extension vendor-name="tt" key="pk-column" value="SEAT_ID"/>
    <extension vendor-name="tt" key="lock-column" value="none"/>
    <extension vendor-name="tt" key="class-column" value="none"/>
    <field name="name">
    <extension vendor-name="tt" key="data-column" value="NAME"/>
    </field>
    <field name="rowOrBox">
    <extension vendor-name="tt" key="data-column" value="ROW_OR_BOX"/>
    </field>
    <field name="positionInRow">
    <extension vendor-name="tt" key="data-column" value="POSITION_IN_ROW"/>
    </field>
    </class>
    </package>
    </jdo>
    Kodo generates queries like this:
    SELECT t0.SEAT_ID, t0.IDX, t0.NAME, t0.POSITION_IN_ROW, t0.ROW_OR_BOX FROM
    SEAT t0
    Why is the IDX column necessary when there is a PK?
    Is there any way I can disable this, as I don't want to change my existing
    schema?
    Regards,
    Rod Johnson

    Rod --
    Are you sure you don't have an 'id' field somewhere in your object that
    you fail to declare non-persistent? I ask because column names used by
    Kodo for PK and other values always begin with 'jdo' to prevent naming
    conflicts... therefore a name like 'idx' has to be generated from a field
    of the class in question.

  • To make three tables from one table

    Hi,
    I have created a random table from a big table and now i want to make three tables of same numbers, means each table should contain 1000 records, as the table has random idx column, so i cant divide directly on basis of idx. in addition, i cant create three seperate tbles from main table, as i dont want any duplicate data in those three tables, whcih may occur if i will create each table individually.
    Best regards,

    Table 1.
    create table emp1 as
    select empno,ename,sal--,................
    from(select e.*,row_number() over(order by rowid) rn,count(*) over(order by null) cnt
         from emp e)
    where rn < cnt/3
    Table 2.
    create table emp1 as
    select empno,ename,sal--,................
    from(select e.*,row_number() over(order by rowid) rn,count(*) over(order by null) cnt
         from emp e)
    where rn between cnt/3 and cnt*2/3
    Table 3.
    create table emp1 as
    select empno,ename,sal--,................
    from(select e.*,row_number() over(order by rowid) rn,count(*) over(order by null) cnt
         from emp e)
    where rn > cnt*2/3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • JTable addColumn into original position

    Hi,
    I have wriiten a generic dialog box to allow a user to select the visible columns in a JTable.
    Basically a TableColumnModel is passed to the routine to dynamically create a grid of JCheckBox's using the info from getHeaderValue().
    I create a list of TableColumn's that are in the TableColumnModel so that I can add a removed column back in again.
    My problem is that I cannot add the columns into the required locations.
    In the code below:
    tcm = TableColumnModel
    tc = TableColumn
    col = original position of table column
    public void setColumnStatus(int col, boolean status)
    if (col > -1 && col <= columnNames.length)
    int index = col > tcm.getColumnCount() ? tcm.getColumnCount() : col ;
    if (status)
    tcm.addColumn(tc[col]);
    System.err.println("New Column Index :" + tcm.getColumnIndex(tc[col].getIdentifier()));
    System.err.println("Original Column Index :" + col);
    tcm.moveColumn(tcm.getColumnIndex(tc[col].getIdentifier()), index);
    else
    tcm.removeColumn(tc[col]);
    If I have approached this in the wrong way, I would appreciate some pointers in the right direction.
    Things would be so much easier if they would have implemented an isVisible for TableColumnModel.
    Regards
    Chris

    I can't think of a reference that would be appropriate since I made the solution up during a few quiet minutes.
    I suppose the closest analogy I can imagine at the moment is that of a SortableTableModel (stay with me for this). The sortable table model wraps a table model and reorders its rows without changing the underlying model. This has proven quite effective in the past and is quite easy to use. You're right, though, the concept can be quite confusing.
    Think of the table model being transformed by the sortable table model like this:
    ORIGINAL TABLE MODEL     SORTABLE TABLE MODEL
    1. goodbye               3. adios
    2. see ya                1. goodbye
    3. adios                 2. see ya
    4. ta ta                 4. ta taAll the sortable table model does is maintain a mapping from its row numbers to the wrapped model's row numbers (ie, row 1 is actually row 3)
    I'll post the complete code at the end so that you can have a good look at it.
    What I'm suggesting is that something similar can be done for the table column model but rather than "reordering" them we actually add/remove them. But not actually add/remove them, just wrap them in something that makes them appear to be added/removed.
    If you'd like me to go further into this then I'd be happy to give it a go.
    import javax.swing.table.AbstractTableModel;
    import javax.swing.table.TableModel;
    import javax.swing.event.TableModelListener;
    import javax.swing.event.TableModelEvent;
    import java.util.Comparator;
    import java.util.ArrayList;
    import java.util.TreeSet;
    import java.util.Iterator;
    import java.util.HashMap;
    * Wrapper for a table model that provides the ability to sort the rows by the values in a particular column.
    * @author Kevin Seal
    public class SortableTableModel extends AbstractTableModel implements TableModelListener
         protected TableModel tableModel;
         protected int[] sortableColumns;
         protected HashMap comparatorMap;
         private int sortColumn;
         private boolean sortAscending;
         private Comparator comparator;
         private int[] fromModelRow;
         private int[] toModelRow;
         private class ComparableValue implements Comparable
              private Object value;
              private int row;
              private ComparableValue(Object value, int row)
                   this.value = value;
                   this.row = row;
              private int getRow()
                   return row;
              private Object getValue()
                   return value;
              public int compareTo(Object obj)
                   ComparableValue c = (ComparableValue)obj;
                   int i;
                   if(comparator == null)
                        if(value == null)
                        i = (c.getValue() == null)?0:-1;
                        else
                             i = ((Comparable)value).compareTo(c.getValue());
                   else
                        i = comparator.compare(value, c.getValue());
                   if(i == 0)
                        i = c.getRow() - row;
                   return sortAscending?i:-i;
         public SortableTableModel(TableModel tableModel, int[] sortableColumns)
              super();
              this.tableModel = tableModel;
                 this.sortableColumns = new int[sortableColumns.length];
              System.arraycopy(sortableColumns, 0, this.sortableColumns, 0, sortableColumns.length);
              comparatorMap = new HashMap();
              sortColumn = -1;
              // If the underlying data changes - we wanna know about it!!
              tableModel.addTableModelListener(this);
         public void setComparator(int column, Comparator comparator)
              if(!isColumnSortable(column))
                   throw new IllegalArgumentException("Cannot set the Comparator for a column that isn't sortable");
              comparatorMap.put(new Integer(column), comparator);
         public int getRowCount()
              return tableModel.getRowCount();
         public int getColumnCount()
              return tableModel.getColumnCount();
         public boolean isColumnSortable(int column)
              for(int idx = 0; idx < sortableColumns.length; idx++)
                   if(sortableColumns[idx] == column)
                        return true;
              return false;
         public void setSorting(int sortColumn, boolean sortAscending)
              if(!isColumnSortable(sortColumn))
                   throw new IllegalArgumentException("Cannot sort by unsortable column: " + sortColumn);
              this.sortColumn = sortColumn;
              this.sortAscending = sortAscending;
              comparator = (Comparator)comparatorMap.get(new Integer(sortColumn));
              calculateSorting();
              fireTableDataChanged();
         public void clearSorting()
              sortColumn = -1;
              calculateSorting();
              fireTableDataChanged();
         public int getSortColumn()
              return sortColumn;
         public boolean isSortAscending()
              return sortAscending;
         protected void calculateSorting()
              if(sortColumn < 0)
                   toModelRow = null;
                   fromModelRow = null;
                   return;
              ArrayList columnValues = new ArrayList(tableModel.getRowCount());
              for(int row = 0; row < tableModel.getRowCount(); row++)
                   columnValues.add(new ComparableValue(tableModel.getValueAt(row, sortColumn), row));
              TreeSet sortedSet = new TreeSet(columnValues);
              toModelRow = new int[sortedSet.size()];
              fromModelRow = new int[sortedSet.size()];
              int idx = 0;
              int row;
              for(Iterator i = sortedSet.iterator(); i.hasNext(); )
                   row = ((ComparableValue)i.next()).getRow();
                   toModelRow[idx] = row;
                   fromModelRow[row] = idx;
                   idx++;
         public int convertToModelRow(int row)
              if((toModelRow == null) || (row >= toModelRow.length))
                   return row;
              return toModelRow[row];
         public int convertFromModelRow(int row)
              if((fromModelRow == null) || (row >= fromModelRow.length))
                   return row;
              return fromModelRow[row];
         public Object getValueAt(int row, int column)
              return tableModel.getValueAt(convertToModelRow(row), column);
         public void setValueAt(Object value, int row, int column)
              tableModel.setValueAt(value, convertToModelRow(row), column);
         public String getColumnName(int column)
              return tableModel.getColumnName(column);
         public Class getColumnClass(int column)
              return tableModel.getColumnClass(column);
         public boolean isCellEditable(int row, int column)
              return tableModel.isCellEditable(convertToModelRow(row), column);
         public void tableChanged(TableModelEvent e)
              calculateSorting();
              // Since this class is essentially a proxy for the table model we propogate the change of data to
              // all of our registered listeners
              // For now we tell them that all data has changed
              // (the mapping between changes in the underlying model and the sorted view should be implemented later)
              fireTableDataChanged();
    }

  • Applescript - coping columns in a new worksheet in Excel 2004

    Dear all,
    I’m new to Applescript and would appreciate a help on the following:
    I'm trying to copy in different worksheets of a new Excel 2004 workbook(New _WB.xls) different columns (blocs of text + data) in the same worksheet (lest’s call it file1 of a workbook named Old_WB.xls). The columns are separated by 2 empty rows.
    I've searched solutions online with no luck.  Can anyone show me how to code the solution of this problem in Applescript?
    Thanks in advance.
    Ghan

    well, then you want something like so:
    tell application "Microsoft Excel"
              open alias "path:to:workbook"
              set x to value of used range of worksheet 1 of workbook 1
    end tell
    set block to {}
    set idx to 1
    repeat with thisLine in x
              if thisLine as list = {"*", "", ""} or thisLine as list = {"", "", ""} then
      -- empty line means end of block; make sure some block has been collected then process
                        if block is not {} then
                                  set rowCount to count of block
                                  tell application "Microsoft Excel"
                                            tell workbook 1
                                                      set nws to make new worksheet at end
                                                      tell nws
                                                                set name to "file" & idx
                                                                set value of range ("A1:C" & rowCount) to block
                                                      end tell
                                            end tell
                                  end tell
                                  set idx to idx + 1
                                  set block to {}
                        end if
                        if thisLine as list = {"*", "", ""} then
      --all done
                                  exit repeat
                        end if
              else
                        copy thisLine to end of block
              end if
    end repeat
    I've used a "*" character o signify the end of data - you'll need to change that to what you use in lines 9 and 25. Be careful that there's nothing else written outside of the data range because the used range command will pick up on it and goof things up.

  • Using a custom itemrenderer in datagrid to update value in the same row but different column/cell

    Here's what I have so far.  I have one datagrid (dg1) with enable drag and another datagrid (dg2) with dropenabled.  Column3 (col3) of dg2 also has a custom intemrenderer that's just a hslider.
    When an item from dg1 is dropped on dg2, a custom popup appears that asks you to use the slider in the popup to set a stress level.  Click ok and dg2 is populated with dg1's item as well as the value you selected from the popup window.  I was also setting a sliderTemp variable that was bound to the itemrender slider to set it but that's obviously causing issues as well where all the itemrenderer sliders will change to the latest value and I don't want that.
    What is needed from this setup is when you click ok from the popup window, the value you choose from the slider goes into dg2 (that's working) AND the intemrenderer slider needs to be set to that value as well.  Then, if you used the intemrenderer slider you can change the numeric value in the adjacent column (col2).   I just dont know how to hook up the itemrenderer slider to correspond with that numeric value (thatds be in col2 on that row);
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600"
                        xmlns:viewStackEffects="org.efflex.mx.viewStackEffects.*" backgroundColor="#FFFFFF" creationComplete="init(event)"
                        xmlns:components="components.*" xmlns:local="*">
         <mx:Script>
              <![CDATA[
                   import mx.binding.utils.ChangeWatcher;
                   import mx.collections.ArrayCollection;
                   import mx.controls.Alert;
                   import mx.controls.TextInput;
                   import mx.core.DragSource;
                   import mx.core.IUIComponent;
                   import mx.events.CloseEvent;
                   import mx.events.DataGridEvent;
                   import mx.events.DragEvent;
                   import mx.events.FlexEvent;
                   import mx.events.ListEvent;
                   import mx.events.SliderEvent;
                   import mx.events.SliderEventClickTarget;
                   import mx.managers.DragManager;
                   import mx.managers.PopUpManager;
                   import mx.utils.ObjectUtil;
                   [Bindable]private var myDP1:ArrayCollection;
                   [Bindable]private var myDP2:ArrayCollection;
                   [Bindable]public var temp:String;
                   [Bindable]public var slideTemp:Number;
                   private var win:Dialog;     
                   protected function init(event:FlexEvent):void{
                        myDP1 = new ArrayCollection([{col1:'Separation from friends and family due to deployment'},{col1:'Combat'},{col1:'Divorce'},{col1:'Marriage'},
                             {col1:'Loss of job'},{col1:'Death of a comrade'},{col1:'Retirement'},{col1:'Pregnancey'},
                             {col1:'Becoming a parent'},{col1:'Injury from an attack'},{col1:'Death of a loved one'},{col1:'Marital separation'},
                             {col1:'Unwanted sexual experience'},{col1:'Other personal injury or illness'}])
                        myDP2 = new ArrayCollection()
                   protected function button1_clickHandler(event:MouseEvent):void
                        event.preventDefault();
                        if(txt.text != "")
                             Alert.yesLabel = "ok";                    
                             Alert.show("", "Enter Stress Level", 3, this,txtClickHandler);
                   private function image_dragEnter(evt:DragEvent):void {
                        var obj:IUIComponent = IUIComponent(evt.currentTarget);
                        DragManager.acceptDragDrop(obj);
                   private function image_dragDrop(evt:DragEvent):void {
                        var item:Object = dg2.selectedItem;                    
                        var idx:int = myDP2.getItemIndex(item);
                        myDP2.removeItemAt(idx);
                   protected function dg1_changeHandler(event:ListEvent):void
                        temp=event.itemRenderer.data.col1;     
                   protected function dg2_dragDropHandler(event:DragEvent):void
                        event.preventDefault();                         
                        dg2.hideDropFeedback(event as DragEvent)
                        var win:Dialog = PopUpManager.createPopUp(this, Dialog, true) as Dialog;
                        win.btn.addEventListener(MouseEvent.CLICK, addIt);
                        PopUpManager.centerPopUp(win);                              
                        win.mySlide.addEventListener(Event.CHANGE, slideIt);
                   private function txtClickHandler(event:CloseEvent):void {
                        trace("alert");
                        if (event.detail==Alert.YES){
                             myDP2.addItem({label:temp});
                   private function addIt(event:MouseEvent):void{                    
                        myDP2.addItem({col1:temp, col2:slideTemp})
                   private function slideIt(event:SliderEvent):void{                    
                        slideTemp = event.target.value;               
              ]]>
         </mx:Script>
                   <mx:Panel x="10" y="10" width="906" height="481" layout="absolute">
                        <mx:Image x="812" y="367" source="assets/woofie.png" width="64" height="64" dragDrop="image_dragDrop(event);" dragEnter="image_dragEnter(event);"/>
                        <mx:DataGrid x="14" y="81" width="307" height="251" dragEnabled="true" id="dg1" dataProvider="{myDP1}" wordWrap="true" variableRowHeight="true" change="dg1_changeHandler(event)">
                             <mx:columns>
                                  <mx:DataGridColumn headerText="Examples of Life Events" dataField="col1"/>
                             </mx:columns>
                        </mx:DataGrid>
                        <mx:DataGrid x="329" y="81" height="351" width="475" dragEnabled="true" dropEnabled="true" id="dg2"
                                        wordWrap="true" variableRowHeight="true" dataProvider="{myDP2}" editable="true"
                                        dragDrop="dg2_dragDropHandler(event)"  rowHeight="50" verticalGridLines="false" horizontalGridLines="true" >
                             <mx:columns>
                                  <mx:DataGridColumn headerText="Stressor" dataField="col1" width="300" wordWrap="true" editable="false">
                                  </mx:DataGridColumn>
                                  <mx:DataGridColumn headerText="Stress Level" dataField="col2" width="82" editable="false"/>
                                  <mx:DataGridColumn headerText="Indicator" dataField="col3" width="175" paddingLeft="0" paddingRight="0" wordWrap="true" editable="false">
                                       <mx:itemRenderer>
                                            <mx:Component>
                                                 <components:Compslide/>
                                            </mx:Component>
                                       </mx:itemRenderer>
                                  </mx:DataGridColumn>
                             </mx:columns>
                        </mx:DataGrid>                    
                        <mx:Text x="14" y="10" text="The first category of underlying stressors is called Life Events. The list includes both positive and negative changes that individuals experience. Both can be stressful. For example, becoming a parent is usually viewed as a positive thing, but it also involves many new responsibilities that can cause stress. " width="581" height="73" fontSize="12"/>
                        <mx:TextInput x="10" y="380" width="311" id="txt"/>
                        <mx:Text x="10" y="335" text="Add events to your list that are not represented in the example list.  Type and click &quot;Add to List&quot;&#xa;" width="311" height="51" fontSize="12"/>
                        <mx:Button x="234" y="410" label="Add to List" click="button1_clickHandler(event)"/>
                   </mx:Panel>     
    </mx:Application>

    how do i go about doing that?  do i put a change event function in the itemrenderer?  and how would i eventually reference data.col2?

  • How can i extend the filter function to also include an option to select which column to filter on?

    Hi.
    I have built an spry test-page (testing it on my localhost  so i cannot give you direct access to it) here i have an XML file that i show in an dynamic/ repeat table with 5 columns.
    I hvae included an spry filter function to easy filter out records, but the code only allows me to filter on one of the columns.
    I would like to add an extra "select-menu" to define which column the filter should be active for, how can i do that
    Here is the filter code and also the html code for the select-menu and the box to type in what to filter.
    The bold parts is the important parts, i would like the options values from the select menu to be inserted in the filterData function to be able to define which column to do the filtering on.
    var ds1 = new Spry.Data.XMLDataSet("report3.xml", "orders/order", {sortOnLoad: "@id", sortOrderOnLoad: "descending"});
    ds1.setColumnType("date", "date");
    ds1.setColumnType("BUTIKNR", "number");
    ds1.setColumnType("EXTRAFRAKT", "number");
    ds1.setColumnType("job/@idx", "number");
    var jobs = new Spry.Data.NestedXMLDataSet(ds1, "job");
    function FilterData()
        var tf = document.getElementById("filterTF");
        var menu = document.getElementById("searchIdent");
        if (!tf.value)
            // If the text field is empty, remove any filter
            // that is set on the data set.
            ds1.filter(null);
            return;
        // Set a filter on the data set that matches any row
        // that begins with the string in the text field.
        var regExpStr = tf.value;
        if (!document.getElementById("containsCB").checked)
            regExpStr = "^" + regExpStr;
        var regExp = new RegExp(regExpStr, "i");
        var filterFunc = function(ds, row, rowNumber)
            var str = row["@id"];
            if (str && str.search(regExp) != -1)
                return row;
            return null;
        ds1.filter(filterFunc);
    function StartFilterTimer()
        if (StartFilterTimer.timerID)
            clearTimeout(StartFilterTimer.timerID);
        StartFilterTimer.timerID = setTimeout(function() { StartFilterTimer.timerID = null; FilterData(); }, 100);
    html:
                <select name="searchIdent" size="1" id="searchIdent">
                    <option value="@id" selected="selected">ID</option>
                    <option value="date">DATUM</option>
                    <option value="time">TID</option>
                    <option value="BUTIKNR">BUTIK</option>
                    <option value="REF">REFERENS</option>
                  </select>
              <input type="text" id="filterTF" onkeyup="StartFilterTimer();" />
    Contains:
      <input type="checkbox" id="containsCB" /></td>
    Thanks in advance.
    //Rickard H

    Now it works, i had to do it like this:
        var filterFunc = function(ds, row, rowNumber)
            var str = row["@id"];
            if (str && str.search(regExp) != -1)
                return row;
            var str1 = row["date"];
            if (str1 && str1.search(regExp) != -1)
                return row;
            var str2 = row["time"];
            if (str2 && str2.search(regExp) != -1)
                return row;
            var str3 = row["BUTIKNR"];
            if (str3 && str3.search(regExp) != -1)
                return row;
            var str4 = row["REF"];
            if (str4 && str4.search(regExp) != -1)
                return row;
            return null;
    I also had to remove the line "ds1.setColumnType("BUTIKNR", "number");" from the code, otherwise it would not search at all (only searches string types?).

  • Sql query slowness due to rank and columns with null values:

        
    Sql query slowness due to rank and columns with null values:
    I have the following table in database with around 10 millions records:
    Declaration:
    create table PropertyOwners (
    [Key] int not null primary key,
    PropertyKey int not null,    
    BoughtDate DateTime,    
    OwnerKey int null,    
    GroupKey int null   
    go
    [Key] is primary key and combination of PropertyKey, BoughtDate, OwnerKey and GroupKey is unique.
    With the following index:
    CREATE NONCLUSTERED INDEX [IX_PropertyOwners] ON [dbo].[PropertyOwners]    
    [PropertyKey] ASC,   
    [BoughtDate] DESC,   
    [OwnerKey] DESC,   
    [GroupKey] DESC   
    go
    Description of the case:
    For single BoughtDate one property can belong to multiple owners or single group, for single record there can either be OwnerKey or GroupKey but not both so one of them will be null for each record. I am trying to retrieve the data from the table using
    following query for the OwnerKey. If there are same property rows for owners and group at the same time than the rows having OwnerKey with be preferred, that is why I am using "OwnerKey desc" in Rank function.
    declare @ownerKey int = 40000   
    select PropertyKey, BoughtDate, OwnerKey, GroupKey   
    from (    
    select PropertyKey, BoughtDate, OwnerKey, GroupKey,       
    RANK() over (partition by PropertyKey order by BoughtDate desc, OwnerKey desc, GroupKey desc) as [Rank]   
    from PropertyOwners   
    ) as result   
    where result.[Rank]=1 and result.[OwnerKey]=@ownerKey
    It is taking 2-3 seconds to get the records which is too slow, similar time it is taking as I try to get the records using the GroupKey. But when I tried to get the records for the PropertyKey with the same query, it is executing in 10 milliseconds.
    May be the slowness is due to as OwnerKey/GroupKey in the table  can be null and sql server in unable to index it. I have also tried to use the Indexed view to pre ranked them but I can't use it in my query as Rank function is not supported in indexed
    view.
    Please note this table is updated once a day and using Sql Server 2008 R2. Any help will be greatly appreciated.

    create table #result (PropertyKey int not null, BoughtDate datetime, OwnerKey int null, GroupKey int null, [Rank] int not null)Create index idx ON #result(OwnerKey ,rnk)
    insert into #result(PropertyKey, BoughtDate, OwnerKey, GroupKey, [Rank])
    select PropertyKey, BoughtDate, OwnerKey, GroupKey,
    RANK() over (partition by PropertyKey order by BoughtDate desc, OwnerKey desc, GroupKey desc) as [Rank]
    from PropertyOwners
    go
    declare @ownerKey int = 1
    select PropertyKey, BoughtDate, OwnerKey, GroupKey
    from #result as result
    where result.[Rank]=1
    and result.[OwnerKey]=@ownerKey
    go
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Redundant X in the column name

    Hi !
    I'm trying to insert object into Oracle DB.
    The object's class has 'id' data member mapped on table primary key also
    named 'ID'.
    The problem is that in the INSERT SQL statement generated by KODO 'ID' table
    column replaced by 'IDX' table column. What is the reason for this?
    Thanks a lot for help and cooperation,
    Alex.
    P.S. Here is the .jdo:
    <?xml version="1.0" encoding="UTF-8"?>
    <!--
    This file is auto-generated by the
    com.solarmetric.modules.integration.ant.JDODoclet ant task.
    Bear in mind that any changes to this file will be overwritten
    if the task is re-run.
    -->
    <jdo>
    <package name="service">
    <class name="Service" identity-type="application"
    objectid-class="Service$Id" requires-extent="true" >
    <extension vendor-name="kodo" key="table"
    value="SERVICE" />
    <extension vendor-name="kodo" key="pk-column"
    value="ID" />
    <extension vendor-name="kodo" key="class-column"
    value="none" />
    <extension vendor-name="kodo" key="lock-column"
    value="none" />
    <field name="activationDate">
    <extension vendor-name="kodo" key="data-column"
    value="ACTIVATION_DATE" />
    </field>
    <field name="description">
    <extension vendor-name="kodo" key="data-column"
    value="DESCRIPTION" />
    <extension vendor-name="kodo" key="column-length"
    value="240" />
    </field>
    <field primary-key="true" name="id">
    </field>
    <field name="name">
    <extension vendor-name="kodo" key="data-column"
    value="NAME" />
    <extension vendor-name="kodo" key="column-length"
    value="50" />
    </field>
    <field name="registrationDate">
    <extension vendor-name="kodo" key="data-column"
    value="REGISTRATION_DATE" />
    </field>
    <field name="status">
    <extension vendor-name="kodo" key="data-column"
    value="STATUS_ID" />
    </field>
    <field name="subscriber">
    <extension vendor-name="kodo" key="data-column"
    value="SUBSCRIBER_ID" />
    </field>
    <field name="type">
    <extension vendor-name="kodo" key="data-column"
    value="SERVICE_TYPE" />
    </field>
    </class>
    </package>
    </jdo>
    begin 666 Service.jdo
    M/#]X;6P@=F5R<VEO;CTB,2XP(B!E;F-O9&EN9STB551&+3@B/SX*/"$M+0H)
    M5&AI<R!F:6QE(&ES(&%U=&\M9V5N97)A=&5D(&)Y('1H90H)8V]M+G-O;&%R
    M;65T<FEC+FUO9'5L97,N:6YT96=R871I;VXN86YT+DI$3T1O8VQE="!A;G0@
    M=&%S:RX*"4)E87(@:6X@;6EN9"!T:&%T(&%N>2!C:&%N9V5S('1O('1H:7,@
    M9FEL92!W:6QL(&)E(&]V97)W<FET=&5N"@EI9B!T:&4@=&%S:R!I<R!R92UR
    M=6XN"BTM/@H\:F1O/@H)/'!A8VMA9V4@;F%M93TB<V5R=FEC92(^"@D)/&-L
    M87-S(&YA;64](E-E<G9I8V4B(&ED96YT:71Y+71Y<&4](F%P<&QI8V%T:6]N
    M(B!O8FIE8W1I9"UC;&%S<STB4V5R=FEC921397)V:6-E260B(')E<75I<F5S
    M+65X=&5N=#TB=')U92(@/@H)"0D\97AT96YS:6]N('9E;F1O<BUN86UE/2)K
    M;V1O(B!K97D](G1A8FQE(@H)"0D)=F%L=64](E-%4E9)0T4B("\^"@D)"3QE
    M>'1E;G-I;VX@=F5N9&]R+6YA;64](FMO9&\B(&ME>3TB<&LM8V]L=6UN(@H)
    M"0D)=F%L=64](DE$(B O/@H)"0D\97AT96YS:6]N('9E;F1O<BUN86UE/2)K
    M;V1O(B!K97D](F-L87-S+6-O;'5M;B(*"0D)"79A;'5E/2)N;VYE(B O/@H)
    M"0D\97AT96YS:6]N('9E;F1O<BUN86UE/2)K;V1O(B!K97D](FQO8VLM8V]L
    M=6UN(@H)"0D)=F%L=64](FYO;F4B("\^"@D)"3QF:65L9"!N86UE/2)A8W1I
    M=F%T:6]N1&%T92(^"@D)"0D\97AT96YS:6]N('9E;F1O<BUN86UE/2)K;V1O
    M(B!K97D](F1A=&$M8V]L=6UN(@H)"0D)"79A;'5E/2)!0U1)5D%424].7T1!
    M5$4B("\^"@D)"3PO9FEE;&0^"@D)"3QF:65L9"!N86UE/2)D97-C<FEP=&EO
    M;B(^"@D)"0D\97AT96YS:6]N('9E;F1O<BUN86UE/2)K;V1O(B!K97D](F1A
    M=&$M8V]L=6UN(@H)"0D)"79A;'5E/2)$15-#4DE05$E/3B(@+SX*"0D)"3QE
    M>'1E;G-I;VX@=F5N9&]R+6YA;64](FMO9&\B(&ME>3TB8V]L=6UN+6QE;F=T
    M:"(*"0D)"0EV86QU93TB,C0P(B O/@H)"0D\+V9I96QD/@H)"0D\9FEE;&0@
    M<')I;6%R>2UK97D](G1R=64B(&YA;64](FED(CX*"0D)/"]F:65L9#X*"0D)
    M/&9I96QD(&YA;64](FYA;64B/@H)"0D)/&5X=&5N<VEO;B!V96YD;W(M;F%M
    M93TB:V]D;R(@:V5Y/2)D871A+6-O;'5M;B(*"0D)"0EV86QU93TB3D%-12(@
    M+SX*"0D)"3QE>'1E;G-I;VX@=F5N9&]R+6YA;64](FMO9&\B(&ME>3TB8V]L
    M=6UN+6QE;F=T:"(*"0D)"0EV86QU93TB-3 B("\^"@D)"3PO9FEE;&0^"@D)
    M"3QF:65L9"!N86UE/2)R96=I<W1R871I;VY$871E(CX*"0D)"3QE>'1E;G-I
    M;VX@=F5N9&]R+6YA;64](FMO9&\B(&ME>3TB9&%T82UC;VQU;6XB"@D)"0D)
    M=F%L=64](E)%1TE35%)!5$E/3E]$051%(B O/@H)"0D\+V9I96QD/@H)"0D\
    M9FEE;&0@;F%M93TB<W1A='5S(CX*"0D)"3QE>'1E;G-I;VX@=F5N9&]R+6YA
    M;64](FMO9&\B(&ME>3TB9&%T82UC;VQU;6XB"@D)"0D)=F%L=64](E-40515
    M4U])1"(@+SX*"0D)/"]F:65L9#X*"0D)/&9I96QD(&YA;64](G-U8G-C<FEB
    M97(B/@H)"0D)/&5X=&5N<VEO;B!V96YD;W(M;F%M93TB:V]D;R(@:V5Y/2)D
    M871A+6-O;'5M;B(*"0D)"0EV86QU93TB4U5"4T-224)%4E])1"(@+SX*"0D)
    M/"]F:65L9#X*"0D)/&9I96QD(&YA;64](G1Y<&4B/@H)"0D)/&5X=&5N<VEO
    M;B!V96YD;W(M;F%M93TB:V]D;R(@:V5Y/2)D871A+6-O;'5M;B(*"0D)"0EV
    M86QU93TB4T525DE#15]465!%(B O/@H)"0D\+V9I96QD/@H)"3PO8VQA<W,^
    4"@D\+W!A8VMA9V4^"CPO:F1O/@H`
    `
    end

    The class-level "pk-column" extension is used to name the primary key
    column for datastore identity classes. You are using an application
    identity class, so instead you should use the "data-column" extension on
    your primary key field, just like you did for every other field.

  • How to create adf columns at runtime

    Hello
    I want to crete a component which will display results of arbitrary sql command.
    for that purpose I created 'declared component' with custom component class which obtains SQL query from passed attibute and executes it.
    so in my component I have
    public List<String> getColumnNames() {
    if (!loaded) {
    loadData();
    return columnNames;
    public List<List<Object>> getData() {
    if (!loaded) {
    loadData();
    return data;
    and in compDef.jspx following:
    <af:table value="#{component.data}" var="row">
    <af:column headerText="No">
    <af:outputText value="#{row}" />
    </af:column>
    <af:forEach items="#{component.columnNames}" var="col" varStatus="colStatus">
    <af:column headerText="#{col}">
    <af:outputText value="#{row[colStatus.index]}" />
    </af:column>
    </af:forEach>
    </af:table>
    query execution is ok and component.columnNames contains several columns (checked this with af:iterator)
    but it shows only 1 column (with header 'No').
    If I use
    <af:iterator value="#{component.columnNames}" var="col" varStatus="colStatus">
    <af:column headerText="#{col}">
    <af:outputText value="#{row[colStatus.index]}" />
    </af:column>
    </af:iterator>
    it shows 4 columns instead of 2 (and doesn't show any text - that is headerText is empy and all cells are empy too)
    So, can anybody tell me how is it ment to be ? Or where is the mistake ?
    Version: 11g TP 4.

    Thank you for your reply.
    Well, if I set headers to
    xx #{col} xx idx: #{colStatus.index} :idx
    it shows only static text and no EL values.
    (So in output I have 4 headers with text "xx xx idx: :idx")
    Actually if I use suck mix of af:table and af:forEach in usual jspx file (not in component's one) - it works as expected
    that is
    code
    <af:table value="#{Query1.data}" var="row">
    <af:column headerText="xxxxx">
    <af:outputText value="#{row}" />
    </af:column>
    <af:forEach items="#{Query1.columnNames}" var="col" varStatus="colStatus">
    <af:column headerText="#{col}">
    <af:outputText value="#{row [ colStatus.index ] }" />
    </af:column>
    </af:forEach>
    </af:table>
    where Query1 JSF bean performs the same functionality (executes arbitrary SQL query and stores results in data and columnNames)
    works OK.
    (colStatus.index is written in brackets - don't know how to disable its transformation to link, how to write preformatted code here ?)
    Another point that behaviour in component's jspx is a bug - the amount of columns.
    It produces 4 columns instead of 2. And I can't figure why because it doesn't show any information neither in var 'col' nor in varStatus 'colStatus'.
    And if I the query returns 3 columns - number of columns in generated table is 9.
    UPD. Specified behaviour is for af:iterator in the component's jspx. af:forEach produces no columns at all.
    Edited by: olegk on Mar 26, 2009 11:05 AM

  • ORA-01401 error on char column with oracle oci driver

    Hello,
    We found a potential bug in the kodo.jdbc.sql.OracleDictionary class
    shipped as source with Kodo:
    In newer Kodo versions (at least in 3.3.4), the method
    public void setString (PreparedStatement stmnt, int idx, String
    val,          Column col)
    has the following code block:
    // call setFixedCHAR for fixed width character columns to get padding
    // semantics
    if (col != null && col.getType () == Types.CHAR
    && val != null && val.length () != col.getSize ())
    ((OraclePreparedStatement) inner).setFixedCHAR (idx, val);
    This block seems to be intended for select statements but is called on
    inserts/updates also. The latter causes a known problem with the Oracle
    oci driver when settings CHAR columns as FixedCHAR, which reports an
    ORA-01401 error (inserted value too large for column) when definitely no
    column is too long. This does not happen with the thin driver.
    We reproduced this with 8.1.7 and 9.2.0 drivers.
    For us we solved the problem by subclassing OracleDictionary and removing
    the new code block.
    Regards,
    Rainer Meyer
    ELAXY Financial Software & Solutions GmbH & Co. KG

    Rainer-
    I read at
    re:'ORA-01401 inserted value too large for column' - 9i that:
    "This is fixed in Oracle9i Release 2"
    Can you try that version of the driver? Also, does it fail in the Oracle
    10 OCI driver?
    Rainer Meyer wrote:
    Hello,
    We found a potential bug in the kodo.jdbc.sql.OracleDictionary class
    shipped as source with Kodo:
    In newer Kodo versions (at least in 3.3.4), the method
    public void setString (PreparedStatement stmnt, int idx, String
    val,          Column col)
    has the following code block:
    // call setFixedCHAR for fixed width character columns to get padding
    // semantics
    if (col != null && col.getType () == Types.CHAR
    && val != null && val.length () != col.getSize ())
    ((OraclePreparedStatement) inner).setFixedCHAR (idx, val);
    This block seems to be intended for select statements but is called on
    inserts/updates also. The latter causes a known problem with the Oracle
    oci driver when settings CHAR columns as FixedCHAR, which reports an
    ORA-01401 error (inserted value too large for column) when definitely no
    column is too long. This does not happen with the thin driver.
    We reproduced this with 8.1.7 and 9.2.0 drivers.
    For us we solved the problem by subclassing OracleDictionary and removing
    the new code block.
    Regards,
    Rainer Meyer
    ELAXY Financial Software & Solutions GmbH & Co. KG
    Marc Prud'hommeaux
    SolarMetric Inc.

  • Cross column radio group solution using dynamically generated HTML

    I am tasked with creating a screen in Apex matching look and feel of an existing application screen; tabular form, multiple column radio buttons to update a single column value (radio group needs to be row oriented, across multiple columns). I could not find a way to use HTMLDB_ITEM.RADIO_GROUP () function for this due to the radio group being column based, great as a row selector but not for use across columns (each button being a column).
    My first thought was to comprise and use checkboxes via HTMLDB_ITEM.CHECKBOX () for the multiple choices (in each column) and HTMLDB_ITEM.HIDDEN() to hold the chosen value, a JavaScript function for “onClick” event to make the checkboxes in one row act like radio buttons in a radio group. I created a simple application to show the concepts of my solutions …
    SQL looks like this:
    select pk_id, -- f01
    object_to_color, -- f02
    HTMLDB_ITEM.CHECKBOX(11, color_choice,
    'onClick="chkboxAction('||pk_id||', document.wwv_flow.f11, ''RED'')"', 'RED') red,
    HTMLDB_ITEM.CHECKBOX(12, color_choice,
    'onClick="chkboxAction('||pk_id||', document.wwv_flow.f12, ''BLUE'')"', 'BLUE') blue,
    HTMLDB_ITEM.CHECKBOX(13, color_choice,
    'onClick="chkboxAction('||pk_id||', document.wwv_flow.f13, ''GREEN'')"', 'GREEN') green,
    color_choice -- f03
    from objects_to_color
    Columns pk_id and color_choice are set as Show off and Display As Hidden. Note that my HTMLDB_ITEM.CHECKBOX items start with id number 11 (f11 – f13) so as not to conflict with the item id’s Apex will generate on it’s own. I could have used HTMLDB_ITEM functions to create all items and had my own PL/Sql update process.
    This creates a tabular presentation with a column for each color choice as a checkbox, shown checked if that color is initially set.
    The JavaScript function chkboxAction() clears the other checkboxes if a color is selected and stores the color in the hidden item db column for use in Apex Submit processing. Sorry the identation get's lost in the post!
    function chkboxAction (id, ckbx, color) {
    // f01 is pk_id (hidden)
    // f11 is RED checkbox
    // f12 is BLUE checkbox
    // f13 is GREEN checkbox
    // f03 db column color_choice for update (hidden)
    var idx;
    // Find row index using pk_id passed in as id argument.
    for (var i=0; i < document.wwv_flow.f01.length; i++) {
    if (document.wwv_flow.f01.value == id) {
    idx = i;
    i = document.wwv_flow.f01.length;
    if (ckbx(idx).checked == true) {
    // Set hidden color_choice column value to be used in update.
    document.wwv_flow.f03(idx).value = color;
    // Uncheck them all, then reset the one chosen.
    document.wwv_flow.f11(idx).checked = false;
    document.wwv_flow.f12(idx).checked = false;
    document.wwv_flow.f13(idx).checked = false;
    ckbx(idx).checked = true;
    } else {
    // Unchecked so clear color_choice column value to be used in update.
    document.wwv_flow.f03(idx).value = '';
    This works well and, as an aside, has an added feature that the color can be “unchosen” by unchecking a checked checkbox and leaving all checkboxes unchecked. This cannot be done with radio buttons unless a radio button is added as “no color”.
    But what if radio buttons must be used, as in my situation? Here is another solution using custom code to dynamically generate radio buttons for a row based radio group rather than using HTMLDB_ITEM.RADIO_GROUP ().
    select pk_id, -- f01
    object_to_color, -- f02
    '<input type="radio" name="rb'||pk_id||'" id="rb'||pk_id||'_1" value="RED" '||
    decode(color_choice, 'RED', 'CHECKED', '')||
    ' onClick="rbAction('||pk_id||', ''RED'')">' red,
    '<input type="radio" name="rb'||pk_id||'" id="rb'||pk_id||'_2" value="BLUE" '||
    decode(color_choice, 'BLUE', 'CHECKED', '')||
    ' onClick="rbAction('||pk_id||', ''BLUE'')">' blue,
    '<input type="radio" name="rb'||pk_id||'" id="rb'||pk_id||'_3" value="GREEN" '||
    decode(color_choice, 'GREEN', 'CHECKED', '')||
    ' onClick="rbAction('||pk_id||', ''GREEN'')">' green,
    color_choice -- f03
    from objects_to_color
    The pk_id column is used here to ensure a unique name and unique id for the items. In practice a custom api should be used to generate items in this way.
    The JavaScript function is actually simpler for radio buttons because the radio group handles the mutually exclusive logic for choosing a color.
    function rbAction (id, color) {
    // f01 is pk_id (hidden)
    // f03 db column color_choice for update (hidden)
    var idx;
    // Find row index using evaluation_question_id.
    for (var i=0; i < document.wwv_flow.f01.length; i++) {
    if (document.wwv_flow.f01.value == id) {
    idx = i;
    i = document.wwv_flow.f01.length;
    // Set hidden result column referenced in update.
    document.wwv_flow.f03(idx).value = color;
    Now the problem is that on update, Apex will be confused by the custom items and try to post updated values to it’s own internal items – which don’t exist. The result is the very frustrating HTTP 404 - File not found error when apex/wwv_flow.accept executes on Submit. So, the trick is to clear the custom items prior to the update with a simple JavaScript function, then the values show again when the page is rerendered, if you are not branching from the page. The Submit button is changed to call the following function:
    function submit () {
    var items = document.getElementsByTagName("INPUT");
    for (i=0; i< items.length; i++) {
    if (items(i).type == "radio") {
    if (items(i).checked == true)
    items(i).checked = false;
    doSubmit('SUBMIT');
    This technique might have general use when using custom items. Comments or improvements on this?
    See Oracle Apex site: workspace SISK01, app OBJECTS_TO_COLOR

    Just the code for formatting.
    Checkboxes to behave like radio group ...
    SQL ...
    select pk_id,              -- f01
           object_to_color,    -- f02
              HTMLDB_ITEM.CHECKBOX(11, color_choice,
                  'onClick="chkboxAction('||pk_id||', document.wwv_flow.f11, ''RED'')"', 'RED') red,
              HTMLDB_ITEM.CHECKBOX(12, color_choice,
                  'onClick="chkboxAction('||pk_id||', document.wwv_flow.f12, ''BLUE'')"', 'BLUE') blue,
              HTMLDB_ITEM.CHECKBOX(13, color_choice,
                  'onClick="chkboxAction('||pk_id||', document.wwv_flow.f13, ''GREEN'')"', 'GREEN') green,
           color_choice  -- f03
    from objects_to_colorJavaScript ...
    function chkboxAction (id, ckbx, color) {
        // f01 is pk_id (hidden)
        // f11 is RED checkbox
        // f12 is BLUE checkbox
        // f13 is GREEN checkbox
        // f03 db column color_choice for update (hidden)
        var idx;
        // Find row index using pk_id passed in as id argument.
        for (var i=0; i < document.wwv_flow.f01.length; i++) {
           if (document.wwv_flow.f01(i).value == id) {
              idx = i;
              i = document.wwv_flow.f01.length;
        if (ckbx(idx).checked == true) {
          //  Set hidden color_choice column value to be used in update.
          document.wwv_flow.f03(idx).value = color;
          // Uncheck them all, then reset the one chosen.
          document.wwv_flow.f11(idx).checked = false;
          document.wwv_flow.f12(idx).checked = false;
          document.wwv_flow.f13(idx).checked = false;
          ckbx(idx).checked = true;
        } else {
          //  Unchecked so clear color_choice column value to be used in update.
          document.wwv_flow.f03(idx).value = '';
    }Radio button solution ...
    SQL ...
    select pk_id,              -- f01
           object_to_color,    -- f02
           '<input type="radio" name="rb'||pk_id||'" id="rb'||pk_id||'_1" value="RED" '||
                decode(color_choice, 'RED', 'CHECKED', '')||
                ' onClick="rbAction('||pk_id||', ''RED'')">' red,
           '<input type="radio" name="rb'||pk_id||'" id="rb'||pk_id||'_2" value="BLUE" '||
               decode(color_choice, 'BLUE', 'CHECKED', '')||
               ' onClick="rbAction('||pk_id||', ''BLUE'')">' blue,
           '<input type="radio" name="rb'||pk_id||'" id="rb'||pk_id||'_3" value="GREEN" '||
               decode(color_choice, 'GREEN', 'CHECKED', '')||
               ' onClick="rbAction('||pk_id||', ''GREEN'')">' green,
           color_choice  -- f03
    from objects_to_colorJavaScript ...
    function rbAction (id, color) {
        // f01 is pk_id (hidden)
        // f03 db column color_choice for update (hidden)
         var idx;
         // Find row index using evaluation_question_id.
        for (var i=0; i < document.wwv_flow.f01.length; i++) {
           if (document.wwv_flow.f01(i).value == id) {
              idx = i;
              i = document.wwv_flow.f01.length;
        //  Set hidden result column referenced in update.
        document.wwv_flow.f03(idx).value = color;
    function submit () {
      // Clears radio buttons to prevent Apex trying to post and causing page error.
      var items = document.getElementsByTagName("INPUT");
      for (i=0; i< items.length; i++) {
        if (items(i).type == "radio") {
          if (items(i).checked == true)
            items(i).checked = false;
      doSubmit('SUBMIT');
    }

  • Using TRUNC function on partitioned column

    Hi All,
    I have a table as follows:
    STEP1
    CREATE TABLE TEST_PARTITION
    EMP_ID VARCHAR2(10 BYTE),
    CREATE_DT DATE,
    EMP_RGN_NM VARCHAR2(2 BYTE),
    DSPTCH_CNT NUMBER
    PARTITION BY RANGE (CREATE_DT)
    SUBPARTITION BY LIST(EMP_RGN_NM)
    SUBPARTITION TEMPLATE(
    SUBPARTITION RGN_E VALUES ('E') ,
    SUBPARTITION RGN_MW VALUES ('MW') ,
    SUBPARTITION RGN_SW VALUES ('SW') ,
    SUBPARTITION RGN_W VALUES ('W') ,
    SUBPARTITION RGN_SE VALUES ('SE')
    PARTITION aug2008 VALUES LESS THAN (TO_DATE('01-Sep-2008', 'DD-MON-YYYY')),
    PARTITION sep2008 VALUES LESS THAN (TO_DATE('01-Oct-2008', 'DD-MON-YYYY')),
    PARTITION oth VALUES LESS THAN (MAXVALUE)
    ENABLE ROW MOVEMENT;
    STEP 2
    insert into TEST_PARTITION values(1000,TO_DATE('01-Aug-2008 12:02:02', 'DD-MON-YYYY HH:MI:SS'),'SE',10)
    insert into TEST_PARTITION values(1000,TO_DATE('02-Aug-2008 12:02:02', 'DD-MON-YYYY HH:MI:SS'),'SE',20);
    insert into TEST_PARTITION values(1000,TO_DATE('03-Aug-2008 12:02:02', 'DD-MON-YYYY HH:MI:SS'),'SE',0);
    insert into TEST_PARTITION values(1000,TO_DATE('01-sep-2008 12:02:02', 'DD-MON-YYYY HH:MI:SS'),'SE',10);
    insert into TEST_PARTITION values(1000,TO_DATE('02-sep-2008 12:02:02', 'DD-MON-YYYY HH:MI:SS'),'SE',10);
    insert into TEST_PARTITION values(1000,TO_DATE('01-Oct-2008 12:02:02', 'DD-MON-YYYY HH:MI:SS'),'SE',10);
    insert into TEST_PARTITION values(1001,TO_DATE('01-Aug-2008 12:02:02', 'DD-MON-YYYY HH:MI:SS'),'SE',1);
    insert into TEST_PARTITION values(1001,TO_DATE('02-Aug-2008 12:02:02', 'DD-MON-YYYY HH:MI:SS'),'SE',2);
    insert into TEST_PARTITION values(1001,TO_DATE('03-Aug-2008 12:02:02', 'DD-MON-YYYY HH:MI:SS'),'SE',0);
    insert into TEST_PARTITION values(1001,TO_DATE('01-sep-2008 12:02:02', 'DD-MON-YYYY HH:MI:SS'),'SE',10);
    insert into TEST_PARTITION values(1001,TO_DATE('02-sep-2008 12:02:02', 'DD-MON-YYYY HH:MI:SS'),'SE',5);
    insert into TEST_PARTITION values(1001,TO_DATE('01-Oct-2008 12:02:02', 'DD-MON-YYYY HH:MI:SS'),'SE',10);
    insert into TEST_PARTITION values(1001,TO_DATE('02-Oct-2008 12:02:02', 'DD-MON-YYYY HH:MI:SS'),'SE',10);
    STEP 3
    I need to get all the dispatches on 1st of August and hence issue the statement as follows:
    select * from test_partition where TRUNC(CREATE_DT)='01-Aug-2008' and EMP_RGN_NM = 'SE'
    Using a function over the partitioned column, will it avaoid partition pruning? I mean will it scan all the partitiones instead of going to specific partition?
    I need this urgently since we are having a discussion on this in few minutes from now.
    Thanks so much
    Saff

    What about a function based index ?
    SQL> select * from test_partition where TRUNC(CREATE_DT)='01-Aug-2008' and EMP_RGN_NM = 'SE';
    Execution Plan
    | Id  | Operation              | Name           | Rows  | Bytes | Cost (%CPU)| Pstart| Pstop |
    |   0 | SELECT STATEMENT       |                |     1 |    32 |     4   (0)|       |       |
    |   1 |  PARTITION RANGE ALL   |                |     1 |    32 |     4   (0)|     1 |     3 |
    |   2 |   PARTITION LIST SINGLE|                |     1 |    32 |     4   (0)|   KEY |   KEY |
    |   3 |    TABLE ACCESS FULL   | TEST_PARTITION |     1 |    32 |     4   (0)|   KEY |   KEY |
    Note
       - 'PLAN_TABLE' is old version
    SQL> create index idx on test_partition (TRUNC(CREATE_DT));
    Index created.
    SQL> select * from test_partition where TRUNC(CREATE_DT)='01-Aug-2008' and EMP_RGN_NM = 'SE';
    Execution Plan
    | Id  | Operation                          | Name           | Rows  | Bytes | Cost (%CPU)| Pstart| Pstop |
    |   0 | SELECT STATEMENT                   |                |     1 |    32 |     2   (0)|       |       |
    |   1 |  TABLE ACCESS BY GLOBAL INDEX ROWID| TEST_PARTITION |     1 |    32 |     2   (0)| ROWID | ROWID |
    |   2 |   INDEX RANGE SCAN                 | IDX            |     1 |       |     1   (0)|       |       |
    Note
       - 'PLAN_TABLE' is old version
    I need this urgently since we are having a discussion on this in few minutes from now.It is not our problem, but yours.
    Nicolas.

  • Kodo 3.0 migrator does not honor metadata table/column names

    it outputs <field_name>X instead completely disregarding what's in the
    metadata

    Ok running it on classess enhanced with 2.5.2 produces bad names, while
    runnung it on unenhanced classed works all right
    <mapping>
    <package name="peacetech.nci.cs.jdo">
    <class name="Contract">
    <jdbc-class-map type="base" table="CONTRACTX"/>
    <jdbc-version-ind type="version-number" column="JDOLOCKX"/>
    <jdbc-class-ind type="in-class-name" column="JDOCLASSX"/>
    <field name="currentModification">
    <jdbc-field-map type="one-one"
    column.CONTRACTIDX="CONTRACTID_CURRENTMODIFICATIOX"
    column.MODIFICATIONIDX="MODIFICATIONID_CURRENTMODIFICX"/>
    </field>
    <field name="id">
    <jdbc-field-map type="value" column="IDX"/>
    </field>
    <field name="lastModification">
    <jdbc-field-map type="one-one"
    column.CONTRACTIDX="CONTRACTID_LASTMODIFICATIONX"
    column.MODIFICATIONIDX="MODIFICATIONID_LASTMODIFICATIX"/>
    </field>
    <field name="modifications">
    <jdbc-field-map type="many-many"
    element-column.CONTRACTIDX="CONTRACTID_MODIFICATIONSX"
    element-column.MODIFICATIONIDX="MODIFICATIONID_MODIFICAT
    IONSX" ref-column.IDX="ID_JDOIDX" table="CONTRACT_MODIFICATIONSX"/>
    </field>
    </class>
    <class name="Modification">
    <jdbc-class-map type="base" table="MODIFICATIONX"/>
    <jdbc-version-ind type="version-number" column="JDOLOCKX"/>
    <jdbc-class-ind type="in-class-name" column="JDOCLASSX"/>
    <field name="approved">
    <jdbc-field-map type="value" column="APPROVEDX"/>
    </field>
    <field name="contract">
    <jdbc-field-map type="one-one" column.IDX="ID_CONTRACTX"/>
    </field>
    <field name="contractId">
    <jdbc-field-map type="value" column="CONTRACTIDX"/>
    </field>
    <field name="description">
    <jdbc-field-map type="value" column="DESCRIPTIONX"/>
    </field>
    <field name="modificationId">
    <jdbc-field-map type="value" column="MODIFICATIONIDX"/>
    </field>
    <field name="obligations">
    <jdbc-field-map type="many-many"
    element-column.IDX="ID_OBLIGATIONSX"
    ref-column.CONTRACTIDX="CONTRACTID_JDOIDX" ref-column.MODIFICATIONIDX="MOD
    IFICATIONID_JDOIDX" table="MODIFICATION_OBLIGATIONSX"/>
    </field>
    </class>
    <class name="Obligation">
    <jdbc-class-map type="base" table="OBLIGATIONX"/>
    <jdbc-version-ind type="version-number" column="JDOLOCKX"/>
    <jdbc-class-ind type="in-class-name" column="JDOCLASSX"/>
    <field name="amount">
    <jdbc-field-map type="value" column="AMOUNTX"/>
    </field>
    <field name="id">
    <jdbc-field-map type="value" column="IDX"/>
    </field>
    <field name="modification">
    <jdbc-field-map type="one-one"
    column.CONTRACTIDX="CONTRACTID_MODIFICATIONX"
    column.MODIFICATIONIDX="MODIFICATIONID_MODIFICATIONX"/>
    </field>
    </class>
    </package>
    </mapping>
    running on unenhanced classes produces proper metadata (as far as names
    concerned)
    <?xml version="1.0" encoding="UTF-8"?>
    <mapping>
    <package name="peacetech.nci.cs.jdo">
    <class name="Contract">
    <jdbc-class-map type="base" table="CONTRACT"/>
    <jdbc-version-ind type="version-number" column="JDO_LOCK"/>
    <field name="currentModification">
    <jdbc-field-map type="one-one"
    column.CONTRACT_ID="CONTRACT_ID"
    column.MODIFICATION_ID="CURRENT_MODIFICATION_ID"/>
    </field>
    <field name="id">
    <jdbc-field-map type="value" column="CONTRACT_ID"/>
    </field>
    <field name="lastModification">
    <jdbc-field-map type="one-one"
    column.CONTRACT_ID="CONTRACT_ID"
    column.MODIFICATION_ID="LAST_MODIFICATION_ID"/>
    </field>
    <field name="modifications">
    <jdbc-field-map type="one-many"
    ref-column.CONTRACT_ID="CONTRACT_ID" table="MODIFICATION"/>
    </field>
    </class>
    <class name="Modification">
    <jdbc-class-map type="base" table="MODIFICATION"/>
    <jdbc-version-ind type="version-number" column="JDO_LOCK"/>
    <field name="approved">
    <jdbc-field-map type="value" column="IS_APPROVED"/>
    </field>
    <field name="contract">
    <jdbc-field-map type="one-one"
    column.CONTRACT_ID="CONTRACT_ID"/>
    </field>
    <field name="contractId">
    <jdbc-field-map type="value" column="CONTRACT_ID"/>
    </field>
    <field name="description">
    <jdbc-field-map type="value" column="DESCRIPTION"/>
    </field>
    <field name="modificationId">
    <jdbc-field-map type="value" column="MODIFICATION_ID"/>
    </field>
    <field name="obligations">
    <jdbc-field-map type="one-many"
    ref-column.CONTRACT_ID="CONTRACT_ID"
    ref-column.MODIFICATION_ID="MODIFICATION_ID" table="OBLIGATION"/>
    </field>
    </class>
    <class name="Obligation">
    <jdbc-class-map type="base" table="OBLIGATION"/>
    <jdbc-version-ind type="version-number" column="JDO_LOCK"/>
    <field name="amount">
    <jdbc-field-map type="value" column="AMOUNT"/>
    </field>
    <field name="id">
    <jdbc-field-map type="value" column="OBLIGATION_ID"/>
    </field>
    <field name="modification">
    <jdbc-field-map type="one-one"
    column.CONTRACT_ID="CONTRACT_ID" column.MODIFICATION_ID="MODIFICATION_ID"/>
    </field>
    </class>
    </package>
    </mapping>
    "Patrick Linskey" <[email protected]> wrote in message
    news:[email protected]...
    Yes; see
    http://solarmetric.com/Software/beta/3.0.0/b1-docs/docs/ref_guide_mapping_factory.html
    for descriptions of the various options.
    The three basic ways to store mapping information are: in metadata
    extensions, in the database, and in separate .mapping files. IMO, storing
    in separate .mapping files is the best -- storing the info in metadata
    makes your metadata get really ugly, and storing it in the db makes it
    relatively hard to modify (at least, until we release our GUI tool...)
    -Patrick
    On Mon, 04 Aug 2003 19:38:16 -0400, Alex Roytman wrote:
    can mapping files be used as an alternative to jdo extensions to
    complement standard jdo metadata or it is strictly for mapping tool? in
    other words can I have a standard jdo metadata with no extensions plus a
    mapping file to replace jdo metadata with extensions if yes, what is
    your primary format two file (jdo + mapping file) or one file jdo with
    extensions--
    Patrick Linskey
    SolarMetric Inc.
    "Patrick Linskey" <[email protected]> wrote in message
    news:[email protected]...
    Can you post the command that you used to run the conversion? I just ran
    through the conversion process for a small (10 tables or so) schema
    earlier today with no problems.
    -Patrick
    On Mon, 04 Aug 2003 19:31:06 -0400, Alex Roytman wrote:
    it outputs <field_name>X instead completely disregarding what's in the
    metadata--
    Patrick Linskey
    SolarMetric Inc.

  • Oracle 10.2.0.4 Index on timestamp column not used when SYSTIMESTAMP Used.

    Hi,
    I have a table A with a column B timestamp(6). The tables contains around 300000 rows..
    I have created index 'idx' on the column B.
    When i compare column 'B' with systimestamp, it does not use the index, whereas if i compare 'B' with sysdate it uses the index.
    Eg :
    select count(*) from a where b<=sysdate;
    The above used the index 'idx' and executed in 1 second
    select count(*) from a where b<=systimestamp;
    The above does not use the index and executed in 19 seconds.
    Any Clue?
    Thanks in Advance

    Oracle is using Internal functions when you use SYSTIMESTAMP:
    Work around will be to use TO_TIMESTAMP as shown below.. Or define a function based index..
    You can check performance problem querying against a "TIMESTAMP WITH TIME ZONE" column link also
    SQL> create table a(b timestamp(6));
    Table created.
    SQL> insert into a
      2  select systimestamp+(level/24) from dual connect by level <= 30000;
    30000 rows created.
    SQL> commit;
    Commit complete.
    SQL> create index ndx on a(b);
    Index created.
    SQL> explain plan for
      2  select count(*) from a where b <= sysdate;
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3858831102
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |    13 |     1   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE   |      |     1 |    13 |            |          |
    |*  2 |   INDEX RANGE SCAN| NDX  |     1 |    13 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("B"<=SYSDATE@!)
    Note
       - dynamic sampling used for this statement
    18 rows selected.
    SQL> explain plan for
      2  select count(*) from a where b <= systimestamp;
    Explained.
    SQL>  select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3918351354
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |     1 |    13 |    20  (15)| 00:00:01 |
    |   1 |  SORT AGGREGATE    |      |     1 |    13 |            |          |
    |*  2 |   TABLE ACCESS FULL| A    |     1 |    13 |    20  (15)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter(SYS_EXTRACT_UTC(INTERNAL_FUNCTION("B"))<=SYS_EXTRACT_UTC(S
                  YSTIMESTAMP(6)))
    Note
       - dynamic sampling used for this statement
    19 rows selected.
    --"Just tried using TO_TIMESTAMP"
    SQL> explain plan for
      2  select count(*) from a where b <= to_timestamp(systimestamp);
    Explained.
    SQL>
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3858831102
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |     1 |    13 |     2   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE   |      |     1 |    13 |            |          |
    |*  2 |   INDEX RANGE SCAN| NDX  |     4 |    52 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("B"<=TO_TIMESTAMP(TO_CHAR(SYSTIMESTAMP(6))))
    14 rows selected.Edited by: jeneesh on Oct 23, 2012 11:18 AM

Maybe you are looking for

  • Sobre alguns problemas que estou tendo com o mozila que não é somente no meu computador..

    estou achando que isso pode ser caso de processo! no pesquisador do google, quando entra em uma pagina e volta, a tela esta ficando toda branca, estou percebendo que isso não é apenas comigo em outros computadores tmbém está assim, que pode ser algo

  • Mail: missing plug-in

    I cannot seem to be able to view PDF files attached to emails whether at the compose stage and attaching PDFs or at the receive stage with PDF file attached to incoming email. Quick Look works well on PDFs all the same and Save button does show the P

  • Standard Manager going down randomly

    Hi, On our user test system the standard managers will shutdown sporadically and I can not figure out what is causing this issue. Here is a snippet of the standard manager log file from today: APP-FND-01564: ORACLE error 6550 in afpoload Cause: afpol

  • I wiped my ipod when I bought a new pcoperarin windows xp

    Hi I am an aging techno but love my music. I bought a new high end laptop (sony vio duo)and when I installed itunes I hit the button to synch and wham all my songs gone. BUT my ipod still show 2gigabytes used up (out 0f 20) so pretty sure songs are o

  • How do I move and scale my photo for wallpaper?

    When I select a photo, I can't get the move or scale to adjust. It just reverts back to the original.