How to find total lines read by the query

HII all
I'm trying to find out the number of records their by read by my request.
I also tried count (*) but it gives me correct result

I want to use the number of lines in my procedure then, how do I use it.

Can I use number of lines in the loop.

so that I can do the math on each result of a line


Thanking you in advance


Concerning
GauravS

If you want to know the total number of rows returned by a query, and you want to know it at the time that the first line is read so that you can use it in a kind of calculation, you would be better using the analytical function of the account...

SQL> select empno, sal, count(*) over () as cnt
  2  from emp;

     EMPNO        SAL        CNT
---------- ---------- ----------
      7369        800         14
      7499       1600         14
      7521       1250         14
      7566       2975         14
      7654       1250         14
      7698       2850         14
      7782       2450         14
      7788       3000         14
      7839       5000         14
      7844       1500         14
      7876       1100         14
      7900        950         14
      7902       3000         14
      7934       1300         14

14 rows selected.

SQL>

If you try to use rowcount % while in a cursor loop, then you will find that it will only return how many rows have been retrieved at that time here...

SQL> ed
Wrote file afiedt.buf

  1  declare
  2    cursor cur_e is
  3      select empno, sal, count(*) over () as cnt
  4      from emp;
  5  begin
  6    for e in cur_e
  7    loop
  8      dbms_output.put_line(to_char(e.empno)||','||to_char(e.sal)||','||to_char(e.cnt)||','||to_char(cur_e%rowcount));
  9    end loop;
 10* end;
SQL> /
7369,800,14,1
7499,1600,14,2
7521,1250,14,3
7566,2975,14,4
7654,1250,14,5
7698,2850,14,6
7782,2450,14,7
7788,3000,14,8
7839,5000,14,9
7844,1500,14,10
7876,1100,14,11
7900,950,14,12
7902,3000,14,13
7934,1300,14,14

PL/SQL procedure successfully completed.

SQL>

Tags: Database

