Using cursor to query from data dictionary

Hi
I am having a weird problem.
In a procedure, I like to compress some tables
so I wrote a cursor like this:
CURSOR crs IS SELECT OWNER,TABLE_NAME FROM ALL_TABLES WHERE TABLE_NAME LIKE '%ABC';then I'm opening the cursor in for loop and running
xSql := 'ALTER TABLE ' || X.OWNER || '.' || X.TABLE_NAME || ' MOVE COMPRESS';
EXECUTE IMMEDIATE (xSql);Now strangely enough, my cursor is not fetching any record at all inside procedure!
But when I run the cursor select statement of its own in SqlPlus, it does fetch lots of record!
So, what's wrong??
Edited by: movilogo on Jun 30, 2010 9:25 AM

Full code
CREATE OR REPLACE PROCEDURE COMPRESS_ABC_TABLES IS
    -- to compress tables
    CURSOR crs IS SELECT OWNER,TABLE_NAME FROM ALL_TABLES WHERE TABLE_NAME LIKE '%ABC';
    xSql VARCHAR2(1000);
BEGIN
    FOR X IN crs
    LOOP
            BEGIN
                xSql := 'ALTER TABLE ' || X.OWNER || '.' || X.TABLE_NAME || ' MOVE COMPRESS';
                DBMS_OUTPUT.PUT_LINE(xSql);
                EXECUTE IMMEDIATE (xSql);
            EXCEPTION
                WHEN OTHERS THEN
                    DBMS_OUTPUT.PUT_LINE(SQLERRM);
            END;
    END LOOP;
END;Edited by: movilogo on Jun 30, 2010 9:53 AM

