How to treat data in a long query

I have a query (over a table connected by dblink) that returns me a lot of rows (over 7 millions), when I try to got data at each row i got an out of memory problem. So I want to view records in legs, but i don't know how to do that in my procedure.
The query is asigned to a cursor and I pass the data I need of each row to another table.
This is the code I have:
CURSOR r_cursor
IS
SELECT *
FROM med_principio_activo@midblink
cursor1 r_cursor%ROWTYPE;
begin
LOOP
FETCH r_cursor
INTO cursor1;
EXIT WHEN r_cursor%NOTFOUND;
SELECT MAX(SID)
INTO medic
FROM medicam
WHERE cursor1.codmedic LIKE xkey;
SELECT MAX(SID)
INTO ppioact
FROM activeingredient
WHERE cursor1.codppioact LIKE xkey;
INSERT INTO med_medicamentai
(medicament, activeingredient
VALUES (medic, ppioact
COMMIT;
END LOOP;
I want to do legs of 10000 records to read all info and got memory free, but i don't know how to do that...
Thnaks,

Hi,
instead of using PL/SQL using cursor you could have insert directly in the table,
like
INSERT INTO med_medicamentai
(medicament, activeingredient
VALUES (
Before that we need to know how the data in med_principio_activo@midblink
,medicam and activeingredient are related.
If you want to use cursor, then bulk collect will improve the performance.
Please look at this link for more info.
http://download.oracle.com/docs/cd/B14117_01/appdev.101/b10807/12_tune.htm#i49139
Thanks

Similar Messages

  • How to compare dates in a select query in open sql

    Hi
                       How can I retrieve data pertaining to a specified date using a select query.
    I have inserted date using the following code:
    String dateString = "2009-03-11";
    java.sql.Date date = java.sql.Date.valueOf(dateString);
    PreparedStatement stmt =con.prepareStatement("insert into DATEACCESS"
                                                                            + "(DATETEST)"
                                                                            + "values (?)");
    stmt.setDate(1,date);
    stmt.executeUpdate();
    How can I pass this in a select query,the below mentioned query did not fetch me any results.
    Select * from  DATEACCESS where DATETEST='2009-03-11'

    Hi
    Has ur date  problem resolved  ?
    If not resolved u can do the following
    As u already have sql date today declared . You want to get the data depending on that date
    As ur query is
    if( today != null)
    String query2 = select * from DATEACCESS where DATETEST<= ?
    PreparedStatement ps = conn.prepareStatement(query2);
    ps.setDate(1,today)
    ResultSet rs = ps.executeQuery();
    While(rs.next)
        ////// Here u will get data from query u needed ///
    If this also does not work just print the date and check in which format is it returning u .
    Regards
    Anuradha Rao
    Edited by: Anuradha Rao on Mar 20, 2009 10:16 AM

  • How to store data from a complex query and only fresh hourly or daily?

    We have a report which runs quite slow (1-2 minutes) because the query is quite complicate, so we would like to run this query daily only and store in a table so for those procedures that need to use this complex query as a subquery, can just join to this table directly to get results.
    However, I am not sure what kind of object I should use to store data for this complex query. Is data in global temp table only persist within transaction? I need something that can persist the data and be access by procedures.
    Any suggestions are welcome,
    Cheers

    Thank you for your reply. I looked at the materialized view earlier on, but have some difficulties to use it. So I have some questions here:
    1.The complex query is not a sum or aggregate functions, it just need to get data from different tables based on different conditions, in this case is it still appropriate to use meterialized view?
    2.If it is, I created one, but how to use it in my procedure? From the articles I read, it seems I can't just query from this view directly. So do I need to keep the complex query in my procedure and how the procedure will use the meterialized view instead?
    3. I also put the complex query in a normal view, then create a materialized view for this normal view (I expect the data from the complex query will be cache here), then in the procedure I just select * from my_NormalView, but it takes the same time to run even when I set the QUERY_REWRITE_ENABLED to true in the alter session. So I am not sure what else I need to do to make sure the procedure use the materialized view instead of the normal view. Can I query from the Materialized View directly?
    Below in the code I copied from one of the article to create the materialized view based on my normal view:
    CREATE MATERIALIZED VIEW HK3ControlDB.MW_RIRating
    PCTFREE 5 PCTUSED 60
    TABLESPACE "USERS"
    STORAGE (INITIAL 50K NEXT 50K)
    USING INDEX STORAGE (INITIAL 25K NEXT 25K)
    REFRESH START WITH ROUND(SYSDATE + 1) + 11/24
    NEXT NEXT_DAY(TRUNC(SYSDATE), 'MONDAY') + 15/24
    enable query rewrite
    AS SELECT * FROM HK3ControlDB.VW_RIRating;
    Cheers

  • How to select data in a LONG datatype

    Hello friends....
    We actually store some texts in a long column datatype, but we're facing the need of search this columns some specifics words. I tryed to select but it says me SQL was wiaintg for the NUMBER dt and got LONG.
    How can I search and select some words through this columns...
    Appreciated...

    SORRY SATYAKI...
    SQL> DESC CORREIO
    Nome Nulo? Tipo
    CHAVE NOT NULL NUMBER
    CHAVE_REMETENTE NOT NULL NUMBER
    NOME_REMETENTE NOT NULL VARCHAR2(50)
    CHAVE_DESTINATARIO NOT NULL NUMBER
    NOME_DESTINATARIO NOT NULL VARCHAR2(50)
    LOG_ENVIO NOT NULL DATE
    MENSAGEM LONG
    LIDA NOT NULL VARCHAR2(3)
    EXCLUIR NOT NULL VARCHAR2(3)
    STATUS NOT NULL VARCHAR2(20)
    ASSUNTO VARCHAR2(50)
    ENVIAR_PALM NOT NULL VARCHAR2(3)
    CHAVE_DEST_COPIA NUMBER
    NOME_DEST_COPIA VARCHAR2(50)
    COPIA VARCHAR2(3)
    CHAVE_TIPO_MENSAGEM NUMBER
    I' running Oracle 10gR2 in a MS Windows 2003 server .
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Here are some parameters to consider..
    PARAMETER VALUE
    NLS_LANGUAGE BRAZILIAN PORTUGUESE
    NLS_TERRITORY BRAZIL
    NLS_CURRENCY Cr$
    NLS_ISO_CURRENCY BRAZIL
    NLS_NUMERIC_CHARACTERS ,.
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD/MM/RR
    NLS_DATE_LANGUAGE BRAZILIAN PORTUGUESE
    NLS_CHARACTERSET WE8MSWIN1252
    NLS_SORT WEST_EUROPEAN
    NLS_TIME_FORMAT HH24:MI:SSXFF
    PARAMETER VALUE
    NLS_TIMESTAMP_FORMAT DD/MM/RR HH24:MI:SSXFF
    NLS_TIME_TZ_FORMAT HH24:MI:SSXFF TZR
    NLS_TIMESTAMP_TZ_FORMAT DD/MM/RR HH24:MI:SSXFF TZR
    NLS_DUAL_CURRENCY Cr$
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_COMP BINARY
    NLS_LENGTH_SEMANTICS BYTE
    NLS_NCHAR_CONV_EXCP FALSE
    SQL> select * from correio
    2 where mensagem like '%teste%'
    3 ;
    where mensagem like '%teste%'
    ERRO na linha 2:
    ORA-00932:inconsistent datatypes: waited NUMBER got LONG

  • How to copy data from a Input query to real time Infocube

    Hi All, I need some help on IP related stuff. The details are as below:
    I am using two real time infocubes and one Multiprovider on them.
    First Infocube u2018PRODUCTu2019  with the following Objects:
    Product Group ,Product,Region ,Fiscal Year , Fiscal Year Varient ,0currency
    Gross Sales
    Second Infocube u2018C_PRODUCT u2018 with the following Objects:
    Product Group ,Product,Region ,Fiscal Year , Fiscal Year Varient ,0currency
    Gross Sales and Forecast Sales
    ( u2018Forecast Salesu2019 in the extra object in the second Infocube. Remaining objects are same in the both the cubes)
    First Infocube  u2018Productu2019 has data but the second cube does not have any data.
    I have created a Multiprovider ZMulti and in that I have included these two cubes. On this Multi Provider, I have created a Aggrigation Level(The details of the aggregation level is provided in the next page).
    On this Aggrigation level  I have built a Input Query by which I run the report.
    (In the Rows area, I have taken Product Group, Product, Region and Fical year.
    In the Key Figure section, I have taken Gross Sales and Forecast Sales( which is part of the second Infocube C_Product). These two Key Figures are made Input as Input ready. And the Query is Input ready query. In the Filter, I have taken Fiscal Year Variant. )
    Data available in the first cube and no data currently in the second cube. Now executed the report and report displayed information from the first cube.
    EX:
    Product     Product     Region          Year     Gross Sales     Forecast Sales
    Group
    PG01           Beer           North           2008            10000           u2026u2026u2026
    PG01           Beer          South          2008          20000           u2026u2026u2026
    PG01          Beer          East          2008          15000           u2026u2026u2026
    The second column is empty and there is no data for the Forecast sales Key Figure in the column.
    Things look OK till the above.
    Now based on the Gross Sales, I am entering  forecast Sales values and I need to save the entire record to the second cube.
    For this in the report, I have given the Forecast sales values in the second column and right clicked the mouse and form the menu which I got, selected the u2018SAVEu2019 Option to save the data. For some time, I can see u2018Processingu2019 message and later values at u2018Forecast Salesu2019 are disappearing.
    Data is not saving to the cube second cube.
    ====================================================
    Am I missing any thing?
    In the Query, Do I need to provide InfoProvider and restrict it to specific value?
    In the query, Do I need to include, 0currency object?
    Could you please guide me on this?
    =============================================
    Details of the Aggrigation level.
                I have created an Aggrigation Level ZAL_Prod  on MultiProvider.
                Selected all the objects and activated.
                In the Filter, I have taken 0Fiscal Year Variant  and saved it.

    Restrict Forecast sales to the Plan cube in the Query.
    that should fix it.

  • How to update data in third SQL query type report (M-D are first two!)

    I have page made through M-D Form wizzard.
    Third report (let's call it detail2) shows same fields as detail grid but some fields are "Standard Report column"-not editable as records in detail1 report. WHERE part in both detail reports are opposite. So together details reports show the whole set of detail records but they never show twice the same detail record (they are mutually exclusive).
    In detail2 I allow just update on one field "NAME".
    I cannot use MRU process-I think it is impossible on such a pages-at least I cannot make it work.
    So I tried different approach creating report like:
    select
      htmldb_item.hidden(3,ID) IDH,
      htmldb_item.text(4,NAZIV,78) "SADRZAJ"
    from "#OWNER#"."MYTABLE"
    where "QUESTION_ID" = :P13_ID AND "....mutual condion..."<br>Executing "for i in 1..htmldb_application.g_f04.count loop " I can retrieve values of "Naziv" field-this is not a problem!
    But it seems that "ID" from detail2 report is not easy to retrieve....Looks like that first detail is somehow involved!
    <br>I tried some things and what I get for now is following. If I execute process like:
    for i in 1..htmldb_application.g_f01.count loopI get following result (each row is record):
      2-<input type="hidden" name="f03" value="137" />
      1-<input type="hidden" name="f03" value="734" />, "1" and "2" are ordinal numbers of rows where ID's are "137" and "734". This looks promising but far away from easy referencing!
    <br>So my question is: How to retrive those values from output like shown above?? Any other hint is welcome!!
    THX!
    <br>P.S.
    <br>One straight question:
    <br>IS THERE ANY DEMO FOR MASTER-DETAIL FORM WITH THIRD REPORT ON IT??
    <br>
    <br>P.S. II
    Collection is probably not a solution because I do not want to update field on other page (like shown in Collection example on Emp table)...

    Okay, I understand now.
    Using Firefox or doing a View Source, you should be able to find out what the last fXX number is, and when coding your 3rd detail form, start like 10 digits higher, i.e., if the last fXX number is f23, I'd start with probably htmldb_item.text(35....). This approach should work, but I have never tried it.
    To me, the basic functionality from the M-D wizard is nice, but adding a third report complicates things enough that I'd probably manually code both the 2nd and 3rd reports. would mean more work with the validations and processes, but I think for this situation it would be more flexible, allowing you greater control. For your manually created detail reports (I'd do both manually), I would skip some numbers between the first and second reports, i.e. first detail report uses htmldb_item.xxxx(1......) through htmldb_item.xxxx(9.....) and then I would start the next detail report as htmldb_itemxxxx.(20....).
    Regarding your example, to 'retrieve' the values of the ID column (htmldb_item.hidden(3,ID)), you should be able to get it through the loop process you described above, htmldb_application.g_f03(i).
    Like:
    for i in 1..htmldb_application.g_f02.count
    loop
    if htmldb_application.g_f03(i) is not null AND htmldb_application.g_f04(i) is not null then
    -- do whatever processing you want to do, insert, updates, etc.
    end if;
    end loop;
    Whatever number you use in the htmldb_item specification is also how yuo refer to it in htmldb_application:
    htmldb_item.XXXX(1....) = htmldb_application.g_f01
    htmldb_item.XXXX(3....) = htmldb_application.g_f03
    etc.
    Use the looping mechanism to (I used (i) in my example above) to go through each row and retrieve that row's value.
    Sorry if any of the above is already familar to you. Judging by what posts I remember of your's, it seems that some of this you already know, but I guess it's better than assuming you do and leaving some stuff out that you didn't know.
    Hope this helps.
    Bill Ferguson

  • How to present results from a sql-query in java

    Hi - I'm having problems finding out how to present data from a database-query in a nice looking way in a JFrame. Want to present them similar to the way they are presented in the database. Is there an easy way doing this?

    Tried to use a JTable, but it's difficult when data in the table should be able to change all the time, i.e the number of rows. What is a Html-table? Can i use it in an application?

  • How to get GML data in LAT/LONG format rather than LONG/LAT format

    I want to generate GML from my spatial data but sdo_util.to_Gmlgeometry extracts data in LONG/LAT format where as I need it in LAT/LONG format.
    Is there an easy way to extract data in LAT/LONG format otehr than parsing the gml and then switching the Lat and long.

    Hi,
    I think it would have to do how you store your geometries, you might need a transformation before, notice the srsName from the resulting query:
    SELECT TO_CHAR(SDO_UTIL.TO_GMLGEOMETRY(MDSYS.SDO_GEOMETRY(2001, 8307, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1), MDSYS.SDO_ORDINATE_ARRAY(170.5,-43.5))))
    from dual
    -- Result:
    <gml:Point srsName="SDO:8307" xmlns:gml="http://www.opengis.net/gml"><gml:coordinates decimal="." cs="," ts=" ">170.5,-43.5 </gml:coordinates></gml:Point>
    So without a transformation I would say it would be hard to get:
    http://trac.osgeo.org/gdal/wiki/rfc20_srs_axes
    If I come across a simple solution (without some fancy manipulation of the ordinates on a custom function/package) I will post it.
    Cheers

  • How to load data from a query?

    Hi all,
    I'm not very familiar with ODI, but we already use it to load table (to Hyperion Planning).
    Now, we need to execute a query (I don't want only to apply filter), that cross differents table, to load it. We can't create view in the datawarehouse.
    How can I do this? What is your recommendation?
    Thanks for your help

    Yes, this is possible.
    Start with a single query that returns you the data for all lecturers.
    Right-click on the "all lecturers" query in the queries pane, and choose Reference, once for each lecturer. This will create a query for each lecturer.
    Open the query for each lecturer and filter the data so that only that lecturer's results are visible.
    Click "Close & Load To..." for each lecturer's query  to load the data into the data model. This will create a data model table for each lecturer.
    If your question is more about how to transform such a survey list into a table that can be easily filtered, please provide an example of how the list shows up in Power Query.
    Ehren

  • HT201274 iPhone 4s, but wifi option is greyed out. I want to erase all content and setting from my old 4s and it will not connect to the internet, because the cellular data is no longer connected, bought a iPhone 5c. how do I erase all on my 4s with no in

    I have an iPhone 4s, but wifi the option is greyed out. The wifi stopped working on it months ago. Now I wanted to erase all content and setting from my old 4s and it will not connect to the internet, because the cellular data is no longer connected, since I bought a new iPhone 5c. I can't erase my phone by pluggin it into my Macbook Pro, since I can't disable the "Find my iPhone" App without internet. How do I erase all the data and setting on my 4s without connecting to the internet? It is running ios 7

    See this https://answers.yahoo.com/question/index?qid=20131119125513AAtRloc
    I just did it. To enter DFU mode, I had to use "method 3" on this post
    http://thebigboss.org/guides-iphone-ipod-ipad/dfu-mode
    Too bad my 4S is 2 years old. Wifi is dead. I had to upgrade to 5S, but 5S is soooooo much faster than 4S so it's kind of good outcome. Without the 4S breaking down, a stingy person like me would have never upgraded the phone.

  • How to apply Date condition for each month in 12 month period to my SQL query

    I am trying to retrieve all Outstanding Problem tickets in my Trendline SSRS report.
    I need to pull the OpenDate <= Last day of last month And CloseDate >= 1st day of current month
    for each month in the Last 12 months. How do I accomplish this in my query?
    I must also need to pull the oustanding tickets for the next 11 months in the same query
    where it will automatically pull the outstanding tickets for when a new month comes
    in out of the 12 month period?
    Here's a sample of my query to pull July 2013 Outstanding Problem tickets:
    Select OpenDate, CloseDate, Ref_Num, Type, status
    From Call_Req
    Where OpenDate <= '2013-07-31 00:00:00' And CloseDate >= '2013-08-01 00:00:00'
    And Type = 'P'
    My Results:
    OpenDate
    CloseDate
    Ref_Num
    Type
    status
    6/13/2013 7:41
    8/26/2013 12:41
    P1726456FY13
    P
    CL
    6/13/2013 8:17
    8/23/2013 12:31
    P1726612FY13
    P
    CL
    6/13/2013 10:17
    9/6/2013 16:54
    P1727352FY13
    P
    CL
    7/12/2013 10:46
    9/6/2013 10:23
    P1812568FY13
    P
    CL
    7/18/2013 10:17
    9/6/2013 8:53
    P1830452FY13
    P
    CL
    7/29/2013 15:54
    9/6/2013 16:16
    P1862906FY13
    P
    CL
    5/17/2013 20:51
    8/22/2013 9:09
    P1653380FY13
    P
    CL
    5/30/2013 13:29
    8/26/2013 7:33
    P1685693FY13
    P
    CL
    7/15/2013 14:14
    9/7/2013 9:42
    P1818874FY13
    P
    CL
    6/7/2013 15:49
    9/6/2013 16:46
    P1712265FY13
    P
    CL
    7/18/2013 10:25
    9/7/2013 9:18
    P1830516FY13
    P
    CL
    7/24/2013 16:30
    8/12/2013 18:26
    P1849909FY13
    P
    CL
    Talitha Davis

    Would this Work?
    DECLARE @now DATE = GETDATE();
    WITH months(lvl, daydate)
    AS (
    SELECT
    1,
    @now
    UNION ALL
    SELECT
    lvl + 1,
    DATEADD(MONTH, -1, daydate)
    FROM months
    WHERE lvl < 12
    ), dateranges(period, opendate, closedate)
    AS (
    SELECT
    CAST(YEAR(daydate) AS CHAR(4))
    + '-'
    + RIGHT('0' + CAST(MONTH(daydate) AS varCHAR(2)), 2),
    DATEADD(DAY, 0-DAY(daydate), daydate),
    DATEADD(DAY, 1-DAY(daydate), daydate)
    FROM months
    SELECT
    b.period,
    a.OpenDate,
    a.CloseDate,
    a.Ref_Num,
    a.Type,
    a.status
    From Call_Req a
    INNER JOIN dateranges b
    ON
    a.OpenDate <= b.opendate
    AND
    a.CloseDate >= b.closedate
    WHERE Type = 'P';
    Microsoft Certified Trainer & MVP on SQL Server
    Please "Propose as Answer" if you got an answer on your question, and vote for it as helpful to help other user's find a solution on a similar question quicker.

  • How to insert date into ms access database using sql query in servlet

    sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
    insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
    or either the system date is inserted with query .
      plz help me
    thanx                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    bhavishya wrote:
    sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
    insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
    or either the system date is inserted with query .
    plz help me
    thanxAnd that SQL statement is another reason to use PreparedStatement. I assume bname and sname are input from some form? Well, if that's the case, simply inserting them into SQL by simple String concatenation is just begging for all sorts of problems. What if there is an apostrophe in the entry? Broken Statement. Worse, it's a wide open invitation to an SQL Injection attack.

  • Formscentral - how do I change required date format to long date (e.g. January 2, 2014) in a form field?

    Formscentral - how do I change required date format to long date (e.g. January 2, 2014) in a form field?  I can't seem to change it from the short date format.

    Hi,
    I would suggest you to change the form language to English (UK), Here are the steps:-
    1. Open your form in FormsCentral
    2. Clik on Options tab
    3. Click on Language and Formatting and check out the selection for Form Language and make sure English (U.K.) is selected and the default date format should be day/month/year.
    Regards,
    Nakul

  • How to write data from query into Real time cube?

    Hi All,
    Can anyone explain me step by step how to write data into a real time cube from front end queries.
    Thanks in advance

    Hi
    You can do this using Integrated Planning
    You need to create a aggregation level on the Real Time infocube and can create Planning function/sequence, Variables if needed.
    Then you can create query on this aggregation level and you can make the keyfigures Input ready in property pane and you can change the data and save it into cube.
    Please find below help link which clearly explains step by step about Integrated Planning like creating input ready queries etc.,
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/43/0c033316cd2bc4e10000000a114cbd/frameset.htm
    Regards
    Ravi

  • How to Convert Data type from CLOB to  LONG

    Hi all
    We changed one Long Data type column to CLOB
    We need to revert back to Long Data type,
    we changed the Data type from Long to CLOB
    Can we change back to Long Again
    we use oracle 10g Rel 2 on Hp-Unix
    thanks all in Advance
    Edited by: jrDba - atm on Apr 6, 2009 4:45 AM

    Hi Satish
    thanks a alot for the Info'
    Can you please provide the
    Notes MOS note 437021.1 for this purpose
    thanks a lot

Maybe you are looking for

  • Set operator NE in Database View creation in  join condition

    Hi Experts,      I have a requirement to set NE(not equal) operator in join condition of Database View creation. Could you please help me how to set in operator. Join condition : Ex : BSAK-AUGBL NE BSAK-BELNR. You know that by default operator is '='

  • How to use "the concurrent employment" in HR_SAP.

    Dear Experts, I'm having the problem that: in our customer's company,  their employee can be assigned to more than one positions in the different companies. It means the EE just has one Personnel number, but they have personnel assignments. And I fou

  • How to create a region which should float in a page . (Like as windows cal)

    Hello Friends Using Apex Version 4 +. Oracle database 11g. How to create a region which should float in a page . ie i can move that region inside that page anywhere like as windows calculator. Can anyone please help me. Thanks in advance regards Edit

  • How can I filter messages that do NOT contain a specific word in the subject?

    I want to do the opposite of what filtering normally does. I want to filter out messages that do not contain a word or a string. For example, I want to display emails that do not contain the word "meeting" in the subject. Is this possible? If so, how

  • Handing off a RoboHelp 8 HTML project to a client

    I'm wrapping up a RoboHelp 8 HTML project for a client. I am copying the files to a shared drive, a nd another person will be copying the files to his PC to maintain the help after I'm gone. Is there any d anger of corruption of files, or are there a