Determining number of rows in blocks

Hello
Assume 8k blocksize
How can I know, how many rows will fit into one block?
Cheers

Not really no. What's a row look like? NUMBERs? VARACHARs? DATE types? If VARCHARs, the amount of data actually being stored could vary hugely.
If you already have some data loaded in a table somewhere, you may try sampling existing data to give you some idea.
Try something like this:
MBOBAK@mstmfgpep> create table test_rows nologging as select * from dba_tables;
Table created.
MBOBAK@mstmfgpep> select count(*) from TEST_ROWS;
  COUNT(*)
      1589
1 row selected.
MBOBAK@mstmfgpep> l
  1* select dbms_rowid.ROWID_to_absolute_fno(rowid,'MBOBAK','TEST_ROWS'),dbms_rowid.ROWID_BLOCK_NUMBER(rowid),count(*) rows_in_block from test_rows group by dbms_rowid.ROWID_to_absolute_fno(rowid,'MBOBAK','TEST_ROWS'),dbms_rowid.ROWID_BLOCK_NUMBER(rowid)
MBOBAK@mstmfgpep> /
DBMS_ROWID.ROWID_TO_ABSOLUTE_FNO(ROWID,'MBOBAK','TEST_ROWS') DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) ROWS_IN_BLOCK
                                                           6                                  212            31
                                                           6                                  216            32
                                                           6                                  218            31
                                                           6                                  221            31
                                                           6                                  222            32
                                                           6                                  224            31
                                                           6                                  255            31
                                                           6                                  206            32
                                                           6                                  213            32
                                                           6                                  220            31
                                                           6                                  223            31
                                                           6                                  225            32
                                                           6                                  227            31
                                                           6                                  239            30
                                                           6                                  245            31
                                                           6                                  208            32
                                                           6                                  211            32
                                                           6                                  240            30
                                                           6                                  243            31
                                                           6                                  247            33
                                                           6                                  253            34
DBMS_ROWID.ROWID_TO_ABSOLUTE_FNO(ROWID,'MBOBAK','TEST_ROWS') DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) ROWS_IN_BLOCK
                                                           6                                  204            32
                                                           6                                  228            31
                                                           6                                  230            31
                                                           6                                  232            31
                                                           6                                  234            31
                                                           6                                  235            30
                                                           6                                  250            41
                                                           6                                  254            33
                                                           6                                  256            31
                                                           6                                  207            31
                                                           6                                  237            30
                                                           6                                  241            31
                                                           6                                  242            32
                                                           6                                  244            32
                                                           6                                  246            31
                                                           6                                  248            38
                                                           6                                  251            34
                                                           6                                  209            32
                                                           6                                  231            31
                                                           6                                  236            30
                                                           6                                  238            30
DBMS_ROWID.ROWID_TO_ABSOLUTE_FNO(ROWID,'MBOBAK','TEST_ROWS') DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) ROWS_IN_BLOCK
                                                           6                                  210            32
                                                           6                                  214            32
                                                           6                                  215            32
                                                           6                                  219            31
                                                           6                                  226            31
                                                           6                                  205            32
                                                           6                                  229            31
                                                           6                                  252            34
50 rows selected.
MBOBAK@mstmfgpep> This will count the number of rows that you're actually getting in each block. Warning, on a large table, this could take a very long time to run and produce lots of output. But you should be able to use the technique to sample how many rows/block you see on various tables.
Hope that helps,
-Mark

