Example: Table with a fixed row, feedback please
I've done a lot of lurking and posted some questions on this forum, but I haven't contribued very much, so I thought I'd share the solution to a problem I recently had. The need I had was pretty straight forward: I have a row of reference data that I want to keep fixed at the top of a JTable while the user scrolls through any number of additional rows. The examples I've seen on the web, e.g,:
http://access1.sun.com/FAQSets/FixedRowExample.java.html
are either too complex or are overkill for the simple functionality I need.
My solution was to overload my table's HeaderRenderer so that they would contain my extra row of data, in addition to displaying normal header titles. I've provided the FixedRowHeaderRenderer class below, along with a main method to demonstrate the result. Any suggestions or feedback would be appreciated!
import javax.swing.*;
import javax.swing.table.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;
public class FixedRowHeaderRenderer extends DefaultTableCellRenderer {
private Object[] headerData;
private Font headerDataFont;
private Color headerDataBackgroundColor, headerDataForegroundColor;
public FixedRowHeaderRenderer(){
this(null, null, null, null);
public FixedRowHeaderRenderer(Object[] headerData, Font headerDataFont,
Color headerDataForegroundColor, Color headerDataBackgroundColor){
super();
this.headerData = headerData;
this.headerDataFont = headerDataFont;
this.headerDataBackgroundColor = headerDataBackgroundColor;
this.headerDataForegroundColor = headerDataForegroundColor;
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
JPanel panel = new JPanel(new BorderLayout());
if (table != null) {
JTableHeader header = table.getTableHeader();
if (header != null) {
setForeground(header.getForeground());
setBackground(header.getBackground());
setFont(header.getFont());
if(headerData!=null) {
DefaultTableCellRenderer headerCell = new DefaultTableCellRenderer();
headerCell.setForeground(getHeaderDataForegroundColor());
headerCell.setBackground(getHeaderDataBackgroundColor());
headerCell.setFont(getHeaderDataFont());
Object datum = headerData[column];
headerCell.setText((datum == null || datum.toString().length()==0)?
" " : datum.toString());
headerCell.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
panel.add(headerCell, BorderLayout.SOUTH);
setText((value == null) ? "" : value.toString());
setBorder(UIManager.getBorder("TableHeader.cellBorder"));
panel.add(this, BorderLayout.NORTH);
return panel;
public Object[] getHeaderData() {
return headerData;
public void setHeaderData(Object[] headerData) {
this.headerData = headerData;
public void setHeaderData(Vector headerData) {
this.headerData = headerData.toArray();
public Font getHeaderDataFont() {
if(headerDataFont == null) {
return getFont();
return headerDataFont;
public Color getHeaderDataBackgroundColor() {
if(headerDataBackgroundColor == null) {
return getBackground();
return headerDataBackgroundColor;
public Color getHeaderDataForegroundColor() {
if(headerDataForegroundColor == null) {
return getForeground();
return headerDataForegroundColor;
public void setHeaderDataFont(Font font) {
headerDataFont = font;
public void setHeaderDataBackgroundColor(Color color) {
headerDataBackgroundColor = color;
public void setHeaderDataForegroundColor(Color color) {
headerDataForegroundColor = color;
public static void main(String[] args) {
class FixedRowTableDemo extends JFrame {
FixedRowTableDemo() {
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
setSize(Toolkit.getDefaultToolkit().getScreenSize().width/4,
Toolkit.getDefaultToolkit().getScreenSize().height/4);
String a = "a", b = "b", c = "c";
int rowcount = 0;
Object[][] data = new Object[][]{{new Integer(rowcount++),a,b,c},
{new Integer(rowcount++),a,b,c},{new Integer(rowcount++),a,b,c},
{new Integer(rowcount++),a,b,c},{new Integer(rowcount++),a,b,c},
{new Integer(rowcount++),a,b,c},{new Integer(rowcount++),a,b,c},
{new Integer(rowcount++),a,b,c},{new Integer(rowcount++),a,b,c},
{new Integer(rowcount++),a,b,c},{new Integer(rowcount++),a,b,c},
{new Integer(rowcount++),a,b,c},{new Integer(rowcount++),a,b,c},
{new Integer(rowcount++),a,b,c},{new Integer(rowcount++),a,b,c},
{new Integer(rowcount++),a,b,c},{new Integer(rowcount++),a,b,c},
{new Integer(rowcount++),a,b,c},{new Integer(rowcount++),a,b,c},
{new Integer(rowcount++),a,b,c},{new Integer(rowcount++),a,b,c}};
Object[] headers = new Object[]{"rowcount",a,b,c};
Object[] headerData = new Object[]{"",c,b,a};
JTable table = new JTable(data, headers);
table.getTableHeader().setDefaultRenderer(new FixedRowHeaderRenderer(null,
new Font(table.getFont().getName(), Font.ITALIC, table.getFont().getSize()),
Color.yellow, Color.red));
JScrollPane scroll = new JScrollPane(table);
this.getContentPane().add(scroll);
this.show();
((FixedRowHeaderRenderer)table.getTableHeader().getDefaultRenderer()).
setHeaderData(headerData);
FixedRowTableDemo demo = new FixedRowTableDemo();
}
nice! really, really nice!
Similar Messages
-
Hello, i have a table in that table i have a header row which has another table with two header rows
When form spans more then one page on page2 the color and border are showing up outside of table see example below.
Anyone have any ideas how I can fix this?
I am using Livecycle designer ES2 9.***
THanksHi,
If the table spans to Next page then if you want to move whole table to other page then uncheck the allow page breaks with content option which is under Object Tab.
Thanks
Vjay. -
Row Level PPR in Advanced Table with Add More Rows Button
<br>
I have programmatically fired PPR event on MessageChoice. But it is in Advanced Table with
Add More Rows Button. When the value is changed in MessageChoice I Show/Hide Custom LOV
through SPEL like this ${oa.BioEmployeePVO.EmpManagerRender} .
But it is <b>hiding the all the ROWS</b> not just the row where the value has been changed.
I even tried with this code and get NULL for rowReference.
String rowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
In Processrequest()
String pageName = pageContext.getRootRegionCode();
Hashtable params = new Hashtable (1);
params.put ("param1", pageName);
Hashtable paramsWithBinds = new Hashtable(1);
paramsWithBinds.put ("param2",new OADataBoundValueFireActionURL (mcb, "{$AttendeeType}"));
mcb.setFireActionForSubmit ("empPositionChange", params, paramsWithBinds,false, false);
In ProcessFormRequest() {
if ("empPositionChange".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM)))
String rowReference = pageContext.getParameter("param2");
// String rowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
Serializable[] parameters = { rowReference };
am.invokeMethod("handlePositionChangeEvent", parameters);
<br>HI Kumar,
Answer to your last post is "yes".
Now to your doubt regarding the code:
Hi Anna
I am trying to understand your code.
FireAction firePartialAction = new FirePartialAction("fireHideEvent"+(i/noOfTlaColSpan));
HideImgBean.setAttributeValue(PRIMARY_CLIENT_ACTION_ATTR,firePartialAction);
1. What is this i/noOfTlaColSpan ?
:)Forget abt this in your case it should be the event name which u r firing and capturing the it in the PFR.
Like FireAction firePartialAction = new FirePartialAction("YOurEventName");
and in PFR u can capture tht as:
if("YOurEventName".equals(pageContext.getParameter(EVENT_PARAM)))
//your logic to invoke AM method
2. I believe this HideImgBean would be MessageChoice for me?
:)Yep ur right
3. This brcdOhInventoryViewUpdateVOImpl would be the Custom PVO(Extending Seeded Base VO)
I create by adding the transient attributes?
:)Yep ur right
4. I cannot understand this code. Could you explain.
:)Please look at my comments in some of the lines .I have explained wht i am doing
if(updateIter==null)
updateIter[0]= invViewVO.createRowSetIterator("updateIter");//This initViewVo should be ur custom VO object
if(cnt>0)
updateIter[0].setRangeStart(0);
updateIter[0].setRangeSize(cnt);
for(int i=0;i<cnt;i++)
row = (brcdOhInventoryViewUpdateVORowImpl)updateIter[0].getRowAtRangeIndex(i);
String selectFlag=(String)row.invokeMethod("getPartNumber");//This getPartNuber should be replaced by the Prim Key inoke methd of ur VO
if(RowID.equals(selectFlag))
//This is my logic to set the transient attributes based on the msgChoiceBean value ..u have to pass the value when u invoke this method
if(reserveMethod.equals("BINARY"))
System.out.println("In Binary");
Boolean bVal= new Boolean("false");
Serializable sr[]={bVal};
Class []methodParamTypes = { bVal.getClass() };
row.invokeMethod("setshowreservetxt",sr,methodParamTypes);
Boolean bVal1= new Boolean("true");
System.out.println("bVal1"+bVal1);
Serializable sr1[]={bVal1};
Class []methodParamTypes1 = { bVal1.getClass() };
row.invokeMethod("setShowreservemsgchoice",sr1,methodParamTypes1);
break;
In my AM I am doing this. Am i doing right?:)Yep u r right
BioPrescribersPVO is the custom VO(extending seeded base VO).
public void handlePositionChangeEvent(String param)
OAViewObject vo = (OAViewObject)findViewObject("BioPrescribersPVO");
OARow row = (OARow)findRowByRef(rowReference);
if (row != null)
String position = (String)row.getAttribute("AttendeeType");
if (("PRESCRIBER".equals(position)) )
// BioEmpManagerRender is the transient attribute in BioPrescribersPVO.
row.setAttribute("BioEmpManagerRender", Boolean.TRUE);
row.setAttribute("BioPresManagerRender", Boolean.FALSE);
else
row.setAttribute("BioEmpManagerRender", Boolean.FALSE);
row.setAttribute("BioPresManagerRender", Boolean.TRUE);
} // end handlePositionChangeEvent()
// Initializing the custom VO
/*No need to initialize the VO because this is not a PVO(Propeties View object)
U r just using the existing VO and tht vo shloud have a primary key.Tht way u can match the rowref u r getting with the actual row from the View object*/
public void init()
OAViewObject appPropsVO = (OAViewObject)getBioPrescribersPVO();
if (appPropsVO != null)
if (appPropsVO.getFetchedRowCount() == 0)
appPropsVO.setMaxFetchSize(0); appPropsVO.executeQuery();
appPropsVO.insertRow(appPropsVO.createRow());
OARow row = (OARow)appPropsVO.first();
row.setAttribute("RowKey", new Number(1));
handlePositionChangeEvent("");
} // end init()
Thanks
Anna -
SQL Server 2012 Undetected Deadlock in a table with only one row
We have migrated our SQL 2000 Enterprise Database to SQL 2012 Enterprise few days ago.
This is our main database, so most of the applications access it.
The day after the migration, when users started to run tasks, the database access started to experiment a total failure.
That is, all processes in the SQL 2k12 database were in lock with each other. This is a commom case of deadlock, but the Database Engine was unable to detect it.
After some research, we found that the applications were trying to access a very simple table with only one row. This table has a number that is restarted every day and is used to number all the transactions made against the system. So, client
applications start a new transaction, get the current number, increment it by one and commit the transaction.
The only solution we found was to kill all user processes in SQL Server every time this situation occurs (no more than 5 minutes when all clients are accessing the database).
No client application was changed in this migration and this process was working very well for the last 10 years.
The problem is that SQL 2k12 is unable to handle this situation compared to SQL 2k.
It seems to occurs with other tables too, but as this is an "entry table" the problem occurs with it first.
I have searched internet and some suggest some workarounds like using table hints to completely lock the table at the begining of the transaction, but it can't be used to other tables.
Does anyone have heard this to be a problem with SQL 2k12? Is there any fixes to make SQL 2k12 as good as SQL 2k?First off re: "Unfortunatelly, this can't be used in production environment as exclusive table lock would serialize the accesses to tables and there will be other tables that will suffer with this problem."
This is incorrect.
Using a table to generate sequence numbers like this is a bad idea exactly because the access must be serialized. Since you can't switch to a SEQUENCE object, which is the correct solution, the _entire goal_ of this exercise to find a way to properly
serialize access to this table. Using exclusive locking will not be necessary for all the tables; just for the single-row table used for generating sequence values with a cursor.
I converted the sample program to VB.NET:
Public Class Form1
Private mbCancel As Boolean = False
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim soConn As ADODB.Connection
Dim soRst As ADODB.Recordset
Dim sdData As Date
Dim slValue As Long
Dim slDelay As Long
'create database vbtest
'go
' CREATE TABLE [dbo].[ControlNumTest](
' [UltData] [datetime] NOT NULL,
' [UltNum] [int] NOT NULL,
' CONSTRAINT [PK_CorreioNumTeste] PRIMARY KEY CLUSTERED
' [UltData] Asc
' )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [PRIMARY]
' ) ON [PRIMARY]
mbCancel = False
Do
' Configure the Connection object
soConn = New ADODB.Connection
With soConn
.ConnectionString = "Provider=SQLNCLI11;Initial Catalog=vbtest;Data Source=localhost;trusted_connection=yes"
.IsolationLevel = ADODB.IsolationLevelEnum.adXactCursorStability
.Mode = ADODB.ConnectModeEnum.adModeReadWrite
.CursorLocation = ADODB.CursorLocationEnum.adUseServer
.Open()
End With
' Start a new transaction
Call soConn.BeginTrans()
' Configure the RecordSet object
soRst = New ADODB.Recordset
With soRst
.ActiveConnection = soConn
.CursorLocation = ADODB.CursorLocationEnum.adUseServer
.CursorType = ADODB.CursorTypeEnum.adOpenForwardOnly
.LockType = ADODB.LockTypeEnum.adLockPessimistic
.Open("SELECT * FROM dbo.ControlNumTest")
End With
With soRst
sdData = .Fields!UltData.Value ' Read the last Date (LOCK INFO 1: See comments bello
slValue = .Fields!UltNum.Value ' Read the last Number
If sdData <> Date.Now.Date Then ' Date has changed?
sdData = Date.Now.Date
slValue = 1 ' Restart number
End If
.Fields!UltData.Value = sdData ' Update data
.Fields!UltNum.Value = slValue + 1 ' Next number
End With
Call soRst.Update()
Call soRst.Close()
' Ends the transaction
Call soConn.CommitTrans()
Call soConn.Close()
soRst = Nothing
soConn = Nothing
txtUltNum.Text = slValue + 1 ' Display the last number
Application.DoEvents()
slDelay = Int(((Rnd * 250) + 100) / 100) * 100
System.Threading.Thread.Sleep(slDelay)
Loop While mbCancel = False
If mbCancel = True Then
Call MsgBox("The test was canceled")
End If
Exit Sub
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
mbCancel = True
End Sub
End Class
And created the table
CREATE TABLE [dbo].[ControlNumTest](
[UltData] [datetime] NOT NULL,
[UltNum] [int] NOT NULL,
CONSTRAINT [PK_CorreioNumTeste] PRIMARY KEY CLUSTERED
[UltData] Asc
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = on, FILLFACTOR = 80) ON [PRIMARY]
) ON [PRIMARY]
go insert into ControlNumTest values (cast(getdate()as date),1)
Then ran 3 copies of the program and generated the deadlock:
<deadlock>
<victim-list>
<victimProcess id="processf27b1498" />
</victim-list>
<process-list>
<process id="processf27b1498" taskpriority="0" logused="0" waitresource="KEY: 35:72057594039042048 (a01df6b954ad)" waittime="1970" ownerId="3181" transactionname="implicit_transaction" lasttranstarted="2014-02-14T15:49:31.263" XDES="0xf04da3a8" lockMode="X" schedulerid="4" kpid="9700" status="suspended" spid="51" sbid="0" ecid="0" priority="0" trancount="2" lastbatchstarted="2014-02-14T15:49:31.267" lastbatchcompleted="2014-02-14T15:49:31.267" lastattention="1900-01-01T00:00:00.267" clientapp="vbt" hostname="DBROWNE2" hostpid="21152" loginname="NORTHAMERICA\dbrowne" isolationlevel="read committed (2)" xactid="3181" currentdb="35" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128058">
<executionStack>
<frame procname="adhoc" line="1" stmtstart="80" sqlhandle="0x020000008376181f3ad0ea908fe9d8593f2e3ced9882f5c90000000000000000000000000000000000000000">
UPDATE [dbo].[ControlNumTest] SET [UltData]=@Param000004,[UltNum]=@Param000005 </frame>
<frame procname="unknown" line="1" sqlhandle="0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000">
unknown </frame>
</executionStack>
<inputbuf>
(@Param000004 datetime,@Param000005 int)UPDATE [dbo].[ControlNumTest] SET [UltData]=@Param000004,[UltNum]=@Param000005 </inputbuf>
</process>
<process id="processf6ac9498" taskpriority="0" logused="10000" waitresource="KEY: 35:72057594039042048 (a01df6b954ad)" waittime="1971" schedulerid="5" kpid="30516" status="suspended" spid="55" sbid="0" ecid="0" priority="0" trancount="1" lastbatchstarted="2014-02-14T15:49:31.267" lastbatchcompleted="2014-02-14T15:49:31.267" lastattention="1900-01-01T00:00:00.267" clientapp="vbt" hostname="DBROWNE2" hostpid="27852" loginname="NORTHAMERICA\dbrowne" isolationlevel="read committed (2)" xactid="3182" currentdb="35" lockTimeout="4294967295" clientoption1="671156256" clientoption2="128058">
<executionStack>
<frame procname="adhoc" line="1" sqlhandle="0x020000003c6309232ab0edbe0a7790a816a09c4c5ac6f43c0000000000000000000000000000000000000000">
FETCH API_CURSOR0000000000000001 </frame>
<frame procname="unknown" line="1" sqlhandle="0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000">
unknown </frame>
</executionStack>
<inputbuf>
FETCH API_CURSOR0000000000000001 </inputbuf>
</process>
</process-list>
<resource-list>
<keylock hobtid="72057594039042048" dbid="35" objectname="vbtest.dbo.ControlNumTest" indexname="PK_CorreioNumTeste" id="lockff6e6c80" mode="U" associatedObjectId="72057594039042048">
<owner-list>
<owner id="processf6ac9498" mode="S" />
<owner id="processf6ac9498" mode="U" requestType="wait" />
</owner-list>
<waiter-list>
<waiter id="processf27b1498" mode="X" requestType="convert" />
</waiter-list>
</keylock>
<keylock hobtid="72057594039042048" dbid="35" objectname="vbtest.dbo.ControlNumTest" indexname="PK_CorreioNumTeste" id="lockff6e6c80" mode="U" associatedObjectId="72057594039042048">
<owner-list>
<owner id="processf27b1498" mode="U" />
<owner id="processf27b1498" mode="U" />
<owner id="processf27b1498" mode="X" requestType="convert" />
</owner-list>
<waiter-list>
<waiter id="processf6ac9498" mode="U" requestType="wait" />
</waiter-list>
</keylock>
</resource-list>
</deadlock>
It's the S lock that comes from the cursor read that's the villian here. U locks are compatible with S locks, so one session gets a U lock and another gets an S lock. But then the session with an S needs a U, and the session with a U needs an
X. Deadlock.
I'm not sure what kind of locks were taken by this cursor code on SQL 2000, but on SQL 2012, this code is absolutely broken and should deadlock.
The right way to fix this code is to add (UPDLOCK,SERIALIZABLE) to the cursor
.Open("SELECT * FROM dbo.ControlNumTest with (updlock,serializable)")
So each session reads the table with a restrictive lock, and you don't mix S, U and X locks in this transaction. This resolves the deadlock, but requires a code change.
I tried several things that didn't require a code, which did not resolve the deadlock;
1) setting ALLOW_ROW_LOCKS=OFF ALLOW_PAGE_LOCKS=OFF
2) SERIALIZABLE isolation level
3) Switching OleDB providers from SQLOLEDB to SQLNCLI11
Then I replaced the table with a view containing a lock hint:
CREATE TABLE [dbo].[ControlNumTest_t](
[UltData] [datetime] NOT NULL,
[UltNum] [int] NOT NULL,
CONSTRAINT [PK_CorreioNumTeste] PRIMARY KEY CLUSTERED
[UltData] Asc
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = on, FILLFACTOR = 80) ON [PRIMARY]
) ON [PRIMARY]
go
create view ControlNumTest as
select * from ControlNumTest_t with (tablockx)
Which, at least in my limited testing, resovlved the deadlock without any client code change.
David
David http://blogs.msdn.com/b/dbrowne/ -
Issue in adding not null constraint on 250 G table with 50 million rows.
Guys,
I need to add not null constraint on 2 column of a table with 50 million rows and ~250 GB in size, These 2 columns are newly added and I have also update the value for each of these columns to not null for each row.
After that I am adding not null constraint on these 2 columns this is taking 1 hour to complete, Is there any way to speed up this, I don't want to use ENABLE NOVALIDATE option or rather I can't use that option.user445775 wrote:
Guys,
I need to add not null constraint on 2 column of a table with 50 million rows and ~250 GB in size, These 2 columns are newly added and I have also update the value for each of these columns to not null for each row.
After that I am adding not null constraint on these 2 columns this is taking 1 hour to complete, Is there any way to speed up this, I don't want to use ENABLE NOVALIDATE option or rather I can't use that option.And what's wrong with it taking an hour? Presumably, this is a one time operation, and it doesn't really interfere with anything else. -
SELECT STATMENT USING JOINS OF 2 TABLE WITH UPT 200 ROWS
Hi
Any give me sample code for select statment'' SELECT STATMENT USING JOINS OF 2 TABLE WITH UPT 200 ROWS''.
Thanks in advance .
regards
veeratables : mara.
data : begin of itab occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
end of itab.
start-of-selection.
select amatnr bmaktx into table itab up to 200 rows
from mara as a inner join makt as b on bmatnr = amatnr. -
How to create editable table with one empty row ?
I'm looking for solution how to create editable table with one empty row using ADF BC. I have seen this solution in application that was created in JHeadstart and it's very well idea to use it insead of creation form.
hammm, i do it this:
drop the VO on the page, select Table->ADF Table....
so, drop the botton create, from de VO->operations->create (the firts), and right botton (mouse) Edit binding....
in Data collection select the VO, in Select an action select CreateInsert
luck -
Pages won't allow me to create a table with just one row.
I'm trying to create a one row, two colum table in Pages. I have no problem with the columns. But I cannot create the table with just one row. Two rows apppears to be the minimum. Any ideas??
In Pages 5.2, click the equal sign at bottom-left of table and reduce the row count to one.
-
Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.The Oracle documentation has a good overview of the options available
Generating XML Data from the Database
Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
You can also find some information in XML DB FAQ -
How much time it take to rebuild an index for a table with 20 millions rows
Hi all,
i need to rebuild the index of a table containing 20 000 000 row (i don't know why the other people working on this didn't think of rebuilding the index regularly, because i asked and apparently it has never been done :cry: :cry:) i am not a sql developper nor a DBA so i can't mesure how long it take to rebuild the index, does any one have an idea (aproximativly of course :aie:), the other question is there any formula to use in order to calculate how often to rebuild the indexes (i can for example retieve how much rows are delated or inserted daily ...)
Thanks again
Tahataha wrote:
:aie: that's why i am asking because i don't know (and to be sure which solution is best)
so the table is like this (the columns) :
45 varchar2, 5 timestamp, 30 Number no LOB columns, (15 indexes : 5 unique indexes and that those indexes uses at a maximum 4 columns)15 indexes - 100,000 deletes: this could mean 1,500,000 block visits to maintain index leaf blocks as the table rows are deleted. If you're unlucky this could turn into 1,500,000 physical block read requests; if you're lucky, or the system is well engineered this could be virtually no physical I/O. The difference in time could be huge. At any rate it is likely to be 1,500,000 redo entries at 250 - 300 bytes per entry for a total of about 400MB of redo (so how large are your redo logs and how many log switches are you going to cause).
yes the tables is used by an application so (update, insert ) can take place at any time
for the deletion , there is the batch which does a mass delete on the table ( 4 or 5 time each day)
You haven't answered the question - how long does it take to do a sample batch delete.
If you can enable SQL tracing, or take a before/after snapshot of v$sesstat or v$session_event for the session as it does the delete then you can get some idea of where the time is going - for all you know it might be spending most of its time waiting for a lock to do away.
>
"How many leaf blocks are currently allocated to the index(es) ?" how can i answer to this question ? may be if i check the all_objects table ?
If you keep your statistics up to date then dba_indexes is a good place, cross-checked with dba_segments, and you can use the dbms_space package for more detail. I have a code sample on my blog which allows you to compare the current size of your indexes with the size they would be if rebuilt at some specific percentage: http://jonathanlewis.wordpress.com/index-sizing/ (It's such good code that Oracle Corp. has copied it into MOS note 989186.1)
Regards
Jonathan Lewis -
Number of Rows, displaying a table with only one row
Hello,
I am doing my first VC tests on the discovery System.
I have an input form where I put in the username, then choose a user from a table and with the user ID I want to show the user details in another table.
Now since I am only pickling one user, the new table will only have one row. In VC I cannot set the no. of rows to 1 though, since I cannot edit the no. of rows field. I also cannot disable the scroll buttons.
Why is that?
Is there another way to display user details? I tried to display it in read-only form, but it is pretty ugly.
Another question regarding designing in VC:
Are there any design elements in VC for example to group form fields that belong together? Let's say I have street name, number, postal code and so on, could I use a design element to group them under the label "Address" ?Peter,
For some reason the No. of Rows and Scroll Buttons options are only available if your compiler is set to Web DynPro. Whenever you compile to Flash they're disabled.
Regards
Hennie -
Select event not triggered in table with only one row
Hi all,
I am building a BI VC application where query data is displayed in a table. When the user clicks on a table row another query is then triggered and output in a second table. The output from table 1 is linked to the input of query2/table2 with a select event.
The problem that I am facing is that if there is only one row in table 1, the select event is never triggered. If, however there are two or more rows in the table the select event is triggered and query 2 is executed. I have searched the forums but all I could find on select event problems was how to avoid the initial select event.
Has anyone else experienced this issue and what is the workaround or is this a bug in Visual Composer? We are on VC 7.0 SP19.
Cheers,
Astein MelandThanks Chittya,
Yes we have considered this option as well. But as we have more than one table linked together we would like to avoid having to manually click several buttons.
In the end I found Note 1364334 describing bugfixes released in VC 7.0 SP20:
"Normally, when a Visual Composer table is populated from a data service, the first row is selected by default. However, we have found that if only one data row is returned from the data service, this row is not selected by default and cannot be manually selected by clicking on it either."
So I think we will just have to upgrade our Portal to the latest support packs to solve this problem.
Thanks,
Astein -
Get min and max for a column from table with 24 million rows.
What is the best way to re-write the following query in a procedure for the table which has around 24 million rows?
SELECT MIN(ft_src_ref_id), MAX(ft_src_ref_id )
INTO gn_Min_ID, gn_Max_ID
from UI_PURGE_FT;
Thanks
Edited by: tcode on Jun 21, 2012 12:31 PMWhich of the following plan is better, can you please breifly explain?
Also I need to gather statics to know recursive calls , db block gets ,consistent gets etc. etc. how can I get that?
Thanks
1.
Execution Plan
Plan hash value: 3702745568
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 6 | 13991 (2)| 00:02:48 |
| 1 | SORT AGGREGATE | | 1 | 6 | | |
| 2 | INDEX FAST FULL SCAN | UI_PURGE_FT_PK | 23M| 136M| 13991 (2)| 00:02:48 |
2.
Execution Plan
Plan hash value: 1974183109
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | | 2 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 6 | | |
| 2 | INDEX FULL SCAN (MIN/MAX)| UI_PURGE_FT_PK | 23M| 136M| 2 (0)| 00:00:01 |
| 3 | SORT AGGREGATE | | 1 | 6 | | |
| 4 | INDEX FULL SCAN (MIN/MAX)| UI_PURGE_FT_PK | 23M| 136M| 2 (0)| 00:00:01 |
| 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
--------------------------------------------------------------------------------------------- -
Locating row with invalid number from table with few million rows
We need to query the a table or a view of same to obtain a id of type VARCHAR with bind value being NUMBER. Any attempts in this regard I try seem to result ORA-01722: invalid number. Once case is below here
SQL> select TEXT_ID FROM ATT_TABLE where to_number(TEXT_ID) = 9411956;
select TEXT_ID FROM ATT_TABLE where to_number(TEXT_ID) = 9411956
ERROR at line 1:
ORA-12801: error signaled in parallel query server P010
ORA-01722: invalid number
1. TEXT_ID column is meant to have numeric values in VARCHAR type. It is possible that some record / row is not complying. How can I locate the non-complying records ?
2. What would be a VIEW definition that would return only records with valid numeric data in TEXT_ID column.
Edited by: bonjonbovi on Feb 13, 2009 3:58 PMOf course the regexp_like is really cpu expensive, but there's no other solution in your situation
The only way to differ numberic value from character, is REGEXP_LIKE function
But you can do it using PL/SQL
BEGIN
FOR c IN (SELECT TO_NUMBER (ID) ID
FROM test_number)
LOOP
DBMS_OUTPUT.put_line (c.ID);
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
NULL;
END; -
Create Table with extra empty row
Hi,
I have two problems...
I need to create a table from DB with one extra empty row.
Is there an easy way to do this?
And I need a button to delete all in that table.
something like SQL:
delete from tableX
Anything that helps me on the way... what I should look for?835652 wrote:
Hi,
I have two problems...
I need to create a table from DB with one extra empty row.
Is there an easy way to do this?this is strange requirement can you clear what is your use case ?
>
And I need a button to delete all in that table.
something like SQL:
delete from tableX
Anything that helps me on the way... what I should look for?Try this http://baigsorcl.blogspot.com/2010/11/how-to-execute-sql-dml-statements-in.html
Maybe you are looking for
-
How do I open a PDF file
-
Standalone Flash Player Crashes On bitmapData.hitTest()
Help. The Flash game "Flak Cannon" from my book, The Essential Guide To Flash Games, dies in the latest 10.1 stand alone player in CS5. It runs perfectly fine in an HTML page, and it runs fine with pre 10.1 stand alone players, but in 10.1.52.14 it
-
Upgradation -hard Coding issue
Hi, I'm working in an Upgradation Project(from 4.6c to ECC 6.0) where I need to remove Hard Coding in general. I met with a situation where I have to use hard coding, but it's not good to use interms of performance. Could anyone post the solution for
-
Issue with new 'Display Summary Type in Table' Attribute
JHeadstart Version: 10.1.3.1.26 JDeveloper Version: 10.1.3.1 We have configured our top level groups in our JHS Application Definition Editor to have each table's first column (Primary Key) set to 'count' for the 'Display Summary Type In Table' field
-
can not down load i tunes up date because old bonjour can not be removed can any one help because apple must know about this problem but are not help full