How to get the total count of the no. or rows a cursor has fetched

Hi All,
Is there a way to get the number of rows a cursor query has fetched, without looping into the cursor and using a counter variable
I mean like in pl/sql table we can directly use the pl/sql table attribute .count is there a way to achieve this in cursor
thanks a lot in advance

Qwerty wrote:
Is there a way to get the number of rows a cursor query has fetched, without looping into the cursor and using a counter variableYes.
It is zero.
On the first loop and first fetch it will be 1, second 2 etc.
This is because cursors have no rows, or fetch no rows until your code or the client uses the cursor to fetch them.
I mean like in pl/sql table we can directly use the pl/sql table attributeA PL/SQL array is not like a cursor, a PL/SQL array has the rows already fetched into it.
A cursor is not an array but a pointer to a compiled SQL statement so you cannot count how many rows it has, because it has none. You can only count how many rows you fetch from it.

Similar Messages

  • How to get grand total text  in the last column of reuse_alv_grid_display ?

    Hi,
    Experts,
    I am able to get the subtotal text but i am not able to get the grand total text please pass some code or idea on it.
    ex:
         2510    gopi       10
         2511   gopi        20
    subtotal                 30
         2521    anand    20
         2522    anand    10
        2523     anand    50
    subtotal                 80
         2512   vikram     30
    subtotal                 30
    (blank----)              140.
    Here i want to get text as 'COMPANY TOTAL'. by using REUSE_ALV_GRID_DISPLAY FM.
    Thanks,
    Shabeer ahmed.

    Hi,
      you can get the 'COMPANY TOTAL' by using the following code:
      LOOP AT i_main INTO w_main.*   Storing the Total text need to be displayed in
      ALV
        w_final-total      = 'COMPANY TOTAL'.
        w_final-field1   = w_main-field1.
        w_final-field2    = w_main-field2.   
        w_final-field3   = w_main-field3 .  
       APPEND w_final TO i_final.  ENDLOOP.
    Regards,
      Santosh

  • [Forum FAQ] How to calculate the total count of insert rows within a Foreach Loop Container in SSIS?

    Introduction
    We need to loop through all the flat files that have the same structure in a folder and import all the data to a single SQL Server table. How can we obtain the total count of the rows inserted to the destination SQL Server table?
    Solution
    We can use Execute SQL Task or Script Task to aggregate the row count increment for each iteration of the Foreach Loop Container. The following steps are the preparations before we add the Execute SQL Task or Script Task:
    Create a String type variable FilePath, two Int32 type variables InsertRowCnt and TotalRowCnt.
    Drag a Foreach Loop Container to the Control Flow design surface, set the Enumerator to “Foreach File Enumerator”, specify the source folder and the files extension, and set the “Retrieve file name” option to “Fully qualified”.
    On the “Variable Mappings” tab of the container, map the variable FilePath to the collection value.
    Drag a Data Flow Task to the container, in the Data Flow Task, add a Flat File Source, a Row Count Transformation, and an OLE DB Destination, and join them. Create a Flat File Connection Manager to connect to one of the flat files, and then configure the
    Flat File Source as well as the OLE DB Destination adapter. Set the variable for the Row Count Transformation to “User::InsertRowCnt”.
    Open the Property Expressions Editor for the Flat File Connection Manager, and set the expression of “ConnectionString” property to
    “@[User::FilePath]”.
    (I) Execute SQL Task Method:
    In the Control Flow, drag an Execute SQL Task under the Data Flow Task and join them.
    Create one or using any one existing OLE DB Connection Manager for the Execute SQL Task, set the “ResultSet” option to “Single row”, and then set the “SQLStatement” property to:
    DECLARE @InsertRowCnt INT,
                   @TotalRowCnt INT
    SET @InsertRowCnt=?
    SET @TotalRowCnt=?
    SET @TotalRowCnt=@InsertRowCnt+@TotalRowCnt
    SELECT TotalRowCnt=@TotalRowCnt
    On to parameter 1. 
    On the “Result Set” tab of the Execute SQL Task, map result 0 to variable “User::TotalRowCnt”.
    (II) Script Task Method:
    In the Control Flow, drag a Script Task under the Data Flow Task and join them.
    In the Script Task, select variable InsertRowCnt for “ReadOnlyVariables” option, and select variable TotalRowCnt for “ReadWriteVariables”.
    Edit the Main method as follows (C#):
    public void Main()
    // TODO: Add your code here
    int InsertRowCnt = Convert.ToInt32(Dts.Variables["User::InsertRowCnt"].Value.ToString()
    int TotalRowCnt = Convert.ToInt32(Dts.Variables["User::TotalRowCnt"].Value.ToString());
    TotalRowCnt = TotalRowCnt + InsertRowCnt;
    Dts.Variables["User::InsertRowCnt"].Value = TotalRowCnt;
    Dts.TaskResult = (int)ScriptResults.Success;
              Or (VB)
              Public Sub Main()
            ' Add your code here
            Dim InsertRowCnt As Integer =        
            Convert.ToInt32(Dts.Variables("User::InsertRowCnt").Value.ToString())
            Dim TotalRowCnt As Integer =
            Convert.ToInt32(Dts.Variables("User::TotalRowCnt").Value.ToString())
            TotalRowCnt = TotalRowCnt + InsertRowCnt
            Dts.Variables("User::TotalRowCnt").Value = TotalRowCnt
            Dts.TaskResult = ScriptResults.Success
           End Sub
    Applies to
    Microsoft SQL Server 2005
    Microsoft SQL Server 2008
    Microsoft SQL Server 2008 R2
    Microsoft SQL Server 2012
    Microsoft SQL Server 2014
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Hi ITBobbyP,
    If I understand correctly, you want to load data from multiple sheets in an .xlsx file into a SQL Server table.
    If in this scenario, please refer to the following tips:
    The Foreach Loop container should be configured as shown below:
    Enumerator: Foreach ADO.NET Schema Rowset Enumerator
    Connection String: The OLE DB Connection String for the excel file.
    Schema: Tables.
    In the Variable Mapping, map the variable to Sheet_Name, and change the Index from 0 to 2.
    The connection string for Excel Connection Manager is the original one, we needn’t make any change.
    Change Table Name or View name to the variable Sheet_Name.
    If you want to load data from multiple sheets in multiple .xlsx files into a SQL Server table, please refer to following thread:
    http://stackoverflow.com/questions/7411741/how-to-loop-through-excel-files-and-load-them-into-a-database-using-ssis-package
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • I want to display total count on the top of a Column in  business graphics

    Hi All ,
        How can I display total count of the column say for example no. of employees in a series of column chart type in business graphics.
    Any type of help would be much appreciated.
    Thanks
    Uday

    Hi Vishweshwara,
    following is the code i wrote. please check the correctness of the code.
    int seriescount = 0;
    for(int i=0;i<nodesize;i++){
    IGraphDataElement catele = gdNode.createGraphDataElement();
    switch(i){
    case 0:   
       if(wdContext.currentContextElement().getQ().equals("Q1")){
         catele.setCategory("Q1");
           catele.setKRA_Series1(Q1_KRA);
           catele.setApp_Pln_Series2(Q1_AP);
           catele.setRev_App_Series3(Q1_RA);
           catele.setEnd_Rev_Series4(Q1_ERP);
           catele.setApp_Procss_Series5(Q1_AIP);
           catele.setApp_overall_Series6(Q1_AOP);
           seriescount = seriescount+1; break;}
            break;
    case 1:       
       if(wdContext.currentContextElement().getQ().equals("Q2")){
           catele.setCategory("Q2");
           catele.setKRA_Series1(Q2_KRA);
           catele.setApp_Pln_Series2(Q2_AP);
           catele.setRev_App_Series3(Q2_RA);
           catele.setEnd_Rev_Series4(Q2_ERP);
         catele.setApp_Procss_Series5(Q2_AIP);
         catele.setApp_overall_Series6(Q2_AOP);
            seriescount = seriescount+1; break; }
                 break;
    case 2:       
    if(wdContext.currentContextElement().getQ().equals("Q3")){
         catele.setCategory("Q3");
         catele.setKRA_Series1(Q3_KRA);
         catele.setApp_Pln_Series2(Q3_AP);
         catele.setRev_App_Series3(Q3_RA);
         catele.setEnd_Rev_Series4(Q3_ERP);
         catele.setApp_Procss_Series5(Q3_AIP);
         catele.setApp_overall_Series6(Q3_AOP);
         seriescount = seriescount+1; break;}
                 break;
    case 3:   
    if(wdContext.currentContextElement().getQ().equals("Q4")){
         catele.setCategory("Q4");
            catele.setKRA_Series1(Q4_KRA);
         catele.setApp_Pln_Series2(Q4_AP);
         catele.setRev_App_Series3(Q4_RA);
         catele.setEnd_Rev_Series4(Q4_ERP);
         catele.setApp_Procss_Series5(Q4_AIP);
         catele.setApp_overall_Series6(Q4_AOP);
            seriescount = seriescount+1; break;}
                 break;
    case 4: if(wdContext.currentContextElement().getQ().equals("All")){
           wdContext.nodeGraphData().invalidate();
         wdContext.currentContextElement().setGraphVisibility(WDVisibility.NONE);
         wdThis.onActiondropdownaction(wdEvent);
    }default:
    wdContext.nodeGraphData().addElement(catele);
    Thanks
    Uday

  • How to get the column count at the bottom of the column

    Hi Friends,
    How to get the column count at the bottom of the column
    Thanks
    Raj

    You mean row count? Add another column, click on the fx button and type RCOUNT(1).
    If you want just the total you can make it MAX(RCOUNT(1)), hide this column and then add a Narrative View after your report and enter "Total Number of Records: @n" where "n" represents what order your column is from the left side.

  • How to count the total lines of the file (including the file header)

    Hi all,
    I am working with Idoc to file scenario(FCC).
    I need to map one of the field with a recound count ie.., count of the total lines of the file (including the file header).
    Eg:Record Count-- mapping area:Total number of records in the file including file header     The total line of the file (including the file header).
    Can i get a help on this.
    Thanks and Regards,
    Manoj

    Hi !
    If there is a tag of your IDOC that occurs the same quantity of times as file lines you have to create in your target file, you could make a Java user defined function in graphical mapping that "caches the entire queue" (use the corresponding option button), that receives as input that field of the IDOC, and returns the "lenght" (.length property value) of that input parameter (it is an array) as output..that should be the file line quantity..you may also add 1 to that count, for the header.
    Hope it helps.
    Regards,
    Matias.

  • How do I get a page count from the HP Photosmart 5514?

    How do I get a page count from the HP Photosmart 5514?

    Simple.  Access the printer web gui by typing in the printers IP address into your browsers address bar.  Select Tools/Usage reports.  Done.

  • How to get a total record count before grouping?

    I need to group a report on a formula that does roughly the following:
    [record count] / ( [total record count] / 20 )
    What this acheives is to label each record with a number of 1 - 20 which I want to group on. Getting this figure is the easy part, what is not working is the fact that I cannot group from a formula that is calculated after grouping. I overcame a portion of this by using "Whilereadingrecords" (rather than "count", running totals, or while printing records) to acheive a record count.
    I can't figure out how to get a total record count done before grouping. Is there a way to do this with "WhileReadingRecords"?? Is this even possible?
    Thanks
    John

    Hi John, 
    The order of how Crystal does things dictates the order of which features you can use.  Crystal has a two pass method.  In the first pass it does things like passing the query, grouping, summarizing.  In the second pass it does formulas, formatting, etc. 
    Unfortunately Crystal does the Grouping before summarizing so what you want to do can't be done in Crystal.  The best way to get around this to either create a SQL Command or view/stored procedure that will do the summarizing for you.  Then in the report you can use it. 
    Hope this helps,
    Brian

  • Getting control totals for all the objects

    Hi All,
    1. I want to get the control totals for all the tables along with table names in Oracle
    the below I google and found, but I am not aware of xml in Oracle, I tested this on small scott db it works fine
    select
    table_name,
    to_number(
    extractvalue(
    xmltype(
    dbms_xmlgen.getxml('select count(*) c from '||table_name)
    ),'/ROWSET/ROW/C')) count
    from user_tables order by 1is the above query correct?
    2. I want all the view name
    This I can get it from user_views ( but I want for entire database excluding system views and only user created views)
    select view_name from user_objects3. I want all the sporc name( including the ones in the package and stand alone)
    I am not sure how to get this.

    Be aware of the statement "Some columns in these views contain statistics that are generated by the DBMS_STATS package or ANALYZE statement."
    See this page specially "Columns marked with an asterisk (*) are populated only if you collect statistics on the table with the ANALYZE statement or the DBMS_STATS package."
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10820/statviews_2117.htm#REFRN20286
    If your statistic is not updated, it can give you totally wrong impression.

  • How to determine the page count of the front document (pdf-Preview) with applescript?

    Hello, I'm a beinnger apple scripter, and I have 2 questions. First, im trying to find the code to generate a page count for the front document of preview. I tried something like this:
    choose file with prompt "Count the number of pages in this PDF file:" without invisibles
    do shell script "/usr/bin/mdls -name kMDItemNumberOfPages " & quoted form of POSIX path of result & " | /usr/bin/grep -o '[0-9]\\+$'"
    But I dont want to have to choose a file with the prompt, and Im not sure how to get the path or POSIX path of an open pdf that is the front document in prievew to then use that directory to select the file to run the shell script on. This is one step in a much larger sequence of automator/apple script commands for large print jobs.
    The large scale view is:
    1. seleting a group .musx Finale 2014 files and creating pdfs of all the documents
         -Achieved with Automator stuff: [Get selected finder items] [open finder items with Finale 2014] [run applescript to convert to pdf all the open files] (which I have working but without a proper repeat condition)
    2. sorting those those exports into even/odd groups
    3. making the even pages 2 up with a create booklet plugin
    3. combinging even/odd group pdfs in their respective folders
    4. sending the 2 up evens to 1 printer, and the singes to another printer.
    but at this stage in the code/automator this is what i'll need to be doing:
    1. Several pdf documents will be open and I need to determine the page count of the front document.
    2. With that result I need to determine if the pagecount is even or odd.
    3. If its even, I need to save as pdf in a file folder /desktop/PDF Export/Doubles
         - if its odd, I need to save as pdf pages from 1 to (pageCount -1) to /desktop/PDF Export/Doubles, and pages (pageCount) to (pageCount) to desktop/PDF Export/Singles. (example: A 5 page pdf will send pages 1-4 to folder "Doubles", and pages from 5 to 5 to Singles, A 1 page pdf will only send a copy to the folder "Singles." A 2 page pdf will send both pages to "doubles"
    4. once the even/odd pages have had pdfs made in the either or both of the folders, Im going to close the document and repeat for all other open pdfs.
    Which also brings me to my 2nd repeat condition question: how can I repeat (print, save as pdf, close) commands for open files and end the script once all files are closed? This can help me both at this stage, as well the coding stage before in creating the pdfs from open Finale/sibelius .sib/.musx files
    would it be something like this?:
    If front document exists
    try
    tell application "preview"
    <bla bla>
    end try
    end tell
    At stage 1 of the large scale i've gotten the files to export pdfs and close multiple files, but if i say "repeat 4 times" and i have 3 files it can do those commands but it gets stuck trying to repeat the code one more time. I need the repeat amount x to be the # of items in selection from the the original finder window.
    Thanks for the help!

    The following AppleScript will get the POSIX path and filename of the current PDF file. It will just return the integer value for page count. Note: The path retrieved is the actual path to the PDF file, unless it is on the Desktop. In the latter case, the path will be ~/Library/Containers/com.apple.Preview/Data/Desktop/filename.pdf.
    The script assumes that the following folders exist, otherwise you will need a try block to test for their presence.
    The AppleScript dictionary for Preview does not provide a page dictionary entry, that would make a repeat loop and page range possible for saving individual page ranges.
    set pdfDoubles to POSIX path of ((path to desktop) & "PDF Export" & Doubles)
    set pdfSingles to POSIX path of ((path to desktop) & "PDF Export" & Singles)
    tell application "Preview"
      -- gets quoted POSIX path and filename
              set pdfFile to (get path of front document)
              set pdfName to (get name of front document)
      log pdfName
              set cmdArg to "/usr/bin/mdls -name kMDItemNumberOfPages " & pdfFile ¬
                        & " | egrep -o \"(\\d+)\""
              set pageCnt to do shell script cmdArg
      display dialog pageCnt
              if pageCnt mod 2 is 0 then
      -- even
      -- save pdfName in pdfDoubles
              else
      -- save pdfName in pdfDoubles
      -- save individual pages in pdfSingles
              end if
    end tell

  • How can I bring the recordset count inside the same recordset?

    I have a query inside a procedure where I'm paging the results.
    I dont know how to bring the total results inside the recordset.
    How can I bring the recordset count inside the same recordset?
    SELECT *
    FROM ( select a.*, rownum rnum
         FROM (SELECT
              FROM table
              ORDER BY id DESC) a
         WHERE rownum <= pg*50 )
    WHERE rnum > (pg-1)*50

    My query is much more comples, so that is why I'm using the other script.
    When I included the "COUNT(*) OVER() tot_cnt AS total" it didn't worked:
    ORA-00904: "TOT_CNT": invalid identifier
    What is the tot_cnt?
    SELECT *
    FROM (SELECT a.*, rownum rnum
    FROM (SELECT
    ed_fotos.id AS COD_FOTO,
    ed_fotos.arquivo AS NOM_ARQUIVO,
    ed_areas.nome AS NOM_REDACAO,
    COUNT(*) OVER() tot_cnt AS total
    FROM edt.ed_fotos ed_fotos
    INNER JOIN edt.ed_volumes ed_volumes ON ed_volumes.id = ed_fotos.volume_id
    INNER JOIN edt.ed_caminhos path_alta ON path_alta.id = ed_volumes.caminho1
    INNER JOIN edt.ed_caminhos path_baixa ON path_baixa.id = ed_volumes.caminho2
    INNER JOIN edt.ed_areas ed_areas ON ed_areas.id = ed_fotos.redacao_id
    ORDER BY id DESC) a
    WHERE rownum <= 200 )
    WHERE rnum >= 100

  • Count the total val of the column in matrix

    hi
    how to count the total value of the column in matrix
    eg:
    id     name     points
    10    sachin    100
    12     rama        80
    count the total points in the matrix
    180

    Hi Hareesh,
    Try This....
      Dim finaltot As Integer = 0
                    Dim i As Integer
                    For i = 1 To omatrix.RowCount
                        oedittot = omatrix.Columns.Item("points").Cells.Item(i).Specific
                        finaltot = finaltot + oedittot.value
                    Next
    Thanks
    Shafi

  • Help in finding the total count for each month

    Hello everyone,
    Sometime back I had posted about the date function. I have that problem solved now my problem is that after finding all records which against each record I need to find the total count for that month if no records than I have to set it to a 0.
    Here is how my program has been written.
    PROCEDURE extract_materials
    IS
    CURSOR xyz
    BEGIN
    FOR xyz1 IN xyz LOOP
    -- once inside the loop for each of the record from
    the cursor I need to find a total count for that record for everymonth in the year.
    All these records will be instered in to a staging table
    Can you please help me out with this. I really appreciate this.
    Thanks in advance.
    -Vani

    Andrew - you missed the tricky bit of the spec - include missing months with a zero.
    You need to do an outer join to a select from any big table with a function involving rownum and add_months to generate all the possible months. However, its time to go home and I can't be bothered to work out the finer details.

  • Although my ipod shows the number of steps, calories, and time, it no longer is saving it to the history. also when I open the history it takes me to May 2010 instead of the current date. Any ideas on how to get it to start recording the history again?

    Although my ipod shows the number of steps, calories, and time, it no longer is saving it to the history. Also when I open the history it takes me to May 2010 instead of the current date. Any ideas on how to get it to start recording the history again?

    Try:                                               
    - iOS: Not responding or does not turn on           
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try another cable                     
    - Try on another computer                                                       
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar
    The missing apps could have been done by setting the Restrictions that can hid those apps. If the backup was made with those retrictions set the the Restrictions are also restored.
    Thus, if you get it to work restore to factory settings/new iPod, not from backup                               
    You can redownload most iTunes purchases by:        
      Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • I just need to know how you get an iTunes library off the original hard drive of a mac and onto an external hard drive and still have it work normally?

    I just need to know how you get an iTunes library off the original hard drive of an imac and onto an external hard drive and still have it work as it normally would?

    http://support.apple.com/kb/HT1449

Maybe you are looking for

  • How do I cancel a cancelation?

    I've just had one of the craziest days of my live. To start with I'm deaf to the extent that I cannot carry out a normal telephone conversation. A few days ago I was advised that we now had Infinity 1 in our area and asking whether I would like to si

  • Error while viewing the SC via BBP_MON_SC

    Hello, BBP_MON_SC(check status) takes me to the initial screen where in I enter the SC number. I get the initial screen with header data. But clicking on for item details button 'item overview' gives me the following error.. System Error: SC not in T

  • Error in starting new process in GP

    Hi All I am facing a problem is starting a new GP process dynamically. On the following step I get a GP InvocationException IGPUserContext userContext =GPContextFactory.getContextManager()                          .createUserContext(processUser);. Me

  • How can i  apply this  java program for  a jsp page?

    import java.io.*; import java.util.*; public class FileProcessing   //create a vector container  for the input variables      Vector variables = new Vector();   //create a vector container for the constants      Vector constants = new Vector();   /*c

  • New Time Zone

    Hi All my country, Venezuela, decided to change the time zone from UTC+4 to UTC+4:30, yes a half an Hour change his is another of Chavez Ideas, but my problem is that I can not set this on the Preference panels of time zone, I Have notice that other