SQL Hard Parsing

How can I program a PL/SQL procedure/function to return a cursor (recordset) to JDBC calling program AND have Oracle NOT reparse the select statement in the package?
I presently return a ref cursor which works, but am dismayed that the statement is hard parsed each and every execution.
thanks..........

I think you are using Statement rather than PreparedStatement when you execute your SQL. PreparedStatement uses bind variables and hence avoids multiple hard parses.
Cheers, APC

Similar Messages

  • Avoid Hard Parsing for executing dynamic SQL using DUAL table Oracle

    I want to know if dynamic sql statements involving DUAL table can be modified to remove HARD PARSING.
    We have several SQL statements are stored in configuration table, here is sample example
    -- query 1 before replacing index values as stored in config table ---
    select count(*) from dual where  'REPLACE_VALUE_OF_INDEX_3' IN ('K')
    AND (('REPLACE_VALUE_OF_INDEX_13' IN ('1053','1095','1199') ) OR ('REPLACE_VALUE_OF_INDEX_13' IN ('1200') ))
    AND 'REPLACE_VALUE_OF_INDEX_2' IN ('6')
    AND 'REPLACE_VALUE_OF_INDEX_15' IN ('870001305')
    -- query 1 after replacing index values--
    select count(*) from dual where  'REPLACE_VALUE_OF_INDEX_10' IN ('K')
    AND (('1030' IN ('1053','1095','1199') ) OR ('1030' IN ('1200') ))
    AND '2' IN ('6')
    AND 'X' IN ('870001305')
    -- query 2 before replacing index values as stored in config table --
    select count(*) from dual where  'REPLACE_VALUE_OF_INDEX_5' IN ('361A','362A')
    AND 'REPLACE_VALUE_OF_INDEX_22' BETWEEN '200707' AND '200806'
    -- query 2 after replacing index values--
    select count(*) from dual where  '3MAA' IN ('361A','362A') AND '201304' BETWEEN '200707' AND '200806'

    If I got it right you have some (maybe lots of) conditions stored in a table (be patient - it's my interpretation)
    create table eb_conditions as
    select 1 rid,q'{:5 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'}' cndtn from dual union all
    select 2,q'{:2 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'}' from dual union all
    select 3,q'{:1 IN ('K') AND ((:2 IN ('1053','1095','1199') ) OR (:4 IN ('1200') )) AND :3 IN ('6') AND :5 IN ('870001305')}' from dual
    RID
    CNDTN
    1
    :5 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'
    2
    :2 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'
    3
    :1 IN ('K') AND ((:2 IN ('1053','1095','1199') ) OR (:4 IN ('1200') )) AND :3 IN ('6') AND :5 IN ('870001305')
    and you have to check the conditions using values stored in an array
    I used a table instead: the vl at rid = 1 representing the value of bind variable :1 in eb_conditions table and so on ...
    create table eb_array as
    select 1 rid,'K' vl from dual union all
    select 2,'1199' from dual union all
    select 3,'200803' from dual union all
    select 4,'1000' from dual union all
    select 5,'870001305' from dual
    RID
    VL
    1
    K
    2
    1199
    3
    200803
    4
    1000
    5
    870001305
    You want to check the conditions using select count(*) from dual where <condition with binds substituted fron the array>
    Judging from the title Hard Parsing represents the major problem and you cannot avoid it since every condition to be verified is different from every other condition.
    I think your best bet is not to evaluate conditions row by row - context shift cannot be avoided and there might be more than one for each iteration.
    So try to do it in a single step:
    declare
    w_cndtn varchar2(4000);
    w_clob  clob;
    w_cursor sys_refcursor;
    one number;
    two number;
    begin
      dbms_lob.createtemporary(w_clob,false);
      for rw in (select rid,
                        max(cndtn) cndtn,
                        listagg(val,',') within group (order by rn)||',' usng
                   from (select c.rid,c.cndtn,c.rn,c.bind,
                                replace(rtrim(c.bind),':'||to_char(v.rid),''''||v.vl||'''') val
                           from (select rid,
                                        cndtn,
                                        regexp_substr(cndtn,':\d+ ',1,level) bind,
                                        level rn
                                   from eb_conditions
                                 connect by level <= regexp_count(cndtn,':')
                                        and prior rid = rid
                                        and prior sys_guid() is not null
                                ) c,
                                eb_array v
                          where instr(c.bind,':'||v.rid||' ') > 0
                  group by rid
      loop
        w_cndtn := rw.cndtn;
        while instr(w_cndtn,':') > 0
        loop
          w_cndtn := replace(w_cndtn,trim(regexp_substr(w_cndtn,':\d+ ',1,1)),substr(rw.usng,1,instr(rw.usng,',') - 1));
          rw.usng := substr(rw.usng,instr(rw.usng,',') + 1);
        end loop;
        w_cndtn := 'select '||to_char(rw.rid)||' cndtn_id,count(*) from dual where '||w_cndtn||' union all ';
        w_clob := w_clob ||' '||w_cndtn;
      end loop;
      w_clob := substr(w_clob,1,instr(w_clob,'union all',-1,1) - 1);
      open w_cursor for w_clob;
      loop
        fetch w_cursor into one,two;
        exit when w_cursor%notfound;
        dbms_output.put_line(to_char(one)||':'||to_char(two));
      end loop;
      dbms_lob.freetemporary(w_clob);
    end;
    1:0
    2:0
    3:0
    Statement processed.
    Regards
    Etbin

  • Hard Parse or Soft Parse ?

    Hi Experts,
    If we execute a SELECT statement in SQL*PLUS by passing the value using ampersand operator, whether hard parsing will occur or soft parsing ?
    SQL> select last_name from employees where department_id = &dept_no;
    Enter value for dept_no: 100
    old   1: select last_name from employees where department_id = &dept_no
    new   1: select last_name from employees where department_id = 100
    SQL> select last_name from employees where department_id = &dept_no;
    Enter value for dept_no: 110
    old   1: select last_name from employees where department_id = &dept_no
    new   1: select last_name from employees where department_id = 110
    When I am executing V$SQL, for each different value I am seeing different SQL_ID. Please explain on this.
    Many thaks in advance for your help.
    Cheers,
    Suri

    hi ,
    the best way to check for for hard parse and soft parse is by querying the data dictionar view v$sqlarea . There is a column called parse_counts(not sure of the name). the moment you execute a query , a row is reflected in this view.
    for eg , when you query
    select * from emp where empno=101,
    select * from emp where empno=102,
    select * from emp where empno=103,
    query the v$sqlarea  with a filter predicate on the sql_text . i.e  select * from v$sqlarea where sql_text like  '%select * from emp %'.
    And then try querying the emp table using bind variable,
    select * from emp where empno=:x; -- pass 101 ,102,103
    No new rows are formed in the v$sqlarea,rather the parsed_count keeps on increasing , contrary to the above queries(without using bind variables in which each query is new to the parser).
    @Gurus : in 11g , i  have observed that all queries are converted to make you of bind variables .I knew that this was the implicit behaviour of plsql ,but now have they enhanced the sql engine too ?
    Thanks
    Rahul

  • Oracle 11g - Is there a way to speed up hard parsing?

    Hi,
    I have used TKPROF to examine my slow SQL and it's pointed out it is because of the hard parsing process. Bind variables would not help in my case because the query conditions vary quite arbitrarily depending on what the user selects on the application GUI.
    I've managed to break the query into smaller ones using UNION ALL and the parsing takes much shorter. However I'm still wondering if, in general, there could be anything one could do to speed up the hard parsing process, or it is something totally internal in Oracle and there's nothing we can do about it?
    A small example of the slow query (execute 0.00s, fetch 0.04s, and parse 66.51s), nr is the primary key.
    SELECT n.nr,n.x,n.y,n.z
    FROM
    data2points n WHERE((n.nr>2595 AND n.nr<2600) OR n.nr=2601 OR (n.nr>2602 AND
      n.nr<2608) OR n.nr=2617 OR n.nr=2623 OR (n.nr>2634 AND n.nr<2637) OR
      (n.nr>6457 AND n.nr<6461) OR n.nr=6462 OR n.nr=6468 OR n.nr=6480 OR
      (n.nr>20677 AND n.nr<20680) OR n.nr=20681 OR n.nr=20683 OR n.nr=26404 OR
      n.nr=26406 OR (n.nr>26408 AND n.nr<26411) OR n.nr=26422 OR (n.nr>26423 AND
      n.nr<26426) OR (n.nr>26426 AND n.nr<26431) OR (n.nr>26432 AND n.nr<26435)
      OR n.nr=26441 OR n.nr=26443 OR (n.nr>26471 AND n.nr<26474) OR (n.nr>26474
      AND n.nr<26478) OR (n.nr>26481 AND n.nr<26486) OR (n.nr>26487 AND
      n.nr<26492) OR n.nr=26498 OR (n.nr>26504 AND n.nr<26507) OR (n.nr>26513 AND
      n.nr<26516) OR (n.nr>26516 AND n.nr<26520) OR n.nr=26522 OR (n.nr>26523 AND
      n.nr<26527) OR (n.nr>26527 AND n.nr<26530) OR (n.nr>26530 AND n.nr<26533)
      OR n.nr=26538 OR n.nr=26562 OR (n.nr>26566 AND n.nr<26570) OR (n.nr>26570
      AND n.nr<26575) OR n.nr=26580 OR n.nr=26603 OR (n.nr>26607 AND n.nr<26610)
      OR (n.nr>26610 AND n.nr<26614) OR (n.nr>26618 AND n.nr<26621) OR n.nr=26624
      OR n.nr=26627 OR (n.nr>26629 AND n.nr<26632) OR n.nr=26634 OR (n.nr>26635
      AND n.nr<26638) OR n.nr=26639 OR n.nr=26642 OR n.nr=26648 OR (n.nr>26650
      AND n.nr<26662) OR n.nr=26663 OR (n.nr>26664 AND n.nr<26668) OR (n.nr>26695
      AND n.nr<26698) OR (n.nr>26699 AND n.nr<26707) OR n.nr=26708 OR n.nr=26710
      OR (n.nr>26714 AND n.nr<26729) OR n.nr=26751 OR (n.nr>26752 AND n.nr<26755)
      OR n.nr=26757 OR (n.nr>26759 AND n.nr<26762) OR (n.nr>26762 AND n.nr<26766)
      OR n.nr=26767 OR (n.nr>26773 AND n.nr<26776) OR n.nr=26798 OR (n.nr>26801
      AND n.nr<26807) OR n.nr=26808 OR (n.nr>26813 AND n.nr<26816) OR n.nr=26817
      OR n.nr=26819 OR (n.nr>26852 AND n.nr<26855) OR (n.nr>26857 AND n.nr<26861)
      OR (n.nr>26862 AND n.nr<26865) OR (n.nr>26869 AND n.nr<26874) OR
      (n.nr>26874 AND n.nr<26881) OR (n.nr>26881 AND n.nr<26884) OR (n.nr>26902
      AND n.nr<26907) OR (n.nr>26907 AND n.nr<26910) OR (n.nr>26910 AND
      n.nr<26918) OR n.nr=26923 OR n.nr=26945 OR (n.nr>26946 AND n.nr<26949) OR
      (n.nr>26951 AND n.nr<26958) OR n.nr=26959 OR n.nr=26964 OR (n.nr>26965 AND
      n.nr<26971) OR n.nr=26972 OR n.nr=26979 OR (n.nr>26998 AND n.nr<27002) OR
      n.nr=27004 OR (n.nr>27005 AND n.nr<27008) OR n.nr=27009 OR (n.nr>27011 AND
      n.nr<27015) OR (n.nr>27019 AND n.nr<27022) OR (n.nr>27022 AND n.nr<27026)
      OR (n.nr>27042 AND n.nr<27050) OR n.nr=27051 OR (n.nr>27052 AND n.nr<27055)
      OR n.nr=27064 OR n.nr=27087 OR (n.nr>27088 AND n.nr<27096) OR (n.nr>27096
      AND n.nr<27099) OR n.nr=27100 OR n.nr=27106 OR n.nr=27130 OR n.nr=27138 OR
      (n.nr>27140 AND n.nr<27145) OR (n.nr>27145 AND n.nr<27150) OR n.nr=27152 OR
      n.nr=27154 OR n.nr=27160 OR n.nr=27182 OR n.nr=27184 OR n.nr=27186 OR
      (n.nr>27188 AND n.nr<27191) OR (n.nr>27191 AND n.nr<27194) OR n.nr=27195 OR
      (n.nr>27200 AND n.nr<27203) OR (n.nr>27204 AND n.nr<27208) OR (n.nr>27223
      AND n.nr<27226) OR (n.nr>27230 AND n.nr<27235) OR n.nr=27236 OR n.nr=27242
      OR (n.nr>27243 AND n.nr<27246) OR (n.nr>27246 AND n.nr<27249) OR n.nr=27250
      OR n.nr=27256 OR n.nr=27258 OR n.nr=27267 OR n.nr=27273 OR n.nr=27276 OR
      (n.nr>27277 AND n.nr<27280) OR (n.nr>27281 AND n.nr<27289) OR (n.nr>27299
      AND n.nr<27303) OR (n.nr>27308 AND n.nr<27312) OR (n.nr>27332 AND
      n.nr<27337) OR n.nr=27339 OR n.nr=27342 OR (n.nr>27344 AND n.nr<27351) OR
      (n.nr>27354 AND n.nr<27357) OR (n.nr>27357 AND n.nr<27362) OR (n.nr>27366
      AND n.nr<27369) OR n.nr=27370 OR (n.nr>27404 AND n.nr<27407) OR (n.nr>27407
      AND n.nr<27410) OR n.nr=27411 OR (n.nr>27412 AND n.nr<27417) OR n.nr=27422
      OR (n.nr>27423 AND n.nr<27427) OR n.nr=27431 OR n.nr=27434 OR n.nr=27437 OR
      n.nr=27446 OR n.nr=27448 OR n.nr=27454 OR n.nr=27457 OR (n.nr>27458 AND
      n.nr<27461) OR (n.nr>27464 AND n.nr<27467) OR (n.nr>27467 AND n.nr<27470)
      OR n.nr=27471 OR n.nr=27473 OR (n.nr>27478 AND n.nr<27481) OR n.nr=27486 OR
      (n.nr>27488 AND n.nr<27491) OR (n.nr>27497 AND n.nr<27501) OR n.nr=27502 OR
      (n.nr>27505 AND n.nr<27511) OR n.nr=27512 OR n.nr=27532 OR n.nr=27534 OR
      n.nr=27560 OR (n.nr>27565 AND n.nr<27571) OR (n.nr>27574 AND n.nr<27577) OR
      n.nr=27578 OR n.nr=27581 OR n.nr=27585 OR (n.nr>27600 AND n.nr<27604) OR
      n.nr=27611 OR (n.nr>27613 AND n.nr<27625) OR (n.nr>27631 AND n.nr<27636) OR
      n.nr=27639 OR n.nr=27641 OR n.nr=27655 OR (n.nr>27656 AND n.nr<27659) OR
      (n.nr>27659 AND n.nr<27663) OR (n.nr>27663 AND n.nr<27667) OR n.nr=27668 OR
      n.nr=27674 OR n.nr=27676 OR n.nr=27678 OR n.nr=27700 OR n.nr=27706 OR
      (n.nr>27707 AND n.nr<27712) OR (n.nr>27716 AND n.nr<27719) OR (n.nr>27719
      AND n.nr<27726) OR n.nr=27728 OR n.nr=27730 OR (n.nr>27755 AND n.nr<27758)
      OR n.nr=27761 OR (n.nr>27762 AND n.nr<27766) OR n.nr=27767 OR n.nr=27773 OR
      (n.nr>27774 AND n.nr<27779) OR n.nr=27782 OR (n.nr>27796 AND n.nr<27799) OR
      (n.nr>27801 AND n.nr<27808) OR n.nr=27809 OR n.nr=27812 OR (n.nr>27813 AND
      n.nr<27817) OR (n.nr>27817 AND n.nr<27823) OR n.nr=27829 OR n.nr=27847 OR
      (n.nr>27848 AND n.nr<27852) OR n.nr=27853 OR n.nr=27855 OR (n.nr>27856 AND
      n.nr<27859) OR n.nr=27860 OR n.nr=27862 OR n.nr=27864 OR (n.nr>27869 AND
      n.nr<27875) OR n.nr=27876 OR n.nr=27879 OR (n.nr>27882 AND n.nr<27885) OR
      (n.nr>27903 AND n.nr<27906) OR n.nr=27907 OR n.nr=27911 OR (n.nr>27912 AND
      n.nr<27915) OR (n.nr>27961 AND n.nr<27964) OR n.nr=27967 OR (n.nr>27968 AND
      n.nr<27974) OR (n.nr>27978 AND n.nr<27984) OR (n.nr>28016 AND n.nr<28022)
      OR (n.nr>28022 AND n.nr<28027) OR n.nr=28033 OR (n.nr>28056 AND n.nr<28059)
      OR (n.nr>28059 AND n.nr<28065) OR (n.nr>28065 AND n.nr<28068) OR n.nr=28077
      OR (n.nr>28083 AND n.nr<28086) OR (n.nr>28090 AND n.nr<28096) OR
      (n.nr>28097 AND n.nr<28103) OR n.nr=28112 OR n.nr=28114 OR (n.nr>28116 AND
      n.nr<28120) OR (n.nr>28120 AND n.nr<28123) OR (n.nr>28153 AND n.nr<28159)
      OR n.nr=28161 OR n.nr=28163 OR (n.nr>28164 AND n.nr<28167) OR (n.nr>28171
      AND n.nr<28174) OR (n.nr>28194 AND n.nr<28197) OR (n.nr>28200 AND
      n.nr<28206) OR n.nr=28207 OR (n.nr>28212 AND n.nr<28215) OR n.nr=28217 OR
      n.nr=28237 OR n.nr=28244 OR (n.nr>28245 AND n.nr<28248) OR (n.nr>28253 AND
      n.nr<28262) OR n.nr=28263 OR n.nr=28265 OR n.nr=28268 OR (n.nr>28269 AND
      n.nr<28273) OR n.nr=28291 OR n.nr=28293 OR (n.nr>28297 AND n.nr<28301) OR
      (n.nr>28301 AND n.nr<28305) OR (n.nr>28308 AND n.nr<28311) OR n.nr=28312 OR
      n.nr=28314 OR n.nr=28316 OR n.nr=28324 OR n.nr=28335 OR (n.nr>28345 AND
      n.nr<28349) OR (n.nr>28350 AND n.nr<28353) OR (n.nr>28354 AND n.nr<28360)
      OR n.nr=28361 OR n.nr=28366 OR (n.nr>28376 AND n.nr<28379) OR (n.nr>28401
      AND n.nr<28405) OR (n.nr>28405 AND n.nr<28416) OR (n.nr>28416 AND
      n.nr<28419) OR (n.nr>28422 AND n.nr<28425) OR (n.nr>28444 AND n.nr<28449)
      OR (n.nr>28449 AND n.nr<28452) OR (n.nr>28453 AND n.nr<28460) OR n.nr=28488
      OR (n.nr>28491 AND n.nr<28494) OR n.nr=28495 OR (n.nr>28496 AND n.nr<28504)
      OR (n.nr>28505 AND n.nr<28510) OR (n.nr>28510 AND n.nr<28517) OR n.nr=28531
      OR (n.nr>28535 AND n.nr<28539) OR (n.nr>28539 AND n.nr<28542) OR
      (n.nr>28547 AND n.nr<28551) OR n.nr=28552 OR n.nr=28573 OR n.nr=28576 OR
      (n.nr>28578 AND n.nr<28582) OR (n.nr>28582 AND n.nr<28587) OR (n.nr>28599
      AND n.nr<28607) OR (n.nr>28607 AND n.nr<28610) OR n.nr=28611 OR (n.nr>28613
      AND n.nr<28617) OR (n.nr>28620 AND n.nr<28624) OR (n.nr>28625 AND
      n.nr<28628) OR (n.nr>28634 AND n.nr<28639) OR n.nr=28641 OR (n.nr>28642 AND
      n.nr<28651) OR n.nr=28657 OR n.nr=28667 OR (n.nr>28668 AND n.nr<28671) OR
      (n.nr>28671 AND n.nr<28674) OR (n.nr>28680 AND n.nr<28691) OR (n.nr>28691
      AND n.nr<28694) OR n.nr=28695 OR (n.nr>28717 AND n.nr<28721) OR (n.nr>28721
      AND n.nr<28724) OR (n.nr>28724 AND n.nr<28729) OR (n.nr>28729 AND
      n.nr<28733) OR n.nr=28735 OR (n.nr>28736 AND n.nr<28747) OR n.nr=28748 OR
      n.nr=28750 OR (n.nr>28753 AND n.nr<28757) OR n.nr=28758 OR n.nr=28763 OR
      n.nr=28765 OR n.nr=28769 OR (n.nr>28771 AND n.nr<28774) OR n.nr=28775 OR
      (n.nr>28776 AND n.nr<28779) OR n.nr=28780 OR n.nr=28783 OR (n.nr>28784 AND
      n.nr<28794) OR n.nr=28808 OR (n.nr>28810 AND n.nr<28813) OR n.nr=28814 OR
      (n.nr>28815 AND n.nr<28821) OR (n.nr>28826 AND n.nr<28834) OR (n.nr>28846
      AND n.nr<28849) OR n.nr=28855 OR n.nr=28857 OR n.nr=28859 OR (n.nr>28864
      AND n.nr<28870) OR (n.nr>28871 AND n.nr<28876) OR (n.nr>28876 AND
      n.nr<28879) OR n.nr=28880 OR n.nr=28884 OR n.nr=28888 OR (n.nr>28889 AND
      n.nr<28892) OR (n.nr>28893 AND n.nr<28896) OR (n.nr>28896 AND n.nr<28901)
      OR (n.nr>28906 AND n.nr<28909) OR n.nr=28931 OR (n.nr>28937 AND n.nr<28943)
      OR n.nr=28948 OR n.nr=28953 OR (n.nr>28958 AND n.nr<28961) OR n.nr=28967 OR
      n.nr=28970 OR (n.nr>28972 AND n.nr<28975) OR (n.nr>28975 AND n.nr<28980) OR
      (n.nr>28980 AND n.nr<28984) OR n.nr=28991 OR n.nr=28993 OR n.nr=28996 OR
      (n.nr>28999 AND n.nr<29002) OR n.nr=29011 OR (n.nr>29012 AND n.nr<29018) OR
      (n.nr>29027 AND n.nr<29036) OR n.nr=29038 OR n.nr=29041 OR n.nr=29044 OR
      (n.nr>29048 AND n.nr<29051) OR n.nr=29053 OR (n.nr>29055 AND n.nr<29060) OR
      n.nr=29062 OR (n.nr>29063 AND n.nr<29069) OR (n.nr>29071 AND n.nr<29075) OR
      n.nr=29077 OR n.nr=29079 OR (n.nr>29097 AND n.nr<29100) OR (n.nr>29104 AND
      n.nr<29109) OR (n.nr>29109 AND n.nr<29112) OR (n.nr>29115 AND n.nr<29118)
      OR (n.nr>29118 AND n.nr<29122) OR n.nr=29135 OR (n.nr>29136 AND n.nr<29140)
      OR (n.nr>29143 AND n.nr<29148) OR n.nr=29149 OR n.nr=29155 OR n.nr=29157 OR
      (n.nr>29177 AND n.nr<29181) OR (n.nr>29182 AND n.nr<29191) OR n.nr=29196 OR
      n.nr=29199 OR (n.nr>29219 AND n.nr<29222) OR (n.nr>29224 AND n.nr<29229) OR
      (n.nr>29229 AND n.nr<29233) OR (n.nr>29236 AND n.nr<29239) OR (n.nr>29239
      AND n.nr<29244) OR (n.nr>29244 AND n.nr<29249) OR n.nr=29257 OR n.nr=29260
      OR (n.nr>29261 AND n.nr<29266) OR n.nr=29267 OR n.nr=29269 OR (n.nr>29270
      AND n.nr<29274) OR (n.nr>29276 AND n.nr<29279) OR n.nr=29280 OR n.nr=29282
      OR n.nr=29286 OR n.nr=29288 OR n.nr=29290 OR n.nr=29296 OR (n.nr>29297 AND
      n.nr<29300) OR (n.nr>29300 AND n.nr<29304) OR (n.nr>29305 AND n.nr<29310)
      OR (n.nr>29310 AND n.nr<29314) OR (n.nr>29319 AND n.nr<29324) OR
      (n.nr>29328 AND n.nr<29332) OR (n.nr>29335 AND n.nr<29338) OR (n.nr>29338
      AND n.nr<29343) OR (n.nr>29347 AND n.nr<29350) OR n.nr=29351 OR n.nr=29354
      OR (n.nr>29357 AND n.nr<29367) OR (n.nr>29367 AND n.nr<29371) OR
      (n.nr>29372 AND n.nr<29376) OR (n.nr>29377 AND n.nr<29385) OR (n.nr>29386
      AND n.nr<29389) OR (n.nr>29393 AND n.nr<29400) OR (n.nr>29405 AND
      n.nr<29408) OR (n.nr>29408 AND n.nr<29412) OR n.nr=29413 OR (n.nr>29414 AND
      n.nr<29417) OR n.nr=29423 OR (n.nr>29424 AND n.nr<29429) OR (n.nr>29429 AND
      n.nr<29433) OR (n.nr>29433 AND n.nr<29439) OR (n.nr>29439 AND n.nr<29443)
      OR n.nr=29444 OR (n.nr>29446 AND n.nr<29455) OR n.nr=29456 OR (n.nr>29457
      AND n.nr<29461) OR n.nr=29463 OR (n.nr>29464 AND n.nr<29467) OR (n.nr>29467
      AND n.nr<29473) OR n.nr=29474 OR n.nr=29476 OR n.nr=29478 OR (n.nr>29479
      AND n.nr<29486) OR (n.nr>29486 AND n.nr<29503) OR (n.nr>29509 AND
      n.nr<29535) OR (n.nr>29535 AND n.nr<29538) OR (n.nr>29538 AND n.nr<29541)
      OR (n.nr>29542 AND n.nr<29548) OR n.nr=29549 OR n.nr=29551 OR (n.nr>29552
      AND n.nr<29555) OR n.nr=29556 OR n.nr=29558 OR (n.nr>29560 AND n.nr<29564)
      OR (n.nr>29564 AND n.nr<29574) OR (n.nr>29574 AND n.nr<29577) OR n.nr=29578
      OR (n.nr>29579 AND n.nr<29582) OR (n.nr>29585 AND n.nr<29589) OR n.nr=29591
      OR n.nr=29593 OR n.nr=29595 OR n.nr=29597 OR n.nr=29605 OR n.nr=29607 OR
      (n.nr>29608 AND n.nr<29612) OR (n.nr>29615 AND n.nr<29623) OR n.nr=29627 OR
      (n.nr>29628 AND n.nr<29633) OR n.nr=29634 OR n.nr=29637 OR n.nr=29643 OR
      n.nr=29653 OR (n.nr>29659 AND n.nr<29664) OR (n.nr>29664 AND n.nr<29670) OR
      (n.nr>29671 AND n.nr<29677) OR n.nr=29679 OR (n.nr>29682 AND n.nr<29686) OR
      (n.nr>29686 AND n.nr<29689) OR (n.nr>29691 AND n.nr<29694) OR (n.nr>29697
      AND n.nr<29702) OR (n.nr>29702 AND n.nr<29705) OR (n.nr>29709 AND
      n.nr<29713) OR n.nr=29714 OR n.nr=29716 OR (n.nr>29736 AND n.nr<29741) OR
      n.nr=29742)Edited by: 808239 on Apr 19, 2011 7:01 AM
    Edited by: 808239 on Apr 19, 2011 7:02 AM

    To add on to what Girish Sharma posted, you can may need more than one temp table and a bit more complex SQL.
    You can improve your parsing time ( 66 seconds is really a lot) by restructuring your statement and using temp tables. I assume that you cannot use PL/SQL - if you can you might be able to get more elegant solution with PL/SQL collections.
    Store all literal values in where clause in temp tables (by temp table I mean a table that is deleted before and after the query– the specific physical implementation is up to you). Use bind variables/bulk load to load the data in the temp tables.
    Select * from temp_1
    val
    2601
    2617
    2623
    6462
    Select * from temp_2
    val1     val2
    2595 2600
    2602 2608
    2634 2637
    Now the query would look like this:
    SELECT n.nr,n.x,n.y,n.z
    FROM
    data2points n WHERE
    n.nr in (select val from temp_1)
    or
    exists
    (select * from temp_2 where n.nr > val1 and where n.nr < val1)

  • How to use bind variable in the query to avoid hard parsing

    Hi,
    I have a query which is using literals
    strquery:='SELECT SUMTOTAL FROM tab1 WHERE BATCHNO = '''
          || gBNo
          || ''' AND A_ID = '''
          || g_id
          || ''' AND L_ID = '''
          || g_LId
          || '''  AND S_Code = ''C_3'' ';
    execute immediate strquery;I have been asked to use a bind variable to avoid hard parsing.
    How do i do it?
    Edited by: user8731258 on Jul 27, 2012 5:07 AM
    Edited by: user8731258 on Jul 27, 2012 5:08 AM

    You dont need Dynamic SQL. Your Table and Column Name are static in that query. Just use Static SQL
    SELECT SUMTOTAL
      INTO lSumTotal
      FROM tab1
    WHERE BATCHNO = gBatchNo
       AND ATM_ID  = gAtm_id
       AND LOAD_ID = gLoadId
       AND STEP_CODE = 'C_3';

  • Dynamic where clause - hard-parse

    Hi there,
    I landed in the middle of a situation that I'm not seeing any solution possible, so I’m turning to you for help.
    We have a batch script that occurs once a day that handles a lot of information (we're talking about thousands of data).
    In many situations we have to run select's with the where clause dynamically build.
    That is, we have a table with something like: ID - COLUMN_NAME - OPPERATOR - COLUMN_VALUE - DEPENDING_VALUE
    Our database is unique for a large number of clients (we have about 90% of my country City Hall's and then some more...), and DEPENDING_VALUE depends on each client.
    So, for each client, we build the where clause based on that table and then we get the data from another table with something like SELECT ABC FROM XPTO WHERE || WHERE_CLAUSE_BUILD using dynamic sql.
    So far so good, except we can have many different combinations of the where clause causing the select to be hard-parse for each client and we are trying to think of a better way to do this. Unfortunately we haven’t found one yet and I’m not seeing any light in the end of the tunnel…
    This is kind of difficult to explain, so I hope I was clear enough.
    Any help would be greatly appreciated.
    Thank you

    Hi, thank you for your answer.
    We are already using the USING clause and binding.
    The (we think kind of stupid) idea we had was:
    We created an array of 100 positions.
    Then we made a function that get’s the where clause and populates the array making something like:
    ‘where a = :param1 and b = :param2 and c= :param3’ and so on.
    For the remaining positions, we added ‘and 1 = :paramMax+1 and … and 1 = :paramMax+N and …’ and put :paramMax+1.value = 1 and :paramMax+N = 1.
    Then, when using the select with the where clause we opened a cursor using :param1.value, :param2.value, :param3.value, … :param100.value
    But this still is hard-parsing because I can have:
    Select x from y where a = :param1 and b = :param2 and 1 = :param3 …
    And for another client
    Select x from y where a = :param1 and 1 = :param2 and 1 = :param3 …
    The statements are different, that’s why I’m not seeing any solution.
    Thanks

  • The SGA was inadequately sized, causing additional I/O or hard parses.

    Dear all,
    We are using 10g RAC On Solaris 5.10
    Very freuently,we are getting the below message in DB Console
    The SGA was inadequately sized, causing additional I/O or hard parses.
    Additional Information
    The value of parameter "sga_target" was "15360 M" during the analysis period.
    Under recommendations,
    I found that
    Increase the size of the SGA by setting the parameter "sga_target" to 30720 M.
    Findings Path
    Findings Impact (%) Additional Information
    The SGA was inadequately sized, causing additional I/O or hard parses. 27 Additional Information
    Wait class "User I/O" was consuming significant database time. 13.2
    Hard parsing of SQL statements was consuming significant database time. 4.9
    Contention for latches related to the shared pool was consuming significant database time. 0.6
    Wait class "Concurrency" was consuming significant database time
    Can I rely on this info alone and increase SGA.. Is there any other way I confirm this ?.
    Dear Seniors,
    Please ignore this Thread if you find this question silly..
    Please advise
    Kai

    Hi Kai,
    Can I rely on this info alone and increase SGA.. Is there any other way I confirm this ?.Yes. Oracle has specific "cache" advisors to say if your data buffers of shared pool regions are too small.
    I have my notes here:
    http://www.dba-oracle.com/art_builder_buffers.htm
    The besy way to see them is to run a STATSPACK or AWR report . . .
    if you find this question silly..It''s not silly at all, it's a VERY common question!
    http://www.dba-oracle.com/t_estimating_sga_size.htm
    If you are running Oracle on a dedicated server, it's wasteful NOT to allocate all of the RAM to Oracle, less 20% for the OS . . .
    Lastly, remember that Oracle has an insatiable appetite for RAM, but there is a point of diminishing marginal return . . .
    Hope this helps . . .
    Donald K. Burleson
    Oracle Press author
    Author of "Oracle Tuning: The Definitive Reference"
    http://www.rampant-books.com/book_2005_1_awr_proactive_tuning.htm

  • List all hard parses

    Hi gurus,
    Could you give me advice how can I list all queries which are hard parse? I've check AWR report and on Top5 I have "latch: library cache" - so as I check it's because of parse statements.
    best,
    Lesak

    SB made an excellent point. You really need to look at the total execution profile to determine if 'latch: library cache' is your problem. You need to understand where the most time is being spent.
    As to 'latch: library cache', consider that when hard parsing, Oracle must also take the shared pool latch, to allocate memory in the shared pool for the new SQL being parsed. This is a more expensive operation than the library cache latch used for searching the library cache. My point being, if all you see is 'latch: library cache', but no 'latch: shared pool', the problem is almost certainly not hard parsing. It's far more likely to be excessive soft parses.
    What version of Oracle are you running? What do you have 'session_cached_cursors' set to? If it's 0, trying setting to 50 or 100 to see if that has any improvement.
    Hope that helps,
    -Mark

  • Error while running PL/SQL XML Parser Samples

    every time try to run the PL/SQL XML Parser Sample program i get this error no file or directory, though the file and dir exists, i have the permissions setup as in readme.txt do i need to do any chnages to init.ora,
    pls advice
    Thanks,
    SQL> exec test
    begin test; end;
    ERROR at line 1:
    ORA-20100: Error occurred while parsing: No such file or directory
    ORA-06512: at "SCOTT.XMLPARSER", line 22
    ORA-06512: at "SCOTT.XMLPARSER", line 69
    ORA-06512: at "SCOTT.TEST", line 13
    ORA-06512: at line 1

    Which examples in particular? Thanks.

  • ?xml version = '1.0' encoding = 'ASCII'? pl/sql xml parser

    When ever I parse a document which has the
    <?xml version = '1.0' encoding = 'ASCII'?> tag as the first line hangs the pl/sql xml parser . If I remove the "encoding = 'ASCII'" from the file everything works fine ! What is the problem ?
    version 8.1.6 / plsql parser v2 / hpux 11x
    Here is the input file
    <?xml version = '1.0' encoding = 'ASCII'?>
    !--- This is a comment -->
    <person>
    <employee>
    <lastname>GHANTASALA</lastname>
    <firstname>SREE</firstname>
    <age>32</age>
    </employee>
    <employee>
    <lastname>TAMATAM</lastname>
    <firstname>SATISH</firstname>
    <age>30</age>
    </employee>
    </person>
    Here is my program
    declare
    p xmlparser.parser;
    doc xmldom.DOMDocument;
    dir varchar2(100) := '/apps/oracle/drugstore';
    errfile varchar2(30) := 'err.txt' ;
    inpfile varchar2(30) := 'person.xml';
    nl xmldom.DOMNodeList;
    len number;
    n xmldom.DOMNode;
    new_node xmldom.DOMNode;
    node_name varchar2(100);
    node_value varchar2(100);
    begin
    -- new parser
    p := xmlparser.newParser;
    -- Set some characteristics
    xmlparser.setValidationMode(p, FALSE);
    xmlparser.setErrorLog(p, dir&#0124; &#0124;'/'&#0124; &#0124; errfile );
    xmlparser.setBaseDir(p, dir);
    -- parse input file
    xmlparser.parse(p, dir&#0124; &#0124;'/'&#0124; &#0124;inpfile);
    -- get document
    doc := xmlparser.getDocument(p);
    -- get all elements
    nl := xmldom.getElementsByTagName(doc, '*');
    len := xmldom.getLength(nl);
    dbms_output.put_line('Length='&#0124; &#0124;len);
    -- loop through elements
    for i in 0..len-1 loop
    n := xmldom.item(nl, i);
    node_name := xmldom.getNodeName(n);
    -- get the text node associated with the element node
    n := xmldom.getFirstChild(n);
    if xmldom.getNodeType(n) = xmldom.TEXT_NODE then
    node_value := xmldom.getNodeValue(n);
    if node_name='lastname' then
    dbms_output.put_line('The value you are looking for is -->:'&#0124; &#0124;node_value);
    if node_value = 'GHANTASALA' then
    xmldom.setNodeValue(n,'TEST2');
    end if;
    end if;
    end if;
    end loop;
    new_node := xmldom.makeNode(doc);
    xmldom.writeToFile(new_node, dir &#0124; &#0124;'/'&#0124; &#0124;'mod.xml');
    end ;
    null

    The encoding header is actually generated by
    by the following piece of code in my pl/sql program .
    new_node := xmldom.makeNode(doc);
    xmldom.writeToFile(new_node, dir &#0124; &#0124;'/'&#0124; &#0124;'mod.xml');
    Since this is a document created by the pl/sql parser, I assume there is some meaning to it !
    Also why is it hanging ? PL/sql parser should tell me that it is not a valid string !

  • Olap worksheet copy and paste fails hard parse

    Hi
    i've noticed something strange in the AWM olap worksheet that may help anyone using it.
    when you copy and paste some code to be executed it fails with strange errors however if you then type the code it runs without problem.
    bizarrely if you copy and paste the code in again it works..
    shown below is the console: 1st is pasted, 2nd typed, 3rd pasted... had me bashing my head against the screen a few times before i worked out what was going on.
    ->ROW 'SMOOTHING' FCQUERY(fc smoothing trial loopindx)
    ERROR: (ORA-33776) ROW is not a command.
    ORA-33776: ROW is not a command.
    ->ROW 'SMOOTHING' FCQUERY(fc smoothing trial loopindx)
    SMOOTHING no
    ->ROW 'SMOOTHING' FCQUERY(fc smoothing trial loopindx)
    SMOOTHING no
    ->
    I assume this is a parsing problem (i'm cutting and pasting from notepad btw).
    Once typed and parsed properly it doesn't do a hard parse again perhaps.
    In any case watch out for it, especially when copying example programs from the help text :), you have to type them a la spectrum48k. (10 print 'start' .....;)

    If you are copying and pasting from the OLAP DML Help then this is a known issue. The DML Help contains hidden characters that stop the code from executing.
    Keith Laker
    Oracle EMEA Consulting
    BI Blog: http://oraclebi.blogspot.com/
    DM Blog: http://oracledmt.blogspot.com/
    BI on Oracle: http://www.oracle.com/bi/
    BI on OTN: http://www.oracle.com/technology/products/bi/
    BI Samples: http://www.oracle.com/technology/products/bi/samples/

  • PL/SQL XML Parser demo

    i've downloaded the Pl/SQL XML parser demo - xslsample / domsample - followed the guide , etc but I'm getting ....
    BEGIN xslsample ('/export/home/oracle/plmx/sample','family.xml','iden.xsl','family.out','errors.txt'); END;
    ERROR at line 1:
    ORA-29516: Aurora assertion failure: Assertion failure at eox.c:187
    Uncaught exception Root of all Java exceptions:
    ORA-06512: at "PLMX.XMLPARSERCOVER", line 0
    ORA-06512: at "PLMX.XMLPARSER", line 57
    ORA-06512: at "PLMX.XSLSAMPLE", line 28
    ORA-06512: at line 1
    anybody seen this ??

    There is no such limit on our Parser for PL/SQL. Could you
    perhaps be using the PLXML Utilities? If you are you might try
    our PL/SQL Parser instead.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    Premal Mehta (guest) wrote:
    : Hi
    : I am using PL/SQL XML Parser to add XML data in database. I
    : am having trouble when using file sixe greater than 500KB?
    : What is the alternative? Can I do something to process
    larger
    : files?
    : Please Help, this is quite urgent.
    : Hoping for help,
    : Premal.
    null

  • How the SQL Query Parsing is processing inside SQL/PLSQL engine?

    Hi all,
    Can you explain how the SQL Query Parsing is processing inside SQL/PLSQL engine?
    Thanks,
    Sankar

    Sankar,
    Oracle Database concepts - Chapter 24..
    You will find the explanation required under the heading parsing.
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14220/sqlplsql.htm

  • Error : SGA was inadequately sized, causing additional I/O or hard parses

    Friends ,
    I got the Following error in my Production server's (Oracle10g with AIX 5.3 platform ) PERFORMANCE ANALYSIS part of OEM :
    "The SGA was inadequately sized, causing additional I/O or hard parses." And it shows the Impact result of Database 1.4% .
    In present my SGA size is = 9584 MB , And oracle itself recommended to increase it to = 19168 MB (that means twice time of the present value) .
    And my total OS Ram size = 32 GB
    In this moment , can anybody plz suggest me ,
    For increasing the SGA Size , which things(or Database related matters) I need to consider .
    OR
    Can I face any major problem If I increase the SGA size ?
    ORacle version : ORacle 10g
    Platform : AIX 5.3 unix server
    Number of Database : One
    Waiting for ur kind reply .. ...
    Edited by: shipon_97 on Oct 19, 2008 6:45 PM

    Hi..
    >
    For increasing the RAM Size , which things(or Database related matters) I need to consider .
    OR
    Can I face any major problem If I increase the RAM size ?
    >
    What is the oracle version you are using??
    Why do you want to increase the RAM size.Its already 32GB.Why don't you increase the SGA.How many databases are installed on the server.Is there some other applications running on the server.
    Anand

  • SQL Query Parser(urgent)

    Hi
    every body i have a requirement of SQL Query parser,
    This SQL Query parser should give me a column names and tables name in the query ,parsing the query , the query may be any complex query it might like
    SELECT CONVERT(bigint, EMD_DATE_TIME) AS CURRENTTIME FROM EVENT_METER_DAY.
    If i pass this query i should get, appropriate columname and table name which is being queried
    DO anybody knows any avaialble SQL parsers , and do to achieve this
    thanks and regards
    anil

    Why don't you use ResultSetMetaData instead? If you need to parse the query string before executing it, probably you have to write your own parser.

Maybe you are looking for

  • Thoughts on Android 4.3 update

    Since there are so many different kinds of problems being reported after the last two Android updates I am wondering if the problem lays with a conflict between the two updates. 4.2.2 supplemental security update was only released a couple of weeks b

  • MSI Big Bang Trinergy Memory problem.....

    I recently purchased a Bing Bang Trinergy mobo. It's combined with an Intel i3 540 cpu and 2 Kingston KVR1333D3N9/2G ram modules. The mobo came with BIOS 1.1 version. When I've tried to update the BIOS to any version above 1.1 (1.2, 1.3, 1.4) and DUA

  • 2 sounds in a flash movie

    hello, i have 2 sounds in a flash movie, music and narration. I have this script in frame 1 for narration sound: _root.my_sound = new Sound(); _root.my_sound.attachSound("antedespacho"); _root.my_sound.start(); and i have a MC, in frame 1 of movie, a

  • Sound waves in FCP

    Hi there, I am sort of stuck... When I opened my project today, I realized that I don't see the sound waves any more in the viewer, even after double click on the sound tracks.... Can someone tell me what I did wrong to "hide" them ? Also, when I dou

  • Packing list printing problem......

    Hello Experts, We are having a new problem in Master Packing List, after the modified package has been loaded to SPD. For same material code, appearing against different WBS elements, the print-out contains separate line items but with same WBS no. (