Always Deleting First Row
Hi
I have a adf page.In my page I have a form and detail table.On my table when I want to delete any row, it deletes always first row. Can you halp me?
Hi,
Use the VO Operation removeRowWithKey and specify #{row.rowKeyStr} as it's parameter when you drag it onto the page.
Brenden
Similar Messages
-
Af:tableselectmany always selects first row and ONLY first row
My table in jsp:
<af:table value="#{bindings.AluNoExpeAluM1.collectionModel}" var="row"
rows="#{bindings.AluNoExpeAluM1.rangeSize}"
first="#{bindings.AluNoExpeAluM1.rangeStart}"
emptyText="#{bindings.AluNoExpeAluM1.viewable ? \'No rows yet.\' : \'Access Denied.\'}"
binding="#{cient20uSeleccionAluBean.tablaMultiple}">
<af:column sortProperty="Vnumdocu" sortable="false"
headerText="#{bindings.AluNoExpeAluM1.labels.Vnumdocu}">
<af:outputText value="#{row.Vnumdocu}"/>
</af:column>
<af:column sortProperty="Vapeynombre" sortable="false"
headerText="#{bindings.AluNoExpeAluM1.labels.Vapeynombre}">
<af:outputText value="#{row.Vapeynombre}"/>
</af:column>
<f:facet name="selection">
<af:tableSelectMany text="Select items and ..." autoSubmit="true">
<af:commandButton text="commandButton 1"
action="#{cient20uSeleccionAluBean.elegirAlumnoAction}"
partialSubmit="true" immediate="true"/>
</af:tableSelectMany>
</f:facet>
</af:table>
Table don't have SelectionListener and SelectionState, but the method only select the first row from iterator.
This method "elegirAlumnoAction":
public String elegirAlumnoAction() {
Iterator itRs = this.getTablaMultiple().getSelectionState().getKeySet().iterator();
while(itRs.hasNext()){
Key k = (Key) itRs.next();
System.out.println(k.toString());
Row r = IteratorUtil.obtenerIteradorPorDefecto(this.ITERADOR_RESULTADO).getRow(k);
System.out.println(r.getAttribute("Vnumdocu"));
IteratorUtil.obtenerIteradorPorDefecto(this.ITERADOR_RESULTADO).setCurrentRow(r);
return null;
Message was edited by:
jortri
Message was edited by:
jortriMaybe the following can help you:
http://andrejusb.blogspot.com/2007_02_01_archive.html
http://andrejusb-samples.blogspot.com/2007/02/jdevadf-sample-multi-selection-feature.html -
Cascading LOV always returns first row in af:query
HI
JDEV 11.1.1.3.0
A strange thing is happening with my cascading LOV which is input text with LOV.
I have a read only table with a query section. I then also bring up any of the tables rows in a popup with single record view where the row is then in an af:form for inserting and updating.
Both the af:query and af:form have the cascaing LOV in them.
When testing the cascading LOV in the BC Browser it works fine. When I use it in the popup in the af:form record it works fine. But in the af:query section, no matter which row I choose in the LOV, it always returns the 1st row of the LOV back to my input text component.
Has anyone experienced this...any ideas?
Thanks,
MarioAha...and the above log message lead me to the solution!! :-)
The VO is based on an Oracle data dictionary view, DBA_TAB_COLUMNS. When you create the read only VO, by default it does not create any of the attributes as "key" attributes, because the oracle view has no primary key.
Setting owner, tableName and columnName as key attributes solved this issue, now my cascading LOV works in the BC Tester, af:query component and my af:form component.
Regards,
Mario -
[Solved] 27.8.4 How to Create a VO on a REF CURSOR - Missing first row
Searching the forum I found: BC4J - Get one less row from view object.
Dive into BC4J related --REF CURSOR (Resultset)
The first message did not have any answers, and the second had a follow up question - still no answers though - and I thought I would try a different title.
(This is off topic, but it would be a great help if the search results also displayed the number of replys in the thread. That way, I wouldn't have to view the messages that don't have responses.)
(This will be deployed on a server that has the ADF for JDeveloper 10.1.2 installed, so using that version of JDeveloper to develop the app.)
Okay, back to the problem ==>
I created a VO from a ref cursor, using the manual as a guide. When I run a page that displays a read only table of the view object, I am missing the first row. (Always the first row!) I don't have any order set, and if I call the ref cursor in a Java program for testing, I see all rows and the count is correct.
One other point, when I call the page, I get the following validation error:
Validation Error
You must correct the following error(s) before proceeding:
* JBO-29000: Unexpected exception caught: java.lang.ClassCastException, msg=null
* null
I still see the table, it is just missing the first row of data.
In my form I have first, previous set, next set , and last
navigation buttons. If I press last then first, the error goes away. I still don't see the missing row though.
Any guidance would be appreciated! I can post my code, but it is pretty much the same code in the AdvancedViewObjectExamples.zip in the ViewObjectOnRefCursor example. I just substituted my two package calls (getRefCursor and getRefCursorCount).
Thanks, KenWent back to a backup copy of the source. Fixed the error. Now I'm back to just not being able to see the first row of data.
Additional Note: I had removed fields in the display. Once I truncated the ps_txn table in the schema defined by the model, the data would display (Still without the first record.)
Are there any examples that are more in depth than the few pages in the developer guide?
Here is the code for my VOImpl class:
package newslinearchive.model.datamodel;
import java.math.BigDecimal;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import oracle.jbo.InvalidParamException;
import oracle.jbo.JboException;
import oracle.jbo.domain.Date;
import oracle.jbo.domain.Number;
import oracle.jbo.server.DBTransaction;
import oracle.jbo.server.QueryCollection;
import oracle.jbo.server.SQLBuilder;
import oracle.jbo.server.ViewObjectImpl;
import oracle.jbo.server.ViewRowImpl;
import oracle.jbo.server.ViewRowSetImpl;
import oracle.jdbc.driver.OracleCallableStatement;
import oracle.jdbc.driver.OracleTypes;
// --- File generated by Oracle ADF Business Components Design Time.
// --- Custom code may be added to this class.
// --- Warning: Do not modify method signatures of generated methods.
public class SearchRefCursorImpl extends ViewObjectImpl {
* This is the default constructor (do not remove)
public SearchRefCursorImpl() {
* Overridden framework method.
* Executed when the framework needs to issue the database query for
* the query collection based on this view object. One view object
* can produce many related result sets, each potentially the result
* of different bind variable values. If the rowset in query is involved
* in a framework-coordinated master/detail viewlink, then the params array
* will contain one or more framework-supplied bind parameters. If there
* are any user-supplied bind parameter values, they will PRECEED the
* framework-supplied bind variable values in the params array, and the
* number of user parameters will be indicated by the value of the
* numUserParams argument.
protected void executeQueryForCollection(Object qc,Object[] params,int numUserParams) {
storeNewResultSet(qc,retrieveRefCursor(qc,params));
super.executeQueryForCollection(qc, params, numUserParams);
* Overridden framework method.
* Wipe out all traces of a built-in query for this VO
protected void create() {
getViewDef().setQuery(null);
getViewDef().setSelectClause(null);
setQuery(null);
* Overridden framework method.
* The role of this method is to "fetch", populate, and return a single row
* from the datasource by calling createNewRowForCollection() and populating
* its attributes using populateAttributeForRow().
protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet rs) {
* We ignore the JDBC ResultSet passed by the framework (null anyway) and
* use the resultset that we've stored in the query-collection-private
* user data storage
rs = getResultSet(qc);
* Create a new row to populate
ViewRowImpl r = createNewRowForCollection(qc);
try {
* Populate new row by attribute slot number for current row in Result Set
// populateAttributeForRow(r,0, rs.getLong(1));
// populateAttributeForRow(r,1, rs.getString(2));
// populateAttributeForRow(r,2, rs.getString(3));
// MASTERID NOT NULL NUMBER
populateAttributeForRow(r,0, rs.getBigDecimal(1));
//ID NOT NULL NUMBER
populateAttributeForRow(r,1, rs.getBigDecimal(2));
// CAID NOT NULL NUMBER
populateAttributeForRow(r,2, rs.getBigDecimal(3));
// LANGUAGE NOT NULL VARCHAR2(30)
populateAttributeForRow(r,3, rs.getString(4));
// IS_CURRENT_VERSION NOT NULL NUMBER(1)
populateAttributeForRow(r,4, rs.getBigDecimal(5));
// FOLDER_ID NOT NULL NUMBER
populateAttributeForRow(r,5, rs.getBigDecimal(6));
// FOLDER_REGION_ID NOT NULL NUMBER
populateAttributeForRow(r,6, rs.getBigDecimal(7));
// NAME NOT NULL VARCHAR2(256)
populateAttributeForRow(r,7, rs.getString(8));
// DISPLAY_NAME VARCHAR2(256)
populateAttributeForRow(r,8, rs.getString(9));
// ITEMTYPE NOT NULL VARCHAR2(30)
populateAttributeForRow(r,9, rs.getString(10));
// SUBTYPE VARCHAR2(40)
populateAttributeForRow(r,10, rs.getString(11));
// SUBTYPE_CAID NUMBER
populateAttributeForRow(r,11, rs.getBigDecimal(12));
// PARENT_ITEM_ID NUMBER
populateAttributeForRow(r,12, rs.getBigDecimal(13));
// CATEGORY_ID NUMBER
populateAttributeForRow(r,13, rs.getBigDecimal(14));
// CATEGORY_CAID NUMBER
populateAttributeForRow(r,14, rs.getBigDecimal(15));
// AUTHOR VARCHAR2(50)
populateAttributeForRow(r,15, rs.getString(16));
// DESCRIPTION VARCHAR2(2000)
populateAttributeForRow(r,16, rs.getString(17));
// PUBLISH_DATE NOT NULL DATE
populateAttributeForRow(r,17, rs.getDate(18));
// EXPIREMODE VARCHAR2(90)
populateAttributeForRow(r,18, rs.getString(19));
// EXPIRENUMBER NUMBER
populateAttributeForRow(r,19, rs.getBigDecimal(20));
// EXPIREDATE DATE
populateAttributeForRow(r,20, rs.getDate(21));
// IMAGE VARCHAR2(350)
populateAttributeForRow(r,21, rs.getString(22));
// KEYWORDS VARCHAR2(2000)
populateAttributeForRow(r,22, rs.getString(23));
// URL VARCHAR2(4000)
populateAttributeForRow(r,23, rs.getString(24));
// FILENAME VARCHAR2(350)
populateAttributeForRow(r,24, rs.getString(25));
// TEXT CLOB()
populateAttributeForRow(r,25, rs.getClob(26));
// FOLDER_LINK_ID NUMBER
populateAttributeForRow(r,26, rs.getBigDecimal(27));
// FOLDER_LINK_CAID NUMBER
populateAttributeForRow(r,27, rs.getBigDecimal(28));
// ACTIVE NOT NULL NUMBER(1)
populateAttributeForRow(r,28, rs.getBigDecimal(29));
// CAN_BE_CHECKEDOUT NUMBER(1)
populateAttributeForRow(r,29, rs.getBigDecimal(30));
// IS_ITEM_CHECKEDOUT NUMBER(1)
populateAttributeForRow(r,30, rs.getBigDecimal(31));
// CHECKER_USERNAME VARCHAR2(256)
populateAttributeForRow(r,31, rs.getString(32));
// CHECKOUT_DATE DATE
populateAttributeForRow(r,32, rs.getDate(33));
// FULLSCREEN NOT NULL NUMBER(1)
populateAttributeForRow(r,33, rs.getBigDecimal(34));
// INPLACE NOT NULL NUMBER(1)
populateAttributeForRow(r,34, rs.getBigDecimal(35));
// CREATEDATE NOT NULL DATE
populateAttributeForRow(r,35, rs.getDate(36));
// CREATOR NOT NULL VARCHAR2(256)
populateAttributeForRow(r,36, rs.getString(37));
// UPDATEDATE DATE
populateAttributeForRow(r,37, rs.getDate(38));
// UPDATOR VARCHAR2(256)
populateAttributeForRow(r,38, rs.getString(39));
// SECURITY VARCHAR2(25)
populateAttributeForRow(r,39, rs.getString(40));
// VISIBLE NOT NULL NUMBER(1)
populateAttributeForRow(r,40, rs.getBigDecimal(41));
// SEQUENCE NOT NULL NUMBER
populateAttributeForRow(r,41, rs.getBigDecimal(42));
// CATEGORY_SEQUENCE NOT NULL NUMBER
populateAttributeForRow(r,42, rs.getBigDecimal(43));
// AUTHOR_SEQUENCE NOT NULL NUMBER
populateAttributeForRow(r,43, rs.getBigDecimal(44));
// CREATE_DATE_SEQUENCE NOT NULL NUMBER
populateAttributeForRow(r,44, rs.getBigDecimal(45));
// ITEMTYPE_SEQUENCE NOT NULL NUMBER
populateAttributeForRow(r,45, rs.getBigDecimal(46));
catch (SQLException s) {
throw new JboException(s);
return r;
* Overridden framework method.
* Return true if the datasource has at least one more record to fetch.
protected boolean hasNextForCollection(Object qc) {
ResultSet rs = getResultSet(qc);
boolean nextOne = false;
try {
nextOne = rs.next();
* When were at the end of the result set, mark the query collection
* as "FetchComplete".
if (!nextOne) {
setFetchCompleteForCollection(qc, true);
* Close the result set, we're done with it
rs.close();
catch (SQLException s) {
throw new JboException(s);
return nextOne;
* Overridden framework method.
* The framework gives us a chance to clean up any resources related
* to the datasource when a query collection is done being used.
protected void releaseUserDataForCollection(Object qc, Object rs) {
* Ignore the ResultSet passed in since we've created our own.
* Fetch the ResultSet from the User-Data context instead
ResultSet userDataRS = getResultSet(qc);
if (userDataRS != null) {
try {
userDataRS.close();
catch (SQLException s) {
/* Ignore */
super.releaseUserDataForCollection(qc, rs);
* Overridden framework method
* Return the number of rows that would be returned by executing
* the query implied by the datasource. This gives the developer a
* chance to perform a fast count of the rows that would be retrieved
* if all rows were fetched from the database. In the default implementation
* the framework will perform a SELECT COUNT(*) FROM (...) wrapper query
* to let the database return the count. This count might only be an estimate
* depending on how resource-intensive it would be to actually count the rows.
public long getQueryHitCount(ViewRowSetImpl viewRowSet) {
Long result = (Long)callStoredFunction(NUMBER,
"PORTAL.SEARCH_REFCURSOR.getRefCursorCount",
viewRowSet.getParameters(true));
return result.longValue();
// ------------- PRIVATE METHODS ----------------
* Return a JDBC ResultSet representing the REF CURSOR return
* value from our stored package function.
* new Object[]{getNamedBindParamValue("Email",params)}
private ResultSet retrieveRefCursor(Object qc, Object[] params) {
ResultSet rs = (ResultSet)callStoredFunction(OracleTypes.CURSOR,
"PORTAL.SEARCH_REFCURSOR.getRefCursor",
null);
return rs ;
private Object getNamedBindParamValue(String varName, Object[] params) {
Object result = null;
if (getBindingStyle() == SQLBuilder.BINDING_STYLE_ORACLE_NAME) {
if (params != null) {
for (Object param : params) {
Object[] nameValue = (Object[])param;
String name = (String)nameValue[0];
if (name.equals(varName)) {
return (String)nameValue[1];
throw new JboException("No bind variable named '"+varName+"'");
* Store a new result set in the query-collection-private user-data context
private void storeNewResultSet(Object qc, ResultSet rs) {
ResultSet existingRs = getResultSet(qc);
// If this query collection is getting reused, close out any previous rowset
if (existingRs != null) {
try {existingRs.close();} catch (SQLException s) {}
setUserDataForCollection(qc,rs);
hasNextForCollection(qc); // Prime the pump with the first row.
* Retrieve the result set wrapper from the query-collection user-data
private ResultSet getResultSet(Object qc) {
return (ResultSet)getUserDataForCollection(qc);
* Return either null or a new oracle.jbo.domain.Date
private static Date nullOrNewDate(Timestamp t) {
return t != null ? new Date(t) : null;
* Return either null or a new oracle.jbo.domain.Number
private static Number nullOrNewNumber(BigDecimal b) {
try {
return b != null ? new Number(b) : null;
catch (SQLException s) { }
return null;
//----------------[ Begin Helper Code ]------------------------------
public static int NUMBER = Types.NUMERIC;
public static int DATE = Types.DATE;
public static int VARCHAR2 = Types.VARCHAR;
public static int CLOB = Types.CLOB;
* Simplifies calling a stored function with bind variables
* You can use the NUMBER, DATE, and VARCHAR2 constants in this
* class to indicate the function return type for these three common types,
* otherwise use one of the JDBC types in the java.sql.Types class.
* NOTE: If you want to invoke a stored procedure without any bind variables
* ==== then you can just use the basic getDBTransaction().executeCommand()
* @param sqlReturnType JDBC datatype constant of function return value
* @param stmt stored function statement
* @param bindVars Object array of parameters
* @return function return value as an Object
protected Object callStoredFunction(int sqlReturnType, String stmt,
Object[] bindVars) {
CallableStatement st = null;
try {
st = getDBTransaction().createCallableStatement("begin ? := " + stmt +
"; end;", 0);
st.registerOutParameter(1, sqlReturnType);
if (bindVars != null) {
for (int z = 0; z < bindVars.length; z++) {
st.setObject(z + 2, bindVars[z]);
st.executeUpdate();
return st.getObject(1);
catch (SQLException e) {
throw new JboException(e);
finally {
if (st != null) {
try {
st.close();
catch (SQLException e) {}
/**Gets the bind variable value for Email
public String getEmail() {
return (String)getNamedWhereClauseParam("Email");
/**Sets <code>value</code> for bind variable Email
public void setEmail(String value) {
setNamedWhereClauseParam("Email", value);
/**getEstimatedRowCount - overridden for custom java data source support.
public long getEstimatedRowCount() {
long value = super.getEstimatedRowCount();
return value;
Thanks, Ken -
First row from Service Order Object list not stored in OBJK table
Hi all,
Please be patience with my terminology .
Could you please explain me if we have SO created based on notification, and that notification already have Equipment number, why this equipment is not created in OBJK table? So always the first row (as in attachment) is not stored in OBJK, other rows(objects) are there.
I know the EQUNR is stored in AFIH, but it's useless for us because I'm creating HANA analytical view with following join logic (simplified):
AFIH.OBKNR=OBJK.OBKNR
OBJK.ILOAN=ILOA.ILOAN
ILOA.TPLNR=IFLOT.TPLNR
ILOA.ILOAN=EQUZ.ILOAN (where EQUZ.DATBI='99991231')
EQUZ.EQUNR=EQUI.EQUNR
The join logic might not be 100% correct.
Thank you for your help.Using the tags to format your code may help you get a response sooner than later.
This and other useful pieces of information are located in the FAQ
http://wiki.oracle.com/page/Oracle+Discussion+Forums+FAQ -
Does't delete final row in alv
hi. friends..^^
i want delete row in alv.
I can delete first row and second row ... final - 1 row.(r_param->t_deleted_rows is not initial)
But...I can't delete final row.(r_param->t_deleted_rows is initial)
how to delete final row?
vesion 2004s
METHOD on_alv_delete .
DATA : ls_row LIKE LINE OF r_param->t_deleted_rows.
DATA : ls_lecture TYPE REF TO zlecture.
FIELD-SYMBOLS : <fs_lecture> TYPE zlecture.
LOOP AT r_param->t_deleted_rows INTO ls_row.
ls_lecture ?= ls_row-r_value.
ASSIGN ls_lecture->* TO <fs_lecture>.
DELETE FROM zregistration WHERE lecture_num = <fs_lecture>-lecture_num
AND devide_num = <fs_lecture>-devide_num.
ENDLOOP.
ENDMETHOD.
Edited by: Ki-Joon Seo on Aug 22, 2008 12:09 PMHi
Are you using the method <node_name>->Invalidate( ). to delete it's data ?
If not, try using this method in you logic to delete the data.
Regards,
Trikanth -
Export in Excel- always first row blank
hi,
if i export in excel file always i am getting first row as blank with line. how can i eliminate this row.Hi Kayadhu,
Generally, if we design a report and the top of report body remain extra blank space, it will result in the extra blank row after export the report to Excel. Please see the screenshot below:
In your case, please try to reduce the blank space in the report body. If the issue still persists, please post more information about your report design structure to us.
Regards,
Bin Long
Bin Long
TechNet Community Support -
Binding on an iterator always return the first row of the Children VO...
I have 3 pages:
A -- tree table bound to VO A; B is used to view the detail of a row selected inside the table; Inside B there is another table that contains the childrens VO of B. Select a row in the table will launch C to view the details of the children.
They are all in unbounded task flow.
From A to B, it works fine: Details of selected row inside the Table of A is showing correctly.
However, From B to C, selecting a row inside B, When C is launched, it always shows the content of the first row of the B's Children VO.
Any idea how this can be fixed? I want C page to show the details of the row selected in B's Table.
B's table is defined like this:
<af:table value="#{bindings.C.collectionModel}"
var="row"
rows="#{bindings.C.rangeSize}"
fetchSize="#{bindings.C.rangeSize}"
rowBandingInterval="1"
selectedRowKeys="#{bindings.C.collectionModel.selectedRow}"
selectionListener="#{bindings.C.collectionModel.makeCurrent}"
rowSelection="single"
id="rTable"
styleClass="AFStretchWidth"
columnStretching="column:c1"
autoHeightRows="20"
contentDelivery="immediate">
</af:table>
How can I fix this to correctly show the details of seleted row for C?
Edited by: user735345 on Oct 3, 2010 9:24 PMHi,
Is this code you provided for B table or for C table??
Do you have your partial triggers set correctly?
Regards,
Dimitris. -
First row of table is displayed as selected always when application loads.
Hi..
I have a table with few rows in it.When the application loads the first row of table is displayed as selected always.I don't want any of the rows to be displayed as selected.
How can I prevent this ?
My jdev version 11.1.1.5.0
Edited by: Lovin_JV_941794 on Mar 12, 2013 2:13 AMHi,
can you remove the attribute
selectedRowKeys="#{bindings.XXXX.collectionModel.selectedRow}"This would ensure that there are no selected rows persisted. you can also paste the jspx code also for better answer.
~Abhijit -
Delete first empty row in a table
Hi,
Can you please provide the script for the below requirement.
Need to delete First empty row in all the tables. (Tables having more number of empty rows. i need to delete first empty row only)
Regards,
Velu@Velu – the following blog post by Jongware might get you started:
Tackling Tables through Scripting
by: Jongware | April 8, 2013
http://indesignsecrets.com/tackling-tables-through-scripting.php
Document Object (DOM) documentation:
Indesign JavaScript Help
InDesign ExtendScript API (10.0)
Table Row specifics:
Adobe InDesign CS6 (8.0) Object Model JS: Row
InDesign ExtendScript API (10.0)
Uwe -
How to delete duplicate rows in oracle and retaining last duplicate rows
Hi,
I'm having millions of records in the table .Some duplicate values/rows are inserted in it.
I just want to delete duplicate rows but also want to retain the last duplicate row.
For eg if one record is found three times ,i want to delete first and second record and retain
the third one i.e the last inserted one.
Regards
Paramdeep Singhuser13310594 wrote:
Hi,
I'm having millions of records in the table .Some duplicate values/rows are inserted in it.
I just want to delete duplicate rows but also want to retain the last duplicate row.
For eg if one record is found three times ,i want to delete first and second record and retain
the third one i.e the last inserted one.Hi Paramdeep,
To start with, since you do not wish to keep multiple rows with same values, why allow them to get inserted in the first place?
Wouldn't it be easier to block duplicate rows from inserting by creating a Unique constraint on Column(s) that define a row as duplicate, then rather deleting duplicate rows periodically?
For deleting duplicate rows, there are N number of techniques available. Always remember, you need to have a rigid criteria that marks row as duplicate.
[url http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:15258974323143]this is one recomended by tom for large tables.
Vivek L -
Deleting a row from a Parent VO gives NullPointerException
I am using JDev 11.1.1.2.0
Deleting a row from a Parent VO gives NullPointerException raised from oracle.jbo.server.EntityImpl.vetoRemoveWithDetails(EntityImpl.java:8214)
Here is my implementation:
There are two Entity Objects(Named "Parent" and "Child").
Both EO are NOT based on a database table. (These are populated from a method in the AM, the method calls a database API that returns an nested array and this array is used to populate the Parent and Child entities)
All attributes in these entity objects are Non-persistent.
The View Object "ParentEv" is based on "Parent" EO
The View Object "ChildEv" is based on "Child" EO
The View Objects "ParentEv" and "ChildEv" are linked by a view link.
The Entities "Parent" and"Child" are linked by Entity Association ( as "Composition Association" with "Implement Cascade Delete" checked.)
I am programatically deleting and populating the View Objects ParentEv and ChildEv from a method in the AM.
The first time I execute the method in BC Tester, it works fine.
The second time I execute the method it works fine.
But on third execution, it gives the below error which seems to be NullPointerException raised from oracle.jbo.server.EntityImpl.vetoRemoveWithDetails(EntityImpl.java:8214)
I am able to reproduce this in a test case scenario. It always works the first 2 times and fails when the method to delete and populate the VOs is executed a 3rd time.
If we base the "Parent" and "Child" entities on some dummy database views, it works fine, the problem only occurs when the Entities are NOT based on any table.
Can someone advise on what could be causing this issue?
Thanks,
Mitesh.Here's the method that I use in my test case to populate the VOs.
* This method populates the VOs ParentEv and ChildEv.
* These VOs are based on EOs Paren and Child, respectively.
* Before populating the VOs I am deleting any existing rows.
* The first two times this method is executed, it works fine.
* The third time this method executes it gives a nullpointerexception raised from
* oracle.jbo.server.EntityImpl.vetoRemoveWithDetails(EntityImpl.java:8214)
public void populateMethod(){
int rowCount = getParentEv().getRowCount();
for (int i = 0; i < rowCount; i++) {
Row row = getParentEv().last();
if(row!=null)
row.remove();
rowCount = getChildEv().getRowCount();
for (int i = 0; i < rowCount; i++) {
Row row = getChildEv().last();
if(row!=null)
row.remove();
int k = 0;
for (int i = 1; i < 5; i++) {
ParentEvRowImpl parentEvRow = (ParentEvRowImpl)getParentEv().createRow();
parentEvRow.setParentPk("Parent " + i);
parentEvRow.setParentDesc("Parent Desc " + i);
getParentEv().insertRow(parentEvRow);
for (int j = 1; j < 5; j++) {
k++;
ChildEvRowImpl childEvRow = (ChildEvRowImpl)getChildEv().createRow();
childEvRow.setChildPk("Child " + k);
childEvRow.setChildDesc("Child Desc " + k);
getChildEv().insertRow(childEvRow);
}==============================================================================
Here is the Parent.xml for the Parent EO:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE Entity SYSTEM "jbo_03_01.dtd">
<!---->
<Entity
xmlns="http://xmlns.oracle.com/bc4j"
Name="Parent"
Version="11.1.1.55.36"
AliasName="Parent"
BindingStyle="OracleName"
UseGlueCode="false"
RowClass="oracle.jbo.server.EntityImpl"
DefClass="oracle.jbo.server.EntityDefImpl"
CollClass="oracle.jbo.server.EntityCache">
<DesignTime>
<AttrArray Name="_publishEvents"/>
</DesignTime>
<Attribute
Name="ParentPk"
IsQueriable="false"
IsPersistent="false"
ColumnName="PARENTPK"
SQLType="VARCHAR"
Type="java.lang.String"
ColumnType="$none$"
PrimaryKey="true"/>
<Attribute
Name="ParentDesc"
IsQueriable="false"
IsPersistent="false"
ColumnName="$none$"
SQLType="VARCHAR"
Type="java.lang.String"
ColumnType="$none$"/>
<AccessorAttribute
Name="Child"
Association="model.eo.ea.ChildParentAssoc"
AssociationEnd="model.eo.ea.ChildParentAssoc.Child"
AssociationOtherEnd="model.eo.ea.ChildParentAssoc.Parent"
Type="oracle.jbo.RowIterator"
IsUpdateable="false"/>
</Entity>==============================================================================
Here is the Child.xml for the Child EO:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE Entity SYSTEM "jbo_03_01.dtd">
<!---->
<Entity
xmlns="http://xmlns.oracle.com/bc4j"
Name="Child"
Version="11.1.1.55.36"
AliasName="Child"
BindingStyle="OracleName"
UseGlueCode="false">
<DesignTime>
<AttrArray Name="_publishEvents"/>
</DesignTime>
<Attribute
Name="ChildPk"
IsUpdateable="while_insert"
IsQueriable="false"
IsPersistent="false"
IsNotNull="true"
ColumnName="CHILDPK"
SQLType="VARCHAR"
Type="java.lang.String"
ColumnType="$none$"
PrimaryKey="true"/>
<Attribute
Name="ChildDesc"
IsQueriable="false"
IsPersistent="false"
ColumnName="$none$"
SQLType="VARCHAR"
Type="java.lang.String"
ColumnType="$none$"/>
<Attribute
Name="ParentPk"
IsQueriable="false"
IsPersistent="false"
IsNotNull="true"
ColumnName="$none$"
SQLType="VARCHAR"
Type="java.lang.String"
ColumnType="$none$"/>
</Entity>==============================================================================
Here is the ChildParentAssoc.xml for the Association between Parent and Child EOs:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE Association SYSTEM "jbo_03_01.dtd">
<!---->
<Association
xmlns="http://xmlns.oracle.com/bc4j"
Name="ChildParentAssoc"
Version="11.1.1.55.36">
<DesignTime>
<Attr Name="_isCodegen" Value="true"/>
</DesignTime>
<AssociationEnd
Name="Parent"
Cardinality="1"
Source="true"
Owner="model.eo.Parent"
DeleteContainee="true"
LockLevel="NONE"
ExposedAccessor="false">
<DesignTime>
<Attr Name="_aggregation" Value="0"/>
<Attr Name="_finderName" Value="Parent"/>
<Attr Name="_isUpdateable" Value="true"/>
<Attr Name="_minCardinality" Value="1"/>
</DesignTime>
<AttrArray Name="Attributes">
<Item Value="model.eo.Parent.ParentPk"/>
</AttrArray>
</AssociationEnd>
<AssociationEnd
Name="Child"
Cardinality="-1"
Owner="model.eo.Child"
HasOwner="true">
<DesignTime>
<Attr Name="_aggregation" Value="0"/>
<Attr Name="_finderName" Value="Child"/>
<Attr Name="_isUpdateable" Value="true"/>
</DesignTime>
<AttrArray Name="Attributes">
<Item Value="model.eo.Child.ParentPk"/>
</AttrArray>
</AssociationEnd>
</Association>==============================================================================
Here is the ParentEv.xml for the ParentEv VO:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
<!---->
<ViewObject
xmlns="http://xmlns.oracle.com/bc4j"
Name="ParentEv"
Version="11.1.1.55.36"
BindingStyle="OracleName"
CustomQuery="true"
RowClass="model.vo.ev.ParentEvRowImpl"
ComponentClass="model.vo.ev.ParentEvImpl"
PageIterMode="Full"
UseGlueCode="false">
<DesignTime>
<Attr Name="_codeGenFlag2" Value="Access|Coll"/>
<Attr Name="_isExpertMode" Value="true"/>
<Attr Name="_isCodegen" Value="true"/>
</DesignTime>
<EntityUsage
Name="Parent"
Entity="model.eo.Parent"/>
<ViewAttribute
Name="ParentDesc"
IsSelected="false"
IsQueriable="false"
IsPersistent="false"
PrecisionRule="true"
Precision="255"
EntityAttrName="ParentDesc"
EntityUsage="Parent"
AliasName="PARENTDESC"/>
<ViewAttribute
Name="ParentPk"
IsQueriable="false"
IsPersistent="false"
PrecisionRule="true"
EntityAttrName="ParentPk"
EntityUsage="Parent"/>
<ViewLinkAccessor
Name="ChildEv"
ViewLink="model.vo.vl.ChildEvParentEvVl"
Type="oracle.jbo.RowIterator"
IsUpdateable="false"/>
</ViewObject>==============================================================================
Here is the ChildEv.xml for the ChildEv VO:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
<!---->
<ViewObject
xmlns="http://xmlns.oracle.com/bc4j"
Name="ChildEv"
Version="11.1.1.55.36"
BindingStyle="OracleName"
CustomQuery="true"
RowClass="model.vo.ev.ChildEvRowImpl"
ComponentClass="model.vo.ev.ChildEvImpl"
PageIterMode="Full"
UseGlueCode="false">
<DesignTime>
<Attr Name="_codeGenFlag2" Value="Access|Coll"/>
<Attr Name="_isExpertMode" Value="true"/>
<Attr Name="_isCodegen" Value="true"/>
</DesignTime>
<EntityUsage
Name="Child"
Entity="model.eo.Child"/>
<ViewAttribute
Name="ChildDesc"
IsSelected="false"
IsQueriable="false"
IsPersistent="false"
PrecisionRule="true"
Precision="255"
EntityAttrName="ChildDesc"
EntityUsage="Child"
AliasName="CHILDDESC"/>
<ViewAttribute
Name="ChildPk"
IsUpdateable="while_insert"
IsQueriable="false"
IsPersistent="false"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="ChildPk"
EntityUsage="Child"/>
<ViewAttribute
Name="ParentPk"
IsQueriable="false"
IsPersistent="false"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="ParentPk"
EntityUsage="Child"/>
</ViewObject>==============================================================================
Here is the ChildEvParentEvVl.xml for the view link between ParentEv and ChildEv VOs:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE ViewLink SYSTEM "jbo_03_01.dtd">
<!---->
<ViewLink
xmlns="http://xmlns.oracle.com/bc4j"
Name="ChildEvParentEvVl"
Version="11.1.1.55.36">
<DesignTime>
<Attr Name="_isCodegen" Value="true"/>
</DesignTime>
<ViewLinkDefEnd
Name="ParentEv"
Cardinality="1"
Owner="model.vo.ev.ParentEv"
Source="true">
<DesignTime>
<Attr Name="_finderName" Value="ParentEv"/>
<Attr Name="_isUpdateable" Value="true"/>
</DesignTime>
<AttrArray Name="Attributes">
<Item Value="model.vo.ev.ParentEv.ParentPk"/>
</AttrArray>
</ViewLinkDefEnd>
<ViewLinkDefEnd
Name="ChildEv"
Cardinality="-1"
Owner="model.vo.ev.ChildEv">
<DesignTime>
<Attr Name="_finderName" Value="ChildEv"/>
<Attr Name="_isUpdateable" Value="true"/>
</DesignTime>
<AttrArray Name="Attributes">
<Item Value="model.vo.ev.ChildEv.ParentPk"/>
</AttrArray>
</ViewLinkDefEnd>
</ViewLink> -
Problem of deletion of rows in jtable, table refreshing too
Hi,
I have a table with empty rows in the beginning with some custom properties( columns have fixed width...), later user would be adding to the rows to this table and can delete, I've a problem while deleting the rows from table,
When a selected row is deleted the model is also deleting the data but the table(view) is not refreshed.
Actually i'm selecting a cell of a row, then hitting the delete button.
So the model is deleting the information, but i'm not able to c the fresh data in table( especially when the last cell of last row is selectd and hit the delete button, i am getting lots of exception)
Kindly copy the below code and execute it, and let me know,
* AuditPanel.java
* Created on August 30, 2002, 3:05 AM
import javax.swing.*;
import java.awt.*;
import javax.swing.table.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.util.Vector;
* @author yaman
public class AuditPanel extends javax.swing.JPanel {
// These are the combobox values
private String[] acceptenceOptions;
private Vector colNames;
private Color rowSelectionBackground = Color.yellow;
private int rowHeight = 20;
private int column0Width =70;
private int column1Width =96;
private int column2Width =327;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
/** Creates new form AuditPanel */
public AuditPanel() {
public void renderPanel(){
initComponents();
public String[] getAcceptenceOptions(){
return acceptenceOptions;
public void setAcceptenceOptions(String[] acceptenceOptions){
this.acceptenceOptions = acceptenceOptions;
public Vector getColumnNames(){
return colNames;
public void setColumnNames(Vector colNames){
this.colNames = colNames;
public Vector getData(){
Vector dataVector = new Vector();
/*dataVector.add(null);
dataVector.add(null);
dataVector.add(null);
return dataVector;
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jPanel2 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jTable1 = new javax.swing.JTable();
setLayout(new java.awt.GridBagLayout());
setBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
jPanel2.setLayout(new java.awt.GridBagLayout());
jPanel2.setBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
jButton1.setText("Add");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipadx = 8;
gridBagConstraints.insets = new java.awt.Insets(0, 1, 5, 0);
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
jPanel2.add(jButton1, gridBagConstraints);
jButton2.setText("Delete");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
jPanel2.add(jButton2, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
add(jPanel2, gridBagConstraints);
jPanel1.setLayout(new java.awt.GridBagLayout());
jPanel1.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.LOWERED, Color.black, Color.gray) );
jTable1.setModel(new javax.swing.table.DefaultTableModel(getData(), getColumnNames()));
// get all the columns and set the column required properties
java.util.Enumeration enum = jTable1.getColumnModel().getColumns();
while (enum.hasMoreElements()) {
TableColumn column = (TableColumn)enum.nextElement();
if( column.getModelIndex() == 0 ) {
column.setPreferredWidth(column0Width);
column.setCellEditor( new ValidateCellDataEditor(true) );
if( column.getModelIndex() == 1) {
column.setPreferredWidth(column1Width);
column.setCellEditor(new AcceptenceComboBoxEditor(getAcceptenceOptions()));
// If the cell should appear like a combobox in its
// non-editing state, also set the combobox renderer
//column.setCellRenderer(new AcceptenceComboBoxRenderer(getAcceptenceOptions()));
if( column.getModelIndex() == 2 ) {
column.setPreferredWidth(column2Width); // width of column
column.setCellEditor( new ValidateCellDataEditor(false) );
jScrollPane1 = new javax.swing.JScrollPane(jTable1);
jScrollPane1.setPreferredSize(new java.awt.Dimension(480, 280));
jTable1.setMinimumSize(new java.awt.Dimension(60, 70));
//jTable1.setPreferredSize(new java.awt.Dimension(300, 70));
//jScrollPane1.setViewportView(jTable1);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
jPanel1.add(jScrollPane1, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
add(jPanel1, gridBagConstraints);
// set the row height
jTable1.setRowHeight(rowHeight);
// set selection color
jTable1.setSelectionBackground(rowSelectionBackground);
// set the single selection
jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
// avoid table header to resize/ rearrange
jTable1.getTableHeader().setReorderingAllowed(false);
jTable1.getTableHeader().setResizingAllowed(false);
// Table header font
jTable1.getTableHeader().setFont( new Font( jTable1.getFont().getName(),Font.BOLD,jTable1.getFont().getSize() ) );
jButton1.setMnemonic(KeyEvent.VK_A);
// action of add button
jButton1.addActionListener( new ActionListener(){
public void actionPerformed(ActionEvent actionEvent){
// If a button press is the trigger to leave a JTable cell and save the data in model
if(jTable1.isEditing() ){
//System.out.println("table is edition ");
String text=((javax.swing.text.JTextComponent)jTable1.getEditorComponent()).getText();
jTable1.setValueAt(text,jTable1.getSelectedRow(),jTable1.getSelectedColumn()) ;
jTable1.getCellEditor().cancelCellEditing();
// find out total available rows
int totalRows = jTable1.getRowCount();
int cols = jTable1.getModel().getColumnCount();
if( jTable1.getModel() instanceof DefaultTableModel ) {
((DefaultTableModel)jTable1.getModel()).addRow(new Object[cols]);
int newRowCount = jTable1.getRowCount();
// select the first row
jTable1.getSelectionModel().setSelectionInterval(newRowCount-1,newRowCount-1);
jButton2.setMnemonic(KeyEvent.VK_D);
// action of Delete button
jButton2.addActionListener( new ActionListener(){
public void actionPerformed(ActionEvent actionEvent){
int totalRows = jTable1.getRowCount();
// If there are more than one row in table then delete it
if( totalRows > 0){
int selectedOption = JOptionPane.showConfirmDialog(null,"Are you sure you want to delete this audit row?","Coeus", JOptionPane.YES_NO_OPTION);
// if Yes then selectedOption is 0
// if No then selectedOption is 1
if(0 == selectedOption ){
// get the selected row
int selectedRow = jTable1.getSelectedRow();
System.out.println("Selected Row "+selectedRow);
if( selectedRow != -1 ){
DefaultTableModel dm= (DefaultTableModel)jTable1.getModel();
java.util.Vector v1=dm.getDataVector();
System.out.println("BEFOE "+v1);
v1.remove(selectedRow);
jTable1.removeRowSelectionInterval(selectedRow,selectedRow);
System.out.println("After "+v1);
}else{
// show the error message
JOptionPane.showMessageDialog(null, "Please Select an audit Row", "Coeus", JOptionPane.ERROR_MESSAGE);
} // end of initcomponents
class AcceptenceComboBoxRenderer extends JComboBox implements TableCellRenderer {
public AcceptenceComboBoxRenderer(String[] items) {
super(items);
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if (isSelected) {
setForeground(table.getSelectionForeground());
super.setBackground(rowSelectionBackground);
} else {
setForeground(table.getForeground());
setBackground(table.getBackground());
// Select the current value
setSelectedItem(value);
return this;
class AcceptenceComboBoxEditor extends DefaultCellEditor {
public AcceptenceComboBoxEditor(String[] items) {
super(new JComboBox(items));
} // end editor class
public class ValidateCellDataEditor extends AbstractCellEditor implements TableCellEditor {
// This is the component that will handle the editing of the
// cell value
JComponent component = new JTextField();
boolean validate;
public ValidateCellDataEditor(boolean validate){
this.validate = validate;
// This method is called when a cell value is edited by the user.
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int rowIndex, int vColIndex) {
if (isSelected) {
component.setBackground(rowSelectionBackground);
// Configure the component with the specified value
JTextField tfield =(JTextField)component;
// if any vaidations to be done for this cell
if(validate){
//tfield.setDocument(new JTextFieldFilter(JTextFieldFilter.NUMERIC,4));
tfield.setText( ((String)value));
// Return the configured component
return component;
// This method is called when editing is completed.
// It must return the new value to be stored in the cell.
public Object getCellEditorValue() {
return ((JTextField)component).getText();
// This method is called just before the cell value
// is saved. If the value is not valid, false should be returned.
public boolean stopCellEditing() {
String s = (String)getCellEditorValue();
return super.stopCellEditing();
public void itemStateChanged(ItemEvent e) {
super.fireEditingStopped();
}//end of ValidateCellDataEditor class
public static void main(String args[]){
JFrame frame = new JFrame();
AuditPanel auditPanel = new AuditPanel();
frame.getContentPane().add(auditPanel);
auditPanel.setAcceptenceOptions(new String[]{"Accepted", "Rejected", "Requested"} );
java.util.Vector colVector = new java.util.Vector();
colVector.add("Fiscal Year");
colVector.add("Audit Accepted");
colVector.add("Comment" );
auditPanel.setColumnNames( colVector);
auditPanel.renderPanel();
frame.pack();
frame.show();Hi,
I've got the solution for it. As when the cursor is in cell of
a row and hit the delete button, the data in that cell is not saved,
So i'm trying to save the data first into the model then firing the action event by doing this ..
jButton2.addActionListener( new ActionListener(){
public void actionPerformed(ActionEvent actionEvent){
// If a button press is the trigger to leave a JTable cell and save the data in model
if(jTable1.isEditing() ){
String text=((javax.swing.text.JTextComponent)jTable1.getEditorComponent()).getText();
jTable1.setValueAt(text,jTable1.getSelectedRow(),jTable1.getSelectedColumn()) ;
jTable1.getCellEditor().cancelCellEditing();
// HERE DO THE DELETE ROW OPERATION
<yaman/> -
Return first row entered based on date column
I'm trying to select the first entered row in a table, as judged by the datetime column. If more than one row has the same date and time, then only one row should be returned (any row having that datetime is fine). Some processing will occur on that row and then it will be deleted. The select statement is used thereafter to select the next (first) entered row in the table, etc. This way, the rows are processed first-in first-out (FIFO) style. Here's my example table:
create table my_table
datetime date,
firstname varchar2(50)
insert into my_table(datetime, firstname) values(to_date('2012-04-02 11:00:00', 'YYYY-MM-DD HH24:MI:SS'),'ken');
insert into my_table(datetime, firstname) values(to_date('2012-04-02 11:00:00', 'YYYY-MM-DD HH24:MI:SS'),'john');
insert into my_table(datetime, firstname) values(to_date('2012-04-02 11:00:00', 'YYYY-MM-DD HH24:MI:SS'),'sue');
commit;
Here's my example select statement, which returns simply one row of the above, since all are the same date and time:
SELECT *
FROM my_table
WHERE datetime = ( select min(datetime) from my_table )
AND rownum = 1;
My question is, if I use the following
SELECT *
FROM my_table
WHERE datetime = ( select min(datetime) from my_table );
It returns all 3 rows:
DATETIME FIRSTNAME
02-APR-12 11:00:00 ken
02-APR-12 11:00:00 john
02-APR-12 11:00:00 sue
So, wouldn't setting rownum = 2 return john, and rownum = 3 return sue? For example,
SELECT *
FROM my_table
WHERE datetime = ( select min(datetime) from my_table )
AND rownum = 2;
return no rows. I just want to make sure I'm understanding how the select statement above works. It seems to work fine for returning one row having the minimum date and time. If this is always the case, then everything is fine. But I wouldn't have expected it not to return one of the other rows when rownum is 2 or 3, which makes me question why? Maybe I can learn something here. Any comments much appreciated.
Edited by: tem on Apr 2, 2012 2:06 PMHi,
tem wrote:
... So, wouldn't setting rownum = 2 return john, and rownum = 3 return sue? For example,, ROWNUM
SELECT *
FROM my_table
WHERE datetime = ( select min(datetime) from my_table )
AND rownum = 2;
return no rows. I just want to make sure I'm understanding how the select statement above works. It seems to work fine for returning one row having the minimum date and time. If this is always the case, then everything is fine. But I wouldn't have expected it not to return one of the other rows when rownum is 2 or 3, which makes me question why? Maybe I can learn something here. Any comments much appreciated.ROWNUM is assigned as rows are fetched and considered for inclusion in the result set. If the row is not chosen for any reason, the same ROWNUM will be reused with the next row fetched. ROWNUM=2 will not be assigned until a row with ROWNUM=1 has been included in hte result set.
So, in your example:
SELECT *
FROM my_table
WHERE datetime = ( select min(datetime) from my_table )
AND rownum = 2;Say the first row that happens to be fetched has firstname='ken'. It is assigned ROWNUM=1, and fails the WHERE clause condition "WHERE rownum = 2".
Say the next row fetched has firstname='john'. ROWNUM=1 hasn't been used yet, so this row is also assigned ROWNUM=1, and it fails the WHERE clause for the same reason. Likewise with the next row; it also is assigned ROWNUM=1, and it also fails.
When using ROWNUM in a WHERE clause, you almost always want to say "ROWNUM = 1" or "ROWNUM <= n".
You could also use the analytic ROW_NUMBER function:
WITH got_r_num AS
SELECT datetime, firstname
, ROW_NUMBER () OVER (ORDER BY datetime) AS r_num
FROM my_table
SELECT datetime, firstname
FROM got_r_num
WHERE r_num = 1
;Here, all values of r_num are available, so it would make sense to say things like "WHERE r_num = 2" or "WHERE r_num >= 2".
Edited by: Frank Kulash on Apr 2, 2012 5:31 PM
Added to explanation. -
Hello,
I have got the following problem. I have got a table with data from my database. And a dataprovider to fetch the data from my rowset. I have got a button in each row of this table where i can get details or delete the corresponding row.
But when i click delete he wont delete the row correct. After a while i realised that the always fetch the same row. I dont understand why because i took the same code as it was used in the tutorial. For control i made a variable to remember the id of the fetched row but it wont change after the first "delete". Can somebody tell me why he wont change the value?
public String l�schen_action() {
try {
RowKey rowKey = tableRowGroup1.getRowKey();
int id = getSessionBean1().getMaxappid().parseInt(applikationDataProvider.getValue("APPID", rowKey).toString(), 10);
getSessionBean1().setTemp(id);
if(rowKey != null && applikationDataProvider.canRemoveRow(rowKey)){
applikationDataProvider.removeRow(rowKey);
applikationDataProvider.commitChanges();
applikationDataProvider.refresh();
} catch (Exception e) {
log("Fehler beim L\366schen des Eintrags", e);
error("Exception deleting row: " + e);
} // end try catch
return null;
Thanks in advance for help
AcinonyxTry this and see if that helps
Rowkey currentRowKey = (RowKey) getBean("currentRow");
- Winston
http://blogs.sun.com/roller/page/winston?catname=Creator
Maybe you are looking for
-
My Macbook pro running Lion 10.7 will not connect via a wireless network to either of my printers, Epson and HP. Both printers report an excellent connection to the correct network. The Macbook reports "printer not found" Until 2 weeks ago all worked
-
Add a Code to Change the ABAP Query
Hi All, I have a requirement in which i need to add a check box to a selection screen in ABAP query i inserted this check box in the infoset .The report is using joins from table EKKO,EKPO and EKES and display all the Vendor Confirmation details but
-
I have set iPhoto 5 preferences so that when I double-click on a photo in the iPhoto library, it should open in Photoshop Elements; however, what happens is that Photoshop attempts to launch then quits without ever opening the picture. I realize this
-
Mi cuenta icloud no esta verificada, me equivoque en la cuenta y no recuerdo la contraseña
Mi cuenta iCloud no esta verificada, me equivoque al registrarme en la cuenta y no recuerdo la contraseña ni las preguntas de seguridad, gracias.
-
Is the radio available on the iPhone and if so where do I find it please?