How to include Drop index in PL/SQL

Hi,
In my PL/SQL, I put a drop index statement in between, but it gave me an error of
"PLS-00103: Encountered the symbol "DROP" when expecting one of the following:
begin declare exit for goto if loop mod null pragma raise
return select update while <an identifier>
<a double-q"
My statement is structured as:
DECLARE
BEGIN
DROP INDEX index_name;
COMMIT;
END;
Why is this error occuring? When I execute the drop index statement seperately it is ok. When i put it in the PL/SQL it gave me error.
Do I need special syntax to include a Drop index statement in a PL/SQL?
Thanks

Any DDL commands in PL/SQL must be executed using dynamic SQL:
execute immediate 'drop index index_name';

Similar Messages

  • How to include Drop Down List?

    Hi!
    I need to include a drop down list wherein the user selects one option and then enters some relative data. Then I need to show some output based on a calculation. Can this be done in Captivate? How to include the drop down list? Please Help, its urgent.
    Thank you
    AJ

    Hello,
    Welcome to Adobe Forums.
    You can choose Combo Box widget for your requirement, You need to use a Text Entry Box (enters some relative data).
    You need to use either Java Script or Advanced Actions for showing output based on a calculation.
    Thanks,
    Vikram

  • How to analyse Indexes with PL/SQL witch a $ in it's name

    Hello there, I'm working on several sniplets of PL/SQL Code. In the end result there should be a PL/SQL Routine which decides which indexes to analyse online.
    I just get stopped by some indexes which have the $ in It's name. Our Apllication provider uses uncommon names like ttols.pk_$lock for some of his indexes.
    So when this procedure try to analyse the ttols.pk_$lock it gives me errors.
    Can someone lend me a hand how I can analyse Indexes with PL/SQL with a $ in it'S name.
    CREATE OR REPLACE PROCEDURE TTOOLS_DBA.rebuild_nonpart_idx
    AS
    BEGIN
    FOR idxq IN (SELECT owner AS obj1, index_name AS obj2
    FROM dba_indexes
    WHERE partitioned = 'NO'
    AND owner = 'TTOOLS'
    AND index_name NOT LIKE '%$%')
    LOOP
    DBMS_OUTPUT.put_line ( 'ALTER INDEX '
    || idxq.obj1
    || '.'
    || idxq.obj2
    || ' REBUILD ONLINE COMPUTE STATISTICS;'
    EXECUTE IMMEDIATE 'ALTER INDEX '
    || idxq.obj1
    || '.'
    || idxq.obj2
    || ' REBUILD ONLINE COMPUTE STATISTICS';
    END LOOP;
    END;
    Greetings from sdohn

    how I can analyse Indexes with PL/SQL with a $ in it'S name.You can try
    create or replace procedure ttools_dba.rebuild_nonpart_idx
    as
    begin
         for idxq
              in (select owner as obj1, index_name as obj2
                        from dba_indexes
                     where partitioned = 'NO'
                         and owner = 'TTOOLS'
                         and index_name not like '%$%')
         loop
              dbms_output.put_line (
                   'ALTER INDEX ' || idxq.obj1 || '."' || idxq.obj2 || '" REBUILD ONLINE COMPUTE STATISTICS;'
              execute immediate   'ALTER INDEX '
                                         || idxq.obj1
                                         || '."'
                                         || idxq.obj2
                                         || '" REBUILD ONLINE COMPUTE STATISTICS';
         end loop;
    end;
    /but actually I don't think that the $ sign should cause an error.
    Can you show us the actual error message?
    Also please always mention your db version.
    Edited by: michaels2 on Aug 10, 2009 9:45 AM

  • How to enter bind variables in Calender SQL statement

    Hi,
    Anyone know how to include bind variables in Calender SQL statement. Let's say in sql statement below:
    select
    EMP.HIREDATE the_date,
    EMP.ENAME the_name,
    null the_name_link,
    null the_date_link,
    null the_target
    from SCOTT.EMP
    order by EMP.HIREDATE
    thanks.

    Hi,
    Here is the sql statement
    select
    EMP.HIREDATE the_date,
    EMP.ENAME the_name,
    null the_name_link,
    null the_date_link,
    null the_target
    from SCOTT.EMP
    where deptno = :dept
    order by EMP.HIREDATE
    Thanks,
    Sharmila

  • Index to Improve SQL Performance

    Please provide a link to information about how to use an Index to enhance SQL performance with Oracle 10g database.

    user8973820 wrote:
    I would like information regarding the use of clustered versus non-clustered indexes.The documentation is your friend :)
    [Overview of Indexed Clusters|http://download.oracle.com/docs/cd/E11882_01/server.112/e10713/tablecls.htm#CFABHBAG]
    [Indexes and Index-Organized Tables|http://download.oracle.com/docs/cd/E11882_01/server.112/e10713/indexiot.htm#BABHJAJF]
    HTH!

  • SQL Server CE 3.5 SP2 - SQLCE Toolbox / Automated Database Schema Upgrade Scripting / Drop Index

    I am provisioning for automated database schema upgrades in a Windows Forms Application (VS2010/VB) which uses SQL Server Compact 3.5 SP2.  A portion of the schema upgrade procedure uses TSQL commands passed to SQLCE like the following:
    cmd.CommandText = "DROP INDEX [SaleComps$ProjID]"
    cmd.ExecuteNonQuery()
    However, when this command is processed by the SQLCE engine, I get the following error:
    Command: DROP INDEX [SaleComps].[ProjID]
    Error: The specified index does not exist. [ ProjID ]
    But, if I try to recreate the index (or try to change the index column) I get the following errors which indicate that the index is still there:
    Command: ALTER TABLE [SaleComps] ALTER COLUMN [ProjID] nvarchar(20) NULL
    Error: Cannot alter a column that is part of a key or an index. [ Index Name = SaleComps$ProjID,Column = ProjID ]
    Command: CREATE INDEX "SaleComps$ProjID" ON "SaleComps" ("ProjID" ASC)
    Error: The specified index already exists. [ SaleComps$ProjID ]
    Any ideas why this would not be working? Thanks!
    -BGood

    No, I was guessing at the syntax from reviewing other web postings, some of which were in different SQL dialects. 
    While your SQLCE Toolbox did not provide the DROP INDEX command, it did provide most of the "Schema Diff" scripting commands.  In hindsight, maybe SQLCE Toolbox should recognize when schema differences involve a Column which is used in an index, and
    DROP the index before executing the ALTER COLUMN command, then re-CREATE the index with the modified column.
    Despite this shortcoming, I am very thankful for the help provided by SQLCE Toolbox, and learned a little more about SQL scripting in the process.
    Thanks, ErikEJ!
    -BGood

  • HOW TO DROP INDEX OF OTHER SCHEMA

    hi,
    I want to know how can we refer to objects that are of other schema. i need to drop an index of a table that belongs to some other schema and so if i write :
    drop tablename.indexname; - its not working.
    Please Help
    Thanks

    You are trying to drop an index on a table that belong to a different schema you are connected to.
    Do not add the table name to your command.
    Simply try
    drop index schema_name.index_name;
    Nico P.

  • How to delete/drop all the tables from SQL Server Database without using Enterprise Manager?

    How to delete/drop all the tables from SQL Server Database without using Enterprise Manager?
    I tried using DROP Tables, Truncate Database, Delete and many more but it is not working.  I want to delete all tables using Query Analyzer, i.e. through SQL Query.
    Please help me out in this concern.
    Nishith Shah

    Informative thread indeed. Wish I saw it early enough. Managed to come up with the code below before I saw this thread.
    declare @TTName Table
    (TableSchemaTableName
    varchar
    (500),
    [status] int
    default 0);
    with AvailableTables
    (TableSchemaTableName)
    as
    (select
    QUOTENAME(TABLE_SCHEMA)
    +
    +
    QUOTENAME(TABLE_NAME)
    from
    INFORMATION_SCHEMA.TABLES)
    insert into @TTName
    (TableSchemaTableName)
    select *
    from AvailableTables
    declare @TableSchemaTableName varchar
    (500)
    declare @sqlstatement nvarchar
    (1000)
    while 1=1
    begin
    set @sqlstatement
    =
    'DROP TABLE '
    + @TableSchemaTableName
    exec
    sp_executeSQL
    @sqlstatement
    print
    'Dropped Table : '
    + @TableSchemaTableName
    update @TTName
    set [status]
    = 1
    where TableSchemaTableName
    = @TableSchemaTableName
    if
    (select
    count([Status])
    from @TTName
    where [Status]
    = 0)
    = 0
    break
    end

  • How to access the text definition of sql indexes

    I am able to access the text definition of stored procedures, views, triggers and functions from sys.sql_modules. I want to get the text definition of indexes.
    Can somebody help me in getting the text definition of indexes in sql server.
    Thanks,
    Puneet

    No, Actually I am trying to compare the indexes of two database programmatically.
    I am able to compare the stored procedures, views, triggers and functions by getting text definition directly from 'sys.sql_modules',  on similar lines do we have any way from where I could get the text definition of indexes
    Not sure if there is any table which stores Index defination but there is a table "sys.indexex" which stores index details.
    You may use below query to get index information (It will list out index details but not defination)
    SELECT s.NAME 'Schema'
    ,t.NAME 'Table'
    ,i.NAME 'Index'
    ,c.NAME 'Column'
    FROM sys.tables t
    INNER JOIN sys.schemas s ON t.schema_id = s.schema_id
    INNER JOIN sys.indexes i ON i.object_id = t.object_id
    INNER JOIN sys.index_columns ic ON ic.object_id = t.object_id
    INNER JOIN sys.columns c ON c.object_id = t.object_id
    AND ic.column_id = c.column_id
    WHERE i.index_id > 0
    AND i.type IN (
    1
    ,2
    ) -- clustered & nonclustered only
    AND i.is_primary_key = 0 -- do not include PK indexes
    AND i.is_unique_constraint = 0 -- do not include UQ
    AND i.is_disabled = 0
    AND i.is_hypothetical = 0
    AND ic.key_ordinal > 0
    ORDER BY ic.key_ordinal
    - Also there is one more SP which you can create and then execute it by specifying DB names. It will list out table columns, indexes, constraints difference in one go.
    EXEC SP_Comparedb db1,db2
    Technet Gallary: Compare two databases for objects differences
    Cheers,
    Vaibhav Chaudhari

  • Need to recover dropped indexes from SQL Server 2008 R2

    Hi All,
    we are reestablishing the transaction replication all non-clustered indexes dropped due to this activity now we are suffering from performance issue is there any way ,we can recover all the dropped indexes.
    Regards,
    Pawan Singh
    Thanks

    Hi Pawan,
    I had blogged about this in the past
    http://sqllearnings.com/2012/04/04/subscription-re-initialization-and-non-clustered-indexes/
    When you re-initialize there is an option which you need to set to true for the non-clustered indexes to be applied in the subscriber end.
    If your replication re-initialization is pretty fast then you can set the option to true and then re-apply the snapshot..
    Else easiest option is to script the indexes from publisher and create them in the subscriber.
    HTH
    Regards, Ashwin Menon My Blog - http:\\sqllearnings.com

  • How to a drop tablespace ?????

    Hi Expert !!
    I am living my life in ORA errors. To describe the complete picture:
    1) We have a partitioned table whose partitions reside in multiple tablespaces.
    2) One of the datafiles got corrupted where one old partition resides.
    3) We are not interested in restoring the corrupt datafile and no more require that partition.
    4) How do I drop the partition or tablespace?
    Well, I have tried the following but no success:
    startup mount
    alter database datafile 'C:\MYDB\DATA\SALES_2005_TS1.DBF' offline;
    alter database open;
    conn sales/sales
    SQL> ALTER TABLE sales_range DROP PARTITION sales_2005 update global indexes;
    ALTER TABLE sales_range DROP PARTITION sales_2005 update global indexes
    ERROR at line 1:
    ORA-00376: file 7 cannot be read at this time
    ORA-01110: data file 7: 'C:\MYDB\DATA\SALES_2005_TS1.DBF'
    SQL> conn /as sysdba
    Connected.
    SQL> drop tablespace sales_2005_ts including contents;
    drop tablespace sales_2005_ts including contents
    ERROR at line 1:
    ORA-14404: partitioned table contains partitions in a different tablespace
    SQL> alter tablespace SALES_2005_TS offline;
    alter tablespace SALES_2005_TS offline
    ERROR at line 1:
    ORA-01191: file 7 is already offline - cannot do a normal offline
    ORA-01110: data file 7: 'C:\MYDB\DATA\SALES_2005_TS1.DBF'
    SQL> alter tablespace SALES_2005_TS offline immediate;
    Tablespace altered.
    SQL> drop tablespace SALES_2005_TS including contents;
    drop tablespace SALES_2005_TS including contents
    ERROR at line 1:
    ORA-14404: partitioned table contains partitions in a different tablespace
    I did search on net and metalink but unfortunately couldn't find anything useful. I did try metalink note 267125.1 but again no luck.
    Could any of you shed some light on this?
    Regards

    What about the following :
    SQL> create tablespace test1 datafile 'E:\oracle\oradata\DEMO102\test01.dbf' size 1m;
    Tablespace created.
    SQL> create tablespace test2 datafile 'E:\oracle\oradata\DEMO102\test02.dbf' size 1m;
    Tablespace created.
    SQL> create table x ( x number not null, y number not null ) partition by list (y) ( partition p1 va
    lues (1,2,3) tablespace test1, partition p2 values (4,5,6) tablespace test2);
    Table created.
    SQL> insert into x values (1,3);
    1 row created.
    SQL> insert into x values (2,6);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from x;
             X          Y
             1          3
             2          6
    SQL> shutdown immediate
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SQL> host del E:\oracle\oradata\DEMO102\test02.dbf
    SQL> startup
    ORACLE instance started.
    Total System Global Area  272629760 bytes
    Fixed Size                  1290084 bytes
    Variable Size             234881180 bytes
    Database Buffers           29360128 bytes
    Redo Buffers                7098368 bytes
    Database mounted.
    ORA-01157: cannot identify/lock data file 10 - see DBWR trace file
    ORA-01110: data file 10: 'E:\ORACLE\ORADATA\DEMO102\TEST02.DBF'
    SQL> alter database datafile 'E:\oracle\oradata\DEMO102\test02.dbf' offline;
    Database altered.
    SQL> alter database open;
    Database altered.
    SQL> select * from x;
    ERROR:
    ORA-00376: file 10 cannot be read at this time
    ORA-01110: data file 10: 'E:\ORACLE\ORADATA\DEMO102\TEST02.DBF'
    no rows selected
    --At this point, I reproduced your problem
    SQL> shutdown immediate
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    SQL> startup mount
    ORACLE instance started.
    Total System Global Area  272629760 bytes
    Fixed Size                  1290084 bytes
    Variable Size             239075484 bytes
    Database Buffers           25165824 bytes
    Redo Buffers                7098368 bytes
    Database mounted.
    SQL> alter database datafile 'E:\oracle\oradata\DEMO102\test02.dbf' offline drop;
    Database altered.
    SQL> alter database open;
    Database altered.
    SQL> drop tablespace test2 including contents;
    drop tablespace test2 including contents
    ERROR at line 1:
    ORA-14404: partitioned table contains partitions in a different tablespace
    SQL> alter table x drop partition p2;
    Table altered.
    SQL> drop tablespace test2;
    Tablespace dropped.
    SQL> create table x1 as select * from x;
    Table created.
    SQL> select * from x;
             X          Y
             1          3
    SQL> Nicolas.

  • How to make an index in InDesign CC 2014.1 using a topics list?

    Hi all,
    I have read the long help document on how to make an index in InDesign CC 2014.1 using a topics list, and still can't work out what to do.
    I have done a 548 page book, using a document for each chapter, and a book file to put them all together in the right order.
    I now need to make an index at the back, as the author has many quotes throughout the book at the start of each chapter and section.
    I have a list of those people quoted and want to upload this list and get the index feature in InDesign to find all instances of the name occurring in the entire book.
    After reading the help document I still cannot work out how to do this.
    My questions are:
    1. Do you have to use an InDesign document as a source for the list of topics? If so, should the document be added to the book file or outside it?
    It seems a bit recursive to have the list of topics in an ID document that is in the book file.
    2. Once you have uploaded the topics into the Index feature, how do you get it to look for all instances of that 'topic' througout the entire book? I can't figure that out from the help documents. What do I select? Do I do it from the Index panel? Do I highlight the text in the source document? Not sure how to do this...
    3. I need the names to list surname first of the quoted authors in the index. This command seems to be different between various editions of ID. For ID CC 2014.1 is it ctrl+alt+shift+]
    4. To make the surname show first, what do I highlight? The topic? and then do ctrl+alt+shift+] and select find all as well? Or do I have to just go through the text and manually do this and ditch the idea of uploading topics first?
    I am confused as you can see and any help with this is appreciated.

    Sorry 007, I really thought you were posting a trick question as on the OCP tests.
    Anyway, as Justin mentioned, if you have an index on ename, it may be used when doing a comparison predicate statement with the ename value.
    What it depends on are several other things: stats, how many rows in the table, use of an index hint, etc.
    Rather than questioning the group on this, why not just turn on autotrace and run the query for the different scenarios.
    The output will show you if it used the index, number of rows returned, blocks read, etc.
    SQL> create table emp (ename  varchar2(40));
    Table created.
    SQL> insert into emp select username from sys.dba_users;
    25 rows created.
    SQL> commit;
    Commit complete.
    SQL> set autotrace on
    SQL> select * from emp where ename != 'SYSTEM';
    Execution Plan
    Plan hash value: 2951343571
    | Id  | Operation        | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT |           |    24 |   528 |     1   (0)| 00:00:01 |
    |*  1 |  INDEX FULL SCAN | ENAME_IDX |    24 |   528 |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("ENAME"<>'SYSTEM')As you can see, the above used an index, even though there were only 25 rows in the table.
    You can test each of your scenarios, one by one, including use of a hint.

  • How can i drop a tablescpace without your dbf ?

    Hi,
    My problem is..
    A have a tablespace and this tablespace has 70 dbf in the past, but someone delete that tablespaces with winscp ... dont use any script to do this, now when i try drop that tablespace return a erro that dont found a dbf. i need drop that tablescpace and delete her dbf files but the FISIC dbf files was deleted, but in sql developer show's the dbf files.
    How i can DROP ALL DBF FILES AND THE TABLESPACE ?
    Thx !

    try
    drop tablespace <tbs> including contents and datafiles;post the exact error message and also verison
    or
    select file_name, tablespace_name from dba_data_files WHERE tablespace_name = <TBS>;
    and do like
    alter database datafile 'file_name' offline drop;and then drop the tablespace
    Edited by: CKPT on Oct 28, 2010 8:03 PM

  • URGENT HELP PLEASE - drop index hangs on SAP

    Hi all,
    OS = Linux
    DBVersion = Oracle10.2.0.2
    Need some urgent help advise please on how to get around this problem.
    On a SAP system, am trying to drop six indexes, largest is 300MB and smallest is 50MB.
    I tried running drop index sapusername.index_name on the 50MB index via SQL*Plus and it seems to be taking forever. Can anyone please suggest if there is anything I can check on the database on why it is taking such a long time?
    I can leave it to run overnight but worried that when I come back the next day, it will still be hanged. Is there any quick way of dropping the index, .i.e. drop immediate ... :-)
    Am not using SAP's BRTOOLs as it is also hanging from there and the SAP-ADMIN had approved for the DBA to drop it from our end instead.
    Any response and advise on this will be very much appreciated.
    From Google'ing, I found some that mentioned that the fault could be because of the existence of the constraints on the table that I am dropping the index of.
    Checking the table, it has 17 SYS_ named constraints. None of these constraints have INDEX_NAME that refers to the indexes that am dropping.
    Should I disable the constraints and then run the drop index again?
    Thanks in advance.
    Edited by: user649596 on Apr 13, 2010 11:49 PM

    Should I disable the constraints and then run the drop index again?NO, certainly not !!
    Ask SAP Support on what methods you should use to diagnose the "hang" and what your next step(s) should be.
    Hemant K Chitale

  • How to disable drop down of Report Server

    Hi,
    i had install Report server 2012 and want to move form 2008 to 2012 .
    1) how to disable drop down that show on folder and report level for end user (as shown in following screen shot).
    2) report name coming on report server are not full name how to show full name of report like we have in 2008. Following is screen shot

    Hi Mujahid,
    1.) For migrating from Sql server 2008 to 2012, please follow this links
    Migrating the whole Instance from 2008 to 2012 - > http://msdn.microsoft.com/en-us/library/ms143747.aspx
    Migrating the rdl defination to 2008 to 2012 - > http://msdn.microsoft.com/en-us/library/a1a10c67-7462-4562-9b07-a8822188a161
    2.) We can't disable the drop down box for the reporting services per user basic(end user), If you really want to do it, you
    need to edit the ReportingServices.js file (This will effect all the user including admins) located at C:\Program Files\Microsoft SQL Server\<<SSRS Instance>>\Reporting Services\ReportManager\js\ReportingServices.js
    If you want the end user not to perform certain action, you set appropriated permission for the report.
    Managing Permissions and Security for Reporting Services
    http://technet.microsoft.com/en-us/library/ms156014.aspx
    3.)  When report name is too long it truncated and dot dot are shown in the end. User always have a option to move from Title View to Details View
         You need click on the right side of the report manager preview and click on the detail view to change between detail view and title view
    Regards Harsh

