Cursor query retrieves records in anon pl/sql block but no data in store pr

Hello,
Can any one please help me,
I am using the below query, to get the table name and constraint name
select table_name,constraint_name
from all_constraints
where constraint_type in ('R','P')
and status = 'ENABLED'
and owner='IRIS_DATA'
order by constraint_type desc;
The below query retrieves data in anonymous pl/sql block and retrieve no data when i use the same cursor with the same query in procedure inside the package.
CREATE USER CLONEDEV
IDENTIFIED BY CLONE123
DEFAULT TABLESPACE IRIS
TEMPORARY TABLESPACE TEMP;
GRANT DBA TO CLONEDEV;
the user from which i am executing this query is granted dba role.
My oracle version is 10.2.0.4
Please update if you any other information.
Please advice.
Thanks

>
Roles cannot be used by pl/sql.
>
NOT TRUE!
That is an oft quoted myth. There are many posts in the forum that mis-state this.
Roles can be, and are used by PL/SQL. In fact, OP stated and demonstrated that in their question: their anonymous block worked.
The Oracle docs provide a very clear explanation - the core restriction is for NAMED PL/SQL blocks that use DEFINER's rights (the default):
>
Roles Used in Named Blocks with Definer's Rights
All roles are disabled in any named PL/SQL block (stored procedure, function, or trigger) that executes with definer's rights. Roles are not used for privilege checking and you cannot set roles within a definer's rights procedure.
>
The Database Security Guide has the information in the section 'How Roles Work in PL/SQL Blocks (which, of course, wouldln't be needed if they didn't work. ;) )
http://docs.oracle.com/cd/B28359_01/network.111/b28531/authorization.htm#i1007304
>
The use of roles in a PL/SQL block depends on whether it is an anonymous block or a named block (stored procedure, function, or trigger), and whether it executes with definer's rights or invoker's rights.
Roles Used in Named Blocks with Definer's Rights
All roles are disabled in any named PL/SQL block (stored procedure, function, or trigger) that executes with definer's rights. Roles are not used for privilege checking and you cannot set roles within a definer's rights procedure.
The SESSION_ROLES view shows all roles that are currently enabled. If a named PL/SQL block that executes with definer's rights queries SESSION_ROLES, then the query does not return any rows.
See Also:
Oracle Database Reference
Roles Used in Named Blocks with Invoker's Rights and Anonymous PL/SQL Blocks
Named PL/SQL blocks that execute with invoker's rights and anonymous PL/SQL blocks are executed based on privileges granted through enabled roles. Current roles are used for privilege checking within an invoker's rights PL/SQL block. You can use dynamic SQL to set a role in the session.