Similar Messages

  • Determine number of rows from javascript so I can hide if zero

    Hi All,
    Found a great article which I adapted to use the link on a report to delete a row in db and remove from table (without a refresh).
    It works great except I want the region to not display when there are no rows left.
    Currently it shows "No Data Found" but because the page does not submit the region does not hide.
    Here is the Java code:
    function ackMsg(p_this, p_empno) {
    // get the table row on which the user clicked
    var tr = $(p_this).closest('tr');
    // perform an asynchronous HTTP AJAX request using jQuery
    $.ajax({
    type: "POST",
    url: "wwv_flow.show",
    data: {
    p_flow_id: $('#pFlowId').val(),
    p_flow_step_id: $('#pFlowStepId').val(),
    p_instance: $('#pInstance').val(),
    x01: p_empno, // assign p_empno to the g_x01 global variable
    p_request: "APPLICATION_PROCESS=ack_message" // refer to the application process
    beforeSend: // executes while the AJAX call is being processed
    function() {
    // delete following HTML classes from the table row element
    // could be possibly theme dependent
    tr.removeClass('even');
    tr.removeClass('odd');
    // use jQuery's animate function to give the table row, and its children, a red background
    tr.children().hover(function() {
    tr.children().animate({'backgroundColor': '#00cc00'}, 300);
    }, function() {
    tr.children().animate({'backgroundColor': '#00cc00'}, 300);
    tr.children().animate({'backgroundColor': '#00cc00'}, 300);
    success: // to be called if the request succeeds
    function() {
    jQuery(p_this).trigger('apexrefresh');
    // jQuery has difficulties animating inline elements
    // that's why we wrap them in a div, which is a block element
    tr.children().wrapInner('<div>').children().fadeOut(400, function() {
    tr.remove(); // visually remove the row from the report
    I did some Googling to add the line ' jQuery(p_this).trigger('apexrefresh');' which refreshes just that report.
    What I think I need to do is add a check for number of rows left after the refresh then if = 0 do full page refresh to allow the region condition to hide it.
    Unfortunately after hours on Google I can't find how to check how many rows are in the table.
    PS the function is called from the link in the report like this onclick="ackMsg(this, #ACK#)"
    Please help
    AT
    Edited by: user1678248 on May 13, 2013 9:39 PM
    Edited by: user1678248 on May 13, 2013 9:40 PM

    1)
    When you set a column to hidden in a classic report using the method I described, it creates hidden form elements for that column.
    <tt><input type="hidden" name="f01" value="" id="f01_0002"></tt>
    You should inspect the source to figure out the name value.
    Since this belongs to the wwv_flow form, we can therefore get this data with: wwv_flow.f01
    Alternatively, you could have used the apex_item API to achieve the same result, which probably gives a bit better control.
    http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/apex_item.htm#CHDBFHGA
    select apex_item.hidden(1, col) || col col
    from table
    Set that column to a standard report column so it doesn't escape the html.
    You can also reference the data in these fields using PL/SQL using the apex_application API:
    http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/apex_app.htm#CHDGJBAB
    2)
    As above, setting the column to hidden creates hidden elements on the page. It is simply f01 because that is the only hidden field I would have on my page. With four reports on the page, you would need to be careful not to do the same on the other reports, as you would get inaccurate data. For each report, setting columns to hidden always starts with f01. In that, you would be best to use the apex_item API.
    I actually initially ran into this issue when i had a tabular form on the same page as a report with hidden fields, which was causing conflicts in the page processes.
    Hope it helps.

  • Determining Number of Rows in a ResultSet

    Hi,
    Is there an easy way to determine the number of rows in a result set with TYPE_FORWARD_ONLY?

    > > Try ResultSet rs = statment.executeQuery(...);
    if(rs
    == null){ //result set is empty}That is incorrect... it should have read:
    ResultSet rs = statment.executeQuery(...);
    if( ! rs.next() )
    //result set is empty
    you're right!! copy/paste from executeUpdate( ) api documentation about statements....
    "a ResultSet object that contains the data produced by the given query; never null"
    here's the catch though: that will advance your result set, which will throw off your cursor in a while loop (used to parse the results). requires you to reset the cursor before processing the result set.

  • Determine Number of  rows in Internal Table

    Hi,
      I have defined my internal table as follows:
         TYPES : BEGIN OF ABC_KEY,
                  FIELD1(2)   TYPE C,
                  FIELD2(1)   TYPE C,
                  FIELD3(8)   TYPE N,
                  END OF ABC_KEY.
    DATA: itab1 TYPE TABLE OF ABC_KEY
                      WITH KEY FIELD1,
           wa_lines_1 LIKE LINE OF itab1.
    How can I retrieve the number of rows in Internal Table?
    Thanks.
    Regards,
    bw_newbie

    You can define the number of rows of the internal table using the DESCRIBE itab command .
    As the rest have already stated a sample code snippet .
    For more info type in DESCRIBE in your prgram and click on (F1) by placing the cursor on DESCRIBE .
    You will find more options as to how you can use the DESCRIBE command according to your requirement .
    Thanks ,
    Hari

  • How to determine the number of rows of data in a datatable?

    I have a datatable that I fill from an SQL query.  I do not know exactly how many rows of data it will return (due to my selection criteria) but will be somewhere between 100 and 300 rows.  I send this data into a report but need to determine the length of the report (panel height data member) programatically based on how much data the query has returned.  So, I need a way to count how many rows are filled in the data table.
    I tried doing a nested "if" statement checking the value of each cell but when I tested the expression at 59 "if" statements (will need 300+) I got a parser error in lookout when I tried to accept the connection.  I also tried a type of loop by assigning cursor.2 either to its own value (circular) or to its own value plus one depending on the value of the cell at cursor.2.  It was close but overshot by one row or more (much more sometimes).
    Any clever ideas?  Perhaps I have just been looking at this problem too long.  Thanks, in advance, for your help.

    Since the datatable gets the data from the SQL query, you can also use the SQL statement to count the number of rows in the query result.  
    For example, in datatable you do "select localtime, trace1 from intdata where xxx". You can get the count by "select count(trace1) from intdata where xxx". Use the same condition in order to get the same number of rows.
    Maybe another SQLExec object is needed to do the count.
    Whenever the datatable executes the SQL, the SQLExec executes and return the count.
    Ryan Shi
    National Instruments

  • How to determine the number of rows to be displayed in a report

    hello experts,
    Has anyone ever come across this requirement before? Before a report finishes being executed and before it displays the results, is there a way to determine the number of rows to be displayed as the result?
    Many thanks in advance.
    Regards,
    Inma

    Hello Arun,
    Thanks for your reply but do you know which method I should use for this purpose if I use the table interface?
    Thanks,
    Inma

  • More Table Blocks in 11g with same number of rows as in 9i

    I was using SQL performance analyzer to compare performance difference between 9i and 11g databases.
    For this purpose I generated a trace file in 9i database and used it to build STS in 11g database.
    After runing two trials and comparison the report showed performance regression (comparing "buffer gets") while using following SQL statement
    *"SELECT * FROM EMP";*
    There were total 14 rows in emp table in both databases( i.e 9i and 11g)
    There was no plan change for above SQL statement in 11g database but still there was performance regression in 11g.
    After querying dba_tables view for number of blocks in emp table on both sides i found that EMP table in 9i database had 1 block where as in 11g emp table had 5 blocks (Even after using alter table emp move;)
    I am unable to understand why emp table has more number of blocks in 11g with same number of rows as in 9i emp table?

    user8916506 wrote:
    Below query was executed in 9i database.
    SQL> select extent_management,initial_extent,allocation_type from dba_tablespaces where tablespace_name='SYSTEM';
    EXTENT_MAN INITIAL_EXTENT ALLOCATIO
    LOCAL 65536 SYSTEM
    Results shows that SYSTEM tablespace in 9i database is locally managed.
    Where as results of below query from 11g database is indicating that users tablespace in 11g is also locally managed.
    SQL> select extent_management,initial_extent,allocation_type from dba_tablespaces where tablespace_name='USERS';
    EXTENT_MAN INITIAL_EXTENT ALLOCATIO
    LOCAL 65536 SYSTEMGood to see that you also picked up the allocation_type at the same time.
    So you have shown that the discrepancy between 9i and 11g isn't down to the difference in extent management.
    Are there any other differences between the tablespaces when you compare 9i system with non-system, and 9i system with 11g non-system ? (Hint - we have an anomaly with space allocation.)
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    Author: <b><em>Oracle Core</em></b>

  • How to determine count for the number of rows

    Appreciate if any of you could think of a way of determining the count for the number of rows in the subquery without having to run another query.
    SELECT *FROM
    (SELECT rownum, rn, rlp_id, rlp_notes, cad_pid, status, jurisdiction_id, s.state_abbr, rlp_address, rlp_route_id, rlp_route_section, psma_version FROM ipod.relevant_land_parcels r, state s WHERE s.state_pid = r.state_pid(+) AND rlp_route_id = 'SM1' AND status = 'CURRENT')WHERE rn > 200 AND rn < 216
    And I want to import this into.net and C# environment.

    Something like this,.....????
    SQL> select * from emp;
    EMPNO ENAME      JOB         MGR HIREDATE          SAL      COMM DEPTNO
    7369 SMITH      CLERK      7902 17/12/1980     800,00               20
    7499 ALLEN      SALESMAN   7698 20/02/1981    1600,00    300,00     30
    7521 WARD       SALESMAN   7698 22/02/1981    1250,00    500,00     30
    7566 JONES      MANAGER    7839 02/04/1981    2975,00               20
    7654 MARTIN     SALESMAN   7698 28/09/1981    1250,00   1400,00     30
    7698 BLAKE      MANAGER    7839 01/05/1981    2850,00               30
    7782 CLARK      MANAGER    7839 09/06/1981    2450,00               10
    7788 SCOTT      ANALYST    7566 19/04/1987    3000,00               20
    7839 KING       PRESIDENT       17/11/1981    5000,00               10
    7844 TURNER     SALESMAN   7698 08/09/1981    1500,00      0,00     30
    7876 ADAMS      CLERK      7788 23/05/1987    1100,00               20
    7900 JAMES      CLERK      7698 03/12/1981     950,00               30
    7902 FORD       ANALYST    7566 03/12/1981    3000,00               20
    7934 MILLER     CLERK      7782 23/01/1982    1300,00               10
    14 rows selected
    SQL>
    SQL> select max(rw) from
    2 (
    3 select empno , row_number () over (order by empno) rw from emp
    4 where job='CLERK'
    5 )
    6 /
       MAX(RW)
             4Greetings...
    Sim

  • How to find number of rows in a table

    i have one table ,it contains millions of record,how can i know number of rows in that table without using count(*),
    i tried in user_table ,for the column NUM_ROWS,but it is not showing number of rows,pls send me a solution for this.
    regards,
    singh

    Ok, that only was to show simply that max option
    might not an option to reduce execution time.Yes, but I/O variances have a tendency to really skew the observed elapsed execution time - making execution time alone a poor choice to determine what SQL will perform better than another.
    Both MAX(ROWNUM) and COUNT(*) results in the same amount of I/O - as both uses the exact same execution plan, I/O wise. In this example, a FTS.
    SQL> create table testtab nologging as select * from all_objects where rownum < 10001;
    Table created.
    -- warmed up the buffer cache with a couple of SELECTs against TESTAB in order
    -- to discard PIOs from the results
    SQL> set autotrace on
    SQL> select count(*) from testtab;
    COUNT(*)
    10000
    Execution Plan
    Plan hash value: 2656308840
    | Id | Operation | Name | Rows | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 35 (9)| 00:00:01 |
    | 1 | SORT AGGREGATE | | 1 | | |
    | 2 | TABLE ACCESS FULL| TESTTAB | 9262 | 35 (9)| 00:00:01 |
    Note
    - dynamic sampling used for this statement
    Statistics
    0 recursive calls
    0 db block gets
    131 consistent gets
    0 physical reads
    0 redo size
    223 bytes sent via SQL*Net to client
    238 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed
    SQL> select max(rownum) from testtab;
    MAX(ROWNUM)
    10000
    Execution Plan
    Plan hash value: 2387991791
    | Id | Operation | Name | Rows | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 35 (9)| 00:00:01 |
    | 1 | SORT AGGREGATE | | 1 | | |
    | 2 | COUNT | | | | |
    | 3 | TABLE ACCESS FULL| TESTTAB | 9262 | 35 (9)| 00:00:01 |
    Note
    - dynamic sampling used for this statement
    Statistics
    0 recursive calls
    0 db block gets
    131 consistent gets
    0 physical reads
    0 redo size
    225 bytes sent via SQL*Net to client
    238 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed
    So seeing that we have the exact same baseline for both queries, and that PIO does not influence the results, we time a 1000 executions of both.
    SQL> declare
    2 cnt number;
    3 begin
    4 for i in 1..1000
    5 loop
    6 select count(*) into cnt from testtab;
    7 end loop;
    8 end;
    9 /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:03.19
    SQL>
    SQL> declare
    2 cnt number;
    3 begin
    4 for i in 1..1000
    5 loop
    6 select max(rownum) into cnt from testtab;
    7 end loop;
    8 end;
    9 /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:15.87
    SQL>
    This shows that what makes the MAX() more expensive is just that - determining the MAX(). For each row, Oracle has to call its internal MAX() function with two values - the current max result and the new value. This function then returns the new max value. This overhead per row adds up to a significant overhead in execution time - making the MAX() approach 5x slower than the COUNT() approach.

  • How to find accurate number of Rows, and size of all the tables of a Schema

    HI,
    How to find the accurate number of Rows, and size of all the tables of a Schema ????
    Thanks.

    SELECT t.table_name AS "Table Name",
    t.num_rows AS "Rows",
    t.avg_row_len AS "Avg Row Len",
    Trunc((t.blocks * p.value)/1024) AS "Size KB",
    t.last_analyzed AS "Last Analyzed"
    FROM dba_tables t,
    v$parameter p
    WHERE t.owner = Decode(Upper('&1'), 'ALL', t.owner, Upper('&1'))
    AND p.name = 'db_block_size'
    ORDER by 4 desc nulls last;
    ## Gather schema stats
    begin
    dbms_stats.gather_schema_stats(ownname=>'SYSLOG');
    end;
    ## Gather a particular table stats of a schema
    begin
    DBMS_STATS.gather_table_stats(ownname=>'syslog',tabname=>'logs');
    end;
    http://www.oradev.com/create_statistics.jsp
    Hope this will work.
    Regards
    Asif Kabir
    -- Mark the answer as correct/helpful

  • How to set number of rows in filters?

    Hi, we need to set another number of rows which is displayed in filters on bex or web template?
    Thanks for advice

    Hi Pavel,
    can you please specify your question more clearly. If you are on NW 7.0 you can determine a number of colums for your filter item with following command:
    COLUMNS
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/85/08e241aa8e9d39e10000000a155106/content.htm
    If you meant the amount of rows within the analysis item you can use following command within your analysis item:
    BLOCK_ROWS_SIZE   (numbers of rows displayed at once)
    BLOCK_ROWS_STEP_SIZE  (numbers of rows to be scrolled for one step)
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/76/489d39d342de00e10000000a11402f/content.htm
    Brgds,
    Marcel
    Edited by: Marcel Landsfried on Feb 10, 2009 7:45 PM
    Edited due to wrong url

  • How to set number of rows in "Rows Per Page Selector" in Interactive Report

    Hi Guys,
    Is there any way to set the number of rows in "Rows Per Page Selector" in Interactive Report. By default it is set to 15.
    I know one way is to change the number of rows when you are running the report and then set that as 'Default Report Setting'.
    If anybody is aware of any other way, please let me know.
    Cheers,
    Ashish Agarwal
    http://www.dbcon.com.sg

    Hi Pavel,
    can you please specify your question more clearly. If you are on NW 7.0 you can determine a number of colums for your filter item with following command:
    COLUMNS
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/85/08e241aa8e9d39e10000000a155106/content.htm
    If you meant the amount of rows within the analysis item you can use following command within your analysis item:
    BLOCK_ROWS_SIZE   (numbers of rows displayed at once)
    BLOCK_ROWS_STEP_SIZE  (numbers of rows to be scrolled for one step)
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/76/489d39d342de00e10000000a11402f/content.htm
    Brgds,
    Marcel
    Edited by: Marcel Landsfried on Feb 10, 2009 7:45 PM
    Edited due to wrong url

  • How to get the number of rows returned by a report?

    Hi,
    I'm developing my first application in APEX and so far everything seems fine, except I can't figure out this very simple thing: I have a report based on a PL/SQL block returning an SQL string. I'd like to have a message (something like "X rows returned") just before the report. The closest thing I could find was "X to Y out of Z" in the pagination styles, but that's not what I want. Also I don't think running the same query to get COUNT() is wise.
    Any help would be appreciated.
    Thanks,
    Konstantin

    My guess is that it only shows the number of rows it has retrieved. I believe the defailt is for it to only retrieve 50 rows and as you page through your report it retrieves more. So this would just tell you how many rows was retireved, but probably not how many rows the report would contain if you pages to the end. Oracle doesn't really have a notion of total number of rows until the whole result set has been materialized.

  • PROCEDURE PROBLEM - Exact Fetch Returns More Than Requested Number of Rows

    Here is my procedure:
    CREATE OR REPLACE PROCEDURE question4
      ( cust_first IN customer.custfirstname%TYPE,
       cust_last IN customer.custlastname%TYPE,
       customer_no OUT customer.customerSsn%TYPE,
       cust_address OUT customer.address%TYPE,
       loanID OUT loan.loanNo%TYPE,
       application_date OUT loan.appdate%TYPE,
       remaining_payments OUT loan.remainingpaymentsdue%TYPE,
       loan_amount OUT loan.loanamount%TYPE,
       loan_term OUT loan.loanterm%TYPE,
       interest_rate OUT loan.interestrate%TYPE,
       monthly_payment OUT loan.monthlypayment%TYPE)
       AS
    BEGIN
      SELECT customerssn, address  INTO customer_no, cust_address FROM CUSTOMER WHERE custfirstname= cust_first AND custlastname = cust_last;
      SELECT loanno, remainingpaymentsdue, loanamount, loanterm, interestrate, monthlypayment, appdate INTO loanID, remaining_payments, loan_amount, loan_term, interest_rate, monthly_payment, application_date FROM LOAN WHERE customerSsn = customer_no;
      EXCEPTION
        WHEN OTHERS
        THEN
        NULL;
    END;Here is the anonymous block showing the use of my procedure.
    SET SERVEROUTPUT ON
    DECLARE
      customer_number customer.customerSsn%TYPE := NULL;
      customer_address customer.address%TYPE := NULL;
      loan_number loan.loanNo%TYPE := NULL;
      app_date loan.appdate%TYPE := NULL;
      rem_payment loan.remainingpaymentsdue%TYPE := NULL;
      l_amount loan.loanamount%TYPE := NULL;
      l_term loan.loanterm%TYPE := NULL;
      i_rate loan.interestrate%TYPE := NULL;
      m_payment loan.monthlypayment%TYPE := NULL;
      view_customerSSN NUMBER;
      view_address VARCHAR2(50);
      view_loanID NUMBER;
      view_date DATE;
      view_remaining_payment NUMBER;
      view_loan_amount NUMBER(8,2);
      view_loan_term VARCHAR2(10);
      view_interest_rate FLOAT(20);
      view_monthly_payment NUMBER(8,2);
    BEGIN
      question4 ('Tim', 'Thompson',  customer_number, customer_address, loan_number, app_date, rem_payment, l_amount, l_term, i_rate, m_payment);
      IF (customer_number IS NULL OR customer_address IS NULL OR loan_number IS NULL OR app_date IS NULL
      OR rem_payment IS NULL OR l_amount IS NULL OR l_term IS NULL OR i_rate IS NULL OR m_payment IS NULL) THEN
         DBMS_OUTPUT.PUT_LINE ('NULL VALUE');
      ELSE
        view_customerSSN := customer_number;
        view_address := customer_address;
        view_loanID := loan_number;
        view_date := app_date;
        view_remaining_payment := rem_payment;
        view_loan_amount := l_amount;
        view_loan_term := l_term;
        view_interest_rate := i_rate;
        view_monthly_payment := m_payment;
        DBMS_OUTPUT.PUT_LINE ('CUSTOMER NO : ' ||  view_customerSSN);
        DBMS_OUTPUT.PUT_LINE ('CUSTOMER ADDRESS : ' ||  view_address);
        DBMS_OUTPUT.PUT_LINE ('LOAN NO : ' ||  view_loanID);
        DBMS_OUTPUT.PUT_LINE ('LOAN APPLICATION DATE : ' ||  view_date);
        DBMS_OUTPUT.PUT_LINE ('REMAINING PAYMENTS : ' ||  view_remaining_payment);
        DBMS_OUTPUT.PUT_LINE ('LOAN AMOUNT : ' ||  view_loan_amount);
        DBMS_OUTPUT.PUT_LINE ('LOAN TERM : ' ||  view_loan_term);
        DBMS_OUTPUT.PUT_LINE ('INTEREST RATE : ' ||  view_interest_rate);
        DBMS_OUTPUT.PUT_LINE ('MONTHLY PAYMENT : ' ||  view_monthly_payment);
      END IF;
    END;
    /Error Message:
    Error report:
    ORA-06550: line 21, column 3:
    PLS-00306: wrong number or types of arguments in call to 'QUESTION4'
    ORA-06550: line 21, column 3:
    PL/SQL: Statement ignored
    *06550. 00000 - "line %s, column %s:\n%s"*
    **Cause: Usually a PL/SQL compilation error.*
    **Action:*
    What is the problem here? Could you anyone help me?
    Thanks for your help from now on.
    Have a beautiful day...
    Edited by: RobertPires on May 1, 2011 5:13 PM
    Edited by: RobertPires on May 1, 2011 8:19 PM

    Thanks for your help, Sir. As you see it as above, I fixed the order of parameters, but since I would like to display multiple records, my procedure did not work properly and I got this error message:
    Error report:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at "S4048958.QUESTION4", line 20
    ORA-06512: at line 21
    *01422. 00000 - "exact fetch returns more than requested number of rows"*
    **Cause: The number specified in exact fetch is less than the rows returned.*
    **Action: Rewrite the query or change number of rows requested*
    I guess I need to create a cursor in my procedure, but I dunno how. Could you give me some suggestion for this please?
    Thanks again...

  • How to Efficiently Sample a Fixed Number of Rows

    Good afternoon. I need to select a specific number of random rows from a table, and while I believe my logic is right it's taking too long, 30 minutes for a routine data size. Hopefully someone here can show me a more efficient query. I've seen the SAMPLE function, but it just randomly selects rows on a one-by-one basis, without a guaranteed total count.
    This is the idea:
    INSERT INTO Tmp_Table (Value, Sequence) SELECT Value FROM Perm_Table, DBMS_RANDOM.VALUE;
    SELECT Value FROM Tmp_Table WHERE ROWNUM <= 1234 ORDER BY Sequence;I'd need to put the ORDER BY in a subselect for ROWNUM to work correctly, but anyway that's just an illustration. My actual need is a little more complicated. I have many sets of data; each set has many rows; and for each set I need to return a specific (different) number of rows. Perhaps project A has three rows in this table, and I want to keep two of them; project B has two rows, and I want to keep one of them. So I need to identify, for each row, whether it's valid for that project. This is what my data looks like:
    Project Person  Sequence Position Keeper
    A       Bill    1234     1        Yes
    A       Fred    5678     3        No
    A       George  1927     2        Yes
    B       April   5784     2        No
    B       Janice  2691     1        YesI populate Sequence with random values, then calculate the position of each person within their project, and finally discard people who's Position is greater than Max_Targets for the Project. Fred and April have the highest random numbers, so they're cut. It's not the case that I'm just trimming one person from each project; the actual percentage kept will range from zero to 100.
    Populating the list with random values is not time-consuming, but calculating Position is. This is my code:
    UPDATE Tmp_Targets T1
    SET Position =
      SELECT
       COUNT(*)
      FROM
       Perm_Targets PT1
       INNER JOIN Perm_Targets PT2 ON PT1.Project = PT2.Project
       INNER JOIN Tmp_Targets T2 ON PT2.Target = T2.Target
      WHERE
           T1.Target = PT1.Target
       AND T2.Sequence <= T1.Sequence
      );The Target fields are PKs, and the Project and Sequence fields are indexed. Is there a better way to approach this? I could write a cursor that pulls out project codes and performs the above operations for each project in turn; that would be logically simpler and possibly faster. Has anyone here addressed a similar problem before? I'd appreciate any ideas.
    This is on 9.2, in case it matters. Thank you,
    Jonathan

    You've not given any indication of how max targets for a given project is determined, so for my example I'm using the ceiling of 1/2 of the number of records in each project which gives the same number of yes and no responses per project as you had:
    with dta as (
      select 'A' project, 'Bill' person from dual union all
      select 'A', 'Fred' from dual union all
      select 'A', 'George' from dual union all
      select 'B', 'April' from dual union all
      select 'B', 'Janice' from dual
    ), t1 as (
      select project
           , person
           , row_number() over (partition by project order by dbms_random.value) ord
           , count(*) over (partition by project) cnt
           , rownum rn
        from dta
    select project
         , person
         , ord
         , cnt
         , case when ord <= ceil(cnt/2) then 'Yes' else 'No' end keep
      from t1
      order by rn
    PROJECT PERSON ORD                    CNT                    KEEP
    A       Bill   2                      3                      Yes 
    A       Fred   3                      3                      No  
    A       George 1                      3                      Yes 
    B       April  1                      2                      Yes 
    B       Janice 2                      2                      No  
    5 rows selectedIn this example I use an analytic function to assign a random ordering for each record within a project in the middle query, in the final output query I am determining the yes no status based on the order within a project and the count of records in the project. If you had a table of projects indicating the thresh hold you could join to that and use the thresh hold in place of the ceil(cnt/2) portion of my inequality in the case statement.

Maybe you are looking for

  • Problem in vf01 with a popup

    Hello experts, im making a call transaction to tx vf01. The program loops a table and for every loop, call to the tx vf01. But the first time i call the vf01, appears a popup. but from the second time that popup does not appear. There is a way to mak

  • Text Is Blurry

    I have been creating DVD menus, and am noticing that while using the same font and size one line of text may be blurry while the lines above and below are just fine. I have tried moving the blurry text around and it does not get better. Changing font

  • How to delete TV shows

    Hi.  I want to remove TV shows from my iPad mini and iPhone but there doesn't appear to be a way to delete them.  Suggestions?

  • Possible memory leak in forms api 6i

    There appears to be a bug in forms 6i. I am getting an error at the following snippet of code. The Name prints fine and the whole code runs great if i comment out free(v_value), but obviously i would not want to do that. I am using MS VC++ 6.0 compil

  • Can you issue a Control = from a webpage button

    Is there any way to issue a Control = from a webpage button to increase the size of the print within the browser. Say I wanted two buttons to increase or decrease the text size just as if I typed Control = or Control -.