Maybe you are looking for

  • Airpot not connecting when mini dvi adapter is pluged in.

    Airport will not work when I hook up a display through the apple mini dvi adapter. When the adapter is unpluged I can connect to the internet. Does anyone know how to fix the problem. Thanks.

  • PAD function in oracle

    Hi, There is a column called description in the table TEST and the data are : NO DESCRIPTION 100 Chennai 200 Mumbai 300 Hyderabad The requiremnt is that I need to add two asteriks before the description followed by a white space and two asteriks afte

  • Need to have a separate iCloud account for daughter's iPod touch

    I would like to manage all my iOS devices under one appleID, but with separate icloud accounts for my two daughters, each with their own iPod.  How do I retain my Apple ID on daughter's iPod but have a separate iCloud address so that she doesn't rece

  • Internet Based Client Updates

    Hi, We have SCCM 2012 R2 installed, with IBCM enabled. These clients are able to switch between intranet and internet fine. Updates work internally and externally fine too. We only have 1 SUP configured for intranet access only, and the Internet faci

  • Ichat crashes when I try to use the camera?  Why?

    Hello, I am a new mac user and I am figuring things out opretty well but when I use Ichat it works fine texting or audio but as soon as I cliclk the camera the green light comes on and then I get the pin wheel of death and then ichat closes. It even