SQL  to retrieve the records in subset

Dear Friends,
I have requirement to fetch 5 Million records from Oracle db and display using JAVA and JSP. Each record is 1 KB size.
The database table is online table used to store the transaction details, the rows will keep increasing. I am not allowed to use stored procedures also.
1) Fetching 5 Million record and displaying in 1 attempt is not feasible as JDBC has limitation and also the User has to wait too long to see the data.
I am thinking of processing the records in subset, for example.. Display first 10000 records then if the users wants next 10000 records fetch and display the next 10000 record.
Are there any other best practices to implement the above requirement.
I am not sure how to write the above SQL query? Can anyone please help me write the above SQL query?
I dont this I can use romnum as the rows are increasing.
Below is my Table structure and SQL query which returns 5 Million record
CREATE TABLE MESSAGE_LOG
SOURCE VARCHAR2(25 BYTE),
TARGET VARCHAR2(25 BYTE),
ENGINE VARCHAR2(100 BYTE),
PROCESS VARCHAR2(400 BYTE),
SERVICE VARCHAR2(100 BYTE),
LOGTIMESTAMP TIMESTAMP(6)
SELECT * FROM MESSAGE_LOG WHERE LOGTIMESTAMP BETWEEN TO_DATE('20-MAY-2010 01:00','DD-MON-YYYY HH24:MI') AND TO_DATE('20-MAY-2010 23:00','DD-MON-YYYY HH24:MI')
Thanks in advance,
Bob

user13109986 wrote:
I have requirement to fetch 5 Million records from Oracle db and display using JAVA and JSP. Why no one will look at five million results. And even if they wanted to it would take longer than the average human lifetime.
I am not allowed to use stored procedures also.Why, is there a business requirement that says the application should be as difficult to develop as possible, be unreliable and hard to maintain when things go wrong?
>
1) Fetching 5 Million record and displaying in 1 attempt is not feasible as JDBC has limitation and also the User has to wait too long to see the data.As the user will never read five million results, it doesn't matter
Try this link and come back when you have got to the 5,000,000 result of the 6,730,000 that are estimated to be there
http://www.google.com/#hl=en&q=oracle+procedure
Or you could list every thread in the forum and multiply the time it takes you to get to the last by 50.
I am thinking of processing the records in subset, for example.. Display first 10000 records then if the users wants next 10000 records fetch and display the next 10000 record.Try looking at 10,000 threads on this forum or 10,000 results from Google and see how long that takes.
Are there any other best practices to implement the above requirement.Yes, don't return more information than anyone could possibly find useful

