Number of records in a cursor
Hi,
In a procedure I use a cursor. It's the result of a query.
Can I know how many records have the cursor ?
Thank you.
Patrick
<p style="margin-top: 0; margin-bottom: 0"><font face="Arial" size="2">OK. I badly expressed myself.</font></p>
<p style="margin-top: 0; margin-bottom: 0"> </p>
<p style="margin-top: 0; margin-bottom: 0"><font face="Arial" size="2">With this procedure I add in the table </font>
<font face="Courier New" SIZE="2" COLOR="#808000">GLMASTER_AUDIT</font><font face="Arial" size="2"> some data from records added in the table </font>
<font face="Courier New" SIZE="2" COLOR="#808000">GLMASTER</font><font face="Arial" size="2">. And I would like to know how many records were added.</font></p>
<p style="margin-top: 0; margin-bottom: 0"> </p>
<font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"></font><font face="Courier New">
<font SIZE="2" COLOR="#0000f0">PROCEDURE</font><font SIZE="2"> GLMASTER_ADDED
</font></font><font SIZE="2" COLOR="#0000f0"><font face="Courier New">IS</font></p>
</font><font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"></font>
<font SIZE="2" COLOR="#0000f0" face="Courier New">BEGIN</p>
</font><font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"></font><font face="Courier New">
<font SIZE="2" COLOR="#0000f0"> INSERT</font><font SIZE="2"> </font>
<font SIZE="2" COLOR="#0000f0">INTO</font><font SIZE="2"> </font></font>
<font SIZE="2" COLOR="#808000"><font face="Courier New">GLMASTER_AUDIT</font></p>
</font><font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"></font><font face="Courier New">
<font SIZE="2" COLOR="#0000f0"> (</font><font SIZE="2">COMPANY</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
ACCT_UNIT</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2"> ACCOUNT</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
SUB_ACCOUNT</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
DATE_AUDIT</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2"> ACTION</font></font><font SIZE="2" COLOR="#0000f0"><font face="Courier New">)</font></p>
</font>
<p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
<font SIZE="2" COLOR="#0000f0"> SELECT</font><font SIZE="2">
GLMASTER</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">COMPANY</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
GLMASTER</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">ACCT_UNIT</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
GLMASTER</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">ACCOUNT</font></font><font SIZE="2" COLOR="#0000f0"><font face="Courier New">,</font></p>
</font><font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
GLMASTER</font></font><font face="Courier New"><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">SUB_ACCOUNT</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
TRUNC</font><font SIZE="2" COLOR="#0000f0">(SYSDATE),</font><font SIZE="2">
</font></font><font SIZE="2" COLOR="#ff0000"><font face="Courier New">'A'</font></p>
</font><font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"></font><font face="Courier New">
<font SIZE="2" COLOR="#0000f0"> FROM</font><font SIZE="2">
FI01_OWNER</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">GLMASTER</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
FI01_OWNER</font><font SIZE="2" COLOR="#0000f0">.</font></font><font SIZE="2" COLOR="#808000"><font face="Courier New">GLMASTER_SAVE</font></p>
</font><font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"></font><font face="Courier New">
<font SIZE="2" COLOR="#0000f0"> WHERE</font><font SIZE="2">
GLMASTER</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">COMPANY
</font><font SIZE="2" COLOR="#0000f0">=</font><font SIZE="2"> </font>
<font SIZE="2" COLOR="#808000">GLMASTER_SAVE</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">COMPANY</font></font><font SIZE="2" COLOR="#0000f0"><font face="Courier New">(+)</font></p>
</font><font SIZE="2" face="Courier New">
<p style="margin-top: 0; margin-bottom: 0">
</font><font face="Courier New"><font SIZE="2" COLOR="#0000f0">AND</font><font SIZE="2">
GLMASTER</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">ACCT_UNIT
</font><font SIZE="2" COLOR="#0000f0">=</font><font SIZE="2"> </font>
<font SIZE="2" COLOR="#808000">GLMASTER_SAVE</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">ACCT_UNIT</font></font><font SIZE="2" COLOR="#0000f0"><font face="Courier New">(+)</font></p>
</font><font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"></font><font face="Courier New">
<font SIZE="2" COLOR="#0000f0">
AND</font><font SIZE="2"> GLMASTER</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">ACCOUNT
</font><font SIZE="2" COLOR="#0000f0">=</font><font SIZE="2"> </font>
<font SIZE="2" COLOR="#808000">GLMASTER_SAVE</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">ACCOUNT</font></font><font SIZE="2" COLOR="#0000f0"><font face="Courier New">(+)</font></p>
</font><font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"></font><font face="Courier New">
<font SIZE="2" COLOR="#0000f0">
AND</font><font SIZE="2"> GLMASTER</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">SUB_ACCOUNT
</font><font SIZE="2" COLOR="#0000f0">=</font><font SIZE="2"> </font>
<font SIZE="2" COLOR="#808000">GLMASTER_SAVE</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">SUB_ACCOUNT</font></font><font SIZE="2" COLOR="#0000f0"><font face="Courier New">(+)</font></p>
</font><font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"></font><font face="Courier New">
<font SIZE="2" COLOR="#0000f0">
AND</font><font SIZE="2"> </font><font SIZE="2" COLOR="#808000">GLMASTER_SAVE</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">ACTIVE_STATUS
</font><font SIZE="2" COLOR="#0000f0">IS</font><font SIZE="2"> </font></font>
<font SIZE="2" COLOR="#0000f0"><font face="Courier New">NULL</font></p>
</font><font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"></font><font face="Courier New">
<font SIZE="2" COLOR="#0000f0"> ORDER</font><font SIZE="2"> </font>
<font SIZE="2" COLOR="#0000f0">BY</font><font SIZE="2"> GLMASTER</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">COMPANY</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
GLMASTER</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">ACCT_UNIT</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
GLMASTER</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">ACCOUNT</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
GLMASTER</font><font SIZE="2" COLOR="#0000f0">.</font><font SIZE="2">SUB_ACCOUNT</font></font><font SIZE="2" COLOR="#0000f0"><font face="Courier New">;</font></p>
</font><font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"></font>
<font SIZE="2" COLOR="#0000f0" face="Courier New">COMMIT;</p>
</font><font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"></font>
<font SIZE="2" COLOR="#0000f0" face="Courier New">END;</p>
</font>
<p style="margin-top: 0; margin-bottom: 0"> </p>
<p style="margin-top: 0; margin-bottom: 0"><font face="Arial" size="2">How can I
have the number of added records ?</font></p>
<p style="margin-top: 0; margin-bottom: 0"> </p>
<p style="margin-top: 0; margin-bottom: 0"><font face="Arial" size="2">Thank you
for your help.</font></p>
<p style="margin-top: 0; margin-bottom: 0"> </p>
<p style="margin-top: 0; margin-bottom: 0">
<font color="#008080" face="Arial" size="2"><i><b>Patrick</b></i></font></p>
Similar Messages
-
Number of records in cursor select statement
hi all,
with the cursor i am selecting set of select statement and writing into the .txt file.
its working file, but it should not open the file if the cursor returns nothing.
how to check for the number of records return by the select statement in the cursor.
pls help me.
Thanks..Hi,
You can use a Cursor for loop (you'll not enter in the loop if the SELECT is retrieving no rows):
begin
for recs in(select * from whatever) loop
null; -- Produce your file
end loop;
end;You can also use a bulk collect and check "yourcollection.count" attribute ... (but don't use it if you are processing a lot of records!) -
Max number of records to hold in explicit cursor
Hi Everyone,
What is the maxmimum number of records that could be holded in
an explicit cursor for manipulation. I need to process millions of records.
Can I hold it in cursors or use temp table to hold those records and
do fixes with volume control.
ThanksHi Kishore sorry for the delayed response,
Table1
prim_oid sec_oid rel_oid
pp101 cp102 101
pp101 cp103 101
pp102 cp104 101
pp102 cp105 101
Table2
ID p_oid b_oid rel_oid
1 pp101 -51 102
2 pp102 -51 102
3 cp102 52 102
4 cp103 53 102
5 cp104 54 102
6 cp105 54 102
From table1 I get the parent and child recs based on rel_oid=101,
the prim_oid and sec_oid are related to another col in table2 again
with a rel_oid. I need to get all the prim_oid that are linked to -ive b_oid
in table2 whose child sec_oid are linked with +ive b_oid.
In the above case, parent pp101 linked to 2 child cp102 & cp103 and
pp102 linked to 2 child cp104 & cp105. Both pp101 and pp102 are linked
to -ive b_oid (table2), but the children of these parents are linked to +ive b_oids.
But pp101's children are linked to 2 diff b_oid and pp102's childrend are linked
to same b_oid. For my requirement I can only update b_oid of pp102 with that
of its children b_oid whereas cannot update pp101's b_oid as it children are
linked to diff b_oid's.
I've a sql that will return prim_oid, b_oid, sec_oid, b_oid as a record as below
1 pp101 -51 3 cp102 52
1 pp101 -51 4 cp103 53
2 pp102 -51 5 cp104 54
2 pp102 -51 6 cp105 54
with a cursor sql that returns records as above, it would be difficult to process
distinct parent and distinct child. So I've a cursor that returns only the parent
records as below,
1 pp101 -51
2 pp102 -51
and then for each parent I get the distinct child b_oid, if I get only one child
b_oid I update parent else dont. but the problem is table2 has 8 million parent recs
with link to -ve b_oid but child of only 2 million recs have link to only one distinct
b_oid.
If i include volume control in the cursor sql chances are all might returns like
pp101 for which update is not required, so I should not have volume control in
curosr sql which will now return all the 8 million record. (my assumption).
is there any other feasible solution? Thanks -
RE: (forte-users) Optimal number of records to fetch fromForte Cursor
Guys,
The behavior (1 fetch of 20000 vs 2 fetches of 10000 each) may also be DBMS
related. There is potentially high overhead in opening a cursor and initially
fetching the result table. I know this covers a great deal DBMS technology
territory here but one explanation is that the same physical pages may have to
be read twice when performing the query in 2 fetches as compared to doing it in
one shot. Physical IO is perhaps the most expensive (vis a vis- resources)
part of a query. Just a thought.
"Rottier, Pascal" <[email protected]> on 11/15/99 01:34:22 PM
To: "'Forte Users'" <[email protected]>
cc: (bcc: Charlie Shell/Bsg/MetLife/US)
Subject: RE: (forte-users) Optimal number of records to fetch from Forte C
ursor
The reason why a single fetch of 20.000 records performs less then
2 fetches of 10.000 might be related to memory behaviour. Do you
keep the first 10.000 records in memory when you fetch the next
10.000? If not, then a single fetch of 20.000 records requires more
memory then 2 fetches of 10.000. You might have some extra over-
head of Forte requesting additional memory from the OS, garbage
collections just before every request for memory and maybe even
the OS swapping some memory pages to disk.
This behaviour can be controlled by modifying the Minimum memory
and Maximum memory of the partition, as well as the memory chunk
size Forte uses to increment its memory.
Upon partition startup, Forte requests the Minimum memory from the
OS. Whithin this area, the actual memory being used grows, until
it hits the ceiling of this space. This is when the garbage collector
kicks in and removes all unreferenced objects. If this does not suffice
to store the additional data, Forte requests 1 additional chunk of a
predefined size. Now, the same behaviour is repeated in this, slightly
larger piece of memory. Actual memory keeps growing until it hits
the ceiling, upon which the garbage collector removes all unrefer-
enced objects. If the garbage collector reduces the amount of
memory being used to below the original Miminum memory, Forte
will NOT return the additional chunk of memory to the OS. If the
garbage collector fails to free enough memory to store the new data,
Forte will request an additional chunk of memory. This process is
repeated untill the Maximum memory is reached. If the garbage
collector fails to free enough memory at this point, the process
terminates gracelessly (which is what happens sooner or later when
you have a memory leak; something most Forte developpers have
seen once or twice).
Pascal Rottier
STP - MSS Support & Coordination Group
Philip Morris Europe
e-mail: [email protected]
Phone: +49 (0)89-72472530
+++++++++++++++++++++++++++++++++++
Origin IT-services
Desktop Business Solutions Rotterdam
e-mail: [email protected]
Phone: +31 (0)10-2428100
+++++++++++++++++++++++++++++++++++
/* All generalizations are false! */
-----Original Message-----
From: [email protected] [SMTP:[email protected]]
Sent: Monday, November 15, 1999 6:53 PM
To: [email protected]
Subject: (forte-users) Optimal number of records to fetch from Forte
Cursor
Hello everybody:
I 'd like to ask a very important question.
I opened Forte cursor with approx 1.2 million records, and now I am trying
to figure out the number of records per fetch to obtain
the acceptable performance.
To my surprise, fetching 100 records at once gave me approx 15 percent
performance gain only in comparsion
with fetching records each by each.
I haven't found significant difference in performance fetching 100, 500
or
10.000 records at once.In the same time, fetching 20.000
records at once make a performance approx 20% worse( this fact I cannot
explain).
Does anybody have any experience in how to improve performance fetching
from
Forte cursor with big number of rows ?
Thank you in advance
Genady Yoffe
Software Engineer
Descartes Systems Group Inc
Waterloo On
Canada
For the archives, go to: http://lists.sageit.com/forte-users and use
the login: forte and the password: archive. To unsubscribe, send in a new
email the word: 'Unsubscribe' to: [email protected]
For the archives, go to: http://lists.sageit.com/forte-users and use
the login: forte and the password: archive. To unsubscribe, send in a new
email the word: 'Unsubscribe' to: [email protected]Hi Kieran,
According to your description, you are going to figure out what is the optimal number of records per partition, right? As per my understanding, this number was change by your hardware. The better hardware you have, the more number of records per partition.
The earlier version of the performance guide for SQL Server 2005 Analysis Services Performance Guide stated this:
"In general, the number of records per partition should not exceed 20 million. In addition, the size of a partition should not exceed 250 MB."
Besides, the number of records is not the primary concern here. Rather, the main criterion is manageability and processing performance. Partitions can be processed in parallel, so the more there are the more can be processed at once. However, the more partitions
you have the more things you have to manage. Here is some links which describe the partition optimization
http://blogs.msdn.com/b/sqlcat/archive/2009/03/13/analysis-services-partition-size.aspx
http://www.informit.com/articles/article.aspx?p=1554201&seqNum=2
Regards,
Charlie Liao
TechNet Community Support -
Optimal number of records to fetch from Forte Cursor
Hello everybody:
I 'd like to ask a very important question.
I opened Forte cursor with approx 1.2 million records, and now I am trying
to figure out the number of records per fetch to obtain
the acceptable performance.
To my surprise, fetching 100 records at once gave me approx 15 percent
performance gain only in comparsion
with fetching records each by each.
I haven't found significant difference in performance fetching 100, 500 or
10.000 records at once.In the same time, fetching 20.000
records at once make a performance approx 20% worse( this fact I cannot
explain).
Does anybody have any experience in how to improve performance fetching from
Forte cursor with big number of rows ?
Thank you in advance
Genady Yoffe
Software Engineer
Descartes Systems Group Inc
Waterloo On
CanadaYou can do it by writing code in start routine of your transformations.
1.If you have any specific criteria for filtering go with that and delete unwanted records.
2. If you want to load specific number of records based on count, then in start routine of the transformations loop through source package records by keeping a counter till you reach your desired count and copy those records into an internal table.
Delete records in the source package then assign the records stored in internal table to source package. -
How to find total number of records in a BDoc?
Dear all,
I have replicated about BP 1088 records from ISU into CRM system with block size 100. Technically on SMW01, for each successfully processed BDoc, there will be 100 records (corresponds to 100 block size). But due to some failed BDocs, not all "successfully" BDocs will have 100 records each, some may have only 1 record inside...or 30...or 88 for example. So, may i know how to find or is there a report i can look into to find the total number of records clearly shown for each of the successfully processed green status BDocs???
Please help and points will be rewards!!
Thank You
Best Regards,
CKI am just showing this to show how to get the rowcount along with the cursor, if the program has so much gap of between verifying the count(*) and opening the cursor.
Justin actually covered this, he said, oracle has to spend some resources to build this functionality. As it is not most often required, it does not makes much sence to see it as a built-in feature. However, if we must see the rowcount when we open the cursor, here is a way, but it is little bit expensive.
SQL> create table emp_crap as select * from emp where 1 = 2;
Table created.
SQL> declare
2 v_cnt number := 0;
3 zero_rows exception;
4 begin
5 for rec in (select * from (select rownum rn, e.ename from emp_crap e) order by 1 desc)
6 loop
7 if v_cnt = 0 then
8 v_cnt := rec.rn;
9 end if;
10 end loop;
11 if v_cnt = 0 then
12 raise zero_rows;
13 end if;
14 exception
15 when zero_rows then
16 dbms_output.put_line('No rows');
17 end;
18 /
No rows
PL/SQL procedure successfully completed.
-- Now, let us use the table, which has the data
SQL> declare
2 v_cnt number := 0;
3 zero_rows exception;
4 begin
5 for rec in (select * from
6 (select rownum rn, e.ename from emp e)
7 order by 1 desc)
8 loop
9 if v_cnt = 0 then
10 v_cnt := rec.rn;
11 dbms_output.put_line(v_cnt);
12 end if;
13 end loop;
14 if v_cnt = 0 then
15 raise zero_rows;
16 end if;
17 exception
18 when zero_rows then
19 dbms_output.put_line('No rows');
20 end;
21 /
14
PL/SQL procedure successfully completed.Thx,
Sri -
How to find total count of records in a cursor
Aassume below is the cursor i defined
cursor c1 is select * from emp;
now, i want to find the total count of records in this cursor using an existing function etc., using one line statement.
FYI: c1%rowcount is always giving 0, so i cant rely on this.
Any thoughts, please share.
Thanks in advance.I am just showing this to show how to get the rowcount along with the cursor, if the program has so much gap of between verifying the count(*) and opening the cursor.
Justin actually covered this, he said, oracle has to spend some resources to build this functionality. As it is not most often required, it does not makes much sence to see it as a built-in feature. However, if we must see the rowcount when we open the cursor, here is a way, but it is little bit expensive.
SQL> create table emp_crap as select * from emp where 1 = 2;
Table created.
SQL> declare
2 v_cnt number := 0;
3 zero_rows exception;
4 begin
5 for rec in (select * from (select rownum rn, e.ename from emp_crap e) order by 1 desc)
6 loop
7 if v_cnt = 0 then
8 v_cnt := rec.rn;
9 end if;
10 end loop;
11 if v_cnt = 0 then
12 raise zero_rows;
13 end if;
14 exception
15 when zero_rows then
16 dbms_output.put_line('No rows');
17 end;
18 /
No rows
PL/SQL procedure successfully completed.
-- Now, let us use the table, which has the data
SQL> declare
2 v_cnt number := 0;
3 zero_rows exception;
4 begin
5 for rec in (select * from
6 (select rownum rn, e.ename from emp e)
7 order by 1 desc)
8 loop
9 if v_cnt = 0 then
10 v_cnt := rec.rn;
11 dbms_output.put_line(v_cnt);
12 end if;
13 end loop;
14 if v_cnt = 0 then
15 raise zero_rows;
16 end if;
17 exception
18 when zero_rows then
19 dbms_output.put_line('No rows');
20 end;
21 /
14
PL/SQL procedure successfully completed.Thx,
Sri -
How to set the number of records displayed at run time
Is it possible to set the number of records displayed block property at run time? The built-in 'GET_BLOCK_PROPERTY' can retrieve the number of RECORDS_DISPLAYED. But I can't find SET_BLOCK_PROPERTY to set this property. Is there anyway I can set this property programmatically? Thanks for any suggestions!
Bookmark Go to End
goal: How to vary the number of records displayed in a block
programmatically
fact: Oracle Forms Developer
fix:
Block property 'Number of Records Displayed' can not be changed during runtime
using SET_BLOCK_PROPERTY. However, it is still possible programmatically change
the visual appearance of the form so that it creates effect of changing this
property. To achieve such an effect follow these steps:
1. in Forms Builder, in the multirecord block define the new set of items.
The simplest way is to copy/paste the original item and rename created item.
2. set properties of these new items so that they are the same as the properties
of the original items. If these new items were copied from original items
then properties are already the same. Modify following properties
'Database item' on new items to value 'No'
'Synchronize with item' to the value of the original item
'Number of Items Displayed' to desired value.
'Visible' to 'No'
In other words, these new items are mirrors of original items.
3. code event, which is meant to trigger the change in block appearance.
This code should use SET_ITEM_PROPERTY built-in to set properties
like 'VISIBLE', 'ENABLED', 'NAVIGABLE', 'UPDATE_ALLOWED' and others
to desired value for items which are about to be displayed, then
move cursor to one of these just displayed items with GO_ITEM built-in
and then hide the previously displayed items.
Example:
Assume that the block is built on SCOTT.DEPT schema. Following will
change the set of displayed items
set_item_property('dept.mdeptno',visible,property_true);
set_item_property('dept.mdname',visible,property_true);
set_item_property('dept.mloc',visible,property_true);
set_item_property('dept.mdeptno',enabled,property_true);
set_item_property('dept.mdname',enabled,property_true);
set_item_property('dept.mloc',enabled,property_true);
set_item_property('dept.mdeptno',update_allowed,property_true);
set_item_property('dept.mdname',update_allowed,property_true);
set_item_property('dept.mloc',update_allowed,property_true);
set_item_property('dept.mdeptno',navigable,property_true);
set_item_property('dept.mdname',navigable,property_true);
set_item_property('dept.mloc',navigable,property_true);
go_item('dept.mdeptno');
set_item_property('dept.deptno',visible,property_false);
set_item_property('dept.dname',visible,property_false);
set_item_property('dept.loc',visible,property_false);
Regards,
Monica -
How to determine number of records in recordset returned by stored procedure?
In TestStand 3.0 I am calling an SQL stored procedure where the stored
procedure returns a recordset. Everything appears to work (I can
iterate through the recordset and see that the data is valid).
However, I can not figure out how to easilly determine how many
records are actually in the recordset. Unlike the 'Open SQL
Statement' step, in the 'Data Operation' step that actually invokes
the stored procedure, there is no 'Number of Records Selected' option
to specify a TestStand variable to accept this value. I know I could
iterate through the returned recordset incrementing a counter until a
Fetch fails, but for larger recordsets, traversing the table multiple
times would be quite time consuming
. I am hoping to avoid this if
possible. Is there an easier way to get the number of records in a
recordset returned from a stored procedure call?
BobBob -
The cursor type of the ADO Recordset object affects whether the number of records can be determined. The Recordset.RecordCount property will return -1 for a forward-only cursor; the actual count for a static or keyset cursor; and either -1 or the actual count for a dynamic cursor, depending on the data source.
Because ADO does not let me set the cursor type for command objects which is what a stored procedure requires, it is up to the data source to determine the type of cursor and the support for record count.
Scott Richardson (NI)
Scott Richardson
National Instruments -
Number of records in each partition
Hi,
Can any one please tell me, how to display number of record in each partion in any table.
I wanted to use following in PL/SQL but it gives me error.
Declare
Cursor c1 is
select partition_name into part_name from all_tab_partition where table_name = 'table_name';
BEGIN
for rec in c1
Loop
select count(*) into temp_var from table_name partition(rec.part_name)
END LOOP;
END;
I guess I need dynamic SQL ..
Any thoughts on this ??
Thanks,
AvIt is always better to analyze the tables and get these details from num_rows as mentioned before but just in case you want the latest information from the table dynamically then use the following
Declare
Cursor c1 is
select table_name,partition_name from all_tab_partitions where table_name = 'SALESDETAILS';
v_sql varchar2(2000);
temp_var number:=0;
BEGIN
for rec in c1
Loop
execute immediate 'select count(*) from '||rec.table_name||' partition('||rec.partition_name||')' into temp_var;
dbms_output.put_line('The Partition '||rec.partition_name||' of table '||rec.table_name||' has '||temp_var||' rows');
END LOOP;
END; -
NUMBER OF RECORDS IN EACH TABLE???
Hi!
how can i find the number of records in each table in the database. the result should be like this
table_1 123
table_2 60
table_3 88
thanks!!
also if we want to see it only for a particular schema???You can get all the table names and schemas from ALL_TABLES table.
then you can stored that on a cursor,
then you can create a function where you use an execute_immediate to run the queries dinamically. with that you can run a COUNT for each TABLE
That's the idea give it a shot :)
Regards -
Problem fetch large number of records
Hi
I want to fetch large number of record from database.and I use secondary index database for improve performance for example my database has 100000 records and query fetch 10000 number of records from this database .I use secondary database as index and move to secondary database until fetch all of the information that match for my condition.but when I move to this loop performance terrible.
I know when I use DB_MULTIPLE fetch all of the information and performance improves but
I read that I can not use this flag when I use secondary database for index.
please help me and say me the flag or implement that fetch all of the information all to gether and I can manage this data to my language
thanks alot
regards
saeedHi Saeed,
Could you post here your source code, that is compiled and ready to be executed, so we can take a look at the loop section ?
You won't be able to do bulk fetch, that is retrieval with DB_MULTIPLE given the fact that the records in the primary are unordered by master (you don't have 40K consecutive records with master='master1'). So the only way to do things in this situation would be to position with a cursor in the secondary, on the first record with the secondary key 'master1' retrieve all the duplicate data (primary keys in the primary db) one by one, and do the corresponding gets in the primary database based on the retrieved keys.
Though, there may be another option that should be taken into consideration, if you are willing to handle more work in your source code, that is, having a database that acts as a secondary, in which you'll update the records manually, with regard to the modifications performed in the primary db, without ever associating it with the primary database. This "secondary" would have <master> as key, and <std_id>, <name> (and other fields if you want to) as data. Note that for every modification that your perform on the std_info database you'll have to perform the corresponding modification on this database as well. You'll then be able to do the DBC->c_get() calls on this database with the DB_MULTIPLE flag specified.
I have other question.is there any way that fetch information with number of record?
for example fetch information that located third record of my database.I guess you're refering to logical record numbers, like the relational database's ROW_ID. Since your databases are organized as BTrees (without the DB_RECNUM flag specified) this is not possible directly.You could perform this if use a cursor and iterate through the records, and stop on the record whose number is the one you want (using an incrementing counter to keep track of the position). If your database could have operated with logical record numbers (BTree with DB_RECNUM, Queue or Recno) this would have been possible directly:
http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am_conf/logrec.html
http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am_conf/renumber.html
Regards,
Andrei -
RE: (forte-users) Optimal number of records to fetch fromForte C ursor
The reason why a single fetch of 20.000 records performs less then
2 fetches of 10.000 might be related to memory behaviour. Do you
keep the first 10.000 records in memory when you fetch the next
10.000? If not, then a single fetch of 20.000 records requires more
memory then 2 fetches of 10.000. You might have some extra over-
head of Forte requesting additional memory from the OS, garbage
collections just before every request for memory and maybe even
the OS swapping some memory pages to disk.
This behaviour can be controlled by modifying the Minimum memory
and Maximum memory of the partition, as well as the memory chunk
size Forte uses to increment its memory.
Upon partition startup, Forte requests the Minimum memory from the
OS. Whithin this area, the actual memory being used grows, until
it hits the ceiling of this space. This is when the garbage collector
kicks in and removes all unreferenced objects. If this does not suffice
to store the additional data, Forte requests 1 additional chunk of a
predefined size. Now, the same behaviour is repeated in this, slightly
larger piece of memory. Actual memory keeps growing until it hits
the ceiling, upon which the garbage collector removes all unrefer-
enced objects. If the garbage collector reduces the amount of
memory being used to below the original Miminum memory, Forte
will NOT return the additional chunk of memory to the OS. If the
garbage collector fails to free enough memory to store the new data,
Forte will request an additional chunk of memory. This process is
repeated untill the Maximum memory is reached. If the garbage
collector fails to free enough memory at this point, the process
terminates gracelessly (which is what happens sooner or later when
you have a memory leak; something most Forte developpers have
seen once or twice).
Pascal Rottier
STP - MSS Support & Coordination Group
Philip Morris Europe
e-mail: [email protected]
Phone: +49 (0)89-72472530
+++++++++++++++++++++++++++++++++++
Origin IT-services
Desktop Business Solutions Rotterdam
e-mail: [email protected]
Phone: +31 (0)10-2428100
+++++++++++++++++++++++++++++++++++
/* All generalizations are false! */
-----Original Message-----
From: [email protected] [SMTP:[email protected]]
Sent: Monday, November 15, 1999 6:53 PM
To: [email protected]
Subject: (forte-users) Optimal number of records to fetch from Forte
Cursor
Hello everybody:
I 'd like to ask a very important question.
I opened Forte cursor with approx 1.2 million records, and now I am trying
to figure out the number of records per fetch to obtain
the acceptable performance.
To my surprise, fetching 100 records at once gave me approx 15 percent
performance gain only in comparsion
with fetching records each by each.
I haven't found significant difference in performance fetching 100, 500
or
10.000 records at once.In the same time, fetching 20.000
records at once make a performance approx 20% worse( this fact I cannot
explain).
Does anybody have any experience in how to improve performance fetching
from
Forte cursor with big number of rows ?
Thank you in advance
Genady Yoffe
Software Engineer
Descartes Systems Group Inc
Waterloo On
Canada
For the archives, go to: http://lists.sageit.com/forte-users and use
the login: forte and the password: archive. To unsubscribe, send in a new
email the word: 'Unsubscribe' to: [email protected]Hi Kieran,
According to your description, you are going to figure out what is the optimal number of records per partition, right? As per my understanding, this number was change by your hardware. The better hardware you have, the more number of records per partition.
The earlier version of the performance guide for SQL Server 2005 Analysis Services Performance Guide stated this:
"In general, the number of records per partition should not exceed 20 million. In addition, the size of a partition should not exceed 250 MB."
Besides, the number of records is not the primary concern here. Rather, the main criterion is manageability and processing performance. Partitions can be processed in parallel, so the more there are the more can be processed at once. However, the more partitions
you have the more things you have to manage. Here is some links which describe the partition optimization
http://blogs.msdn.com/b/sqlcat/archive/2009/03/13/analysis-services-partition-size.aspx
http://www.informit.com/articles/article.aspx?p=1554201&seqNum=2
Regards,
Charlie Liao
TechNet Community Support -
Ref Cursor - How to append records into ref cursor?
Hi,
Is it possible to append ref cursor?
Iam having a procedure which accepts 1 string as input
parameter. That string will have list of ID delimited by comma.
I want to extract & match every ID with some tables.
My problem is for first ID i would get 10 records
and for 2nd ID i 'l get other 20 records. But while returning
i need to send the same(10 + 20 records) as ref cursor(OUT parameter).
But in below given code i could send only last 20 records. first
10 records are not append/updated into ref cursor.
How to append 2nd 20 records with 1st 10 records? so that i can
send all the 30 records.
Here goes my code...
CREATE OR REPLACE PROCEDURE getCRMGroupsAndRollups_PRC
in_groupId IN VARCHAR2,
out_getCRMGroups OUT TYPES.DATASET
IS
v_temp VARCHAR2(500) := in_groupId ||',';
v_temp_split VARCHAR2(500);
v_pos1 NUMBER := 0;
v_pos2 NUMBER := 1;
v_pos3 NUMBER := 0;
v_extract_char VARCHAR(1) := NULL;
v_comma_cnt NUMBER := 0;
BEGIN
-- check in for null input parameters
IF ( in_groupId IS NOT NULL ) THEN
-- loop to count no of in_groupId
FOR j IN 1..LENGTH(v_temp)
LOOP
v_extract_char := SUBSTR(v_temp,j,1);
IF (v_extract_char = ',') THEN
v_comma_cnt := v_comma_cnt + 1;
END IF;
END LOOP;
-- loop to extract in_group Id
FOR i IN 1..v_comma_cnt
LOOP
v_pos1 := instr(v_temp,',',(v_pos1 + 1));
v_pos3 := ((v_pos1-1) - v_pos2 )+ 1;
v_temp_split := SUBSTR(v_temp,v_pos2,v_pos3);
v_pos2 := v_pos1 + 1;
-- query to return dataset filled BY list of all the current
-- CRM groups and the associated rollup groups
OPEN out_getCRMGroups FOR
SELECT
DISTINCT
gcs.crm_st_id_cd,
gcs.lgcy_roll_up_grp_num,
gcs.lgcy_roll_up_grp_name,
gcs.grp_xwalk_complt_dt,
gcs.crm_grp_num,
gcs.facets_gnat_id,
gcs.crm_grp_name
FROM
grp_convsn_stat gcs
--lgcy_xref_elem lxe
WHERE
( gcs.mbrshp_convsn_aprvl_dt = NULL )
OR ( gcs.mbrshp_convsn_aprvl_dt < (SYSDATE - 7 ) )
AND ( gcs.facets_grp_stat_actv_ind = 'Y' )
AND ( gcs.lgcy_roll_up_grp_num = v_temp_split );
END LOOP;
END IF;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('INTERNAL ERROR');
END getCRMGroupsAndRollups_PRC;
in this v_temp_split will have extracted id & iam opening
ref cursor for each & every ID extracted from list.
2) How to handle no_data_found exception for this ref cursor?
Please help me....
-thiyagarajan.http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:110612348061
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:210612357425
Message was edited by:
Kamal Kishore -
Find - tables with largest number of records?
Hi,
I need to find tables with largest number of records. Any transaction show this details?
aRsGo to transaction DB02, then click on the button that reads, "Space Statistics", the dialog box, click ok, leave the "*" for all tables, In the next screen put your cursor in the appropriate column labeled as Rows and click the sort button. Now you will see your biggest tables at the top of the list.
Regards,
Rich Heilman
Maybe you are looking for
-
Can I have the same itunes on two computers?
I want to have the same info on one computer, mine as i do on my husbands. He doesn't use itunes & sometimes we only take one computer with us. I would like for them to be able to sync together with mine & his laptops.
-
When I open iTunes, I get a message saying under iTunes.exe - Entry Point Not Found, it says, The procedure entry point sqlite3_wal_checkpoint could not be located in the dynamic link library SQLite3.dll. And I'm not talking about the AppleSyncNotifi
-
Every time I wake my iPad with the sleep/wake button, I am asked for my Apple ID Password. There are no apps running prior to the previous shutdown. Any guesses as to why I am getting this?
-
Hello all, I am curious about people's experiences with the Powerbook's power adapter. I'm officially on my third adapter in two years of owning my laptop. Anyone else have as much trouble with this as I have? On a side note, I was within my one year
-
Best practice for patching ( Feb 2014 CU) of Project Server 2010
Hi, Please advise. Thanks srabon