Similar Messages

  • Set  mo_global.set_policy_context in sql developer,But no datas to view

    Hi All
    I have query some tables in sql developer.but no datas retrivee
    So i have try to set the MO_global based on org_id
    BEgin
    Apps.Mo_Global.Set_Policy_Context('S',81);
    End;
    Begin
    Dbms_Application_Info.Set_Client_Info(81);
    End;
    " select * from Mfg_lookups; " - no data showing in sql developer
    How can i fix the issue in sql developer
    Thanks

    Hello,
    Please check if Note 415860.1 : "How to view org-specific data in a MOAC environment" can help.
    Regards, Carlo.

  • Apex 4.0 - Can see view data in SQL*Plus but no data in Object Browser

    Hi There,
    I have just started using Apex 4.o and migrated some apps. I have an issue with a report, but see the same issue with Object browser, which is easier to describe.
    I have a view:
    create or replace view V_PLJ_USERDEF_CODES (
             CODE_SET_ID,
             CODE_SET_CODE,
             CODE_SET_DESC,
             CODE_ID,
             CODE_SYS_CODE,
             CODE_VALUE,
             CODE_DESC,
             DISPLAY_SEQ,
             DISPLAY_FLAG,
             LANGUAGE_CODE) as
      select CS.CODE_SET_ID,
             CS.CODE_SET_CODE,
             CS.CODE_SET_DESC,
             C.CODE_ID,
             C.CODE_SYS_CODE,
             C.CODE_VALUE,
             C.CODE_DESC,
             C.DISPLAY_SEQ,
             C.DISPLAY_FLAG,
             C.LANGUAGE_CODE
        from PLJ_CODES C,
             PLJ_CODE_SETS CS
       where C.CODE_SET_ID         = CS.CODE_SET_ID
         and CS.CODE_SET_TYPE_CODE = SYS_CONTEXT('PLJUMPSTART','C_USERDEF_CODE_SET');This returns data in SQL*Plus, but no data in Object Browser OR report region based on this view.
    Workspace parses in the same schema as tested in SQL*Plus.
    If, in report, I swap out view, and use underlying table - no problem.
    Any ideas -
    thanks
    P

    Hi all,
    Thanks for getting back so promptly.
    It just seems weird to me, as tables are just fine, but not views.
    In the underlying schema:
    SQL> sho user
    USER is "ICSREPORTING"
    SQL> select count(*) from plj_codes;
      COUNT(*)
           107
    SQL> select count(*) from v_plj_userdef_codes;
      COUNT(*)
            29And in the APEX schema
    SQL> sho user
    USER is "APEX_040000"
    SQL> select count(*) from icsreporting.plj_codes;
    select count(*) from icsreporting.plj_codes
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL> select count(*) from icsreporting.v_plj_userdef_codes;
    select count(*) from icsreporting.v_plj_userdef_codes
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL>However, in SQL browser, I can see the data in PLJ_CODES but in V_PLJ_USERDEF_CODES, just the message "This view has no data". Indeed, it is like this for all views.
    I even explicitly granted access to APEX_040000 but no good.
    In fact, I would like to know more about how Apex gets access to do DML against the underlying parsing schema(s).
    This is a little frustrating though. It worked just fine in lots of apps in version 2.1 to 3.2
    Am I missing something
    paul
    p.s I knew there would be a question about the context, but I had already checked that. :)
    Edited by: PJ on Nov 19, 2010 4:09 AM

  • I know I can retrieve voicemails from callers I have blocked but is there anyway to retrieve imessages from blocked callers?

    I know I can retrieve voicemails from callers I have blocked but is there anyway to retrieve imessages that were sent while a caller was blocked?

    No.

  • Inner Query is excuting properly in 10g SQL developer, but not in Form 6i

    Hi All,
    I am able to excute below query in Oracle SQL developer in 10g , but when I tried to excute it in Forms 6i on WHEN-NEW-FORM_INSTANCE trigger, it is giving me below error message
    SELECT okl2.line_number subline_number, okl2.sts_code subline_status,
    okl2.start_date subline_start_date, okl2.end_date subline_end_date,
    okl2.date_terminated,oks.cognomen line_ref,okl2.ID subline_id,okl2.lse_id,
    (SELECT orig_model_no
    FROM apps.emcoks_msh_subst_models sm
    WHERE okh.contract_number = sm.contract_number
    AND okl.line_number = record_line_id) orig_model_no,
    (SELECT orig_model_qty
    FROM apps.emcoks_msh_subst_models sm
    WHERE okh.contract_number = sm.contract_number
    AND okl.line_number = record_line_id) orig_model_qty
    FROM apps.okc_k_lines_b okl2,
    apps.okc_k_headers_b okh,
    apps.okc_k_lines_b okl,
    apps.okc_k_items oki ,
    apps.okc_k_lines_tl oks
    WHERE 1 = 1
    AND okl2.dnz_chr_id = okl.chr_id
    AND okl.lse_id = 1
    AND okl2.lse_id IN (7, 9)
    AND okl.ID = okl2.cle_id
    AND okl.ID = oki.cle_id
    AND okl2.ID = oks.ID
    AND okl.chr_id = okh.ID
    AND okl2.dnz_chr_id = okh.ID
    AND okl.ID = 130246066126590818122526020119476052469
    order by subline_id;
    Error 103 : Encountered the symbol "Select" when expecting one of the following
    ( - + mod not null others <an identifier>

    I am new to Oracle Forms. Could you please guide me, how to create this statement as a view in the database ?
    I have tried to rewrite it using OUTER JOIN, but I am not getting same results.
    SELECT okl.line_number subline_number, okl.sts_code subline_status,
    okl.start_date subline_start_date, okl.end_date subline_end_date,
    okl.date_terminated,oks.cognomen line_ref,okl.ID subline_id,okl.lse_id,
    sm.orig_model_no orig_model_no,
    sm.orig_model_qty orig_model_qty
    FROM apps.okc_k_lines_b okl2,
    apps.okc_k_headers_b okh,
    apps.okc_k_lines_b okl,
    apps.okc_k_items oki ,
         apps.okc_k_lines_tl oks
    , apps.emcoks_msh_subst_models sm
    WHERE 1 = 1
    AND okl2.dnz_chr_id = okl.chr_id
    AND okl.lse_id = 1
    AND okl2.lse_id IN (7, 9)
    AND okl.ID = okl2.cle_id
    AND okl.ID = oki.cle_id
    AND okl2.ID = oks.ID
    AND okl.chr_id = okh.ID
    AND okl2.dnz_chr_id = okh.ID
    AND okl.ID = 130246066126590818122526020119476052469
    AND okh.contract_number (+) = sm.contract_number
    AND okl.line_number (+) = sm.record_line_id
    order by subline_id;
    Edited by: Swarup_C on May 8, 2013 6:46 AM

  • Retrieving records using SQL Date Queries

    Hello,
    I am using Lab Windows CVI 8.5 and also SQL TOolkit for my project. I am using DBMapColumnToChar function for mapping Date to the database. And for retrieving records I am using SQL Query as follows:
    SELECT * FROM DBTable WHERE DATE_TABLE BETWEEN '%s' AND '%s'",cCurrentDate,cCurrentDate
    I have given a drop down for selecting dates.
    When I execute the query I am not getting the selected date values an instead I am getting some records for which the dates aren't selected...
    Quick help needed for this..Thanks in advance

    Depending on the database, the date/time structure can be completely different from the structure in CVI.  CVI uses the Windows format for time(), that is the number of seconds since 1900.  The tm struct can break this apart into a date and time structure that is usable.
    I am using MS Access for the databases and SQL toolkit.  I finally ended up replace the date field with an INT field format, and then store the CVI time (gotten with time()) as an INT value.
    Easy then to get a search range, store it a tm struct and then convert with mktime() to a calendar time to search with.
    Hope this helps.  The date/time thing is a never ending struggle.
    Regards, David E.

  • How to print/store in file the ref cursor in pl/sql block ?

    How to print/store in file the ref cursor in pl/sql block ?.

    How to print/store in file the ref cursor in pl/sql block ?.You question is quite confusing?
    So, i'm providing link in this manner.
    For RefCursor,
    http://www.oracle-base.com/articles/misc/UsingRefCursorsToReturnRecordsets.php
    http://www.oracle.com/technology/oramag/code/tips2003/042003.html
    For UTL_FILE,
    http://www.morganslibrary.org/reference/utl_file.html
    Regards.
    Satyaki De.
    Updated with new morgan library link.
    Edited by: Satyaki_De on Feb 24, 2010 9:03 PM

  • Calling DBMS_STATS within PL/SQL block

    Hy guys
    I trying to call the package DBMS_STATS within a pl/sql block but I'm getting the following error..
    here is my blok
    BEGIN
    IF FGLOBAL('ABC_STATS') = 'SIM' THEN
    FOR V_OBJETOS IN C_CURSOR_STATS LOOP
    EXECUTE IMMEDIATE 'EXEC DBMS_STATS.GATHER_TABLE_STATS('''||USER||''','''||V_OBJETOS.TABLE_NAME||''')';
    END LOOP;
    END IF;
    here is the execution error
    SQL> exec analisa_stats;
    BEGIN analisa_stats; END;
    ERROR on line 1:
    ORA-00900: invalid SQL instruction
    ORA-06512: on "username.ANALISA_STATS", line 12
    ORA-06512: on line 1
    How can I call the package using execute immediate ? is there any other way ?
    Tks to All

    Hi,
    1. in pl/sql you cannot specify "exec dbms_stats ..." but only "dbms_stats ...".
    2. why execute immediate, just call dbms_stats and pass your parameters
    regards, martina

  • Query returns record in SQL Developer but not in iSQLPlus

    ... back in a minute, I may not have done a commit at the end of the insert.
    The problem I was having was I hadnt commited the record in SQL Developer but the queries where returning records in this environment but not in iSQLPlus or Apex and it was confusing me.
    Message was edited by:
    Benton
    Message was edited by:
    Benton

    Finally got to know the reason why Timezone Abbr woudn't show up in SQL Plus.
    I ran below query in SQL PLUS
    SELECT SESSIONTIMEZONE, CURRENT_TIMESTAMP, systimestamp, LOCALTIMESTAMP FROM DUAL;
    SESSIONTIMEZONE CURRENT_TIMESTAMP SYSTIMESTAMP LOCALTIMESTAMP
    -05:00 08-SEP-12 12.00.31.575228 AM -05:00 08-SEP-12 12.00.31.575223 AM -05:00 08-SEP-12 12.00.31.575228 AM
    Now executed the same query in SQL Developer:
    SESSIONTIMEZONE CURRENT_TIMESTAMP SYSTIMESTAMP LOCALTIMESTAMP
    America/Chicago     08-SEP-12 12.08.32.072424000 AM AMERICA/CHICAGO     08-SEP-12 12.08.32.072420000 AM -05:00     08-SEP-12 12.08.32.072424000 AM
    The difference between the 2 outputs is the way in which time_zones were respresented. In SQL PLUS, it is shown as an offset whereas in SQL Developer as a time zone region name. Now there are many "time sone regions" that follow an offset of -5:00. This confuses Oracle and a "UNK"(Unknown) for a query like the one below when trying to execute in SQL PLUS:
    select extract(timezone_abbr from from_tz(cast(sysdate as timestamp),SESSIONTIMEZONE)) from dual;
    EXTRACT(TI
    UNK
    Therefore we need to specify the exact Time Zone Region(TZR) in order to obtain the corresponding TZD(Daylight Savings Format i.e. CDT or CST). This we do by altering the session environment vaiable time_zone
    alter session set time_zone='America/Chicago';
    Now executing the queries to find the abbreviated time zone( in TZD format) will finally work to return a non-null char value.
    select extract(timezone_abbr from from_tz(cast(sysdate as timestamp),SESSIONTIMEZONE)) from dual;
    EXTRACT(TI
    CDT
    select to_char(CURRENT_TIMESTAMP, 'TZD') from dual;
    TO_CHA
    CDT

  • Retrieving records from a Data Block same as retrieving records from cursor

    Dear Gurus,
    Is it possible to retrieve records from a datablock same as retrieving records from a cursor,
    Eg:
    I am having two data blocks in two different tabs, Say B1 in Tab1, B2 in Tab2
    B1 is filled with two records, now when I switch to Tab2,
    I want all records of B1 in B2, assuming that blocks are having the same structure.
    The code I wish to write is,
    Goto B1,
    Take all the records like a cursor,
    Goto B2,
    loop
    insert
    end loop;
    Is this possible???

    I need to show it before saving,
    I tried this and it is successful somehow, do not know about any further problems,
    I took the record count of both blocks
    if :B1.reccount <> :B2.reccount
                   then
                   go_block('B1');
                   first_record;
                   for i in 1..:B1.reccount
                   loop
                        go_block('B1');
                        go_record(i);
              assign values from B1 to variables.
              go_block('B2');
              assign values from variables to B2
              next_record;
                   end loop;
                   clear_record;
              end if;
    This is working, Now I just want to know, if my block is having numerous fields, say more than 100 (may not be a value for large databases)
    how can I replace these variables here.
    I mean is it possible to declare something like a cursor record type.
    For eg : r1 cursor%rowtype

  • Retrieving a single value from sql:query

    Hi all, pretty new to jsp and tag libraries so appoligies if this isn't the correct forum or my question is a bit lame...
    I've got a basic input form written in JSP and i'm trying to use AJAX to return a customers name when they input there customer IS. My AJAX interaction works ok and so far i have got it to return a string value to indicate if the customer ID is valid or invalid.
    However, now i want to return the customers name based on a SELECT SQL statement. My sql works ok but i can't figure out how to return / access the single cname field that is returned. ALL the <sql:query> examples that i have seen use a <c:forEach> loop but this doesn't seem to work for me.
    My AJAX / Jsp code looks like this:
    <%@ page contentType="text/html" info="Customer Id Lookup" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
    <sql:setDataSource scope="application"
       driver="com.mysql.jdbc.Driver"
       url="jdbc:mysql://localhost:3306/dbawp"
       user="*******"
       password="********"
    />
    <sql:query var="qryValidCustomer" >
        SELECT cname FROM camper WHERE cid = ?;
        <sql:param value="${param.data}"/>
    </sql:query>
    <c:choose>
    <c:when test="${qryValidCustomer.rowCount == 0}">
    unknown camper
    </c:when>
    <c:otherwise>
    <c:forEach items="${qryValidCustomer.row}" var="row">
    ${fn:escapeXml(row.cname)}                                                         <- Doesn't seem to work - i get nothing returned
    </c:forEach>
    <%--good camper--%>
    </c:otherwise>   
    </c:choose>Can anyone point me in the right direction?
    Manythanks in advance,
    Sam

    > my db fields contain a list of sections, " 1,2,3,4,"
    When you find yourself storing delimited lists in a field,
    that's a sign that you should
    normalize
    your data. Storing lists is difficult to query, error prone and bad
    for performance.
    A separate table should be used to represent a many-to-many
    relationship.
    Table - Columns
    Advertisement - AdvertisementID, AdvertisementDescription,
    ...other columns
    Type - TypeID, TypeTitle, ...
    AdvertisementType - AdvertisementID, TypeID
    Instead of storing the related types as a list
    AdvertisementID | TypeID
    1 | 1,2,3,4
    Store them as separate records in the 3rd table
    AdvertisementID, TypeID
    1, 1 (ad # 1, type # 1)
    1, 2 (ad # 1, type # 2)
    1, 3 (ad # 1, type # 3)
    1, 4 (ad # 1, type # 4)

  • Select AR_LOOKUPS retrieved no record while in pl/sql plus record exist

    I ran "select * from ar_lookups" no record retrieved while when I run the same script in TOAD or pl/sql plus there are records retrieve.

    Sorry for the very late response, but the problem is probably related to AR_LOOKUPS being an eBusiness Suite language specific view, which means the conditions in the view include:
    LV.LANGUAGE = userenv('LANG')SQL Developer defaults the NLS settings based on the Regional Settings (assuming you are on Windows) and not the Oracle registry entries (what is typically used by other tools), although you can change this by explicitly setting your NLS preferences via Tools > Preferences > Database > NLS Parameters.
    If your only installed transaction for the eBusiness Suite is US (for example), but your SQL Developer NLS settings are such that userenv('LANG') doesn't return US, you will not get any records returned by the AR_LOOKUPS view (or any of the other many language specific views). To get SQL Developer to match the NLS behaviour of other tools, set your NLS parameters to match what you have set in the Oracle registry entries.
    theFurryOne

  • Cursors are not closed when using Ref Cursor Query in a report  ORA-01000

    Dear Experts
    Oracel database 11g,
    developer suite 10.1.2.0.2,
    application server 10.1.2.0.2,
    Windows xp platform
    For a long time, I'm hitting ORA-01000
    I have a 2 group report (master and detail) using Ref Cusor query, when this report is run, I found that it opens several cursors (should be only one cursor) for the detail query although it should not, I found that the number of these cursors is equal to the number of master records.
    Moreover, after the report is finished, these cursors are not closed, and they are increasing cumulatively each time I run the report, and finally the maximum number of open cursors is exceeded, and thus I get ORA-01000.
    I increased the open cursors parameter for the database to an unbeleivable value 30000, but of course it will be exceeded during the session because the cursors are increasing cumulatively.
    I Found that this problem is solved when using only one master Ref Cursor Query and create a breake group, the problem is solved also if we use SQL Query instead of Ref Query for the master and detail queries, but for some considerations, I should not use neither breake group nor SQL Query, I have to use REF Cursor queries.
    Is this an oracle bug , and how can I overcome ?
    Thanks
    Edited by: Mostafa Abolaynain on May 6, 2012 9:58 AM

    Thank you Inol for your answer, However
    Ref Cursor give me felxibility to control the query, for example see the following query :
    function QR_1RefCurDS return DEF_CURSORS.JOURHEAD_REFCUR is
    temp_JOURHEAD DEF_CURSORS.JOURHEAD_refcur;
              v_from_date DATE;
              v_to_date DATE;
              V_SERIAL_TYPE number;
    begin
    SELECT SERIAL_TYPE INTO V_SERIAL_TYPE
    FROM ACC_VOUCHER_TYPES
    where voucher_type='J'
    and IDENT_NO=:IDENT
    AND COMP_NO=TO_NUMBER(:COMPANY_NO);
         IF :no_date=1 then
                   IF V_SERIAL_TYPE =1 THEN     
                   open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
                   FROM JOURHEAD
                   WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
                   AND IDENT=:IDENT
              AND ((TO_NUMBER(VOCH_NO)=:FROM_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NULL)
              OR (TO_NUMBER(VOCH_NO) BETWEEN :FROM_NO AND :TO_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NOT NULL )
              OR (TO_NUMBER(VOCH_NO)<=:TO_NO and :FROM_NO IS NULL AND :TO_NO IS NOT NULL )
              OR (:FROM_NO IS NULL AND :TO_NO IS NULL ))
                   ORDER BY TO_NUMBER(VOCH_NO);
                   ELSE
                   open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
                   FROM JOURHEAD
                   WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
                   AND IDENT=:IDENT               
              AND ((VOCH_NO=:FROM_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NULL)
              OR (VOCH_NO BETWEEN :FROM_NO AND :TO_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NOT NULL )
              OR (VOCH_NO<=:TO_NO and :FROM_NO IS NULL AND :TO_NO IS NOT NULL )
              OR (:FROM_NO IS NULL AND :TO_NO IS NULL ))     
                   ORDER BY VOCH_NO;          
                   END IF;
         ELSE
                   v_from_date:=to_DATE(:from_date);
                   v_to_date:=to_DATE(:to_date);                         
              IF V_SERIAL_TYPE =1 THEN
                   open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
                   FROM JOURHEAD
                   WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
              AND IDENT=:IDENT                         
                   AND ((voch_date between v_from_date and v_to_date and :from_date is not null and :to_date is not null)
                   OR (voch_date <= v_to_date and :from_date is null and :to_date is not null)
                   OR (voch_date = v_from_date and :from_date is not null and :to_date is null)
                   OR (:from_date is null and :to_date is null ))     
                   ORDER BY VOCH_DATE,TO_NUMBER(VOCH_NO);     
              ELSE
                   open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
                   FROM JOURHEAD
                   WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
                   AND IDENT=:IDENT                         
              AND ((voch_date between v_from_date and v_to_date and :from_date is not null and :to_date is not null)
                   OR (voch_date <= v_to_date and :from_date is null and :to_date is not null)
                   OR (voch_date = v_from_date and :from_date is not null and :to_date is null)
                   OR (:from_date is null and :to_date is null ))     
                   ORDER BY VOCH_DATE,VOCH_NO;          
              END IF;
         END IF;               
         return temp_JOURHEAD;
    end;

  • Cursor query works in anonymous block but not in procedure

    Hello,
    My cursor query works fine in anonymous blcok but fails in pl/sql block.
    Anonymous block:
    declare
    cursor c1 is
    select object_name
    from all_objects
    where owner='IRIS_DATA'
    and object_type='SEQUENCE';
    v_string varchar2(2000);
    begin
    for c2 in c1 loop
    v_string := 'DROP SEQUENCE IRIS_DATA.'||c2.object_name;
    execute immediate v_string;
    end loop;
    commit;
    exception
    when others then
    dbms_output.put_line('Exception :'||sqlerrm);
    end;
    works fine.
    but inside the procedure the it doesn't go inside the cursor loop
    procedure get_sequence is
    l_dp_handle NUMBER;
    v_job_state varchar2(4000);
    l_last_job_state VARCHAR2(30) := 'UNDEFINED';
    l_job_state VARCHAR2(30) := 'UNDEFINED';
    l_sts KU$_STATUS;
    v_logs ku$_LogEntry;
    v_row PLS_INTEGER;
    v_string1 varchar2(2000);
    cursor seq_obj is
    select object_name
    from all_objects
    where owner='IRIS_DATA'
    and object_type='SEQUENCE';
    begin
         log_status('get_sequence started.');
         --Cursor records to drop the sequences before importing.
         for seq_obj_rec in seq_obj loop
    log_status('get_sequence: Dropping sequence started.');
         v_string1 := 'DROP SEQUENCE IRIS_DATA.'||seq_obj_rec.object_name;
    execute immediate v_string1;
         end loop;
         log_status('get_sequence: Dropping sequence completed.');
    exception
    WHEN OTHERS THEN
    log_status('get_sequence: exception.');
    end get_sequence;
    it's not going into the seq_obj_rec cursor.
    I granted select on all_objects to the user.this user is also having the DBA role as well.
    Please advice.

    PROCEDURE Get_sequence
    IS
      l_dp_handle      NUMBER;
      v_job_state      VARCHAR2(4000);
      l_last_job_state VARCHAR2(30) := 'UNDEFINED';
      l_job_state      VARCHAR2(30) := 'UNDEFINED';
      l_sts            KU$_STATUS;
      v_logs           KU$_LOGENTRY;
      v_row            PLS_INTEGER;
      v_string1        VARCHAR2(2000);
      CURSOR seq_obj IS
        SELECT object_name
        FROM   all_objects
        WHERE  owner = 'IRIS_DATA'
               AND object_type = 'SEQUENCE';
    BEGIN
        Log_status('get_sequence started.');
        --Cursor records to drop the sequences before importing.
        FOR seq_obj_rec IN seq_obj LOOP
            Log_status('get_sequence: Dropping sequence started.');
            v_string1 := 'DROP SEQUENCE IRIS_DATA.'
                         ||seq_obj_rec.object_name;
            EXECUTE IMMEDIATE v_string1;
        END LOOP;
        Log_status('get_sequence: Dropping sequence completed.');
    EXCEPTION
      WHEN OTHERS THEN
                 Log_status('get_sequence: exception.');
    END get_sequence; How do I ask a question on the forums?
    SQL and PL/SQL FAQ
    scroll down to #9 & use tags in the future.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Query works in SQL Developer but not in Oracle APEX

    The query below runs and produces the correct result in SQL Developer, but when I try to put it into a PL/SQL process in Apex I get the error shown. There is no semi-colon at the end of the query in APEX.
    The error is:
    ORA-06550: line 10, column 54: PL/SQL: ORA-00933: SQL command not properly ended ORA-06550: line 2, column 1: PL/SQL: SQL Statement ignored ORA-06550: line 11, column 21: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: ( begin case declare end exception exit for goto if loop mod null pragma raise return select update while with.
    The query is:
    SELECT *
    FROM
    (SELECT *
    from T3_LEADS
    WHERE
    (SYSDATE - Last_Mailed_Date) > 60 OR Last_Mailed_Date is null
    WHERE MARKET_ID = 'Salt_Lake_City' AND rownum <= 100

    That is because when you run a SQL in SQL*Plus or SQLDeveloper the output is displayed on the screen, but in Apex you need to select those values into variables so you can do something with the data.
    delcare
      v_emp_id    employee.emp_id%type;
    begin
      select emp_id
        into v_emp_id
        from employee
      where lname = 'JOHNSON' and fname = 'BILLY';
      -- Then do something with that data
      if v_emp_id between 1 and 10 then
      end if;
    end;Probably a bad SQL for an example. For your SQL though, you are selecting * which you would be able to select into a rowtype variable, but you are probably going to start having problems like "Exact fetch returns more that one row" since your query will probably return more that one value. In those cases you want to use cursors, and loop through the data one record at a time. You can Google all of that.

Maybe you are looking for

  • Paging in JSP using

    Hi!! How to do paging in JSP using SQL SERVER 2000. In my SQL we can fire query like ResultSet resultado = declaracao.executeQuery("Select * from tbl_livro limit 20,5 "); It means that it fetches 20 onwards 5 records.. how to do same thing in SQL SER

  • Is there a way to display a "loading screen" for dataGrid?

    Hi All, I have a dataGrid that is loading a lot of data and it takes a good 5 seconds before all the data is loaded and displayed into the dataGrid. I would like to show a loading screen that has a nice little loader animation when the data is being

  • Sentense as an output

    Below is my program which takes a file as an input and output the same file but with a word in each line. e.g this is an example //start import java.io.*; import java.util.*; import java.util.StringTokenizer; class FileReaderDemo { public static void

  • Backslash & Pipe key not functioning in Arch on Chromebook C710

    Hello, I am unable to figure out why my backslash / pipe key is not functioning on my Acer C710 chromebook. Every other key appears to work. I check the forums and the Wiki but I was unable to find a solution. Here is my localectl status:    System L

  • What album is photo in?

    Is there a way to click on a photo in the library and find out what album it is in, if any? Thanks.