Similar Messages

  • Callprocedure which contain dynamic sql that retrieve multiple records from VB

    hi dear i have problem with using dynamic sql to retrieve multipule records
    and access them from visual basic
    first i use Oracle8 Enterprise Edition Release 8.0.4.0.0
    and odbc microsoft odbc for oracle version 2.573.4403.00
    these are the whole processes to do that
    please check the steps and if u find any error say to me....
    1-table description
    Name Null? Type
    PORT_KEY NOT NULL VARCHAR2(4)
    CITY_KEY NOT NULL VARCHAR2(4)
    and port_key is primary key
    2- package declaration
    create or replace package ww1
    as
    procedure bound_type
    (v_origin in varchar2,v_flag in varchar2
    ,city_key out dbms_sql.varchar2_table
    end ;
    3- package body
    create or replace package body ww1
    as
    procedure bound_type
    (v_origin in varchar2,v_flag in varchar2
    ,city_key out dbms_sql.varchar2_table
    is
    str varchar2(1000);
    cur_hdl integer :=dbms_sql.open_cursor;
    rows_processed integer;
    indx integer :=1;
    begin
    str:='select ltrim(rtrim(city_key)) from special_airport ';
    if ltrim(rtrim(upper(v_flag))) = upper('c')
    then
    str:=str | | ' where city_key=ltrim(rtrim(upper('| |''''| |v_origin| |''''| |')))';
    elsif ltrim(rtrim(upper(v_flag))) = upper('a') then
    str:= str | |' where port_key=ltrim(rtrim(upper('| |''''| |v_origin| |''''| |')))';
    end if;
    dbms_sql.parse(cur_hdl,str, dbms_sql.native );
    dbms_sql.define_array(cur_hdl,1,city_key,10,indx);
    rows_processed:=dbms_sql.execute(cur_hdl);
    loop
    rows_processed:=dbms_sql.fetch_rows(cur_hdl);
    dbms_sql.column_value(cur_hdl,1,city_key);
    exit when rows_processed != 10;
    end loop;
    dbms_sql.close_cursor(cur_hdl);
    end bound_type;
    end ww1;
    4- code for calling stored procedure from visual basic
    dim c As New ADODB.Connection
    Dim cmd As New ADODB.Command
    Dim rs As New ADODB.Recordset
    c.Open "dsn=dsnName;uid=uidValue;pwd=pwdValue"
    With cmd
    Set .ActiveConnection = c
    .CommandType = adCmdText
    '---------(call bound_type stored procedure)--------------
    .Parameters.Append .CreateParameter(, adBSTR, adParamInput, , "bwi")
    .Parameters.Append .CreateParameter(, adBSTR, adParamInput, , "a")
    .CommandText = "{call fares_procedures.bound_type (?,?,{resultset 10, city_key }) }"
    End With
    Set rs.Source = cmd
    rs.Open
    While Not rs.EOF
    z = rs.Fields("city_key")
    rs.MoveNext
    Wend
    Set cmd = Nothing
    rs.Close
    Set rs = Nothing
    c.Close
    Set c = Nothing
    ***********result get error*************
    please check the code and steps and if u find any error contact me
    thanks any way
    null

    hi every one i got a simple solusion and its faster than dbms_sql package by 1.5 to 3 times...but it works only for oracle 8i or higher......
    after concatenat the string of dynamic sql
    but it in a ref cursor and loop on it
    TYPE VAR_TABLE IS TABLE OF VARCHAR2(40)
    INDEX BY BINARY_INTEGER;
    procedure bound_type
    (v_origin in varchar2,v_flag in varchar2
    ,city_key out var_table )
    is
    str varchar2(1000);
    type curtype is ref cursor;
    sa_cur curtype;
    i integer default 1;
    begin
    str:='select ltrim(rtrim(city_key)) from special_airport ';
    if ltrim(rtrim(upper(v_flag))) = upper('c')
    then
    str:=str | | ' where city_key=ltrim(rtrim(upper('| |''''| |v_origin| |''''| |')))';
    elsif ltrim(rtrim(upper(v_flag))) = upper('a') then
    str:= str | |' where port_key=ltrim(rtrim(upper('| |''''| |v_origin| |''''| |')))';
    end if;
    open sa_cur for str;
    loop
    fetch sa_cur into city_key(i);
    exit when sa_cur%notfound;
    i:=i+1;
    end loop;
    close sa_cur;
    end bound_type;
    null

  • Retrieve the records based on date where date is not stored

    Hi,
    I have one table in Oracle.
    I want to retrieve the records which are added or modified after a particular date & time.(but the table does not contain any column for date & time )
    For example: Product table(pid number,pname varchar2)
    i am entering 10 records on date 21/07/2005
    i am entering 20 records on date 22/07/2005
    i am entering 15 records on date 23/07/2005
    i am entering 30 records on date 24/07/2005
    If i want to retrieve the records added after 22/7/2005
    (ie.) last 45 records
    But the table does not contain any date field.
    How will you know date & time of each record updated in the table.
    If any one knows, help me.
    bye.

    for 9iR2: check out online document of Oracle9i Application Developer's Guide - Fundamentals and search flash back query
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96590/adg08sql.htm#10851
    for 10G, flash back feature is enhenced to whole database level, you can still use flash back query though.

  • Query to retrieve the records which have more than one assignment_id

    Hello,
    I am trying to write a query to retrieve all the records from the table per_all_assignments_f which has more than one different assignment_id for each person_id. Below is the query i have written but this retrieves the records even if a person_id has duplicate assignment_id's but i need records which have more than one assignement_id with no duplicates for each person_id
    select assignment_id ,person_id, assignment_id
    From per_all_assignments_f
    having count(assignment_id) >1
    group by person_id, assignment_id
    Thank You.
    PK

    Maybe something like this?
    select *
    From   per_all_assignments_f f1
    where  exists (select 1
                   from   per_all_assignments_f f2
                   where  f2.person_id = f1.person_id
                   and    f2.assignment_id != f1.assignment_id
                  );Edited by: SomeoneElse on May 7, 2010 2:23 PM
    (you can add a DISTINCT to the outer query if you need to)

  • SQL Query to retrieve the records

    Hi All,
    I have one table. It contains millions of records.I gave the query as follows.
    select * from emp where empnob in (1,1000)
    it displays empnob
    1 A 300000 Manager
    6 B 120000 Analyst
    87 C 32980 salsman
    Now I want to retrieve remaining records. Pelase let me know the query which are not available in emp table between the given limit.
    Thank you.

    Hi ,
    For example there are 10 records only.
    I gave
    select * from emp where empno in (1,10)
    t displays the records having the empnos 1,3,4,6,8
    Now I want to display the records 2,5,7,9,10 also...
    Please let me know the query.Are use using an oracle database? My Oracle database would never return such a result for your query.
    Please post some output from an sqlplus session where you show us exactly what you do.
    Message was edited by:
    Sven W.

  • SQL Plus: retrieve the commands

    11g R2 (11.2.0.3) on Linux. At the SQL Plus prompt such as SQL>, I typed some commands, say, select from test;* Sometime I want to re-use the query, so I need to retype in select from test.* Is there a way to retrieve the earlier issued commands back?
    Also, I can not use the BACK arrow key. Suppose I want to insert or delete a character in the middle of the commandline, how can I move the cursor over the character?
    Thanks

    955300 wrote:
    11g R2 (11.2.0.3) on Linux. At the SQL Plus prompt such as SQL>, I typed some commands, say, select from test;* Sometime I want to re-use the query, so I need to retype in select from test.* Is there a way to retrieve the earlier issued commands back?Yes. The utility is called rlwrap. You use it to run sqlplus. I alias it. So in my +.bash_profile+, I will have the following line:
    alias sqlplus="rlwrap $ORACLE_HOME/sqlplus"It provides full command line recall (inside SQL*Plus) and command line editing.
    There is no rlwrap rpm available for installation AFAIK. I'm downloading the source code and doing a manual build and install for all the server installations I do (I do not use Oracle Linux or RHEL as a desktop o/s - think for my Ubuntu desktop it installed via an <i>apt-get</i>). For a manual source code build, you need to install a couple of development rpm's as I recall, such as the readline lib.

  • SQL to group the records and apply logic to pick one record from each group

    Hi Friends,
    I am looking for a query to group the records on certain columns in a table and then from each group I want to pick only one record based on certain rules.
    May be having data laid out will make my point more clear to you. Here you go :
    CREATE TABLE AD_LIST
      FILE_NAME             VARCHAR2(50 BYTE),
      ACTIVITY_START        DATE,
      ACTIVITY_END          DATE,
      DIVISION              VARCHAR2(50 BYTE),
      ITEM_CODE             VARCHAR2(50 BYTE),
      MULT                  NUMBER,
      RETAIL                NUMBER,
      AD_PAGE               VARCHAR2(1 BYTE),
      FORECAST              NUMBER,
      MEMO                  VARCHAR2(50 BYTE)
    INSERT INTO AD_LIST VALUES ('FILE_1','01-APR-2010','15-APR-2010','B',1111,5,10,'A',10,'This must be in my result');
    INSERT INTO AD_LIST VALUES ('FILE_1','01-APR-2010','15-APR-2010','B',1111,1,1,'B',15,'Must not be in my result');
    INSERT INTO AD_LIST VALUES ('FILE_1','01-APR-2010','15-APR-2010','B',1111,6,15,'C',11,'Must not be in my result');
    INSERT INTO AD_LIST VALUES ('FILE_1','16-APR-2010','30-APR-2010','N',1111,4,20,'D',40,'Must not be in my result');
    INSERT INTO AD_LIST VALUES ('FILE_1','16-APR-2010','30-APR-2010','N',1111,5,15,'E',30,'Must not be in my result');
    INSERT INTO AD_LIST VALUES ('FILE_1','16-APR-2010','30-APR-2010','N',1111,1,2,'F',20,'This must be in my result');
    CREATE TABLE PAGE_RANK
      AD_PAGE VARCHAR2(1 BYTE),
      RANK NUMBER
    INSERT INTO PAGE_RANK VALUES ('A',1);
    INSERT INTO PAGE_RANK VALUES ('B',2);
    INSERT INTO PAGE_RANK VALUES ('C',3);
    INSERT INTO PAGE_RANK VALUES ('D',4);
    INSERT INTO PAGE_RANK VALUES ('E',5);
    INSERT INTO PAGE_RANK VALUES ('F',6);
    COMMIT;
    SELECT * FROM AD_LIST
    FILE     ACTIVITY     ACTIVITY          ITEM               AD
    NAME     START          END          DIV     CODE     MULT     RETAIL     PAGE     FORECAST     MEMO
    FILE_1     4/1/2010     4/15/2010     B     1111     5     10     A     10     This must be in my result
    FILE_1     4/1/2010     4/15/2010     B     1111     1     1     B     15     Must not be in my result
    FILE_1     4/1/2010     4/15/2010     B     1111     6     15     C     11     Must not be in my result
    FILE_1     4/16/2010     4/30/2010     N     1111     4     20     D     40     Must not be in my result
    FILE_1     4/16/2010     4/30/2010     N     1111     5     15     E     30     Must not be in my result
    FILE_1     4/16/2010     4/30/2010     N     1111     1     2     F     20     This must be in my resultNow, from the table AD_LIST I want to group the records based on FILE_NAME, ACTIVITY_START, ACTIVITY_END, DIVISION, ITEM_CODE.
    So in my example here we have 2 set of records grouped based on the columns specified.
    Also we have one more table, PAGE_RANK, which has a rank corresponding to each ad_page number. Here 1 is higher rank than 2. Hence ad page 'A' takes priority over 'B'. Similarly for all other ad pages.
    Now, we need to pick one ad from each group of ads by determining the highest ranked ad page within the group and the value for mult and retail must be replaced with the value that has min(retail/mult). So, using the above data we will have the one having ad page = 'A' and ad page = 'D' as the final results since they have highest ad page rank in their group.
    The value for mult and retail values for ad_page 'A' = min (10/5 , 1/1, 15/6) = 1,1(mult,retail).
    The value for mult and retail values for ad_page 'D' = min (20/4 , 15/5, 2/1) = 1,2(mult,retail).
    Finally I have this query below
    SELECT a.file_name,
           a.activity_start,
           a.activity_end,
           a.division,
           a.item_code,
           FIRST_VALUE (a.mult) OVER (PARTITION BY a.file_name, a.activity_start, a.activity_end, a.division, a.item_code ORDER BY (a.retail /
                                                                                                                                    a.mult))
                                                                                                        mult,
           FIRST_VALUE (a.retail) OVER (PARTITION BY a.file_name, a.activity_start, a.activity_end, a.division, a.item_code ORDER BY (a.retail /
                                                                                                                                      a.mult))
                                                                                                      retail,
           FIRST_VALUE (a.ad_page) OVER (PARTITION BY a.file_name, a.activity_start, a.activity_end, a.division, a.item_code ORDER BY (b.RANK))
                                                                                                     ad_page,
           a.forecast,
           a.memo                                                                                                
      FROM ad_list a, page_rank b
    WHERE a.ad_page = b.ad_pageThis query is giving me all the records but with the values what I wanted in Ad_Page, Mult and Retail columns.
    How can I pick only one from each group.
    I am getting this FILE     ACTIVITY     ACTIVITY          ITEM               AD
    NAME     START          END          DIV     CODE     MULT     RETAIL     PAGE     FORECAST     MEMO
    FILE_1     4/1/2010     4/15/2010     B     1111     1     1     A     15     Must not be in my result
    FILE_1     4/1/2010     4/15/2010     B     1111     1     1     A     10     This must be in my result
    FILE_1     4/1/2010     4/15/2010     B     1111     1     1     A     11     Must not be in my result
    FILE_1     4/16/2010     4/30/2010     N     1111     1     2     D     20     This must be in my result
    FILE_1     4/16/2010     4/30/2010     N     1111     1     2     D     30     Must not be in my result
    FILE_1     4/16/2010     4/30/2010     N     1111     1     2     D     40     Must not be in my resultBut I want this FILE     ACTIVITY     ACTIVITY          ITEM               AD
    NAME     START          END          DIV     CODE     MULT     RETAIL     PAGE     FORECAST     MEMO
    FILE_1     4/1/2010     4/15/2010     B     1111     1     1     A     10     This must be in my result
    FILE_1     4/16/2010     4/30/2010     N     1111     1     2     D     20     This must be in my resultI have to run this query for thousands of such group combination.
    Hope some one can throw some light on this query.
    Thanks in advance,
    Raj.

    Frank,
    You are marvelous.
    That is what I was expecting, but basically I want to display the row with highest page rank which is 'A' and 'D' in this case.
    So I have changed my query as below using yours :
    WITH mainq AS
         (SELECT a.file_name,
                 a.activity_start,
                 a.activity_end,
                 a.division,
                 a.item_code,
                 FIRST_VALUE (a.mult) OVER (PARTITION BY a.file_name, a.activity_start, a.activity_end, a.division, a.item_code ORDER BY (a.retail /
                                                                                                                                          a.mult))
                                                                                                        mult,
                 FIRST_VALUE (a.retail) OVER (PARTITION BY a.file_name, a.activity_start, a.activity_end, a.division, a.item_code ORDER BY (a.retail /
                                                                                                                                            a.mult))
                                                                                                      retail,
                 --FIRST_VALUE (a.ad_page) OVER (PARTITION BY a.file_name, a.activity_start, a.activity_end, a.division, a.item_code ORDER BY (b.RANK))
                 a.ad_page,
                 a.forecast,
                 a.memo,
                 ROW_NUMBER () OVER (PARTITION BY a.file_name, a.activity_start, a.activity_end, a.division, a.item_code ORDER BY b.RANK)
                                                                                                 AS r_num
            FROM ad_list a, page_rank b
           WHERE a.ad_page = b.ad_page)
    SELECT *
      FROM mainq a
    WHERE r_num = 1
    FILE     ACTIVITY     ACTIVITY          ITEM               AD
    NAME     START          END          DIV     CODE     MULT     RETAIL     PAGE     FORECAST     MEMO
    FILE_1     4/1/2010     4/15/2010     B     1111     1     1     A     10     This must be in my result
    FILE_1     4/16/2010     4/30/2010     N     1111     1     2     D     40     Must not be in my resultMy apologies that I gave you wrong forecast and memo values in my earlier post.
    But that is what I wanted and your input greatly helped me to save lot of time by using in one single query.
    Earlier I was using cursor to do that and it was not doing any good performance wise.
    Thanks to every body for your time and your efforts.
    I appreciate it.
    Have fun.
    ~Raj

  • Stored pl/sql procedure retrieving similar records from different tables using

    Hi all I'm trying to retrieve the employee num and employee name if they are both a driver and mechanic
    I'm script my own procedure and it compiles with no issue but when i try to execute it. they will show me this error.
    Error starting at line 29 in command:
    EXECUTE VERIFY(1,'John Smith')
    Error report:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at "CARSON.VERIFY", line 8
    ORA-06512: at line 1
    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
    This is how my procedure look like:
    CREATE OR REPLACE PROCEDURE VERIFY(
    enum IN NUMBER,
    ename IN VARCHAR) IS
    empnum NUMBER;
    empname VARCHAR(50);
    Fail EXCEPTION;
    BEGIN
    select employee.e#, employee.name
    into empnum, empname
    from employee join driver
    on driver.e# = employee.e#
    join mechanic
    on driver.e# = enum;
    EXCEPTION
    WHEN Fail THEN
    dbms_output.put_line('OK');
    END VERIFY;
    and this is how i execute the procedure
    EXECUTE VERIFY(1,'John Smith');
    so may i know what have gone wrong? would be glad if someone is able to enlighten me.

    No need for a loop.
    Just make sure that your query always returns at most one row. Adding a predicate like 'where rownum=1' is a way to achieve that:
    select employee.e#
    ,      employee.name
    into   empnum
    ,      empname
    from   employee join driver on driver.e# = employee.e#
                    join mechanic on driver.e# = enum
    where rownum = 1;

  • BPM - DB Adapter retrieves the record from DB but says modelling error

    We are trying to read a record from a view ( The View is a join of two tables ) . And the join condition is on a column called CUSTID ( whose values is also there ) . Looks like the query is executed and the values are retrieved but we get an exception saying "This exception is considered not retriable, likely due to a modelling mistake. " and "Primary keys must not contain null. ".
    I am doing a transformation after the results are fetched . I am mapping the values directly to a payload xml . Is there any problem ?
    Not sure what the problem is . Please help ! .
    TIA
    Stack Trace :
    Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'QuoteDetailsSelect' failed due to: DBReadInteractionSpec Execute Failed Exception. Query name: [QuoteDetailsSelect], Descriptor name: [QuoteDetails.Quotesummary]. Caused by Exception [EclipseLink-6044] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.QueryException Exception Description: The primary key read from the row [DatabaseRecord( QUOTESUMMARY.CUSTID => 1000 QUOTESUMMARY.GENDER => Female QUOTESUMMARY.FIRSTNAME => Remya QUOTESUMMARY.SURNAME => namboothiri QUOTESUMMARY.TELEPHONE => 9999 QUOTESUMMARY.DOB => 1970-01-01 00:00:00.0 QUOTESUMMARY.EMAIL => [email protected] QUOTESUMMARY.PWD => welcome1 QUOTESUMMARY.SORTCODE => 000 QUOTESUMMARY.ACCOUNTNUMBER => 111 QUOTESUMMARY.ACCOUNTNAME => remya QUOTESUMMARY.DDDATE => 2011-07-13 14:33:37.0 QUOTESUMMARY.MONTHLYBENEFIT => 2000 QUOTESUMMARY.RESIDENCE => Res QUOTESUMMARY.CONTEMPLOYMENT => null QUOTESUMMARY.REDUNDANCIES => null QUOTESUMMARY.EMPLOYMENTSTATUS => permanent QUOTESUMMARY.EMPSTARTDATE => 2011-07-13 14:33:37.0 QUOTESUMMARY.GROSSSAL => 40000 QUOTESUMMARY.BUSINESSTYPE => fulltime QUOTESUMMARY.BUSINESSROLE => manager QUOTESUMMARY.MORTAGE => 111 QUOTESUMMARY.LOAN => 2000 QUOTESUMMARY.CREDITCARDS => xxxx QUOTESUMMARY.USEDTOB_NICO => xxx QUOTESUMMARY.MEDICALCOVERED => yes QUOTESUMMARY.QUOTEID => 2000 QUOTESUMMARY.STATUS => initiated QUOTESUMMARY.AMOUNT => 400000 QUOTESUMMARY.POLICYTYPE => lifestyle QUOTESUMMARY.POLICYSUBTYPE => lf QUOTESUMMARY.MONTHLY_BENEFIT => 200 QUOTESUMMARY.COVERPERIOD => 2 QUOTESUMMARY.WAITPERIOD => 1 QUOTESUMMARY.COVERSTARTDATE => 2011-07-13 14:35:23.0)] during the execution of the query was detected to be null. Primary keys must not contain null. Query: ReadAllQuery(name="QuoteDetailsSelect" referenceClass=Quotesummary sql="SELECT CUSTID, GENDER, FIRSTNAME, SURNAME, TELEPHONE, DOB, EMAIL, PWD, SORTCODE, ACCOUNTNUMBER, ACCOUNTNAME, DDDATE, MONTHLYBENEFIT, RESIDENCE, CONTEMPLOYMENT, REDUNDANCIES, EMPLOYMENTSTATUS, EMPSTARTDATE, GROSSSAL, BUSINESSTYPE, BUSINESSROLE, MORTAGE, LOAN, CREDITCARDS, USEDTOB_NICO, MEDICALCOVERED, QUOTEID, STATUS, AMOUNT, POLICYTYPE, POLICYSUBTYPE, MONTHLY_BENEFIT, COVERPERIOD, WAITPERIOD, COVERSTARTDATE FROM QUOTESUMMARY WHERE QUOTEID = (?)"). See root exception for the specific exception. This exception is considered not retriable, likely due to a modelling mistake. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.
    Edited by: user13123387 on Jul 13, 2011 3:07 AM
    Edited by: user13123387 on Jul 13, 2011 3:31 AM

    I have seen that problem several times. It means you'll have to set your tuning parms. Have a look: http://www.it-eye.nl/weblog/2006/09/18/bpel-tuning-or-why-threads-matter/

  • How to compare two rows in PL/SQL and retrieve the values?

    Hello,
    I have two tables which have identical schemas, one table (tbl_store) is used to hold the latest version, and the other table (tbl_store_audit) holds previous versions. When the latest record is updated, it is inserted into the tbl_store_audit table as a revision, and the updated details are used as the latest record.
    For example: The latest version is held in tbl_store, however the tbl_store_audit may hold 5 records which are the past records used before changes were made - these are seen as revisions.
    I want to be able to compare what has changed between each revision in the tbl_store_audit table. For example: Out of the 10 columns, the change between revision 1 and revision 2 was the size from XL to XXL. The change between revision 3 and revision 4 was the size XS to M and price 4.99 to 10.99, and so on.
    Eventually i will create an APEX report that will show the user the revision number and what was changed from and to.
    I seen in a previous post i need to note my oracle version: Oracle version 10.2.0.4.0

    Hi,
    Like suggested already you should give some sample data and output.
    Maybe you would like to have something like this:
    -- Sample data
    -- Note PK is the primairy key of the source table and rev are the revisions
    with tbl_store_audit as
    select 1 pk, 1 rev , 1 price  , 'XXL' unit_size from dual union all
    select 1 pk, 2 rev , 1 price,   'XL'  unit_size from dual union all
    select 1 pk, 3 rev , 1.4 price, 'XXL' unit_size from dual union all
    select 2 pk, 1 rev , 1.4 price, 'XL'  unit_size from dual union all
    select 2 pk, 2 rev , 1.4 price, 'XL'  unit_size from dual union all
    select 2 pk, 3 rev , 1.4 price, 'XL'  unit_size from dual union all
    select 1 pk, 4 rev , 1 price  , 'XL'  unit_size from dual union all
    select 1 pk, 5 rev , 1 price  , 'XL'  unit_size from dual union all
    select 3 pk, 1 rev , 1.2 price, 'XL'  unit_size from dual union all
    select 3 pk, 2 rev , 1.2 price, 'XXL' unit_size from dual union all
    select 4 pk, 1 rev , 1 price  , 'XL'  unit_size from dual
    -- end of sample data
    ,tbl_store_audit_tmp as
    select
      pk
      ,rev
      ,'PRICE'          field_name
      ,to_char(price)   field_value
      ,to_char(lag(price,1) over (partition by pk order by rev) ) old_field_value
    from
      tbl_store_audit
    union all
    select
      pk
      ,rev
      ,'UNIT_SIZE'           field_name
      ,to_char(UNIT_SIZE)    field_value
      ,to_char(lag(UNIT_SIZE,1) over (partition by pk order by rev) ) old_field_value
    from
      tbl_store_audit
    -- include all other fields from the table here with it's own union all select ...
    select
    from
      tbl_store_audit_tmp
    where
      field_value != old_field_value
    PK REV FIELD_NAME FIELD_VALUE                              OLD_FIELD_VALUE                       
    1   3 PRICE      1.4                                      1                                       
    1   4 PRICE      1                                        1.4                                     
    1   2 UNIT_SIZE  XL                                       XXL                                     
    1   3 UNIT_SIZE  XXL                                      XL                                      
    1   4 UNIT_SIZE  XL                                       XXL                                     
    3   2 UNIT_SIZE  XXL                                      XL                                      
    6 rows selected If you realy want to keep track of all the changes I think it would be better if you make a "after update trigger" on the base table that checks what changed and put that directly in the uadit table.
    Regards,
    Peter
    Edited by: Peter vd Zwan on Aug 16, 2012 8:25 AM

  • SQL to retrieve the specific backuppiece to restore the archivelog/datafile

    Hi,
    Does anybody have any scripts handy to figure out which specific backuppiece to restore if I need to restore a specific archivelog/datafile? i.e.
    1. I am using a controlfile and no rman catalog.
    2. There is a gap in the Standby site and I need to scp multiple backup pieces to DR site to restore the archivelogs and apply them.
    3. I want to query the primary database and find which specific backuppieces I need to scp to restore these files.
    Is there a function/Procedure/Package/Table/View/SQL Query available to figure this out?
    Thanks a lot.

    Thanks Fahd for the reply.
    But my question is a bit different. I know the archilogs that are needed and they have already been backed up by RMAN and deleted in primary. I need to restore them in DR but need to scp only those pieces which are holding the gap logs. I dont want to scp all of the backuppieces, just the ones holding multiple logs that I need to apply.
    Hope it helps. Thanks for your effort though... Appreciated :)

  • How to retrieve the records

    Actually I have three tables.
    Table1
    PID varchar(10) primary key
    EID varchar(10)
    Table2
    PID varchar(10) primary key
    PDESC varchar(30)
    Table3
    PID varchar(10) primary key
    Value varchar(10)
    All the three table PID values will be different. Nothing will be same
    Suppose If i want to retrieve all the PID values by single query from all three tables,
    how can I do it.

    Try like this
    select pid from table1
    union
    select pid from table2
    union
    select pid from table3

  • Oracle 8i SQL - Dealing with no records matching a value

    Warning: before you read this, please understand I'm no expert on SQL, so it's quite likely I screwed something obvious up...
    I'm trying to do a query kind of like the following:
    SELECT
    BOM.COMPONENT, BOM.QTY_PER, BOM.PARENT, BOM2.PARENT_QTY_PER
    FROM
    BOM BOM, BOM BOM2
    WHERE
    BOM2.COMPONENT=BOM.PARENT AND
    BOM.TOP_ASSY='ABC-123'
    (Don't worry about my punctuation, my company only allows me to do [read-only] queries through Excel, so I don't need the semi-colons)
    What I'm doing is pulling information from the bill of materials (BOM) for a particular assembly (BOM.TOP_ASSY). Each assembly has components (BOM.COMPONENT), and each component has a parent part (BOM.PARENT), which it goes into. Each parent part will also have its own parent part, unless the parent part is the assembly for which I'm querying (BOM.TOP_ASSY) - in the example above, the assembly I'm looking for is 'ABC-123'.
    This leads me to my problem. Since I'm looking for the QTY_PER for both the component and the parent, I have to refer to two separate copies of the BOM table. And, since BOM.PARENT could equal BOM.TOP_ASSY, and BOM.TOP_ASSY has no parent, so it can't be a component, so it would never be in the column BOM.COMPONENT. Thus, when I run this query, all components that go directly into the top assembly ('ABC-123') are left off the query.
    Is there any way to retrieve the records for the components that go directly into the top assembly, and just make BOM2.PARENT_QTY_PER equal to 0? Basically, I only want BOM2.PARENT_QTY_PER to equal something if the parent is also a component, but 0 if it's the top assembly.
    Using NVL doesn't help, and since I'm stuck with an Oracle 8i database to query, I can't use CASE...WHEN either (though, I don't even know if this is possible with a case statement or not)...
    I don't even know if this is possible, but could someone let me know one way or the other?
    Thanks so much!

    Hi,
    user11033437 wrote:
    The whole example with the BOM and BOM2 tables were just an example of what I'm actually doing. What I'm actually doing is much more complex, and since it's all in VBA code, it was much easier for me to make up a simple example then to actually get my SQL out of VBA That's an excellent approach! I suggest you continue with it. Make sure the tiny test situation works as posted, and then, when it does work perfectly, make it a little more like your real case (say, add just one more condition in the WHERE clause), and test again.
    (which looks like this:
    strSQL = "SELECT "
    strSQL = strSQL & "C_BOM.BILL_LEVEL, "
    strSQL = strSQL & "C_BOM.COMP_PART_NBR, "
    strSQL = strSQL & "C_PART.PART_DESC, " )
    But, in the interest of getting my query to work, and hopefully learning a few things in the process, I've extracted my actual SQL, and pasted it below:
    SELECT
         C_BOM.BILL_LEVEL,
         C_BOM.COMP_PART_NBR,
         C_PART.PART_DESC,
         C_PART.PART_TYPE,
         C_BOM.QTY_PER,
         C_BOM.BOM_UM,
         C_BOM.BOM_DOC_NBR,
         C_BOM.OPER_NBR,
         C_BILL.COMP_OFF_ADJ,
         C_PART.QTY_ON_HAND,
         P_PART.QTY_ON_HAND,
         NVL(P_BOM.QTY_PER,0)
    FROM
         PART C_PART,
         PART P_PART,
         BILL C_BILL,
         V087_BOM C_BOM,
         V087_BOM P_BOM
    WHERE
         C_PART.PART_NBR=C_BOM.COMP_PART_NBR AND
         P_PART.PART_NBR=C_BOM.BOM_DOC_NBR AND  --fixed a typo here from extracting from vba
         P_BOM.COMP_PART_NBR (+) = C_BOM.BOM_DOC_NBR AND
         C_BILL.COMP_PART_NBR=C_BOM.COMP_PART_NBR AND 
         C_BILL.BOM_DOC_NBR = C_BOM.BOM_DOC_NBR AND
         ((C_BOM.STATUS = 'RL') AND
         (C_BOM.PART_NBR= 'ABC-123') AND
         (C_BOM.END_EFF_DT>sysdate) AND
         (C_BOM.BEGN_EFF_DT<=sysdate) AND
         (C_BOM.VIEW_CODE<>'E') AND
         (P_BOM.STATUS = 'RL') AND
         (P_BOM.PART_NBR= 'ABC-123') AND
         (P_BOM.END_EFF_DT>sysdate) AND
         (P_BOM.BEGN_EFF_DT<=sysdate) AND
         (P_BOM.VIEW_CODE <> 'E') AND
         (C_BILL.VIEW_CODE <> 'E') AND     <--for some reason my <> is being parsed out here
         (C_BILL.QTY_PER_TYPE <> 0) AND  <--for some reason my <> is being parsed out here
         (C_BILL.END_EFF_DT>sysdate) AND
         (C_BILL.BEGN_EFF_DT<=sysdate))
    ORDER BY
         C_BOM.BILL_LEVEL, C_BOM.BOM_DOC_NBRPART is the table with the information associated with each part in the system
    BILL is the table with the bill of materials for each assembly in the system
    V087_BOM is a view that I didn't create, but seems to compile the full bill of materials (from the BILL table) for a top-level assembly (so, the BOM for that part, and for all of it's sub-assemblies, and all of their sub-assemblies, etc.)
    Does that give a clearer picture of what I'm trying to accomplish?
    Edited by: user11033437 on Apr 15, 2009 10:07 AM
    Fixed a typo where indicated (P_PART_NBR changed to P_PART.PART_NBR)I see where you made the join condition between p_bom and c_bom an outer join:
    P_BOM.COMP_PART_NBR (+) = C_BOM.BOM_DOC_NBRThat says: "join the tables like this if possible, but if there's no match, then pretend there was a match in the table marked with the + sign". The resuolting joined row will have bom_doc_nbr (and all the other columns from c_bom), but comp_part_nbr (and all the other columns from p_bom) will be NULL.
    One of those columns is status. Your WHERE clause includes the condition:
    (P_BOM.STATUS = 'RL')Since all columns from p_bom are NULL in this case, the condition above will fail, even though the first condition succeeded.
    You have to add a + to all the conditions in this query that refer to p_bom, including
    ...     (P_BOM.STATUS (+)      = 'RL')      AND
         (P_BOM.PART_NBR (+)    = 'ABC-123') AND
         (P_BOM.END_EFF_DT (+)  > sysdate)   AND If you want to include rows that have no match in the p_part table, you'll have to make all of its conditions outer-joins, too:
         P_PART.PART_NBR (+) = C_BOM.BOM_DOC_NBRIsn't that annoying about the &lt;&gt; operator? This site treats it as some kind of markup, even inside &#123;code&#125; tags. I'm surprised any of them showed up. Thanks for flagging them with comments.
    There's no problem with the other inequality operator, !=. You can use that when you post to this site.

  • Using PL/SQL to retrieve column names and column values

    If I have a table as follows
    Table A(
    meal varchar2(32),
    beverage varchar2(32),
    desert varchar2(32));
    and the table contains a row
    meal beverage desert
    pork chops iced tea apple crisp
    Is there a way in pl/sql to retrieve the column names along with the values. I have an object type
    DATA_DEFINITION_T AS OBJECT (
              "FIELD_NAME"          VARCHAR2(32),
              "FIELD_VALUE" VARCHAR2(32)
    I need to store the column name in field_name and the column value in field_value.
    So the result would be:
    FIELD_NAME = meal
    FIELD_VALUE = pork_chops
    FIELD_NAME = beverage
    FIELD_VALUE = iced tea
    FIELD_NAME = desert
    FIELD_VALUE = apple crisp
    Thanks in advance.

    Hi,
    try this procedure ....just create it and give the table name..the object M_DATA_TAB has the required data
    procedure l_fill_data_dict(p_table_name varchar2) is
    connection_id EXEC_SQL.CONNTYPE;
    bIsConnected BOOLEAN;
    cursorID EXEC_SQL.CURSTYPE;
    nIgn PLS_INTEGER;
    m_val VARCHAR2(40);
    m_col_name varchar2(40);
    m_col_val varchar2(240);
    m_cnt number;
    m_id number := 0;
    m_incr number := 0;
    p_sqlstr varchar2(4000);
    p_sql_cnt varchar2(4000) ;
    p_org_sql varchar2(4000);
    TYPE DATA_DEFINITION_TABS IS RECORD (
    FIELD_NAME VARCHAR2(32),
    FIELD_VALUE VARCHAR2(240));
    TYPE DATA_DEFINITION_TAB IS TABLE OF DATA_DEFINITION_TABS;
    M_DATA_TAB DATA_DEFINITION_TAB := DATA_DEFINITION_TAB();
    --m_file text_io.file_type;
    Begin
    --     m_file := text_io.fopen('c:\eg.txt','w');
         --Set default connection
    connection_id := EXEC_SQL.DEFAULT_CONNECTION;
    bIsConnected := EXEC_SQL.IS_CONNECTED;
    IF bIsConnected = FALSE THEN
         message('Connection Failed');
    RETURN;
    END IF;
    --Find the total no.of columns in the given table
    p_sql_cnt := 'Select COUNT(column_name) from user_tab_columns where table_name='''||p_table_name||''' order by column_id';
    cursorID := EXEC_SQL.OPEN_CURSOR;
    EXEC_SQL.PARSE(cursorID, p_sql_cnt, exec_sql.V7);
    EXEC_SQL.DEFINE_COLUMN(cursorID, 1, m_val,40);
    nIgn := EXEC_SQL.EXECUTE(cursorID);
    IF (EXEC_SQL.FETCH_ROWS(cursorID) > 0) THEN
         EXEC_SQL.COLUMN_VALUE(cursorID, 1, m_val);
    end if;
    EXEC_SQL.CLOSE_CURSOR(cursorID);
    --EXEC_SQL.CLOSE_CONNECTION;
    m_cnt := m_val;---column count
    ---get the column names from the user_Tab_columns and fetch the values from the given table for that column...
    For i in 1..m_cnt loop
         m_id := m_id+1;
    p_sqlstr := 'Select column_name from user_tab_columns where table_name='''||p_table_name||''' and column_id ='||m_id||' order by column_id';
    cursorID := EXEC_SQL.OPEN_CURSOR;
    EXEC_SQL.PARSE(cursorID, p_sqlstr, exec_sql.V7);
    EXEC_SQL.DEFINE_COLUMN(cursorID, 1, m_col_name,40);
    nIgn := EXEC_SQL.EXECUTE(cursorID);
    IF (EXEC_SQL.FETCH_ROWS(cursorID) > 0) THEN
         EXEC_SQL.COLUMN_VALUE(cursorID, 1, m_col_name);
    end if;
    EXEC_SQL.CLOSE_CURSOR(cursorID);
    --fetch the column value from the given table
         p_org_sql := 'select DISTINCT '||m_col_name||' from '||p_table_name;
         cursorID := EXEC_SQL.OPEN_CURSOR;
    EXEC_SQL.PARSE(cursorID, p_org_sql, exec_sql.V7);
    EXEC_SQL.DEFINE_COLUMN(cursorID, 1, m_col_val,240);
         nIgn := EXEC_SQL.EXECUTE(cursorID);
         Loop      
         nIgn := EXEC_SQL.FETCH_ROWS(cursorID);
              IF (nIgn > 0) THEN
                   EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 1, m_col_val);
    M_DATA_TAB.extend();
                   M_DATA_TAB(M_DATA_TAB.last).field_name := m_col_name;
                   M_DATA_TAB(M_DATA_TAB.last).FIELD_VALUE := m_col_val;
                   m_incr := m_incr+1;
                   -- text_io.put_line(m_file,m_col_name||'##'||m_col_val);
              else
                   exit;
              End if;
         End loop;--loop of records in the table for the given column
    EXEC_SQL.CLOSE_CURSOR(cursorID);
    End loop; ---loop of columns in the table
    --text_io.fclose(m_file);
    message('Total no. of items in the object='||m_incr);
    EXEC_SQL.CLOSE_CONNECTION;
    EXCEPTION
    When EXEC_SQL.Invalid_Connection then
         message('invalid connection');
         when EXEC_SQL.Package_Error     then
         message('pkg err');
         when EXEC_SQL.Invalid_Column_Number          then
         message('invalid col num defined');
         when others then
              MESSAGE(SQLERRM);
    End;
    Regards
    Dora
    Edited by: Dora on Sep 27, 2009 3:13 PM

  • SQL Loader and the bad file

    I use SQL Loader to read a file into a table. In my tests a lot of rows are rejected and written to the bad file. But there are no error messages.
    Is there a way to find out why the row was rejected.

    The Bad File
    The bad file contains records that were rejected, either by SQL*Loader or by the Oracle database server. Some of the possible reasons for rejection are discussed in the next sections.
    SQL*Loader Rejects
    Datafile records are rejected by SQL*Loader when the input format is invalid. For example, if the second enclosure delimiter is missing, or if a delimited field exceeds its maximum length, SQL*Loader rejects the record. Rejected records are placed in the bad file.
    Oracle Rejects
    After a datafile record is accepted for processing by SQL*Loader, it is sent to the Oracle database server for insertion into a table as a row. If the Oracle database server determines that the row is valid, then the row is inserted into the table. If the row is determined to be invalid, then the record is rejected and SQL*Loader puts it in the bad file. The row may be invalid, for example, because a key is not unique, because a required field is null, or because the field contains invalid data for the Oracle datatype.
    YOU WILL get more information
    sqlldr help=y
    also send your control file syntax
    kuljeet pal singh

Maybe you are looking for

  • How can I find the latest added contacts?

    Hi, I'm syncing my Address Book with my Nokia 6233, and it works fine. However, the 6233 has limited contacts memory (500 entries), so I had to create a special group within Address Book which is the one synced to the phone. Problem is, whenever I ad

  • InDesign CS4 won't open at all!   I'm doomed!

    What happened? I've been using InDesign CS4 (bought the master collection) since March on my brand new MacBook Pro (2.93GHz Intel Core 2 Duo 4 GB 1067 Mhz DDR3) just fine...the other adobe updater ran and now..nothing. I click on the app and nothing

  • Trying to get Home Sharing to work

    Hi all, So I've turned on Home Sharing on my MacBook Pro. I loaded iTunes on my daughter's Dell laptop and turned on Home Sharing. I want to transfer some of my music library to her computer. iTunes on my MBP properly shows the existence of her (I su

  • How to measure disk IO....

    Hi there, my aim is to measure the overall disk-IO of my unix-server to identify a potential hardware bottleneck. One method is to call "sar -d", then sum up all the disks io. The other method is to look into v$sysstat and sum up "physical reads" and

  • Portal SLD configuration

    Hi experts, I must do SLD configuration of portal to define technical system for ECC system. On configuration i must select porduct and software component for ECC system. Is there a blog how to configure portal SLD? Thanks.