Count the number of rows inserted
Hi,
Is there a way to count the number of rows processed post DML in PL/SQL?
For eg,
BEGIN
INSERT INTO TMP1
SELECT * FROM EMP;
a function to count the number of rows inserted into tmp1
SQL> set serveroutput on;
SQL> begin
2 insert into tmp1 select * from emp;
3 dbms_output.put_line(SQL%ROWCOUNT||' rows inserted');
4 end;
5 /
15 rows inserted
PL/SQL procedure successfully completed.
Similar Messages
-
How to count the number of Rows to be Updated before Update takes place..
Hi all,
I have a requirement, where i have to count the number of rows to be updated before updating it. SQL%ROWCOUNT gives the no. of rows updated ( after update takes place). How do i get to know the count of no. of rows to be updated/inserted/ deleted. I was looking for a simple solution, as above SQL%Rowcount. But i couldn't find any. I can use a Function and Return the value which will give me number of rows to be updated, But is there any Simple Logic other than this.. or any count function. Your Help is Appreciated. Thanks!If you really want to do this (I have no clue why you would need it), then you can piggy back on any existing pessimistic locking you may already have in place.
However, it would require two loops through the records of which you want to know the count before you update, and a second pass to update them.
I would really re-think the need for this, though.
SQL> create table t0304(c number);
Table created.
SQL> insert into t0304 select rownum from all_objects where rownum <= 10;
10 rows created.
SQL> commit;
Commit complete.
SQL> select * from t0304;
C
1
2
3
4
5
6
7
8
9
10
10 rows selected.
SQL> declare
2 cursor mycursor is select * from t0304 where mod(c,2) = 0 for update;
3 i number := 0;
4 begin
5 for r in mycursor loop
6 i := i + 1;
7 end loop;
8 dbms_output.put_line(i);
9 for r in mycursor loop
10 update t0304 set c = c + 20 where current of mycursor;
11 end loop;
12 end;
13 /
5
PL/SQL procedure successfully completed.
SQL> commit;
Commit complete.
SQL> select * from t0304;
C
1
22
3
24
5
26
7
28
9
30
10 rows selected.
SQL>Edited by: Steve Howard on Mar 4, 2011 5:57 PM -
How to count the number or rows in file
Hi Experts,
I am file as source and Oracle as target. My file containing the some data which is going to load to the target.
My requirement is that I want to count the number of rows which my file contains. Please help me how to count the total number of rows in file.
Thx,
Sahadeva.Hi,
You won't give a name DEST_USER_NAME:ODI will get these information.
it is important Command on source and Command on Source side .
-Pls write jython code on Command on Source side
-And Command On Target side Choose technology as Oracle and set logical schema to HR_logical
Sorry my mistake.İt is related jython syntax.Here is code:
import java.lang as lang
import java.sql as sql
import java.lang.String
import os
lang.Class.forName("<%=snpRef.getInfo("DEST_JAVA_DRIVER")%>")
cons=sql.DriverManager.getConnection("<%=snpRef.getInfo("DEST_JAVA_URL")%>", "<%=snpRef.getInfo("DEST_USER_NAME")%>", "<%=snpRef.getInfo("DEST_PASS")%>")
dblinks= cons.createStatement()
file1=open('EMP.txt','r')
count=0
line=file1.readline()
while line !='':
count+=1
line=file1.readline()
file1.close()
sqlQuery = "insert into HR.ETL_FILE_LOG (FILE_COUNT) values (count)"
rqQuery= dblinks.execute(sqlDBLink)
cons.close()
Regards -
How to count the number of rows in a cube!!??
Experts,
I can somebody tell me how do I count the number of rows in my cube when i am using listcube???..
Thanks
AshwinHi,
have a look ath this theard too
Number of Records in Cube
regards -
How to count the number of rows in a resultser object?
hi there
how to count the number of rows in a resultser object which may contains millions of rows? besides using a while loop? thanksYou don't, you execute a query whose result is the record count of those records that match the search and then you execute the actual query to create your record set. Typically you do
select count(id) from YourTable where [filter]
from the resulting ResultSet do
int res.getInt(1);
which gives you the count and then
select id from YourTable where [filter]
to produce the actual result set.
in the second query the id part can be substituted with the actual fields you want. -
Count the Number of Rows in Data form
Hi,
I want to count the number of rows in a data form.In my form there is a large number of rows.Is there any way to count it.
Thanks.If you are on 11.1.2.x then you could look at adding a formula and using the CountA function - http://download.oracle.com/docs/cd/E17236_01/epm.1112/hp_admin/apcs03s06.html
Otherwise it would be possible using custom javascript which you would have to had some experience in using.
Cheers
John
http://john-goodwin.blogspot.com/ -
Count the number of rows in a workbook.
Hi Experts , I have a requirement to count the number of rows in a WorkBook.Will it be possible to do this by creating a KeyFigure?Or are there any options in BEx to count and display the number of Rows.Many thanks for all your help.
Hi
In the query create a calculated key figure called 'Count' and put a formula as =1, then use this count where ever applicable..you can very well count the no. of rec.
with this.
Hope this helps..
assign points if useful..
Cheers,
Pattan. -
Count the number of rows resulting from a select statement
Hi,
Is there any way of counting the number of rows resulting from a select statement. i.e I have a select distinct statement and I then want to perform an IF statement on the number of rows resulting from the select statement.
Any help appreciated
Thanks
GaryDeclare
var1 number;
Begin
select count(distinct column_name) into
var1 from table_name;
If var1 > x Then
End IF;
End;
Hope I understood the problem correctly
null -
Count the number of rows in an array
Hi there,
I'm quite new with Labview, maybe somebody can help me.
I have a .vi that controls two pump with certain ratios (to make a composition gradient). I export the data to an ascii file, which write the displacement of the two pumps in 2 colums. However, the number of rows is related to the ms-counter, and thus related to the processor of the computer. Now I need, at the end of the vi, to get the number of rows written to the ascii file, to do some further calculations. Does anybody know how to do this?!
ThanksYou could wire the loop-counter to a variable outside the loop, so you can see the number of iterations (don't forget to add 1).
You also can use the Array Size-Function. Here you get different outputs, according to the dimensions of the array to get the size of.
Here you can see what you get if you use this function:
1D-Array: one value
2D-Array: array, item 0 = number of rows, item 1 = number of columns
3D-Array: array, item 0 = number of pages, item 1 = number of rows, item 2 = number of columns
So if (in your case) you wire a 2D-Array you can use the array-size function, select item 0 of the array you get and you get the number of rows.
You can also have a look at the attachement.
Hope it helps.
Thomas
Using LV8.0
Don't be afraid to rate a good answer...
Attachments:
ArraySize.vi 17 KB -
Can I "count" the number of rows excluding the header and footers
I have some tables that consist of a different number of rows, as the number is part of an equation I need to know the number of rows excluding the header and footers. I have the work around in =ROWS(ColumnG)-3, but is there a tidier way? I want to be able to add footers (or headers) too and not have these counted.
Many thanks
LeeHi Lee,
Add a column to your table (for purposes of this discussion, the new column is placed before column C, and becomes the new column C). enter the formula below in all regular cells, but NOT in header or footer cells:
=1
Use the formula below, placed anywhere (except in a regular cell in column C) to get the number of non-header, non-footer cells:
=COUNT($C)
The first formula will automatically be placed in cells added to column C, and the results will change to reflect the added rows.
Regards,
Barry -
Want to count the number of rows of analysis item in WAD Template
HI all,
Detail Description:
In my WAD report, i have a Export to Excel Option. But I want when I click on this button, one pop up will come only if no of rows of the Analysis Item is Greater than 10,000 ask for Do you want to proceed or not.
Means 1st i want to count the no of rows in the Analysis Item, after that it will check, if the no of rows is greater that 10,000. then the pop up will come.
Question:
Does anyone know, "how to count the no of rows of the analysis Item ?" . It will be better if you know you to implement this with the help of java script.
Means there must be some varible, which counts the no of rows. If you know then please help meHi,
Please find the below link which helps you to get solution of your question.
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0bbb20f-2d7e-2e10-258f-8655daa41fab?QuickLink=index&overridelayout=true
It is mainly used to automate queries, web templates, and reports in different output formats like PDF, Excel,
XML, XHTML, and HTML
How to see WAD reports on browser:
The BEx Web Application Designer is a desktop application for creating Web applications with BW-specific contents. Using the BEx Web Application Designer, you can create an HTML page that contains contents such as various tables, charts or maps. This HTML page (Web application) provides the basis for not only Web applications with complex interaction, but also for Web cockpits and iViews.
http://help.sap.com/saphelp_nw04/helpdata/en/1a/456a3badc1b315e10000000a114084/content.htm
Web Application Designer for Beginners
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/749a4622-0a01-0010-36bf-b6b30a2a3a22
Web Application Solutions: A Designer's Guide
http://www.lukew.com/resources/webapplicationsolutions.pdf
http://sap.ittoolbox.com/groups/technical-functional/sap-solution-manager/bw-web-application-designer-1955944
Feautures of WAD in 7.0
http://help.sap.com/saphelp_nw70/helpdata/en/88/4d354277dcb26be10000000a155106/frameset.htm
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5c46376d-0601-0010-83bf-c4f5f140e3d6
Regards
Sudheer -
Count the number of rows based on the values!!!
Hi all,
What I am using:
I am working with a multidimensional database in Visual Studio 2010 using its Data source view and calculation member and dimension usage.
What I want to do:
I have a fact table that has five columns(leg(s),hand(s), Head and body,overall) that shows the category of how severe the injury is. Let say for the records all columns never have an empty value(no injury is stated with 'No injury' ) . These five columns
are connected with a dimension that has all the available values (Category A-E of injury).The overall has the most severe from the other four columns. I want to create a bar chart with five different measure
values, one for each column, and count the values in those columns.
For example : I have a slicer in the excel and a bar chart and the slicer has all the values of the Category of the injury ( Cat a,Cat B, Cat C, ... Cat E, No injury ) and when i select one of them, lets say
Cat C, the bar chart should update and show how many Cat C each measurement column has.
Example FACT table:
ID LEG HAND HEAD BODY OVERALL
1 No A No No A
2 No D C C C
3 E C D A A
4 E E B C B
So if i selected C the bar chart will count (Leg = 0, Hand = 1, Head = 1, body = 2 and Overall = 1).
Any ideas ?
Thanks for the help and the time :)Hi DBtheoN,
According to your description, you want to create a chart on excel worksheet to count the rows based on the value, right? If in this case, I am afraid this issue is related to Office forum, I am not the expert of Office, you can post the issue on the corresponding
forum.
However, this requirement can be done easily on SQL Server Reporting Services. You can using the expression below to count the rows.
=COUNT(IIF(Fields!LEG.Value=Parameters!TYPE.Value,1,NOTHING))
Regards,
Charlie Liao
TechNet Community Support -
Hi,
For the different log on dates for user , I want to calculate the number of times user has logged on i.e. count for (0calmonth) in the report .
Is this possible ?
Please let me know.
Thanks & Regards,
JeetuHI Jeetu,
Check this doc................
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/009819ab-c96e-2910-bbb2-c85f7bdec04a
Regards,
Vijay. -
I have a JSP page that access to a JAVA class, where I connect with the MySQL data base, and where I make some consults.
Hi, I need to knows how many rows I get from a SELECT consult.
I have this class to do:
package connectDB;
import java.lang.*;
import java.sql.*;
public class MyConnection{
Connection dbconn;
ResultSet results;
PreparedStatement sql;
public MyConnection()
try
Class.forName("org.gjt.mm.mysql.Driver");
try
dbconn = DriverManager.getConnection("jdbc:mysql://localhost/MyDataBase?user=USER&password=PASSWORD");
}catch (SQLException s)
System.out.println("SQL Error<br>");
}catch (ClassNotFoundException err)
System.out.println("Class loading error");
public int getDescribFile()
int number=0;
try
String consulta = "SELECT id_user, name_file, date_file, length_file FROM File_user";
sql = dbconn.prepareStatement(consulta);
results = sql.executeQuery();
/* HERE I�M TRYING TO COUNT HAOW MANY ROWS ARE THERE*/
boolean fr = results.absolute(1);
number = results.getResultRowCount() ;
}catch (SQLException s)
System.out.println("SQL Error<br>");
return number;
}How can I do ??
ThanksHi, I have done wath you say and I have been able to do this
In th JSP page
String StringFiles[][] = myConnection.getDescribFile();
In the Java class
public String[][] getDescribFile(){
int numberRows=0;
try{
String consulta = "SELECT count(id_file) as numero FROM File_user where id_file>0";
sql = dbconn.prepareStatement(consulta);
results = sql.executeQuery();
numberRows = results.getInt("numero");
}catch (SQLException s)
System.out.println("SQL Error<br>");
String cadReturn[][] = new String[numberRows][4];
try
String consulta = "SELECT id_user, name_file, date_file, length_file FROM File_user";
sql = dbconn.prepareStatement(consulta);
results = sql.executeQuery();
for(int i=0;i<numberRows;i++)
results.next();
cadReturn[0] = results.getString("id_user");
cadReturn[i][1] = results.getString("name_file");
cadReturn[i][2] = results.getString("date_file");
cadReturn[i][3] = results.getString("length_file");
}catch (SQLException s)
System.out.println("SQL Error<br>");
return cadReturn;
Thanks -
Count the number of rows in each table
I have a list of table names, how to I write a query to find out the row count of each table.
select table_name from all_tables a where owner='XXX' and num_row > 100
or
select table_name from all_tables a where owner='XXX' and sample_size > 100
doesn't quite work.
Why?
Thanks in advance,
Edited by: mpt_fz on Jan 12, 2010 12:06 PMWell, then another method learned from Michael ;)
scott@ORCL>
scott@ORCL>select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
PL/SQL Release 11.1.0.6.0 - Production
CORE 11.1.0.6.0 Production
TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
Elapsed: 00:00:00.14
scott@ORCL>
scott@ORCL>
scott@ORCL>select table_name,
2 DBMS_XMLGEN.getxmltype(
3 'select count(*) c from '||table_name
4 ).extract('//text()').getnumberval() tot_rows
5 from user_tables
6 where iot_type is null
7 or iot_type != 'IOT_OVERFLOW';
TABLE_NAME TOT_ROWS
A_TEST_TB_CASHFLOW 14
TEST_DUMMY 1
A_TEST_TB_CASHFLOW_N 1
TEST_CAST 1
DEPT 4
EMP 14
BONUS 0
SALGRADE 5
EMP_DETAILS 3
T_EMP 0
AUDIT_T 0
TABLE_NAME TOT_ROWS
C_C 4
TRAIN_DET 2
TEST_COM_IMP 2
TIME_P 1
PRI_UQ 4
TEST_CHK 0
ANSHUMANSAHAISGENIOUS 1
T 1
XEUROPE 2
D_D 8
PUBLICTRANSPORT 4
TABLE_NAME TOT_ROWS
XASIA 2
TF1 0
TEST_HH 14
TEST_SWAP 4
REVIVE_XML 3
XGMT 1
CUSTOMER_DET 1
FOURWHEELER 2
SPOOL_LOG 13
CITYTRANSPORT 8
T1 2
TABLE_NAME TOT_ROWS
T2 2
A_A 1
B_B 2
AUTOMOBILE 1
XDUAL 1
S_TEMP 0
39 rows selected.
Elapsed: 00:00:08.78
scott@ORCL>Regards.
Satyaki De.
Maybe you are looking for
-
Mini-month view stuck on January 2007. Non-functional.
Hi there, As the subject line indicates, my mini-month view has stopped functioning. It is stuck on Jan 07 and clicking to a month and selecting a day results in a flicker, no movement to the main calendar window and the mini-month returning to Jan 0
-
Hello everyone. Can anyone shed some light on this problem? If I downloaded an app from the app store called "Print to PDF" that allows opening any application and going to print converts that to a PDF e.g. Safari pages, mail etc and I did not sync o
-
How to create a folder inobiee 10g
Hi, I will get a option to create a folder while saving a report. Instead of that where can i create a Folder in obiee 10g. Thanks
-
Need to purchase XP, is Pro worth the extra coin or should I get Home!
-
Toolbar Button for "Add to Index"
I make CHM (context-sensitive help) using RH8. My SME wants an index (it's quite heavy technical stuff) and I add index keywords by: * select text in the topic, * right-click, * Add to > Index Keyword > ProjectName. If I could make a toolbar button f