Performance: Cursor declaration versus explicit query in BEGIN/END block

Hi guys!
Anyone knows if declare an explicit cursor inside a pl/sql block is faster than using a cursor declaration, and how fast it its?
Which block runs faster? And how fast? ( once, twice, once and a half ? )
Block1:
DECLARE
CURSOR cur_test (p1 NUMBER) IS
SELECT field1, field2 FROM table WHERE field0 = p1;
vf1 VARCHAR2(1)
vf2 NUMBER;
n NUMBER := 0;
BEGIN
OPEN cur_test ( n );
FETCH cur_test INTO vf1, vf2;
CLOSE cur_test;
END;
Block2:
DECLARE
vf1 VARCHAR2(1)
vf2 NUMBER;
n NUMBER := 0;
BEGIN
BEGIN
SELECT field1, field2
INTO vf1, vf2
FROM table WHERE field0 = n;
EXCEPTION
WHEN others THEN
null;
END;
END;
I have LOOP in a cursor and may open/fetch/closes in this loop. I´m wondering how fast would it be if I change the open/fetch/closes to explicit query blocks...
Thanks!
Murilo

If you expect your qurey to return a single row, you would generally want to use a SELECT ... INTO. You'd only want to use a cursor if you expect to return multiple rows of data.
If you are doing this in a loop, I would strongly suspect that you should be letting Oracle join the tables in SQL rather than doing your own pseudo-join logic in PL/SQL. Letting SQL do the work of joining tables is going to generally be a sustantial performance difference. The difference between the two blocks you posted will be marginal at best.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • SQLplus command in a begin/end block

    Hi all,
    is it possible to use a SQLplus command (i.e. "@") inside a begin/end block , so in a plsql script ?
    thanks in advance and regards
    John

    user10899797 wrote:
    is it possible to use a SQLplus command (i.e. "@") inside a begin/end block , so in a plsql script ?Just a quick explanation why not.
    That begin..end block is called an anonymous (nameless, unlike a procedure or function) PL/SQL block. The client (in this case, SQL*Plus) transmits the block to Oracle.
    The server process servicing that client receives the block, parses it and executes it.
    This server process only understands SQL and PL/SQL. Not any language.
    So just as you cannot use .Net/Cobol/Visual Basic/Java/etc commands inside that PL/SQL anonymous block, you cannot use SQL*Plus commands in it.
    Part of the confusion regarding SQL*Plus is using substitution variables. This enables you to create an anonymous PL/SQL block in SQL*Plus that contains substitution variables.
    However, SQL*Plus itself does a very primitive parse of that block before it fires it off at the server - it detects these substitution variables and replace them with the assigned values for these variables. It then transmits this resulting block to the Oracle server for parsing and execution.
    Just remember that PL/SQL is a server-side language that runs inside an Oracle server process and that should clear most confusion in this regard (including whether PL/SQL can read keyboard data or write to a client PC's harddrive, or interactively display progress status on a client monitor).

  • LOV Select List How to create query with begin & End in LOV

    Dear All,
    i am using Apex 3.2 ver
    i want to use below code in LOV select list
    BEGIN
    IF  UPPER(:P23_SERVICE_TYPE) like 'GUIDE%' THEN
    SELECT NAME D, CODE R FROM SPECIAL_SERV_MAS
    WHERE NVL(ACTIVE_FLG,'N') = 'Y'
    AND NVL(GUIDE_FLAG,'N') = 'Y'
    and CITY_CODE LIKE NVL (:P23_CITY_CODE, '%')
    ORDER BY 2
    ELSIF
    UPPER(:P23_SERVICE_TYPE) LIKE 'ACCOM%' THEN
    SELECT   NAME D, CODE R
        FROM   HOTEL_MAS
       WHERE   NVL (ACTIVE_FLG, 'N') = 'Y'
               AND CITY_CODE LIKE NVL(:P23_CITY_CODE,'%')
    ORDER BY   PRIORITY
    END IF;
    END;When i put this code in my LOV Select list Section then display me Error
    Not Found
    The requested URL /pls/apex/f was not found on this server.
    Oracle-Application-Server-10g/10.1.2.0.2 Oracle-HTTP-Server Server at tidevserv1 Port 7777
    How to Resolve it.

    Hi Vedant,
    you dont need to use begin ...end block
    Try the Below code
    IF  UPPER(:P23_SERVICE_TYPE) like 'GUIDE%' THEN
    RETURN
    'SELECT NAME D, CODE R FROM SPECIAL_SERV_MAS
    WHERE NVL(ACTIVE_FLG,''N'') = ''Y''
    AND NVL(GUIDE_FLAG,''N'') = ''Y''
    and CITY_CODE LIKE NVL (:P23_CITY_CODE, ''%'')
    ORDER BY 2' ;
    ELSIF  UPPER(:P23_SERVICE_TYPE) LIKE 'ACCOM%' THEN
    RETURN
    'SELECT   NAME D, CODE R
        FROM   HOTEL_MAS
       WHERE   NVL (ACTIVE_FLG, ''N'') = ''Y''
               AND CITY_CODE LIKE NVL(:P23_CITY_CODE,''%'')
    ORDER BY   PRIORITY' ;
    END IF;In this way you can create conditional LOVs ,
    Hope this will helps you.
    Regards,
    Jitendra

  • Error in Delare/Begin/End block

    Dear all
    i wrote a query to show all functions and procedures including their name,parameter,parameter type and return type
    I should say that using the structure delcare,begin,end is mandatory for me here.
    DECLARE
    BEGIN
    SELECT uo.object_name,ua.ARGUMENT_NAME,ua.DATA_TYPE FROM user_arguments ua
    join user_objects uo
    on ua.object_id=uo.object_id
    WHERE uo.OBJECT_TYPE IN ('FUNCTION','PROCEDURE');
    END;but i get this error
    Error starting at line 3 in command:
    DECLARE
    BEGIN
    SELECT uo.object_name,ua.ARGUMENT_NAME,ua.DATA_TYPE FROM user_arguments ua
    join user_objects uo
    on ua.object_id=uo.object_id
    WHERE uo.OBJECT_TYPE IN ('FUNCTION','PROCEDURE');
    END;
    Error report:
    ORA-06550: line 4, column 1:
    PLS-00428: an INTO clause is expected in this SELECT statement
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:I know that it may be mandatory to have "into" in select when we use delcare/begin/end.
    So would you please rewrite the query?
    im using oracle 11.2.0.2
    thank you in advance.
    best,david

    1003209 wrote:
    Dear all
    i wrote a query to show all functions and procedures including their name,parameter,parameter type and return type
    I should say that using the structure delcare,begin,end is mandatory for me here.
    DECLARE
    BEGIN
    SELECT uo.object_name,ua.ARGUMENT_NAME,ua.DATA_TYPE FROM user_arguments ua
    join user_objects uo
    on ua.object_id=uo.object_id
    WHERE uo.OBJECT_TYPE IN ('FUNCTION','PROCEDURE');
    END;but i get this error
    Error starting at line 3 in command:
    DECLARE
    BEGIN
    SELECT uo.object_name,ua.ARGUMENT_NAME,ua.DATA_TYPE FROM user_arguments ua
    join user_objects uo
    on ua.object_id=uo.object_id
    WHERE uo.OBJECT_TYPE IN ('FUNCTION','PROCEDURE');
    END;
    Error report:
    ORA-06550: line 4, column 1:
    PLS-00428: an INTO clause is expected in this SELECT statement
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:I know that it may be mandatory to have "into" in select when we use delcare/begin/end.
    So would you please rewrite the query?
    im using oracle 11.2.0.2
    thank you in advance.
    best,davidHi David,
    The query will throw error if the schema where you are executing has more than "1" function or procedure in the system.
    Its not clear in your requirement.
    Assuming you want to display the output
    SQL> set serveroutput on
    SQL> DECLARE
      2  CURSOR cur_obj IS
      3  SELECT uo.object_name,ua.ARGUMENT_NAME,ua.DATA_TYPE
      4  FROM user_arguments ua
      5   join user_objects uo
      6  on ua.object_id=uo.object_id
      7  WHERE uo.OBJECT_TYPE IN ('FUNCTION','PROCEDURE');
      8  BEGIN
      9  FOR rec_obj IN cur_obj LOOP
    10  dbms_output.put_line('OBJECT_NAME:'||rec_obj.object_name||' '||'ARGUMENT_NAME:'||' '||rec_obj.a
    rgument_name||' '||'OBJECT_TYPE:'||rec_obj.data_type);
    11  END LOOP;
    12  END;
    13 
    14 
    15  .
    SQL> /
    OBJECT_NAME:GETUSERORDERCOUNT ARGUMENT_NAME:  OBJECT_TYPE:NUMBER
    OBJECT_NAME:GETUSERORDERCOUNT ARGUMENT_NAME: REGKEY OBJECT_TYPE:NUMBER
    OBJECT_NAME:GETUSERORDERCOUNT ARGUMENT_NAME: PARTNERKEY OBJECT_TYPE:NUMBER
    OBJECT_NAME:GSK_ACCOUNT_FIRSTADDRESS ARGUMENT_NAME:  OBJECT_TYPE:NUMBER
    OBJECT_NAME:GSK_ACCOUNT_FIRSTADDRESS ARGUMENT_NAME: ACCOUNT_KEY
    OBJECT_TYPE:NUMBER
    OBJECT_NAME:SUMCONCAT ARGUMENT_NAME:  OBJECT_TYPE:VARCHAR2
    OBJECT_NAME:SUMCONCAT ARGUMENT_NAME: INPUT OBJECT_TYPE:VARCHAR2
    OBJECT_NAME:GSK_PB_SHOW ARGUMENT_NAME:  OBJECT_TYPE:NUMBER
    ...........Regards,
    Achyut K

  • How to start a trigger in a begin/end block ?

    Hi all, I need to start a trigger inside a block begin end in order to manage errors.
    The trigger is created inside trigger_faef_c.sql as
    CREATE OR REPLACE TRIGGER TRIGGER_FAEF
    and I would like to start the trigger in another file "create_trigger.sql" with this format:
    BEGIN
    @trigger_faef_c;
    EXCEPTION WHEN OTHERS THEN
    dbms_output.Put_Line('#255#> Error in trigger_faef_c ' || Sqlerrm );
    END;
    I have this error executing the script:
    PLS-00103: Encountered the symbol "@" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "<an identifier>" was substituted for "@" to continue
    Can anyone help me please ?
    I have to use EXCEPTION WHEN OTHERS THEN.
    Thansk
    Erik

    Hi Erik,
    I think you mean Create the trigger(?), i.e, executing the trigger_faef_c.sql script.
    SQL*Plus doesn't have exception handling (Someone please correct me if I'm wrong).
    One way to circumvent that is to rewrite the script itself to PL/SQL. Something like:
    Declare
       stmt varchar2(32767);
    Begin
       stmt := 'Create Trigger ....';
       Execute Immediate stmt;
    Exception
       When Others Then
           --Do what?
    End;
    /And then just execute that
    @trigger_faef_c.sqlDon't know if you want to go that way. I use it myself to be able to run the same deployment scripts multiple times, without causing various failures due to "Table Already Exists" and so on.
    But, for triggers, I would never do that, since this has CREATE OR REPLACE.
    For triggers, I just (This time script is plain static SQL)
    WHENEVER SQLEXCEPTION CONTINUE
    SPOOL deployment.log
    @trigger_faef_c.sql
    @other_script.sql
    SPOOL OFF
    EXITRegards
    Peter

  • Sequence of begin/end blocks.Delete only if updated.Updte only if row exist

    Here is a sequence of events I need to perform.
    1) I need to update a table with the systime for a given id.
    2) Commit (so that the systime is stored before I delete)
    3) Once updated, delete row from that table for the given id so that the row moves to the audit table with the updated systime - added in step 2.
    For this I need to keep the following things in mind:
    a) Update only if that particular id (passed as IN parameter to the SP) exists. That is validate existence before updating/deleting.
    Here are questions ralted to the above scenario:
    1) How is this kind of validation usuallty performed?
    2) Update and delete will be in 2 separate begin exception end block?
    Example
    begin
        begin
        update...
           commit
        exception
           rollback
        end;
    delete...
    commit
    exception
    rollbacl
    endHowever if update fails for some reason, I do not wish to come to the delete option.
    How can I take care of that?
    Edited by: [email protected] on Oct 20, 2008 9:47 AM
    Edited by: [email protected] on Oct 20, 2008 9:48 AM

    Mass25 wrote:
    The reason why I commit after doing the update is so that when I delete, what I have updated goes to the audit table.But that would only be necessary if it was a seperate session trying to read the data.
    If you update data on a table then your own session will see that data at existing on the table whether you have committed it or not, whilst other sessions will only see that data once it is committed.
    A commit should be issued when it logically makes sense, not just to try and ensure that the data is on the table for yourself.
    What would happen if you update some data, commit it, someone else reads it in their session and then you go and delete it? They have read your updated data whereas if they do a read before you delete then it's more logical that they should have read the pre-updated data.
    It seems like you are trying to incorporate more steps than are necessary to perform a simple task.

  • Want to ignore exception in a begin-end block

    Hi,
    For a given plsql block (inside a procedure or function for example) I want to ignore a certain oracle exception. Ignore as in, it should not be raised at all.
    What I want to do is something like this -
    begin (tell somehow to NOT raise NO Data Found (NDF) )
    bq. select &lt;something&gt; \\ into  &lt;some Variable&gt; \\ from &lt;somewhere&gt;; \\ if sql%rowcount = 0 \\ then \\ +&lt;take action meant for NDF&gt;;+ \\ end if;
    end;
    Any Ideas ?
    cheers
    raghav..

    Justin,
    If you have queries that can properly return 0 or more rows, that is the natural way to implement that. It won't raise an exception if no data is found, it won't raise an exception if multiple rows are found.How can I write a query that would not raise an exception when 0 rows are returned ?
    I'm not clear on how a design can "not like the NDF as such". Why would you have to convert that to a business exception and pass it along to the caller? Why wouldn't you just handle the exception in your code if you expect that the NO_DATA_FOUND exception is valid.
    The design doesnt like NDF just because the end user has to receive a better response than "No Data was found". We want to include lots of contextual info about the error and the location etc. Even though the NDF is valid, I wont pass it along as such, I would probably convert it to a business exception which would probably say something like "no entities found for end client <ID>" etc..
    cheers
    raghav..

  • Ref Cursors... Query

    Hello,
    I have created the package which uses the ref cursor.
    I was able to compile the package.. I was not able to execute this package which calculates the sum of col1
    ====================================================
    create table temp123 (col1 number, col2 varchar2(10), col3 date);
    insert into temp123 values ( 1, 'A',sysdate-3);
    insert into temp123 values ( 2, 'B',sysdate-2);
    insert into temp123 values ( 3, 'C',sysdate-1);
    insert into temp123 values ( 4, 'D',sysdate);
    commit;
    create or replace package asu123 as
    type ref_def is record ( a_col temp123.col1%type,b_col temp123.col2%type, c_col temp123.col3%type);
    type rec_type is ref cursor return ref_def;
    function fun return rec_type;
    end;
    create or replace package body asu123 as
    function fun return rec_type
    as
    a_rec rec_type;
    begin
    open a_rec for select * from temp123;
    return a_rec;
    end;
    end;
    If I execute the below sql, it will work fine...
    select asu123.fun from dual;
    COL1 COL2 COL3
    1 A 04-NOV-04
    2 B 05-NOV-04
    3 C 06-NOV-04
    4 D 07-NOV-04
    =======================================================
    Some how I need to execute this query as which sum's the COL1 field.
    SELECT NVL (COUNT (*), 0) TOTALCOUNT,NVL (SUM (asu123.ref_def(sum(col1) ), 0) SUM_VALUE from dual;Any one have any inputs on this?. Thanks for your valuable feedback in advance.
    --Binny

    Either you are using cursor variables to solve the wrong problem or you are using them the wrong way. Consider these two different approaches. First, with REF CURSOR...
    SQL> CREATE TABLE temp123 (col1 number, col2 varchar2(10), col3 date)
      2  /
    Table created.
    SQL> INSERT INTO temp123 VALUES ( 1, 'A',sysdate-3)
      2  /
    1 row created.
    SQL> INSERT INTO temp123 VALUES ( 2, 'B',sysdate-2)
      2  /
    1 row created.
    SQL> INSERT INTO temp123 VALUES ( 3, 'A',sysdate-1)
      2  /
    1 row created.
    SQL> INSERT INTO temp123 VALUES ( 4, 'A',sysdate)
      2  /
    1 row created.
    SQL> INSERT INTO temp123 VALUES ( 5, 'B',sysdate+1)
      2  /
    1 row created.
    SQL> INSERT INTO temp123 VALUES ( 6, 'B',sysdate+2)
      2  /
    1 row created.
    SQL> CREATE OR REPLACE PACKAGE asu123 AS
      2      --  in 9i we can use the predeclared sys_refcursor and skip this bit
      3      TYPE rec_type is ref cursor ;
      4      FUNCTION recs RETURN rec_type;
      5      FUNCTION sums RETURN rec_type;
      6  END;
      7  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY asu123 AS
      2      FUNCTION recs RETURN rec_type
      3      AS
      4          a_rec rec_type;
      5      BEGIN
      6          OPEN a_rec FOR SELECT * FROM temp123;
      7          RETURN a_rec;
      8      END recs;
      9      FUNCTION sums RETURN rec_type
    10      AS
    11          a_rec rec_type;
    12      BEGIN
    13          OPEN a_rec FOR SELECT col2, COUNT (*) AS totalcount, sum(nvl(col1, 0)) AS sum_value 
    14                         FROM temp123
    15                         GROUP BY col2;
    16          RETURN a_rec;
    17      END sums;
    18  END;
    19  /
    Package body created.
    SQL> SELECT  asu123.recs FROM dual
      2  /
    RECS
    CURSOR STATEMENT : 1
    CURSOR STATEMENT : 1
          COL1 COL2       COL3
             1 A          05-NOV-04
             2 B          06-NOV-04
             3 A          07-NOV-04
             4 A          08-NOV-04
             5 B          09-NOV-04
             6 B          10-NOV-04
    6 rows selected.
    SQL> SELECT  asu123.sums FROM dual
      2  /
    SUMS
    CURSOR STATEMENT : 1
    CURSOR STATEMENT : 1
    COL2       TOTALCOUNT  SUM_VALUE
    A                   3          8
    B                   3         13...versus using NESTED TABLE...
    SQL> CREATE TYPE my_rec AS OBJECT (col1 number, col2 varchar2(10), col3 date);
      2  /
    Type created.
    SQL> CREATE TYPE my_tab AS TABLE OF my_rec;
      2  /
    Type created.
    SQL> CREATE OR REPLACE PACKAGE asu123 AS
      2      FUNCTION recs RETURN my_tab;
      3  END;
      4  /
    Package created.
    SQL> CREATE OR REPLACE PACKAGE BODY asu123 AS
      2      FUNCTION recs RETURN my_tab
      3      AS
      4          a_rec my_tab;
      5      BEGIN
      6          SELECT my_rec(col1, col2, col3) BULK COLLECT INTO a_rec
      7          FROM   temp123;
      8          RETURN a_rec;
      9      END recs;
    10  END;
    11  /
    Package body created.
    SQL> SELECT * FROM table(asu123.recs)
      2  /
          COL1 COL2       COL3
             1 A          05-NOV-04
             2 B          06-NOV-04
             3 A          07-NOV-04
             4 A          08-NOV-04
             5 B          09-NOV-04
             6 B          10-NOV-04
    6 rows selected.
    SQL> SELECT col2, COUNT (*) AS totalcount, sum(nvl(col1, 0)) AS sum_value
      2  FROM   table(asu123.recs)
      3  GROUP BY col2
      4  /
    COL2       TOTALCOUNT  SUM_VALUE
    A                   3          8
    B                   3         13
    SQL> Cheers, APC

  • Performance Problem While Selecting a Query....

    Hi Users
    I have problem with performance with appliction
    where are using D2K frent end and backend oracle 9i
    we have a validaion buttion that is taking lot of time to check the date like 500 records
    i want some links about performance issue process pls help.
    Here some of the query taking more than 1sec to more
    1)
    SELECT      
    /*+(INDEX(KBS_CHKSHTCARDTB(IND1_CHKSHTCARD))*/
    COUNT(DISTINCT A.KBCK_CHKSHEET_NO)
    FROM     
    KBS_CHKSHTCARDTB A ,KBS_CHKSHTHDRTB B                              WHERE A.KBCK_CHKSHEET_NO=B.KBCH_CHKSHEET_NO          
    AND KBCK_E_DATE =TRUNC(SYSDATE)
    AND KBCH_PRINT_STATUS='P'     
    OutPut: 206
    Time : 1sec
    2)
    UPDATE KBS_CARDMASTERTB
    SET KBCM_LOCK_FROM = KBCM_LOCK_FROM_CONTROL,
    KBCM_LOCK_STATUS= NULL
         WHERE KBCM_LOCK_FROM_CONTROL is not null
         and KBCM_LOCK_FROM IS NULL
         and KBCM_LOCK_FROM_CONTROL <=trunc(sysdate)      
         AND KBCM_LOCK_STATUS = 'Y'
    and KBCM_UNIQUE_IDNO IN(SELECT DISTINCT KBSA_UNIQUE_IDNO
    FROM KBS_SCANTB WHERE TRUNC(KBSA_E_DATE)      = TRUNC(:KANBAN_CTRL_BLK.DAT)
    AND KBSA_TRUCK_SQ_NO           = :Kanban_ctrl_blk.cycl
    AND KBSA_ERROR_CODE      IS NULL)
    AND (KBCM_VENDOR_NO,KBCM_PLANT_CODE)in (SELECT DISTINCT kbsa_vendor_no,KBSA_PLANT_CODE
    FROM KBS_SCANTB      WHERE TRUNC(KBSA_E_DATE)      = TRUNC(:KANBAN_CTRL_BLK.DAT)           AND KBSA_TRUCK_SQ_NO = :Kanban_ctrl_blk.cycl AND KBSA_ERROR_CODE      IS NULL)
    AND KBCM_PROCESS_CODE IN (SELECT DISTINCT KBSA_PROCESS_CODE
    FROM KBS_SCANTB                                              WHERE TRUNC(KBSA_E_DATE)      = TRUNC(:KANBAN_CTRL_BLK.DAT) AND KBSA_TRUCK_SQ_NO = :Kanban_ctrl_blk.cycl
    AND KBSA_ERROR_CODE      IS NULL);
    OutPut: Totatl Number of Table:29288
    Time : more than     5sec
    3)
    CURSOR GET_TEMP_CARDS_SWIPED_CUR IS
         SELECT KBCM_VENDOR_NO
                        ,KBCM_PLANT_CODE
                        ,KBCM_FAMILY --ADDED BY SUJITH.C TO SUPPORT PSMS2
                        ,KBCM_BACK_NO
                        ,KBCM_UNIQUE_IDNO
                        ,KBCM_KANBAN_TYPE
         FROM KBS_CARDMASTERTB
         WHERE KBCM_KANBAN_TYPE IN ('T','B')
         AND KBCM_UNIQUE_IDNO IN
    (SELECT KBSA_UNIQUE_IDNO
    FROM          KBS_SCANTB
    WHERE KBSA_E_DATE                = :DAT
    AND          KBSA_TRUCK_SQ_NO      = :CYCL
    AND KBSA_ERROR_CODE      IS NULL
    AND KBSA_TYPE IS NULL);
    Thanks Advance ........

    [When your query takes too long...|http://forums.oracle.com/forums/thread.jspa?messageID=1812597#1812597]
    [How to post a SQL statement tuning request|http://forums.oracle.com/forums/thread.jspa?threadID=863295&tstart=0]

  • How to pass dynamically table name in my cursor declaration

    Hi:
    I am new. could you please let me know how to pass a table name dynamically in my cursor declaration? for instance I am declaring the following cursor in my pl/sql procedure:
    CURSOR crs_validate IS
    select * FROM <ACT_JUN_2006_LOB>;
    this ACT_JUN_2006_LOB table name, I should able to pass it when I open the cursor ... any help appreciated. thanks.
    srini

    Thanks all for the response. REFCURSOR does work: here is an example ... which I found on-line
    procedure emp_test(
    month varchar2,
    year varchar2)
    is
    type cur_typ is ref cursor;
    c cur_typ;
    query_str varchar2(200);
    emp_number number := 7900;
    salary number;
    name varchar2(30);
    Begin
    query_str := 'Select empno, ename, sal from emp_' || month ||'_'||year
    || ' where empno = :id';
    open c for query_str using emp_number;
    loop
    fetch c into emp_number, name, salary;
    exit when c%notfound;
    dbms_output.put_line(emp_number);
    end loop;
    close c;
    end;

  • Performance Issue Executing a BEx Query in Crystal Report E 4.0

    Dear Forum
    I'm working for a customer with big performance issue Executing a BEx Query in Crystal via transient universe.
    When query is executed directly against BW via RSRT query returns results in under 2 seconds.
    When executed in crystal, without the use of subreports multiple executions (calls to BICS_GET_RESULTS) are seen. Runtimes are as long as 60 seconds.
    The Bex query is based on a multiprovider without ODS.
    The RFC trace shows BICS connection problems, CS as BICS_PROV_GET_INITIAL_STATE takes a lot of time.
    I checked the note 1399816 - Task name - prefix - RSDRP_EXECUTE_AT_QUERY_DISP, and itu2019s not applicable because the customer has the BI 7.01 SP 8 and it has already
                domain RSDR0_TASKNAME_LONG in package RSDRC with the
                description: 'BW Data Manager: Task name - 32 characters', data
                type: CHAR; No. Characters: 32, decimal digits: 0
                data element RSDR0_TASKNAME_LONG in package RSDRC with the
                description 'BW Data Manager: Task name - 32 characters' and the
                previously created domain.
    as described on the message
    Could you suggest me something to check, please?
    Thanks en advance
    Regards
    Rosa

    Hi,
    It would be great if you would quote the ADAPT and tell the audience when it is targetted for a fix.
    Generally speaking, CR for Enteprise  isn't as performant as WebI,  because uptake was rather slow .. so i'm of the opinion that there is improvements to be gained.   So please work with Support via OSS.
    My onlt recommendations can be :
    - Patch up to P2.12 in bi 4.0
    -  Define more default values on the Bex query variables.
    - Implement this note in the BW 1593802    Performance optimization when loading query views 
    Regards,
    H

  • Options to control display performance of CLOBs, etc. in Query Result view?

    Whenever I attempt to query a table that contains LOBs (e.g. a CLOB or XMLTYPE), the lack of performance pretty much makes the "Query Result" view (from F9) unusable. Any time I attempt to scroll the results, SQL developer apparently continues to query the database for the additional characters to populate the view.
    Resizing the columns containing the LOB to only a few characters almost solves the issue. Unfortunately, the size of the columns showing the LOBs apparently attempt to resize to the length of the LOB, making the column several pages long - and the same performance issue prevents resizing it smaller.
    Ideally, there would be some way to resize a column to a given or even a predefined and small size, without having to drag the resize handle the entire width of the desired resize amount. Alternatively, there could be a user preference to never set default column widths above a given number of pixels or characters. Another option would be a user preference to disable the in-line display of LOB contents, displaying only and requiring a click on the "..." (or pencil icon) button to open the "View Value" dialog. Ideally, all 3 of these options could be implemented.
    One crude work-around I'm using for now is to exclude the LOB columns from the results, requiring me to make secondary queries to see the LOB contents when necessary, and doesn't allow for scrolling through and viewing the LOB contents at all. Another work-around is to run the query as a script (F5) instead of a query (F9), and view the results in the "Script Output" view instead.
    I'm currently using SQL Developer 2.1.0.63, but experienced this same issue with all previous versions, including 1.5.5.
    Thanks!

    I agree.
    When I requested to auto-width the columns, I said to build in a maximum, but apparently they didn't.
    I suggest you log 2 feature requests on the SQL Developer Exchange; 1 for the maximum width, 1 for the CLOB contents/performance. Like this others can vote too and add weight for future implementation (I will).
    Have fun,
    K.

  • Can we perform restriction on attribute in query designer?

    Hi
    can we perform restriction on attribute in query designer? My scenario is to restrict on an attribute..Could any one help me out i this issue?
    Regards,
    Suman

    Hi,
    Restriction can be done only for navigational attribute.U cannot do restriction for display attirbute.
    if it is a display attribute u want to restrict -make it navigational for that infoobject.
    Also the attribute must be 'checked on' as navigational in the infoprovider as well on which the query is built.
    hope it helps.
    Regards,
    Rathy

  • ORA-20001:Error fetching column value:Query must  begin with SELECT or WITH

    Hi all,
    I have implemented an application with a master-detail form using Apex 3.1.2 and I imported that to Apex 3.2 on different server. Everything else seems to be fine except when I add detail record (clicking on Add Rows), I am getting following error.
    =================
    report error:
    ORA-20001: Error fetching column value: ORA-20001: Query must begin with SELECT or WITH
    ====================
    Both the databases have same version 10gR2. I didn't make any change after importing it as well. Can someone let me know what could be the issue? Thanks in advance.
    SHY

    May we know your first name?
    Can you put the application in your workspace on apex.oracle.com so we can take a look?
    Scott

  • ORA-20001: Query must begin with SELECT or WITH

    Hi,
    On a page we have a hidden item :P3_SQL in which we save the dynamic sql query.
    We have a report region of SQL QUERY type whose source is this item :P3_SQL.
    This used to work fine in apex 3.*. We have upgraded our application to 4.0.1 and now we get this error.
    ORA-20001: Query must begin with SELECT or WITH
    I have a workaround for this, but just wanted to make sure somebody recognizes this as a bug in our latest apex version.
    Thanks
    Knut

    Hello Knut,
    I'm not sure if you encountered a bug or an improved validation of your query. If you had just ":P3_SQL" as source, this obviously is neither a correct query nor is it a function returning a query. I guess your workaround is actually encapsulating ":P3_SQL" in a block that returns the value. This is the intended way, not a bug. You just were lucky it was not validated and worked in previous versions.
    If my assumption was wrong, please post both working and non-working solution and a more precise description on when this error actually occurs.
    Thanks,
    Udo

Maybe you are looking for

  • Can not see web forms

    I have installed two versions of forms developer on my pc: 1. Forms [32 Bit] Version 9.0.4.2.0 (Production) 2. Forms [32 Bit] Version 10.1.2.0.2 (Production) http://pc4711.mycompany.lan:8888/forms90/f90servlet?form=myforms.fmx&userid=scott/tiger@orcl

  • Primary key vs Secondary key - why would a rpt hit one as to the other?

    Post Author: kevans CA Forum: Data Connectivity and SQL Here's an issue that surfaced when using CRW10, happens with XI as well, but not an issue with CRW8 - each one is hitting the same SQL Server db. I discovered something today and I'm not sure if

  • To connect oracle database with ms access database

    i want to connect oracle database with ms access database i have follow the following steps 1. create ms access database. 2. create system dsn. 3. make change in listener.ora. 4. make change in hs folder. 5.change the tnsname.ora. 6. lsnrctl stop and

  • How to set the customized template as Default ??

    I have created a new view based on the Classic View template and added it through MyProfile--> Search Template in Admin Console of UCM. But the change is specific to a user only. I want it to make as default so that every user can get this template a

  • Mac pro running 10.6 won't boot

    My Mac pro is late (2007) running OSX 10.6 (should be newest update). Can't get in to see any if my specs to give you more info. Mac keeps rebooting I tried resetting PRam, booting into safe mode, booting into firmware and booting from CD none of whi