Similar Questions

  • How can I launch Adobe Reader, accept the end-user agreement, quit and re-launch the browser?

    How can I launch Adobe Reader.accept the end user agreement, quit and re-launch the browser?

    Go to Launchpad, find Adobe Reader, double-click it.

  • How to find these different namespaces in the schema?

    Hello

    I heard that this schema contains different namespaces. How to find these different namespaces in the schema?

    I checked with this, but it is throwing "table or view does not exist.

    Select the namespace of v$ librarycache.


    Thank you
    Praveen

    Are you referring to this? From the reference manual of the SQL language under the schema object names and qualifiers

    7. part of a namespace, no two objects can have the same name.
    The following schema objects share a namespace:
    Tables
    Display
    Sequences
    Private synonyms
    Autonomous procedures
    Autonomous stored functions
    Packages
    Materialized views
    User-defined types

    Each of the following schema objects has its own namespace:
    Index
    Constraints
    Clusters
    Database triggers
    Private database links
    Dimensions

    Because tables and views are in the same namespace, a table and a view in the same schema cannot have the same name. However, the tables and indexes are in different namespaces. Therefore, a table and an index in the same schema may have the same name.

    Each schema in the database has its own namespaces for objects that it contains. This means, for example, two tables in different schemas are in different namespaces and can have the same name.

    Each of the following schema objects also have its own namespace:
    User roles
    Public synonyms
    Links to public database
    Storage spaces
    Profiles of school boards
    The files (PFILEs) settings and server settings (SPFILEs) files

    Because objects in these namespaces do not appear in the drawings, these namespaces cover the entire base.

    That's why you can do:

    SQL> create table t (id number, descr varchar2(10));
    
    Table created.
    
    SQL> alter table t add constraint t check (mod(id,2) = 0);
    
    Table altered.
    
    SQL> create index t on t(id);
    
    Index created.
    
    SQL> create trigger t
      2  before update on t
      3  begin
      4     dbms_output.put_line('T Trigger');
      5  end;
      6  /
    
    Trigger created.
    

    but not:

    SQL> create view t as select * from t;
    create view t as select * from t
                *
    ERROR at line 1:
    ORA-00955: name is already used by an existing object
    

    or

    SQL> create procedure t
      2  begin
      3     null;
      4  end;
      5  /
    create procedure t
    *
    ERROR at line 1:
    ORA-00955: name is already used by an existing object
    

    John

  • How can I get a read by the recipient of my email receipt?

    I have a Mac book pro 7.1. I have El Captain sw.

    How can I get a reading of the receiver of my email confirmation?

    Hello...

    Mail for Mac does not support this feature.

  • Hello, my bare of tools a missing person is left and not of I don't know how to find I is still in the tool to crop my picture thanks.

    Hello, my bare of tools a missing person is left and not of I don't know how to find I is still in the tool to crop my image.

    Go to the window menu and choose Tools.

  • How to find inserted last record in the table.

    Version: Oracle 10g

    I have a table called 'Manufacturing' and 3 columns as mfno, itemname, quantity.
    How to find inserted last record in the table 'manufacturing '.

    As I got to know that the Rowid is not a result perfect result. Please provide your inputs.

    user13416294 wrote:
    Version: Oracle 10g

    This is not a version. It's a product name. A version is 10.1.0.2 or 10.2.0.4, etc.

    I have a table called 'Manufacturing' and 3 columns as mfno, itemname, quantity.
    How to find inserted last record in the table 'manufacturing '.

    Not possible as your data model do not answer for him. As simple as that.

    If there is a need to determine an order or associate some time to an entity, then that should be part of the data model - and a relationship, or one or several attributes are necessary to represent this information. Your data model in this case is therefore unable to meet your requirements.

    If the requirements are valid, set the data model. In other words - your question has nothing to do with Oracle and nothing to do with the other pseudo columns in Oracle, the rowscn or the rowid. It is a question of pure data modeling. Nothing more.

  • How to insert multiple lines using a single query

    Hi all

    How to insert multiple lines using a single query to the emp table?
    I have the number of rows to insert into table x. consumes a lot of time. I tried to insert several lines using a single query, but get errors. I know exactly the query to do this.


    Thank you
    Sunil

    Like this?

    SQL> create table test(id number , dt date);
    
    Table created.
    
    SQL> insert into test values(&a,&b);
    Enter value for a: 1   --- It asked me and I entered 1
    Enter value for b: sysdate  --- It asked me and I entered sysdate
    old   1: insert into test values(&a,&b)
    new   1: insert into test values(1,sysdate)
    
    1 row created.
    
    SQL> 
    

    g.

  • How to find on-site quantity on the specified date

    I have this request to find available courses:

    [code]

    SELECT mp.organization_code org, msi. ATTRIBUTE13, msi. ATTRIBUTE7,

    SUM (NVL (mmt.transaction_quantity, 0)) onhand

    OF mtl_system_items_b msi.

    mtl_parameters mp,

    mtl_material_transactions mmt

    WHERE mp.organization_id = msi.organization_id

    AND mmt.organization_id (+) = msi.organization_id

    AND mmt.inventory_item_id (+) = msi.inventory_item_id

    and mmt.transaction_quantity <>0

    GROUP BY msi. ATTRIBUTE13, mp.organization_code, msi. ATTRIBUTE7

    [\code]

    If I add this line:

    [code]

    "AND mmt.transaction_date (+) < ' 01-sep-2015."

    [\code]

    will I have the date on the quantity available so far?

    because when I add it, it shows less value...

    ' 01-sep-2015' is not a string, a date, so you can reasonably make a comparison of the range (lower to higher etc.) against it.

    Try instead:

    AND mmt.transaction_date (+)<>

    If this gives you what you want, I don't know that you haven't posted your tables or data in the example, or shown what number you encounter, or the expected output you want.

    Read: Re: 2. How can I ask a question on the forums?

  • How to find a line number in excel

    Hello

    I need help to find line number in excel.

    Actually what I try to do is, I use the scanner to read the barcode (string) then I need to search for the same string in the excel file (my datas are recorded as like this for ex: in line 5, column 1 I have to chain column 2 column 10 (West) I have certain values). Now when my string corresponds to the West his will display values from column 2 to 10, so I have to find which line matched the West channel number.

    Thank you

    The search through the forums helps a lot. Here is a discussion where I've solved your problem.

    http://forums.NI.com/NI/board/message?board.ID=170&message.ID=200494&jump=true

    For more information and some samples VI and tool kits, you can go to the excel Council

  • Void total line display in the results

    Hello

    I have a report that has 7 columns. I'm a subtotal for SUBLOC, Dept, person - combined. They all will change only together. For example, the report will look like below

    Location FY Pimnt SubLoc Dept person ID
    2007 0700 205000 CAR3 OSDA RICKS ABCDEFG
    1234567 2008 0700 205000 CAR3 OSDA RICKS
    2009 0700 CAR3 205000 OSDA RICKS AB12345
    2007 0700 CAR3 205000 OSDA RICKS CD00000
    Total-
    2007 0700 205000 WAS3 OSDA RICKS ABCDEFG
    1234567 2008 0700 205000 WAS3 OSDA RICKS
    2009 0700 WAS3 205000 OSDA RICKS AB12345
    2007 CD00000 0700 WAS3 205000 OSDA RICKS
    Total-



    Currently, this is how it is displayed. I want the Total row to look like the following

    Location FY Pimnt SubLoc Dept person ID
    2007 0700 205000 CAR3 OSDA RICKS ABCDEFG
    1234567 2008 0700 205000 CAR3 OSDA RICKS
    2009 0700 CAR3 205000 OSDA RICKS AB12345
    2007 0700 CAR3 205000 OSDA RICKS CD00000
    Total of CAR3OSDARICKS-
    2007 0700 205000 WAS3 OSDA RICKS ABCDEFG
    1234567 2008 0700 205000 WAS3 OSDA RICKS
    2009 0700 WAS3 205000 OSDA RICKS AB12345
    2007 CD00000 0700 WAS3 205000 OSDA RICKS
    Total of WAS3OSDARICKS-

    How can I 'CHAT' data and bring it as a legend in the line of subtotal for display purpose? Help, please. Thank you.

    Hello

    Create a dummy column, in which concatenate the columns you want to display in the subtotal and hide the dummy column.
    Now go to rotate the view, add the dummy column and other dimensions in the section lines, add the measure to the measure.
    put the dummy column as the first column of the pivot display lines section.
    For the dummy column select the sub total (after).

    Thank you
    Vino

  • How to find my WEP key and the name of my network?

    I need to reset my wireless printer to scan.  It asks for my WEP key and I thought it was one that is not correct.  How to find the right WEP key and my correct network name? I have a laptop HP Pavilion dm4 with HP scanner/printe wireless

    You must log - on to your AP or wireless router and look for the 'Wireless' or similar tab for your WEP key and the network name (SSID). Or you may be able to locate the information by going to control Panel\All Control Panel Items\Network and Center sharing on your laptop.

    Frank

  • How to find if an invoice to the AP is approved automatically or manually?

    Hello

    I have a question about invoices in Payables.

    How know if an invoice is approved manually or automatically, is approved?

    Like, for example, a company, all less than $ 50 bills can be approved without the consent of the Manager. These invoices can be automatically approved. But all these bills over $ 50 must be approved by the Manager.

    Do we not have this kind of scenario? If so, how do we identify them in oracle tables. What table and column that specify this source.

    Thank you

    Hello

    You can find it by referring to the WFAPPROVAL_STATUS column in the AP_INVOICES_ALL table.

    If your workflow design is not not approve invoices less than $ 50,
    then the approval status of invoices less than $ 50 would be the value in WFAPPROVAL_STATUS as '' NOT NECESSARY ''.

    If your design workflow is to approve the Bills above $ 50
    then the approval status of the Bills above $ 50 would be the value in WFAPPROVAL_STATUS as 'WFAPPROVED '.

    Apart from the above, there are several other statuses available for invoice approval such as,.

    REQUIRED approval is required for a Bill, but no authorization is launched
    INSIDER = approval is required for a Bill, and approval is launched
    REJECTED = approval is required for a Bill, and the approver rejects the approval
    MANUAL APPROVED approval is required for a Bill, but with approval of Force the invoice has been approved

    Kind regards
    Ivruksha

  • How to find a list with all the shortcuts in EBS R12

    How everything,.
    Someone knows how to find all the shortcuts for R12 as CTRL + F11, F11, F4... etc?




    Thanks in advance,
    Bahchevanov.

    Someone knows how to find all the shortcuts for R12 as CTRL + F11, F11, F4... etc?

    You can search all of this (help > keyboard help).

    Thank you
    Hussein

  • How to find users and groups in the Sun box

    Please adivce how to find users and group in sunsolaris

    Thanks in advance

    We can get all the details of the Group of the file/etc/Group.

    Similarly the user details are in/etc/passwd.

  • How to find on what progams share the tuner tv on my computer

    I have a 600with touchsmart a tuner tv with windows xp.  How I found on which programs share my tv tuner?

    How can I connect my cable to the computer to watch cable.  I have an hp touchsmart 600 desktop computer with windows xp

Maybe you are looking for