Similar Messages

  • WebI:Creating a minus query from data providers not using the same universe

    Hi there. A client of ours wishes to use Combined Query on multiple universes in the same WebI report. So far, I have heard it is not feasible in WebI. I know it is possible in DeskI. Even the sub-query option is limited to just one universe in WebI. So, I am stuck.
    Is there a workaround to creating a minus query from data providers not using the same universe in WebI?

    Hello Amit,
    what are the Datasources ? Usually when you create a Sub Query you can choose a seperate Universe.
    Maybe if you only see one Universe you only have the rights for this Universe ?!.
    Regards
    -Seb.

  • Select schemas from relational model on import from data dictionary option

    Hi All,
    I have one relational model with 3 diferent schemas,
    I want to compare one of my schemas with the data dictionary I have in a database,
    I select the import option in the general file menu, select from data dictionary option,
    select the connection from my database,swap target model checked,select a physical model and select the objects i want to compare from the database,
    My problem is that the result is the comparison between all the objects in my model and the objects in the database that I have selected,
    what I really want is to compare a list of objects in my model to a list of objects in my database,
    this could be possible? or always need to compare all the objects of the model?
    Thanks in advance

    Hi jbellver,
    there is no any development in DM 3.1.0.691 on that problem. In production release you'll be able to compare objects in subview with database or just to select several objects and compare them with database. And of course "generate in DDl" filtering still can be used - it works at "Compare dialog" level.
    Philip

  • How to find function and SP from data dictionary?

    For example:
    create or replace package SPK_A is
    lv_empno number;
    lv_deptno number;
    function FUN_A(in_empno number) return varchar2;
    function SP_A(in_deptno number) return varchar2;
    end;
    Then, how can i to find FUN_A and SP_A from data dictionary.
    and mark the former is a function, the latter is a stored procedure.
    I have tried to use the following 2 views, but i cannot give me the answer.
    (1)dba_procedures: it can only find the sole function or sole stored procedure, which is not define in a package.
    and it can not distinguish between function and SP.
    For example, it can only find the function or SP as below:
    create or replace function FUN_OUT return number is
    begin
    null;
    end;
    (2)all_arguments: it can list all function or SP which has varibles, but can not distinguish between function and SP.
    Can anyone help me?
    Any ideas appreciated.
    Merry Chirstmas!

    Is this what you mean?
    SQL> connect test/test
    Connected.
    SQL> create or replace package SPK_A is
      2  lv_empno number;
      3  lv_deptno number;
      4  function FUN_A(in_empno number) return varchar2;
      5  function SP_A(in_deptno number) return varchar2;
      6  end;
      7  /
    Package created.
    SQL> create or replace function FUN_OUT return number is
      2  begin
      3  null;
      4  end;
      5  /
    Function created.
    SQL> select object_type, object_name from user_objects;
    OBJECT_TYPE
    OBJECT_NAME
    TABLE
    ABC
    PACKAGE
    SPK_A
    FUNCTION
    FUN_OUT

  • Comments not imported from Data Dictionary of SQL Server. SDDM 3.3.0.747

    Hi,
    SDDM 3.3.0.747 32-bit on Windows 7 64-bit.
    Comments are not imported from Data Dictionary of SQL Server 2008. Connection through Microsoft JDBC Driver 4.0 for SQL Server or jTDS 1.2.7
    What I have tried? In SDDM DDL generation, Comments in DBRMS for SQL Server are generated with "EXEC sp_addextendedproperty 'MS_Description' , 'Test Comment' ..." so I added extended property named "MS_Description" into SQL Server database, both on table and column. None of them were imported from Data Dictionary into SSDM. I have tried both drivers stated above. Is it a bug or am I missing something?
    I've found similar question thread Re: Data dictionary import doesn't import column comments for SDDM 3.0.0.665, so I guess it is a bug when importing with JDBC drivers.
    MiGli
    Edited by: MiGli_1006342 on May 25, 2013 8:32 AM
    Edited by: MiGli_1006342 on May 25, 2013 9:02 AM

    Extended properties were not imported correctly from SQLServer databases at DM 3.3.0.747.
    Calls to sp_addextendedproperty and fn_listextendedproperty have been modified.
    I don't think it is a problem with JDBC drivers.
    A bug fix should be available in the next release of DM.

  • SQL modeler can not import from data dictionary

    It was very frustruted to see that the SQL Modeler hang in import from data dictionary of a database as part of revise engineering. I have to question myself if sql modeler is a serious tool and should I give up.

    I am not sure if Data Modeller is still in Beta./Production. First couple off initial versions of a new product are normally buggy.
    Regards
    Alternatively, If this product is still in Beta, then you can contact the development team or report the issue so that they can take care of this issue in next beta release.
    Edited by: skvaish1 on Mar 30, 2010 3:18 PM
    Edited by: skvaish1 on Mar 30, 2010 3:26 PM

  • SQL remote query and data-dictionary

    Hi,
    We are considering the implementation of SAP Business One 2005. I've installed a demo version but in order for it to continue to support some business functions I need to perform a number of SQL queries against the data. Unfortunately I'm having difficulties in getting the answer from our reseller.
    Does anyone know the answers to the following question. I'd very much appreciate some help.
    1) Is there a data-dictionary document showing which tables perform which roles and the associated joins/associations.
    2) Is it 'advised' to open the SAP datasource directly to perform a SELECT query to obtain the results or should a third-party tool be used?
    3) Do I need the SDK if I want to perform direct SELECT queries or if I want to automate posting invoices to SAP? We have competent programmers in the company - I believe they use VB6 and VB.net.
    4) Is there an example if I simply wanted to query all suppliers within SAP? (e.g. SELECT NAME FROM Supplier_tbl...etc..etc)
    Any help would be very much appreciated - it's a huge application and I'm struggling a little.
    Many thanks,
    Gavin Russell.

    Gavin,
    The forum that you have posted your questions in is or questions related to the SAP Business One Integration for SAP NetWeaver.  Your questions seem to be along the line of general data access to SAP Business One.  You should typically post those types of questions in the SAP Business One Discussion Forum or the SAP Business One SDK Discussion Forum.
    As to your questions ...
    1.  The definition of the SAP Business One table schema is part of the SAP Business One SDK Help Center documentation.  You simply need to install the SAP Business One SDK Help and you will have it.  There is not a "data dictionary" other than this documentation.
    2.  Typically any direct access to SAP Business One data using SQL is discouraged as if data corruption occurs as a result of it, the environment would not then be supported by SAP.
    3.  If you want to push data into SAP Business One, as stated, direct access to the Business One database is forbidden.  You would use the SAP Business One SDK for this.
    4.  You can use the SAP Business One Query Manager/Wizard in the SAP Business One product which in essence is performing SQL type SELECTS for data on Business One tables.
    HTH,
    Eddy

  • Need using cursor for query

    Hi all,
    can anybody tell me how to get the result of the following query by using cursor?
    SELECT (SUBSTR('        ', 1,LEVEL*2)
      || t1.label) AS t1_label,
      amount
    FROM
      (SELECT t1.label,
        t1.ID,
        t1.parent_id,
        SUM(t2.turnover) AS amount
      FROM t1,
        t2
      WHERE t2.t1_id = t1.id
      AND t2.t1_id  IN
        (SELECT id
        FROM t1
          START WITH t1.ID       = 2
          CONNECT BY PRIOR t1.ID = t1.parent_id
      GROUP BY t1.label, t1.ID, t1.parent_id
      ) t1
      START WITH t1.ID       = 2
      CONNECT BY PRIOR t1.ID = t1.parent_id;...and the result:
    t1_label             amount
         B11     11778.54
          B121     19980.28
            B1211     18842.77
            B1212     25480.56
          B122     18339.07
        B12            23455.9
        B13            20876.52Thanks,
    Alex
    Edited by: 860003 on Jun 9, 2011 1:30 AM
    Edited by: 860003 on Jun 9, 2011 1:31 AM
    Edited by: 860003 on Jun 9, 2011 1:31 AM

    860003 wrote:
    Is not that i don't want to use hierarchy queries, but find others ways, tricks to reach the result needed. I just want to explore different ways that Oracle provides to resolve issues.Not a problem with that in principle.
    Maybe using "loop, if-else, for" will provide us with an elegant way to get the result. However, a problem in principle with this. SQL and PL/SQL are not the same thing. Two separate and very different languages.
    In PL/SQL, you can code both PL and SQL - so you can write source code of 2 different language and mix these. The PL/SQL parser is clever enough to figure out what is what and glues the code seamlessly and transparently together.
    SQL is used to crunch SQL data. PL/SQL sucks at this in comparison (and Java/.Net sucks a heck of a lot worse at this). Cursor fetch loops? Bulk processing. Neat. But will always be slower than running that data crunching in SQL only.
    That is why there is a simple maxim for performance in Oracle: Maximise SQL. Minimise PL/SQL.
    Do not use PL/SQL to do what the SQL is perfectly able and capable of doing. The exception is when the processing is too complex for SQL to handle and you need the programming logic part of the PL/SQL language.
    My question is how to use this cursor to get the value, fetch it and then get another value(ofc only for the children) and fetch it again so i can output it? I thing this can be achieve but don't know how.All SQLs (and anonymous PL/SQL) are parsed and cursors are created. A cursor is a basically a set of instructions (as seen via execution plans) of how to get the job done. Think of cursors as programs that are executed and output data.
    So do you want t create a bunch of cursors (programs) and then call these from PL/SQL, consume their output, create/call new cursor programs and repeat?
    Or do you want to create a single cursor program that does the job and outputs the required results?
    Maximise SQL. Minimise PL/SQL.

  • How can i fetch numeriic records from data dictionary table

    hi friends..
    let assume one data dictionary table ztable which contain
    fields like 1. key datatype c length 2
                  2. data datatype c length 10
    which contain data like
    aa      varehouse
    bb      material
    cc      sales
    01      one
    02      two
    03      three
    from these i want to fetch only 01, 02 and 03 records...
    i.e i want all the records that is in numbers only in key field of ztable
    can you guide me how to get tis?

    select * into table itab
    from ztable
    where key eq '01'
    or key eq '02'
    or key eq '03'.
    declare itab of the type same as ur ztable..
    the above select query will giv u required records..
    Edited by: Rudra Prasanna Mohapatra on Jul 14, 2008 11:13 AM

  • Can we determine path of my INIT.ORA file from data dictionary views.

    Hello Guru’s
    I am new to oracle, My question is for the sake of my knowledge: I work on oracle 10G.
    Is there any data dictionary view from where I can get the path of my INIT.ORA file.
    Regards,

    NewDay wrote:
    Hello Guru’s
    I am new to oracle, My question is for the sake of my knowledge: I work on oracle 10G.
    Is there any data dictionary view from where I can get the path of my INIT.ORA file.
    AFAIK , its no. You can check the path from the show parameter command like following,
    SQL> show parameter spfile
    NAME                                 TYPE
    VALUE
    spfile                               string
    /u01/app/oracle/product/10.2.0
    /db_1/dbs/spfileorcl.ora
    SQL>HTH
    Aman....

  • Running out of memory while using cursored stream with large data

    We are following the suggestions/recommendations for the cursored stream:
    CursoredStream cursor = null;
              try
                   Session session = getTransaction();
                   int batchSize = 50;
                   ReadAllQuery raq = getQuery();
                   raq.useCursoredStream(batchSize, batchSize);
                   int num = 0;
                   ArrayList<Request> limitRequests = null;
                   int totalLimitRequest = 0;
                   cursor = (CursoredStream) session.executeQuery(raq);
                   while( !cursor.atEnd() )
                        Request request = (Request) cursor.read() ;
                        if( num == 0 )
                             limitRequests = new ArrayList<Request>(batchSize);
                        limitRequests.add(request);
                        totalLimitRequest++;
                        num++;
                        if( num >= batchSize )
                             log.warn("Migrating batch of " + batchSize + " Requests.");
                             updateLimitRequestFillPriceForBatch(limitRequests);
                             num = 0;
                             cursor.releasePrevious();
                   if( num > 0 )
                        updateLimitRequestFillPriceForBatch(limitRequests);
                   cursor.close();
    We are committing every 50 records in the unit of work, if we set DontMaintianCache on the ReadAllQuery we are getting PrimaryKeyExceptions intermittently, and we do not see much difference in the IdentityMap size.
    Any suggestions/ideas for dealing with large data sets? Thanks

    Hi,
    If I use read-only classes with CursoredStream and execute the query within UOW, should I be saving any memory?
    I had to use UOW because when I use Session to execute the query I get
    6115: ISOLATED_QUERY_EXECUTED_ON_SERVER_SESSION
    Cause: An isolated query was executed on a server session: queries on isolated classes, or queries set to use exclusive connections, must not be executed on a ServerSession or in CMP outside of a transaction.
    I assume marking the descriptor as read-only will avoid registering in UOW, but I want to make sure that this is the case while using CursoredStream.
    We are running in OC4J(OAS10.1.3.4) with BeanManagedTransaction.
    Please suggest.
    Thanks
    -Raam
    Edited by: Raam on Apr 2, 2009 1:45 PM

  • Query on data dictionary results in large number of physical reads

    I don't understand why I am getting 80,000 physicals for this query. I am not looking for help re-writing this. I just don't understand why I would hit the disk at all.
    My understanding had been that v$views where sql structures that pointed to x$tables. These x$tables are sql structures.
    underneath, the x$tables were linked lists stored in memory. This is why when you bounce the database, all the data, gets reset. Since it is not saved to disk.
    I am doing a simple insert/select off of v$open_cursor that is resulting in 80,000+ physical reads. I am posting the tkprof. It is all from v$open_cursor.
    mysid_table has 6 records. It is 1 mb in size
    if I index mysid_table.sid the query reduces to 20,000 physical reads. (but all the physical reads are on v$session_event)
    the sequence number I am passing returns 2 SIDs
    insert into my_save_table
    select *
    from v$session_event
    where sid in (select sid
      from my_sid_table
    where id = vseq);
    vrowcount := sql%rowcount;
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.01       0.01          0          0          0           0
    Execute      1     31.70      47.57      88570         22          0           1
    Fetch        0      0.00       0.00          0          0          0           0
    total        2     31.71      47.58      88570         22          0           1
    Misses in library cache during parse: 1
    Optimizer mode: CHOOSE
    Parsing user id: 22 
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      latch: row cache objects                        1        0.00          0.00
      log file sync                                   1        0.00          0.00
      SQL*Net message to client                       1        0.00          0.00
      SQL*Net message from client                     1        0.00          0.00
    ********************************************************************************

    It seems like there is some missing information.
    You have a wait for a log file sync, but no commit.
    Your table my_sid_table is 1 MB for only 6 records?
    Does the target table you are inserting into (my_save_table) have indexes on it?

  • Interactive Analysis error when using BW BEx query as data source

    Hello,
    When we try to create a new report based on a BW BEx with the "Interactive Analaysis" tool in the BO 4.0 Launchpad, for all the BEx queries created under one of our multiproviders, we get the following error:
    The DSL Service returned an error: com.businessobjects.mds.services.helpers.OlapUniverseHelper$DimensionsFromCubeFailedException: Cannot retrieve dimensions from cube Cartera de ventas (Ap)
         at com.businessobjects.mds.services.helpers.OlapUniverseHelper.createSapBusinessLayer(OlapUniverseHelper.java:444)
         at com.businessobjects.mds.services.helpers.OlapUniverseHelper.createBusinessLayer(OlapUniverseHelper.java:248)
         at com.businessobjects.dsl.services.workspace.impl.QueryViewAnalyzer.createOlapUniverse(QueryViewAnalyzer.java:286)
         at com.businessobjects.dsl.services.workspace.impl.QueryViewAnalyzer.createOlapUniverse(QueryViewAnalyzer.java:263)
         at com.businessobjects.dsl.services.datasource.impl.DirectOlapAccessUniverseProvider.provideUniverse(DirectOlapAccessUniverseProvider.java:97)
         at com.businessobjects.dsl.services.datasource.impl.DirectOlapAccessUniverseProvider.provideUniverseFromCms(DirectOlapAccessUniverseProvider.java:50)
         at
    With BEX queries from other multiproviders we're not getting this error and however.
    Moreover, if we try to create a new report with the "Analysis Edition for OLAP" tool in the BO Launchpad using these same problematic BEx queries, we don't get any errors with this other tool. The thing is that we need to create them with the Interactive Analaysis.
    Does anybody know why we're getting this error in the "Interactive Analysis" tool and how can we solve it?
    Any help would be very appreciated.
    Thank you and regards,
    Edited by: Juan Jose Catoira on Jul 28, 2011 2:46 PM
    Edited by: Juan Jose Catoira on Jul 28, 2011 2:47 PM

    Hey,
    Did you find out any solution for this. I am also facing the same issue.
    Thanks in advance.

  • Can not select from data dictionary view from a procedure

    Hi,
    I wonder, which privilege is missing here:
    my schema has this roles and privs:
    GRANT CONNECT, RESOURCE TO cb ;
    GRANT CREATE SESSION TO cb ;
    GRANT SELECT_CATALOG_ROLE TO cb ;
    GRANT CREATE SYNONYM TO CB;
    GRANT CREATE VIEW TO CB;
    I create a procedure:
    create or replace procedure dd_test as
    begin
         dbms_output.enable(2000000);
         for r in (select table_name from sys.dba_tab_partitions     where owner = 'CB') loop
                   dbms_output.put_line(r.table_name);
         end loop;
    end;
    sho err
    4/38 PL/SQL: ORA-00942: table or view does not exist
    When I run the core statement form sql prompt, it works !
    so what privilege is missing here ???
    thanks for any hint, Lao De

    Hi,
    thanks for that reply, after doing that I can not select this DD-view from sql-prompt anymore (which I don't wonder ;-). Can you tell me, what idea you had behind that test ?
    I found another instance, where the procedure works and I will compare those privileges, but it's hard to sort out that complex structure of nested roles and sys_privs.
    How ever, I will update here, when I found the missing privilege.
    regards LaoDe

  • Using data dictionary in PL/SQL

    What people think about using data dictionary in PL/SQL witch supposed to be used for a long time (selects, type declarations and so on)?
    Oracle does not guarantee data dictionary names will be same forever.
    Is it a good idea to restrict the using of this in the Development standards?

    The reason I open this thread I am trying to improve the Development Standards
    My attempt was to restrict using SELECT FROM Data Dictionary if it is possible.
    Here are examples, what I trying to figure out
    SELECT SYS_CONTEXT ('USERENV', 'DB_NAME')
      FROM DUAL;
    or
    SELECT VALUE
      FROM gv$parameter
    WHERE NAME = 'db_name';
    SELECT SYS_CONTEXT ('USERENV', 'CURRENT_SCHEMAID')
      FROM DUAL;
    or
    SELECT user#
      FROM SYS.user$
    WHERE NAME = USER;
    I am not asking ‘Can I...?’ I am asking ‘What people think?’
    Probably, it is not an issue.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for

  • HT1222 Since I have installed the iOS 6 I have not been able to get my Internet / wi fi connection freely ..... What can be done..... Please help

    Need to know why I am not getting Internet / wi fi connection frequently and smoothly as I use to before installing Iso 6 ... Can I change back to the old system or do something about it. Thanks ...please help

  • Profit center issue

    Hi one of our billing documnet has got cash pricing procedure assigned to it. Accordingly, when a billing document is created, certain G/L is getting debited instead of customer account. We are also crediting same G/L account thru VKOA settings. e.g.

  • Help with opening PDF files in Firefox

    I can't open pdf files on Firefox, however, I can open them on Safari.  What can I do to get Firefox to open my pdf files?

  • LCCS rtc Code Completion

    Hi, I have downloaded version 1.2.5 of the LCCS SDK. I am using Flash Builder 4 (4.1 SDK) and attempting to create a spark LCCS application. I have copied script into the project and can get the tutorial web app to run okay. However I am not getting

  • Read out more than 1 number

    Hi, I am currently working on a code for some scales that reads out the weight and saves it on a .lvm file. The program works as it should except for saving it to the .lvm file. The program only saves the last number before I click stop, ex last numb