Get No. of Affected Rows After Commit
In my application, I'm showing data in af:table which is editable.
I need to show the no. of rows affected after calling a commit.
Edited by: Anooj on Nov 21, 2011 10:52 PM
There are some possible solutions for your problem. Only we can't help if you tell us which jdev version you are using and which technology you are working on.
Timo
Similar Messages
-
Refresh only current row after commit, when ChangeEventPolicy set to none
Hi,
I'm using jdeveloper 11.1.2.3.0
I'm editing a table with a popup, I set the ChangeEventPolicy to none because it made some problems.
Now I would like to know, when i'm closing the popup and doing commit,
how could I refresh only the current row, and not whole the table?
I would like it to work as with ChangeEventPolicy set to ppr.
Thanks!could you please explain a little bit more?
When I used the ChangeEventPolicy with ppr it looks like only the selected row was changed after commit.
but with PartialTrigger i see that it's refreshing all the table.
are you sure they are working the same?
what about row.refresh(..), is it only used for rollback? -
Reset of current row after commit in ADF-UIX
Dear experts,
I have developed an application with Oracle JDeveloper 10g and ADF-UIX using BC4J. The problem is that wherenever a commit is performed the current row for the master table is reset which causes confusion for the end user.
Do you know how can I solve that problem?
Thank you in advance,
Constantine... I forgot to mention that I use JDeveloper 3.1 on Windows NT4.
About my problem, it seems that a "key" does not exist in the record (Row object) i'm using for.
So, what really is a "key"? Is this an internal complicated number or just the values of some data fields, indicated as "Primary Key" in the table?
If the answer is the second one, I have to say that at the really before commit of the record, the value of my primary key fields is NULL, because they are filled up by a "sequence object" created in the database (triggered by a "TRIGGER BEFORE INSERT", which calls the "sequence.nextval" SQL command).
So, I really have the value of my primary key fields just after committing the record in the database, and would explain everything.
But is really this the "key"?
Thanks -
Delete statement: how to get count of affected rows in a variable
Hi folks
I write a proc which deletes data from bunch of table based on data value. i want to produce a report which will have 1 line for each table like:
Del: Table name : number of rows
I parse delete statement into variable and use execute immediate. I know I could precede delete by select count(*) using the same criteria. Is there any more effective way to catch output from execution of 'delete' itself to avoid an overhead of running select count(*)?
Thank you, Gene.Gene,
I thought you said you wanted to have the number of rows deleted. In that case, see Sänjay's example above.
Btw, is there a particular reason that you are using EXECUTE IMMEDIATE (?)
To have it in a variable
declare
v_rows_deleted number;
begin
delete from emp;
v_rows_deleted := SQL%ROWCOUNT;
end ;Regards
Peter
Edited by: Peter on Jul 23, 2009 7:48 AM
Added example -
Hi,
I have three tabs in my page , and in each tab , i have separate taskflows.
The first tab taskflow contains a jsff which has lets say master table iterator i.e departments iterator.
In the second tab, i have a table based on read only query, but when i click on add button, i will be inserting in to detail VO (employee VO) and using postChanges() .
so that read-only query based table gets the new data.
now when i click on save button and commit , the iterators in taskflows of tab1, tab2 are pointing to first record rather than the current record.
1) even i tried with having an action for the 'save' button and navigating to method activity which sets the iterator to current row.
When i am returning back to taskflow,i am still seeing the iterator pointing to first record rather than the current record i intend to see.
could anybody tell me why iterator is pointing to first row after commit()
i don't have 'refresh' -- if needed for taskflows. its default.
for transactions, datacontrols, its default for my taskflows.I generally retain the previously selected row using the following code in my VOImpl after every executeQuery().
public void executeQuery()
// current row key if any
Key currentRowKey = null;
Row currentRow = getCurrentRow();
if ( currentRow != null )
// get current row key
currentRowKey = getCurrentRow().getKey();
// super call
super.executeQuery();
if ( currentRowKey != null )
// set current row now using previously stored key
Row[] rows = findByKey( currentRowKey, 1 );
if ( rows != null && rows.length == 1 )
setCurrentRow( rows[0]);
} -
Hi, when can i get the recently deleted rows
Hi,
Where can I get the recently deleted rows after commiting the transactions.
Thanks in advance.To query your table e.g. one hour ago:
select * from your_table as of timestamp sysdate - 1/24change 1/24 to a number where you think your data were still in the table. -
After commit current row is no longer highlighted
JDeveloper 11.1.1.20.
Scenario: a master detail page where master and detail are both ordinary ADF table ( NOT read-only).
If I place the cursor on a master row and do a click the row is highlighted.
If I do a createInsert operation (with a button) a new row is created above the previous mentioned row.
Problem:
If I do a commit after the new row is filled with data sometimes the newly made row is now longer highlighted after the commit.
The newly created row is stil active. This is seen by the fact that if I subsequently creates a new deatil row it is correctly connected to the newly created master row.
And - after the newly created detail row is created the master row is again highligted.
Any ideas?
Best regards
ErikHi,
To keep highlight the selected row do some operation in bean ,Get selected row and set that row again after commit
Check
http://jobinesh.blogspot.com/2011/01/declaratively-setting-current-row-key.html -
HANA equivalent of oracle's sql%rowcount to get affected rows.
I want to get the number of rows affected from an insert or update statement inside a stored procedure.
Is there any equivalent to oracle's sql%rowcount that can be called after the query.
For example:
create procedure procedure_name
begin
declare l_c integer;
insert into table values ('somevalue');
l_c := sql%rowcount; -- This would return 1 for the row inserted.
end;Yes, after the INSERT statement....
SELECT ::ROWCOUNT into L_C FROM DUMMY;
Cheers,
Rich Heilman -
How can i get all these values in single row with comma separated?
I have a table "abxx" with column "absg" Number(3)
which is having following rows
absg
1
3
56
232
43
436
23
677
545
367
xxxxxx No of rows
How can i get all these values in single row with comma separated?
Like
output_absg
1,3,56,232,43,436,23,677,545,367,..,..,...............
Can you send the query Plz!These all will do the same
create or replace type string_agg_type as object
2 (
3 total varchar2(4000),
4
5 static function
6 ODCIAggregateInitialize(sctx IN OUT string_agg_type )
7 return number,
8
9 member function
10 ODCIAggregateIterate(self IN OUT string_agg_type ,
11 value IN varchar2 )
12 return number,
13
14 member function
15 ODCIAggregateTerminate(self IN string_agg_type,
16 returnValue OUT varchar2,
17 flags IN number)
18 return number,
19
20 member function
21 ODCIAggregateMerge(self IN OUT string_agg_type,
22 ctx2 IN string_agg_type)
23 return number
24 );
25 /
create or replace type body string_agg_type
2 is
3
4 static function ODCIAggregateInitialize(sctx IN OUT string_agg_type)
5 return number
6 is
7 begin
8 sctx := string_agg_type( null );
9 return ODCIConst.Success;
10 end;
11
12 member function ODCIAggregateIterate(self IN OUT string_agg_type,
13 value IN varchar2 )
14 return number
15 is
16 begin
17 self.total := self.total || ',' || value;
18 return ODCIConst.Success;
19 end;
20
21 member function ODCIAggregateTerminate(self IN string_agg_type,
22 returnValue OUT varchar2,
23 flags IN number)
24 return number
25 is
26 begin
27 returnValue := ltrim(self.total,',');
28 return ODCIConst.Success;
29 end;
30
31 member function ODCIAggregateMerge(self IN OUT string_agg_type,
32 ctx2 IN string_agg_type)
33 return number
34 is
35 begin
36 self.total := self.total || ctx2.total;
37 return ODCIConst.Success;
38 end;
39
40
41 end;
42 /
Type body created.
[email protected]>
[email protected]> CREATE or replace
2 FUNCTION stragg(input varchar2 )
3 RETURN varchar2
4 PARALLEL_ENABLE AGGREGATE USING string_agg_type;
5 /
CREATE OR REPLACE FUNCTION get_employees (p_deptno in emp.deptno%TYPE)
RETURN VARCHAR2
IS
l_text VARCHAR2(32767) := NULL;
BEGIN
FOR cur_rec IN (SELECT ename FROM emp WHERE deptno = p_deptno) LOOP
l_text := l_text || ',' || cur_rec.ename;
END LOOP;
RETURN LTRIM(l_text, ',');
END;
SHOW ERRORS
The function can then be incorporated into a query as follows.
COLUMN employees FORMAT A50
SELECT deptno,
get_employees(deptno) AS employees
FROM emp
GROUP by deptno;
###########################################3
SELECT SUBSTR(STR,2) FROM
(SELECT SYS_CONNECT_BY_PATH(n,',')
STR ,LENGTH(SYS_CONNECT_BY_PATH(n,',')) LN
FROM
SELECT N,rownum rn from t )
CONNECT BY rn = PRIOR RN+1
ORDER BY LN desc )
WHERE ROWNUM=1
declare
str varchar2(32767);
begin
for i in (select sal from emp) loop
str:= str || i.sal ||',' ;
end loop;
dbms_output.put_line(str);
end;
COLUMN employees FORMAT A50
SELECT e.deptno,
get_employees(e.deptno) AS employees
FROM (SELECT DISTINCT deptno
FROM emp) e;
DEPTNO EMPLOYEES
10 CLARK,KING,MILLER
20 SMITH,JONES,SCOTT,ADAMS,FORD
30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES
CREATE OR REPLACE FUNCTION concatenate_list (p_cursor IN SYS_REFCURSOR)
RETURN VARCHAR2
IS
l_return VARCHAR2(32767);
l_temp VARCHAR2(32767);
BEGIN
LOOP
FETCH p_cursor
INTO l_temp;
EXIT WHEN p_cursor%NOTFOUND;
l_return := l_return || ',' || l_temp;
END LOOP;
RETURN LTRIM(l_return, ',');
END;
COLUMN employees FORMAT A50
SELECT e1.deptno,
concatenate_list(CURSOR(SELECT e2.ename FROM emp e2 WHERE e2.deptno = e1.deptno)) employees
FROM emp e1
GROUP BY e1.deptno;
DEPTNO EMPLOYEES
10 CLARK,KING,MILLER
20 SMITH,JONES,SCOTT,ADAMS,FORD
30 ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES
CREATE OR REPLACE TYPE t_string_agg AS OBJECT
g_string VARCHAR2(32767),
STATIC FUNCTION ODCIAggregateInitialize(sctx IN OUT t_string_agg)
RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateIterate(self IN OUT t_string_agg,
value IN VARCHAR2 )
RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateTerminate(self IN t_string_agg,
returnValue OUT VARCHAR2,
flags IN NUMBER)
RETURN NUMBER,
MEMBER FUNCTION ODCIAggregateMerge(self IN OUT t_string_agg,
ctx2 IN t_string_agg)
RETURN NUMBER
SHOW ERRORS
CREATE OR REPLACE TYPE BODY t_string_agg IS
STATIC FUNCTION ODCIAggregateInitialize(sctx IN OUT t_string_agg)
RETURN NUMBER IS
BEGIN
sctx := t_string_agg(NULL);
RETURN ODCIConst.Success;
END;
MEMBER FUNCTION ODCIAggregateIterate(self IN OUT t_string_agg,
value IN VARCHAR2 )
RETURN NUMBER IS
BEGIN
SELF.g_string := self.g_string || ',' || value;
RETURN ODCIConst.Success;
END;
MEMBER FUNCTION ODCIAggregateTerminate(self IN t_string_agg,
returnValue OUT VARCHAR2,
flags IN NUMBER)
RETURN NUMBER IS
BEGIN
returnValue := RTRIM(LTRIM(SELF.g_string, ','), ',');
RETURN ODCIConst.Success;
END;
MEMBER FUNCTION ODCIAggregateMerge(self IN OUT t_string_agg,
ctx2 IN t_string_agg)
RETURN NUMBER IS
BEGIN
SELF.g_string := SELF.g_string || ',' || ctx2.g_string;
RETURN ODCIConst.Success;
END;
END;
SHOW ERRORS
CREATE OR REPLACE FUNCTION string_agg (p_input VARCHAR2)
RETURN VARCHAR2
PARALLEL_ENABLE AGGREGATE USING t_string_agg;
/ -
Does Update function module gets executed after Commit Work?
Hi Gurus,
I have a BAPI with a Commit work. Does update function module V1 , V2 - i need mainly about the sequence of V2, gets executed after Commit work or before Commit work.
ThanksPl refer to SAP help on the same as follows.
https://help.sap.com/saphelp_nw04/helpdata/en/e5/de86e135cd11d3acb00000e83539c3/content.htm
Regards,
Naveen Vishal -
Get the number of rows affected by update statement
Hi
I'm working on an application that uses OCI as interface against an Oracle database.
I'm trying to find out how i can get the number of rows affected by a query executed with OCIStmtExecute. it is not a select query.
Best regards,
Benny TordrupIf I run a bulk UPDATE query using OCIBindArrayOfStruct, is there a way I can tell which+ rows successfully updated?
I have a file of records of which 75% of PKs are already in the table and will be updated, the other 25% aren't and should be inserted later. I want to attempt an UPDATE statement using OCIBindArrayOfStruct to execute in bulk and then check which entries in my bulk array successfully updated. If an array entry isn't successfully updated then I will assume it should be inserted and will store it for a Direct Path load later.
Many thanks for any advice you can give as I've been trawling through the docs trying to find a solution for ages now. -
How Do I get SSIS To Stop Looping Through Excel Rows After Last Populated Record?
I have a package that loops through many excel files. Each Excel File has about 5000 rows. My problem is that after the 5000th row SSIS keeps looping through all the rows after the last row. There are nothing in these rows. This is a complete bottleneck
of my package because it takes forever when doing this. How do I stop this?
ThanksAnother way is to specify the range in select statement which can be done in two ways
http://getsetsql.blogspot.in/2012/01/using-ssis-load-data-to-excel-sheet-at.html
http://sqlserversolutions.blogspot.in/2009/02/selecting-excel-range-in-ssis.html
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Updating row after insert that causes trigger
Hi,
I have a table which one of the columns is a sequence number which each time a new row is written I want to automatically write to this sequence column the latest number (which is maintained using an Oracle sequence). I decided to use a trigger which works great:
CREATE OR REPLACE TRIGGER pre_insert_trg before insert ON INCOMING
for each row
BEGIN
SELECT INCOMING_SEQ.NEXTVAL
INTO :new.SEQ
FROM DUAL;
END;
The problem is I have many multi-threaded processes writing to this table and the sequence number gets allocated before the row is committed which means although thread 1 may write first it may commit after thread 2 which has a later sequence number which has the result that sequence number 2 may be shown before 1. The problem is much larger when dealing with many threads with 100's of messages a second and so I would prefer the seq to be added AFTER the insert (once committed), e.g.
CREATE OR REPLACE TRIGGER post_insert_trg after insert ON INCOMING
for each row
BEGIN
SELECT INCOMING_SEQ.NEXTVAL
INTO :new.SEQ
FROM DUAL;
END;
Trying to create this trigger results in a "ORA-04084: cannot change NEW values for this trigger type". Is there a way to update a column for the row which caused the trigger? If I try and remove the :new. I then get errors when inserting about mutating table (which I understand the DML locking but need a way round)
Many thanks,
JohnOff hand I think the only way you can do what you say you want to do is to replace the sequence with a code table. A transaction locks the code table, gets the next value from it and unlocks the code table at the end of the transaction. This ensures that the sequence number is always assigned in transaction completion order (or rather the transactions always complete in sequence assigned order). It is basically what java does with its synchronize statement.
The only drawback with this approach is that it completely shags the performance of the sort of multi-threaded environment you've just described. :P
So you need to decide what's more important: having stuff inserted into a queue in sequence order or having a multi-threaded system running quickly. I really don't see how you can acheive what you're attempting in a genuinely concurrent environment; you'll have to introduce an artificial serialism (ie bottleneck) somewhere.
If you do crack this please tell me how: I would be interested in ordering multiple AQs in the fashion you described.
Cheers, APC -
"The option FOR UPDATE is blocking the table instead of blocking the rows returned
by the SELECT .. FROM .. WHERE clause.
Is there any way to only block the affected rows; keeping in mind that I am using Power Builder."well
it depends. if you design your application to have a mass update , then you may need to lock the entire qualifying rowset.
if you need to process record by record , it is better to include a COMMIT immediately after you complete UPDATE operation.
This immediate COMMIT is to avoid the EXPLICIT locking of records by POWERBUILDER. and This will facilitate other users
by allowing an access to the remaining records in the table.
thanks
prakash -
How to get a Sum of rows, when i use the property max. rows p. page ?
Hi all.
I've got a query and get a lot of rows (amounts) back.
Now i want to have max. 21 rows per page.
So, first i used the property "max. rows p. page"=21.
But i want a have Sum-Field p.page too, which shows the sum of the amount p. page at a >fixed place (bottom, left) at the page.
this didnt work well....
Because when i have 30 rows, then the sum will shown at the second page (because the sum-field its after the repeating frame).
...Now i forgot the property and placed a function and two placeholder in the query like this:
Function:
:cp_row:=:cp_row +1;
if (mod (:cp_row,21)=0)) then :CP_pagenr:=:CP_pagenr+1;
Placeholders: cp_row, cp_pagenr
Now i want to use :CP_pagenr to change the group - but Report Builder says: I cant... because placeholder are not allowed to change a group.
So.. perhaps anyone can give me a hint how i can do this ?
Thanks a lot...hello.
that sound to me as you wanted a running total. check out the metalink knwoledge base and search for running total and you will find a note on how to do that.
regards,
the oracle reports team --pw
Maybe you are looking for
-
IE won't display Dreamweaver template.
I did a quick site for a friend. "Quick" also meaning "free", in this instance. I use a Mac and had not looked at the site in IE until last weekend. Is there code you can stick into the template (twoColHybLtHdr) that will make it display the page cor
-
is there any device (enclosure, housing, hub, adapter, cable, etc) which allows me to take the SSD out of my cylinder Mac Pro and connect it to an other device (MacBook Pro, iMac, ...) over USB, Thunderbolt or what ever? i found a lot of those cases
-
Hi everyone, I just got a question about the Mac that I'm using, why there is a black border on items that I've selected, how can I remove/disable it? In my browser the close button is surrounded by the black border. In dialog box the buttons like YE
-
Chat keeps showing me offline when i talk in facebook to people and i am still online and logged in
i chat to people in facebook and i appear offline then when they answer they get the message that i am offline and need to send it as a message ie hello (send as a message) your chat message wasn't sent because madmax was offline . i am logged in all
-
Migration from Former budgeting to BCS
Dear experts, is there anybody who has experience with migration from FB to BCS? If yes, which method have you used - from scratch, migrating totals or migrating documents and what problems have you met during the course of migrating? Thank you in ad