DDL in package

hi all ,
I was trying to do a DDL IN PACKAGE but i am receiving an error.
Basically i am preparing for OCA so it came in my mind to do a ddl in package's procedure even if i do a ddl in BEGIN section of package body i still get the same error. The code that i have used is
create package p1 is
procedure p1;
end;
  create or replace package body p1 is
     cnt number;
   cursor c1 is select * from hr.employees;
      v1 c1%rowtype;
        procedure p1 is
     cnt number :=0 ;
               begin
         loop
             exit when c1%notfound or cnt= 10;
               fetch c1 into v1;
                 cnt := cnt+1;
                 dbms_output.put_line('The name is proc  '||v1.first_name);
                  execute immediate('create table tst(no number)');
                 dbms_output.put_line('id is '||v1.employee_id);
         end loop;
     dbms_output.put_line(c1%rowcount);
            end;
   BEGIN
      open c1 ;
       fetch c1 into v1;
         dbms_output.put_line('The name is '||v1.first_name);
   end;
O/P is :->
The name is Donald
The name is proc  Douglas
begin
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "PLSQL.P1", line 13
ORA-06512: at line 2
but if i do like
SQL> begin
  2  execute immediate('create table tst(no number)');
  3  end;
  4  /
PL/SQL procedure successfully completed.
SQL> select * from tst;
no rows selectedthanks

810345 wrote:
I was trying to do a DDL IN PACKAGE but i am receiving an error.Sounds like the database protection is working correctly.
Basically i am preparing for OCA If you are learning Oracle, the one thing you should from learn from this is never, ever, create or alter database objects from code. It is error prone, unreliable and renders your database completely unsupportable.
Object creation should be done in SQL scripts, applied during production windows, and stored in a source control system.

Similar Messages

  • How to Read the contents (code )

    Gurus,
    Please advise me to get / view the code (DDL) of packages in Oracle9i ...??

    If you mean source code of FUNCTIONS, PROCEDURES and PACKAGES then look in this view
    SQL> desc all_source
    Name Null? Type
    OWNER VARCHAR2(30)
    NAME VARCHAR2(30)
    TYPE VARCHAR2(12)
    LINE NUMBER
    TEXT VARCHAR2(4000)
    Thanks

  • IMPDP SQLFILE : multibyte characters in constraint_name leads to ORA-00972

    Hi,
    I'm actually dealing with constraint_name made of multibyte characters (for example : constrain_name='VALIDA_CONFIRMAÇÃO_PREÇO13').
    Of course this Bad Idea® is inherited (I'm against all the fancy stuff like éàù in filenames and/or directories on my filesystem....)
    The scenario is as follows :
    0 - I'm supposed to do a "remap_schema". Everything in the schema SCOTT should now be in a schema NEW_SCOTT.
    1 - The scott schema is exported via datapump
    2 - I do an impdp with SQLFILE in order to get all the DDL (table, packages, synonyms, etc...)
    3 - I do some sed on the generated sqlfile to change every occurence of SCOTT to NEW_SCOTT (this part is OK)
    4 - Once the modified sqlfile is executed, I do an impdp with DATA_ONLY.
    (The scenario was imagined from this thread : {message:id=10628419} )
    I'm getting some ORA-00972: identifier is too long at step 4 when executing the sqlfile.
    I see that some DDL for constraint creation in the file (generated at step#2) is written as follow :ALTER TABLE "TW_PRI"."B_TRANSC" ADD CONSTRAINT "VALIDA_CONFIRMAÃÃO_PREÃO14" CHECK ...Obviously, the original name of the constraint with cedilla and tilde gets translated to something else which is longer than 30 char/byte...
    As the original name is from Brazil, I also tried do add an EXPORT LANG=pt_BR.UTF-8 in my script before running the impdp for sqlfile. This didn't change anything. (the original $LANG is en_US.UTF-8)
    In order to create a testcase for this thread, I tried to reproduce on my sandbox database... but, there, I don't have the issue. :-(
    The real system is an 4-nodes database on Exadata (11.2.0.3) with NLS_CHARACTERSET=AL32UTF8.
    My sandbox database is a (nonRAC) 11.2.0.1 on RHEL4 also AL32UTF8.
    The constraint_name is the same on both system : I checked byte by byte using DUMP() on the constraint_name.
    Feel free to shed any light and/or ask for clarification if needed.
    Thanks in advance for those who'll take on their time to read all this.
    I decided to include my testcase from my sandbox database, even if it does NOT reproduce the issue +(maybe I'm missing something obvious...)+
    I use the following files.
    - createTable.sql :$ cat createTable.sql
    drop table test purge;
    create table test
    (id integer,
    val varchar2(30));
    alter table test add constraint VALIDA_CONFIRMAÇÃO_PREÇO13 check (id<=10000000000);
    select constraint_name, lengthb(constraint_name) lb, lengthc(constraint_name) lc, dump(constraint_name) dmp
    from user_constraints where table_name='TEST';- expdpTest.sh :$ cat expdpTest.sh
    expdp scott/tiger directory=scottdir dumpfile=testNonAscii.dmp tables=test- impdpTest.sh :$ cat impdpTest.sh
    impdp scott/tiger directory=scottdir dumpfile=testNonAscii.dmp sqlfile=scottdir:test.sqlfile.sql tables=testThis is the run :
    [oracle@Nicosa-oel test_nonAsciiColName]$ sqlplus scott/tiger
    SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 12 18:58:27 2013
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> @createTable
    Table dropped.
    Table created.
    Table altered.
    CONSTRAINT_NAME                  LB       LC
    DMP
    VALIDA_CONFIRMAÇÃO_PREÇO13             29         26
    Typ=1 Len=29: 86,65,76,73,68,65,95,67,79,78,70,73,82,77,65,195,135,195,131,79,95
    ,80,82,69,195,135,79,49,51
    SQL> exit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    [oracle@Nicosa-oel test_nonAsciiColName]$ ./expdpTest.sh
    Export: Release 11.2.0.1.0 - Production on Tue Feb 12 19:00:12 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Starting "SCOTT"."SYS_EXPORT_TABLE_01":  scott/******** directory=scottdir dumpfile=testNonAscii.dmp tables=test
    Estimate in progress using BLOCKS method...
    Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
    Total estimation using BLOCKS method: 0 KB
    Processing object type TABLE_EXPORT/TABLE/TABLE
    Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
    . . exported "SCOTT"."TEST"                                  0 KB       0 rows
    Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
    Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
      /home/oracle/scott_dir/testNonAscii.dmp
    Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at 19:00:22
    [oracle@Nicosa-oel test_nonAsciiColName]$ ./impdpTest.sh
    Import: Release 11.2.0.1.0 - Production on Tue Feb 12 19:00:26 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Master table "SCOTT"."SYS_SQL_FILE_TABLE_01" successfully loaded/unloaded
    Starting "SCOTT"."SYS_SQL_FILE_TABLE_01":  scott/******** directory=scottdir dumpfile=testNonAscii.dmp sqlfile=scottdir:test.sqlfile.sql tables=test
    Processing object type TABLE_EXPORT/TABLE/TABLE
    Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
    Job "SCOTT"."SYS_SQL_FILE_TABLE_01" successfully completed at 19:00:32
    [oracle@Nicosa-oel test_nonAsciiColName]$ cat scott_dir/test.sqlfile.sql
    -- CONNECT SCOTT
    ALTER SESSION SET EVENTS '10150 TRACE NAME CONTEXT FOREVER, LEVEL 1';
    ALTER SESSION SET EVENTS '10904 TRACE NAME CONTEXT FOREVER, LEVEL 1';
    ALTER SESSION SET EVENTS '25475 TRACE NAME CONTEXT FOREVER, LEVEL 1';
    ALTER SESSION SET EVENTS '10407 TRACE NAME CONTEXT FOREVER, LEVEL 1';
    ALTER SESSION SET EVENTS '10851 TRACE NAME CONTEXT FOREVER, LEVEL 1';
    ALTER SESSION SET EVENTS '22830 TRACE NAME CONTEXT FOREVER, LEVEL 192 ';
    -- new object type path: TABLE_EXPORT/TABLE/TABLE
    CREATE TABLE "SCOTT"."TEST"
       (     "ID" NUMBER(*,0),
         "VAL" VARCHAR2(30 BYTE)
       ) SEGMENT CREATION DEFERRED
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 COMPRESS FOR OLTP LOGGING
      TABLESPACE "MYTBSCOMP" ;
    -- new object type path: TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
    ALTER TABLE "SCOTT"."TEST" ADD CONSTRAINT "VALIDA_CONFIRMAÇÃO_PREÇO13" CHECK (id<=10000000000) ENABLE;I was expecting to have the cedilla and tilde characters displayed incorrectly....
    Edited by: Nicosa on Feb 12, 2013 7:13 PM

    Srini Chavali wrote:
    If I understand you correctly, you are unable to reproduce the issue in the test instance, while it occurs in the production instance. Is the "schema move" being done on the same database - i.e. you are "moving" from SCOTT to NEW_SCOTT on the same database (test to test, and prod to prod) ? Do you have to physically move/copy the dmp file ? Hi Srini,
    On the real system, the schema move will be to and from different machines (but same DBversion).
    I'm not doing the real move for the moment, just trying to validate a way to do it, but I guess it's important to say that the dump being used for the moment comes from the same database (the long story being that due to some column using object datatype which caused error in the remap, I had to reload the dump with the "schema rename", drop the object column, and recreate a dump file without the object_datatype...).
    So Yes, the file will have to move, but in the current test, it doesn't.
    Srini Chavali wrote:
    Obviously something is different in production than test - can you post the output of this command from both databases ?
    SQL> select * from NLS_DATABASE_PARAMETERS;
    Yes Srini, something is obviously different : I'm starting to think that the difference might be in the Linux/shell side rather than on the impdp as datapump is supposed to be NLS_LANG/CHARSET-proof +(when traditional imp/exp was really sensible on those points)+
    The result on the Exadata where I have the issue :PARAMETER                      VALUE
    NLS_LANGUAGE                   AMERICAN
    NLS_TERRITORY                  AMERICA
    NLS_CURRENCY                   $
    NLS_ISO_CURRENCY               AMERICA
    NLS_NUMERIC_CHARACTERS         .,
    NLS_CHARACTERSET               AL32UTF8
    NLS_CALENDAR                   GREGORIAN
    NLS_DATE_FORMAT                DD-MON-RR
    NLS_DATE_LANGUAGE              AMERICAN
    NLS_SORT                       BINARY
    NLS_TIME_FORMAT                HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT           DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY              $
    NLS_COMP                       BINARY
    NLS_LENGTH_SEMANTICS           BYTE
    NLS_NCHAR_CONV_EXCP            FALSE
    NLS_NCHAR_CHARACTERSET         AL16UTF16
    NLS_RDBMS_VERSION              11.2.0.3.0the result on my sandbox DB :PARAMETER                      VALUE
    NLS_LANGUAGE                   AMERICAN
    NLS_TERRITORY                  AMERICA
    NLS_CURRENCY                   $
    NLS_ISO_CURRENCY               AMERICA
    NLS_NUMERIC_CHARACTERS         .,
    NLS_CHARACTERSET               AL32UTF8
    NLS_CALENDAR                   GREGORIAN
    NLS_DATE_FORMAT                DD-MON-RR
    NLS_DATE_LANGUAGE              AMERICAN
    NLS_SORT                       BINARY
    NLS_TIME_FORMAT                HH.MI.SSXFF AM
    NLS_TIMESTAMP_FORMAT           DD-MON-RR HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT             HH.MI.SSXFF AM TZR
    NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_DUAL_CURRENCY              $
    NLS_COMP                       BINARY
    NLS_LENGTH_SEMANTICS           BYTE
    NLS_NCHAR_CONV_EXCP            FALSE
    NLS_NCHAR_CHARACTERSET         AL16UTF16
    NLS_RDBMS_VERSION              11.2.0.1.0------
    Richard Harrison .  wrote:
    Hi,
    Did you set NLS_LANG also when you did the import?Yes, that is one of the difference between the Exadata and my sandbox.
    My environnement in sandbox has NLS_LANG=AMERICAN_AMERICA.AL32UTF8 where the Exadata doesn't have the variable set.
    I tried to add it, but it didn't change anything.
    Richard Harrison .  wrote:
    Also not sure why you are doing the sed part? Do you have hard coded scheme references inside some of the plsql?Yes, that is why I choose to sed. The (ugly) code have :
    - Procedures inside the same package that references one another with the schema prepended
    - Triggers with PL/SQL codes referencing tables with schema prepended
    - Dynamic SQL that "builds" queries with schema prepended
    - Object Type that does some %ROWTYPE on tables with schema prepended (that will be solved by dropping the column based on those types as they obviously are not needed...)
    - Data model with object whose names uses non-ascii characters
    +(In France we use to call this "gas power plant" in order to tell how a mess it is : pipes everywhere going who-knows-where...)+
    The big picture is that this kind of "schema move & rename" should be as automatic as possible, as the project is to actually consolidate several existing databases on the Exadata :
    One schema for each country, hence the rename of the schemas to include country-code.
    I actually have a workaround yet : Rename the objects that have funky characters in their name before doing the export.
    But I was curious to understand why the SQLFILE messed up the constraint_name on one sustem when it doesn't on another...

  • CVS support

    Are there any plans to add CVS support?
    It would be great to have a way to completly source repository all ddl, views, packages, procedures, and functions. Or only certain items.

    We are aware this is a top priority and have it on our list to do. The priority for this release was to rebuild some of the underlying architecture, such as the Navigator, in readiness for future features.
    We have a choice, to release less frequently with more features, or more frequently with less feature in each release. We have opted to release 1.1 with lots of smaller features and in a future release add in functionality such as version control support.
    Regards
    Sue

  • Using Designer as a code repository

    Hello,
    I am curious as to how many users on this forum use Designer as a source code repository as well as for logical/ physical modelling, code generation, etc.? We're in a position where we have a number of repositories to store 'code', and what is in Designer is often not the 'master'.
    I've always found the big weakness of CASE tools as code repositories to be the fact that, normally, only a handful of people in an organisation use them, and that most developers will just code by hand anyway. In addition, you need somebody with access to the tool to get the table DDL, or package or whatever.
    I realise that it would be good practice to have somebody administer this kind of thing anyway, but I'm interested in peoples' opinions. We're (still) using v6 so I realise the level of version control is far less granular than later versions of Designer, and I wondered if this is a big hindrance for us in this respect?
    Thanks, Antony

    Hi Antony,
    I would love to have used it - even with the version control of 6i/10g versions. However, as you said, on all the projects I've been on most developers prefer other tools ie: TOAD for writing the source code.
    I find now that Designer has just been left behind and has no chance of ever being used for writing code.
    If I was in the position of a brand new project with NO schema or PL/SQL what would I use? Dunno :) It may well be Designer to control the table/view definitions but would not be Designer for anything else (ie PL/SQL based). It might just be TOAD schema browser on a blank schema.
    Would be wary of using v6 without version control switched on - it's a great feature - but a little too late :(
    Steve

  • INVALID 상태의 OBJECT를 RECOMPILE하는 PROCEDURE

    제품 : ORACLE SERVER
    작성날짜 : 2002-04-18
    INVALID 상태의 OBJECT를 RECOMPILE하는 PROCEDURE
    ===============================================
    Purpose
    Import를 하거나 DDL 작업을 하고 나서 procedure 나 package등의
    pl/sql object가 invalid로 빠지는 경우가 있다. 이런 object들을
    찾아서 recompile해주는 procedure를 소개한다.
    Explanation
    이 procedure는 User 내의 모든 Invalid 상태의 procedure, function,
    package 등의 Object 들을 Recompile한다. Compile에러가 발생하는 경우
    dbms_output package를 이용하여 화면에 display해 주게 되므로 실행하기
    전에 set serveroutput on 을 반드시 실행한다.
    Invalid된 object가 많은 경우라면 compile에러의 확인을 위해 spool을
    받는 것이 좋다.
    CREATE OR REPLACE PROCEDURE RecompileInvalid IS
    CURSOR getlist IS SELECT object_type, object_name FROM
    user_objects WHERE status = 'INVALID' AND
    object_type IN ('PROCEDURE', 'FUNCTION', 'PACKAGE',
    'PACKAGE BODY', 'TRIGGER' );
    schemaname VARCHAR2(100);
    CURSOR geterr ( objname VARCHAR2, objtype VARCHAR2 ) IS
    SELECT text, line, position FROM user_errors WHERE
    name = objname AND type = objtype;
    BEGIN
    SELECT username INTO schemaname FROM user_users;
    FOR getlistrec IN getlist LOOP
    dbms_output.put_line( 'attempting compile on ' ||
    getlistrec.object_name );
    dbms_ddl.alter_compile( getlistrec.object_type,
    schemaname, getlistrec.object_name );
    END LOOP;
    FOR getlistrec IN getlist LOOP
    dbms_output.put_line( '---ERROR---' );
    dbms_output.put_line( 'compile failed on ' ||
    getlistrec.object_name );
    FOR geterrrec IN geterr( getlistrec.object_name,
    getlistrec.object_type ) LOOP
    dbms_output.put_line( 'line: ' || geterrrec.line ||
    ' col: ' || geterrrec.position );
    dbms_output.put_line( substr( geterrrec.text, 1, 100 ));
    END LOOP;
    END LOOP;
    END;
    Example
    SQL> spool Compile.log
    SQL> set serveroutput on
    SQL> exec recompileinvalid;
    attempting compile on CRYPTIT
    attempting compile on CRYPTIT
    attempting compile on DECRYPT
    attempting compile on ENCRYPT
    attempting compile on SYNC_IM_INDEX
    PL/SQL procedure successfully completed.
    SQL> spool off

    우연의 일치인지 저도 어제 rac 기술지원을 나왔는데..
    통계정보를 수집하려고하니 dbms_stats가 invalid되어 있더군요.
    compile 명령을 하려다가 다른 패키지도 invalid되어있기도해서
    utlrp.sql을 수행했습니다.
    물론 백업 후 restart한 후에 세션 모두 클리어시키고 수행했습니다.
    그런데 한번 해서 안되는 경우도 있으니 invalid object의 결과를 보고
    utlrp.sql을 여러번 더 수행하면 해결됩니다.
    ## invalidobj.sql
    doc
    invalid 된 object에 대한 출력
    col owner format a20
    col object_name format a30
    select owner, object_name, OBJECT_TYPE,CREATED,LAST_DDL_TIME, STATUS
    from dba_objects where status<>'VALID';
    글 수정:
    민천사 (민연홍)
    그런데 중요한 것은.. 이것이 open상태에서 수행되더라도
    오라클에서는 그냥 수행해도 문제없다고 하더라도..
    제 개인적인 의견으로는 서비스 중에 수행해서는 절대 안된다고
    생각합니다. 서비스에 어떠한 영향이 갈지도 모르니까요. 문제가
    발생하면 그건 이 작업을 수행한 DBA탓 이겠죠. 장애보고서 써야하고
    골치가 아픕니다.
    저같은 경우에는 백업을 2copy를 하는데 미디어(테이프장치)를
    서로 다른 미디어를 써서 2copy를 해야 작업 시작하겠다고 했고
    그렇게 했습니다. 또한 세션을 모두 클리어시킨 후에 작업했구요.
    장애에 대한 강박관념이라고 할지 모르겠지만 지금까지 본 봐로는
    이렇게 꼼꼼하게 챙기지 않고 장애가 난다면 업계에 오래에 머무르기
    힘들 것 같다는 생각이 들더군요..~
    제가 장애에 너무 민감해서 말씀드리는 것이지 충고를 하는 것은 아닙니다.
    오해가 없으시길 바랍니다.

  • PL Package to sync ddl between two schemas

    About a year or so ago I came across a website (can't remember) that indicated that in 11g there is a package that would automatically update a target schema from a source schema to make it structurally the same (ddl). I've been unable to find such a package and want to know if anyone else out there knows if such a package exists. We are writing some software that would push the ddl changes made in a dev schema to test and then prod without the need to maintain scripts. We would want it to work similar to the way jDeveloper works with database changes made to a model. We could write it from scratch, but didn't want to go that route if there was something available from oracle that we could leverage.
    Thanks in advance for any insight.

    Never used it but probably you are talking about DBMS_COMPARISON?!
    The aforementioned document further links you to Comparing and Converging Data.

  • Get DDL for uncrypted packages using DBMS_METADATA

    Hi all,
    i was wondering if i could extract DDL sources for only uncrypted packages in my database using DBMS_METADATA?
    i have a lot of crypted packages stored in the DB.
    thank you in advance for your help

    dodi wrote:
    mmm so there is no way i can do that :( too bad!What about something like this (note untested)?
    DECLARE
    BEGIN
            FOR r IN
                    SELECT  DISTINCT OWNER
                    ,       NAME
                    ,       TYPE
                    FROM    DBA_SOURCE WHERE
                    NOT REGEXP_LIKE(UPPER(TEXT),'(PROCEDURE|PACKAGE|PACKAGE BODY) (.*) WRAPPED')
                    AND OWNER NOT IN ('SYS','SYSTEM','SYSMAN') -- Or OWNER IN for a specific set of SCHEMAS
                    AND TYPE IN ('PROCEDURE','PACKAGE')
                    AND LINE = 1
            LOOP
                    /*EXECUTE IMMEDIATE 'SELECT DBMS_METADATA.GET_DDL(''' || r.TYPE || ''',''' || r.NAME || ''',''' || r.OWNER || ''') FROM DUAL';*/
                    DBMS_OUTPUT.PUT_LINE('SELECT DBMS_METADATA.GET_DDL(''' || r.TYPE || ''',''' || r.NAME || ''',''' || r.OWNER || ''') FROM DUAL');
            END LOOP;
    END;

  • How to query DDL locks on stored procedures/functions and packages?

    Hi!
    The subject says it all: How do I see existing DDL locks on stored procedures/functions and packages?
    While a procedure is executed it can't be deleted or replaced, so there has to be a DDL lock on it. The information does not seem to be in V$LOCK or V$LOCKED_OBJECTS.
    Thanks!
    Marcus
    Edited by: MMarcus on Nov 21, 2009 3:43 PM

    Hello,
    Here you can find an article about the view DBA_DDL_LOCKS:
    [http://www.praetoriate.com/int_40.htm]
    If you don't have this view on the Data Dictionary, you may have
    to execute the "OH/rdbms/admin/catblock.sql" script first.
    Hope it can help.
    Best regards,
    Jean-Valentin

  • Problems using DDL & EXECUTE IMMEDIATE in package

    Hi...
    I have an 8i package in which I am trying to execute some DDL via EXECUTE IMMEDIATE to create temporary tables from which I then populate a REF_CURSOR by selecting from the last table created in the DDL. The problem is that the compiler doesn't seem to like the DDL.
    Here's what I'm using:
    CREATE OR REPLACE PACKAGE BODY NEREP_REF
    AS
    Procedure GetNE_REF (
    i_Node IN VARCHAR2,
    io_cursor IN OUT t_cursor )
    IS
    sql_stmt varchar2(200);
    v_cursor t_cursor;
    BEGIN
    sql_stmt := 'CREATE TABLE tmp AS SELECT * FROM nerep4;';
    EXECUTE IMMEDIATE sql_stmt;
    OPEN v_cursor FOR
    SELECT NE_Node, NE_Type, EHA, Status, Curr_Func, TP_Name,
    Order_Item_Name, Required_Start, Required_End, Trail_Name
    FROM tmp
    WHERE NE_Node = i_Node ;
    io_cursor := v_cursor;
    END GetNE_REF;
    END NEREP_REF;
    The problem is that when I compile the package I get the errors below:
    SQL> @sp_nerep_body
    Warning: Package Body created with compilation errors.
    SQL> show err
    Errors for PACKAGE BODY NEREP_REF:
    LINE/COL ERROR
    20/7 PL/SQL: SQL Statement ignored
    23/14 PLS-00201: identifier 'NE_NODE' must be declared
    So it seems that it doesn't like the DDL (have I got the sql_stmt assignment in the wrong place maybe?) and then it complains it can't find the columns, which is reasonable because of course it doesn't know that the table 'tmp' comes from the result of the DDL statement!
    If I change the table name in the 'OPEN v_cursor FOR' select clause to a table that already exists (ie: not created in this package) it runs just fine and I get the data I asked for... the problem is that I need to create this table on the fly by using DDL in my package!
    This is driving me crazy - basically I need to be able to execute DDL to do various 'create table ... as select ... from ...' statements which eventually builds a final table which I then want to populate using a REF_CURSOR so I can return the results back to ASP via ADO... but I just can't get the DDL bit to work no matter what I try!!
    Can anyone see what I'm doing wrong here?
    Mike.
    null

    Here are a some ideas to try:
    Remove the extra semicolon from your sql_stmt, so that line reads:
    sql_stmt := 'CREATE TABLE tmp AS SELECT * FROM nerep4';
    Ensure that you have proper privileges as an individual user, not just through a role, by:
    connecting to the database using username system and password manager and granting yourself the proper privileges. For example, if you are user SCOTT, then:
    SQL> GRANT CREATE TABLE TO SCOTT;
    Then, exit and connect as yourself and try to compile and execute your procedure again.
    If that still doesn't work, try testing one little piece at a time until you can identify the part that causes trouble. For example, start with a procedure that does nothing but try to create the tmp table using execute immediate, then add the other pieces, then try to put the procedure in a package.

  • Privilege to view Package DDL only

    Hello Friends,
    I need your help on GRANTS.
    Oracle version: Oracle 11G R2
    OS: AIX
    I have three users in a database. Among these three users, two users, say USR1 and USER2 are having all database objects which is needed for my application and poses all system privileges equivalent to a DBA role.
    The 3rd one I have created is a READ user. I want this user to view only source code of PACKAGES AND PACKAGES BODY objects of only USR1, not USR2. Also, I have more than thousand packages/package bodies in USR1. READ should not be able to CREATE or compile a procedure, just simply be able to view the source code.
    FYI, GRANT EXECUTE enables me to see PACKAGE specific only, not PACKAGE BODY.
    Which privilege should I grant to READ user to achieve this security?
    Please help.

    AshishGautam wrote:
    Hello Friends,
    I need your help on GRANTS.
    Oracle version: Oracle 11G R2
    OS: AIX
    I have three users in a database. Among these three users, two users, say USR1 and USER2 are having all database objects which is needed for my application and poses all system privileges equivalent to a DBA role.
    The 3rd one I have created is a READ user. I want this user to view only source code of PACKAGES AND PACKAGES BODY objects of only USR1, not USR2. Also, I have more than thousand packages/package bodies in USR1. READ should not be able to CREATE or compile a procedure, just simply be able to view the source code.
    FYI, GRANT EXECUTE enables me to see PACKAGE specific only, not PACKAGE BODY.
    Which privilege should I grant to READ user to achieve this security?
    Please help.CREATE OR REPLACE PROCEDURE READ_MY_SOURCE ...
    -- which SELECT TEXT FROM USER_SOURCE ORDER BY LINE
    have this procedure owned be both USR1 & USER2
    GRANT EXECUTE ON USR1.READ_MY_SOURCE TO READ;
    GRANT EXECUTE ON USR2.READ_MY_SOURCE TO READ;

  • Execute DDL in a package

    I connected as system/manager and executed:
    CREATE OR REPLACE PROCEDURE create_user IS
    BEGIN
    EXECUTE IMMEDIATE 'create user my_user identified by my_user' ;
    END;
    But the following error displayed:
    ORA-01031: insufficient privileges
    How can we solve the problem?
    null

    If you got the error while compiling that means you don not have enough privilges to create procedures , if you got the error while running it means that you do not have the priv to create users.
    say
    SELECT * FROM SESSION_PRIVS; -- to have a look at the privs that you have .If you lack the above privs, please contact u're DBA to grant you the same.

  • Support package / add on import error in DB2 V9.1 / windows 2003 system

    Hi
    I have installed ERP 6.0 IDES version in Windows 2003 server with DB2 LUW 9.1 / FP5.
    I have selected "Row Compression" and "Deferred Table Creation" during installation.
    Now when I am importing add on BI Content 7.03, I am getting error during Movename tabs phase.
    Error in phase: IMPORT_PROPER
    Reason for error: TP_STEP_FAILURE
    Return code: 0008
    Error message: OCS Package ALL, tp step "6", return code 0008
    The error message in the file D:\usr\sap\trans\log\P090113.IDS is as follows,
    2 ETP301
    3 ETP361 "96" Shadow-Nametabs activated, DDL executed
    2 ETP362 "6" Shadow-Nametab activations failed
    2 ETP360 Begin: Act. of Shadow-Nametabs with DDL ("2009/01/13 02:57:51")
    2 ETP363 End : Act. of Shadow-Nametabs with DDL ("2009/01/13 02:58:07")
    2 ETP301
    1 ETP172 MOVE OF NAMETABS
    1 ETP110 end date and time : "20090113025807"
    1 ETP111 exit code : "8"
    1 ETP199 ######################################
    I have read some notes it may be due to "Row compression" and "Deffered table creation" option in DB2. Please help me in resolving this issue if it is DB2 related.
    Regards,
    Nallasivam.D

    Hi,
    Please find the real error message which I found in the same log file. This is a new installation.
    System configuration details:
    ERP 6.0 IDES SR3 + Windows 2003 enterprise server SP2 + DB2 V9.1 / FP5
    BASIS and ABAP support pack level: (700) 13.
    Error message:
    3 ETP399 INDEX IN "IDS#BTABI"
    3 ETP399 LONG IN "IDS#BTABD COMPRESS YES"
    3 ETP399 
    2WETP000 02:53:26: Retcode 1: error in DDL statement for "/OSP/T_REPINFO                " - repeat
    2EETP345 02:53:38: Retcode 1: SQL-error "-107-SQL0107N  The name "IDS#BTABD COMPRESS YES" is too lo
    2EETP345 ng.  The maximum length is "18".  SQLSTATE=42622" in DDL statement for "/OSP/T_REPINFO   
    2EETP345             "
    2 ETP399  -
    DB-ROLLBACK() -
    3 ETP399 INDEX IN "IDS#POOLI"
    3 ETP399 LONG IN "IDS#POOLD COMPRESS YES"
    3 ETP399 
    2WETP000 02:54:05: Retcode 1: error in DDL statement for "/SAPPO/CMP_ASG                " - repeat
    2EETP345 02:54:17: Retcode 1: SQL-error "-107-SQL0107N  The name "IDS#POOLD COMPRESS YES" is too lo
    2EETP345 ng.  The maximum length is "18".  SQLSTATE=42622" in DDL statement for "/SAPPO/CMP_ASG   
    2EETP345             "
    2 ETP399  -
    DB-ROLLBACK() -
    2EETP334 02:54:17: error in DDL, nametab for "/SAPPO/CMP_ASG" not activated
    3 ETP399 IN "IDS#POOLD"
    3 ETP399 INDEX IN "IDS#POOLI"
    3 ETP399 LONG IN "IDS#POOLD COMPRESS YES"
    3 ETP399 
    2WETP000 02:54:17: Retcode 1: error in DDL statement for "/SAPPO/CSCRN_HDR              " - repeat
    2EETP345 02:54:29: Retcode 1: SQL-error "-107-SQL0107N  The name "IDS#POOLD COMPRESS YES" is too lo
    2EETP345 ng.  The maximum length is "18".  SQLSTATE=42622" in DDL statement for "/SAPPO/CSCRN_HDR 
    2EETP345             "
    2 ETP399  -
    DB-ROLLBACK() -
    2EETP334 02:54:29: error in DDL, nametab for "/SAPPO/CSCRN_HDR" not activated
    3 ETP399 INDEX IN "IDS#POOLI"
    3 ETP399 LONG IN "IDS#POOLD COMPRESS YES"
    3 ETP399 
    2WETP000 02:54:29: Retcode 1: error in DDL statement for "/SAPPO/F_ASG                  " - repeat
    2EETP345 02:54:41: Retcode 1: SQL-error "-107-SQL0107N  The name "IDS#POOLD COMPRESS YES" is too lo
    2EETP345 ng.  The maximum length is "18".  SQLSTATE=42622" in DDL statement for "/SAPPO/F_ASG     
    2EETP345             "
    2 ETP399  -
    DB-ROLLBACK() -
    2EETP334 02:54:41: error in DDL, nametab for "/SAPPO/F_ASG" not activated
    Regards,
    Nallasivam.D

  • SAP Ides ECC 6.0 Install: Import ABAP - Package SAPDODS Error - ORA-00903

    Experts,
    Good Morning!
    I'm trying to install SAP IDES ECC 6.0 version on a Windows 2008 R2 Server with Oracle 11g DB (11.2).
    System Info: 16GM RAM & 600GB Hdd. Prereqs passed.
    I'm getting the following error during the Import ABAP phase (16 of 29) in the sapinst log:
    "An error occurred while processing option Enhancement Package 6 for SAP ERP 6.0 > SAP Application Server ABAP > Oracle > Central System > Central System( Last error reported by the step: Program 'Migration Monitor' exits with error code 103. "
    Here's the dump of import_monitor.java.log
    java version "1.4.2_32"
    Java(TM) 2 Runtime Environment, Standard Edition (build 4.1.012)
    SAP Java Server VM (build 4.1.012 1.6-b03, Oct 21 2011 14:18:45 - 41_REL - optU - windows amd64 - 6 - bas2:161688 (mixed mode))
    Import Monitor jobs: running 1, waiting 1, completed 141, failed 0, total 143.
    Loading of 'SAPDODS' import package: ERROR
    Import Monitor jobs: running 0, waiting 1, completed 141, failed 1, total 143.
    Here's the dump of import_monitor.log:
    INFO: 2014-07-05 13:42:53
    Data codepage 4103 is determined using TOC file 'C:\Target\Export1\DATA\D010TAB.TOC' for package 'D010TAB'.
    TRACE: 2014-07-05 13:42:53 com.sap.inst.migmon.LoadTask run
    Loading of 'SAPDODS' import package is started.
    TRACE: 2014-07-05 13:42:53 com.sap.inst.migmon.LoadTask processPackage
    Loading of 'SAPDODS' import package into database:
    C:\usr\sap\AVV\SYS\exe\uc\NTAMD64\R3load.exe -i SAPDODS.cmd -dbcodepage 4103 -l SAPDODS.log -stop_on_error
    ERROR: 2014-07-05 13:42:54 com.sap.inst.migmon.LoadTask run
    Loading of 'SAPDODS' import package is interrupted with R3load error.
    Process 'C:\usr\sap\AVV\SYS\exe\uc\NTAMD64\R3load.exe -i SAPDODS.cmd -dbcodepage 4103 -l SAPDODS.log -stop_on_error' exited with return code 2.
    For mode details see 'SAPDODS.log' file.
    Standard error output:
    sapparam: sapargv(argc, argv) has not been called!
    sapparam(1c): No Profile used.
    sapparam: SAPSYSTEMNAME neither in Profile nor in Commandline
    WARNING: 2014-07-05 13:43:21
    Cannot start import of packages with views because not all import packages with tables are loaded successfully.
    WARNING: 2014-07-05 13:43:21
    1 error(s) during processing of packages.
    INFO: 2014-07-05 13:43:21
    Import Monitor is stopped.
    Here's the log of SAPDODS...
    C:\usr\sap\AVV\SYS\exe\uc\NTAMD64\R3load.exe: START OF LOG: 20140705134253
    C:\usr\sap\AVV\SYS\exe\uc\NTAMD64\R3load.exe: sccsid @(#) $Id: //bas/720_REL/src/R3ld/R3load/R3ldmain.c#13 $ SAP
    C:\usr\sap\AVV\SYS\exe\uc\NTAMD64\R3load.exe: version R7.20/V1.4 [UNICODE]
    Compiled Aug 16 2011 02:26:36
    patchinfo (patches.h): (0.098) DB6: correction for R3load PL 91 on HP-UX and SOLARIS (note 1609719)
    process id 1488
    C:\usr\sap\AVV\SYS\exe\uc\NTAMD64\R3load.exe -i SAPDODS.cmd -dbcodepage 4103 -l SAPDODS.log -stop_on_error
    DbSl Trace: ORA-1403 when accessing table SAPUSER
    (DB) INFO: connected to DB
    (DB) INFO: DbSlControl(DBSL_CMD_NLS_CHARACTERSET_GET): UTF16
    (SQL) INFO: Searching for SQL file SQLFiles.LST
    (SQL) INFO: SQLFiles.LST not found
    (SQL) INFO: Searching for SQL file C:\Target\Export1\DB/SQLFiles.LST
    (SQL) INFO: C:\Target\Export1\DB/SQLFiles.LST not found
    (SQL) INFO: Searching for SQL file DODS.SQL
    (SQL) INFO: DODS.SQL not found
    (SQL) INFO: Searching for SQL file C:\Target\Export1\DB/ORA/DODS.SQL
    (SQL) INFO: found C:\Target\Export1\DB/ORA/DODS.SQL
    (SQL) INFO: Trying to open C:\Target\Export1\DB/ORA/DODS.SQL
    (SQL) INFO: C:\Target\Export1\DB/ORA/DODS.SQL opened
    (DB) ERROR: DDL statement failed
    (DROP TABLE "/BI0/APERS_BOD00")
    DbSlExecute: rc = 103
      (SQL error 942)
      error message returned by DbSl:
    ORA-00942: table or view does not exist
    (IMP) INFO: a failed DROP attempt is not necessarily a problem
    DbSl Trace: Error 903 in exec_immediate() from oci_execute_stmt(), orpc=0
    DbSl Trace: ORA-00903 occurred at SQL stmt (parse error offset=15)
    (DB) ERROR: DDL statement failed
    (  CREATE TABLE [/BI0/APERS_BOD00]         (  [TCTUSERNM] nvarchar(000012)          NOT NULL  ,           [TCTOBJVERS] nvarchar(000001)          NOT NULL  ,           [TCTSYSID] nvarchar(000010)          NOT NULL  ,           [TCTQUACT] nvarchar(000001)          NOT NULL  ,           [TCTOBJNM] nvarchar(000040)          NOT NULL  ,           [TCTTLOGO] nvarchar(000004)          NOT NULL  ,           [RECORDMODE] nvarchar(000001)          NOT NULL  ,           [TCTTIMSTMP] nvarchar(000014)          NOT NULL   )          WITH ( DATA_COMPRESSION = PAGE )   )
    DbSlExecute: rc = 99
      (SQL error 903)
      error message returned by DbSl:
    ORA-00903: invalid table name
    (DB) INFO: disconnected from DB
    C:\usr\sap\AVV\SYS\exe\uc\NTAMD64\R3load.exe: job finished with 1 error(s)
    C:\usr\sap\AVV\SYS\exe\uc\NTAMD64\R3load.exe: END OF LOG: 20140705134254
    FYI - A retry does not help. Also tried to search for the error on scn, google but haven't been able to find the right solution.
    Can you help?
    Regards,
    Cobain.

    Divyanshu - sorry to ask but can you explain why i need to update r3load and r3trans to resolve this error? Just want to understand why I'm doing a correction so I can learn from the same.
    Also, can you clarify the file update process:
    For R3load:
    a) the r3load used by the command is dated 8/16/2011 (location:C:\usr\sap\AVV\SYS\exe\uc\NTAMD64\...)
    b) the r3load i have in my db folder is dated 10/23/2011 (location:C:\Final\Installer\BS7i2011_Installation_Master_\DATA_UNITS\BS2011_IM_WINDOWS_X86_64\ORA\UC\...)
    Do i replace (a) with (b)?
    For R3trans:
    How do I update this file?
    - Cobain.

  • Support package update error

    Dear all,
    I am currently update my system.
    The current version is ECC6 EHP7 based on NW7.4
    SAP_BASIS 740 0002
    SAP_ABA 740 0002
    I would like to upgrade to SPS level 5
    We use DB2 LUW 10.5
    In the update phase, we encountered an error message:
    SQL-error "-203-SQL0203N  A reference to column "TABNAME" is ambiguou
    2EETP345 s.  SQLSTATE=42702" in DDL statement for "V_DSH_TF_DETAIL
    As I can see  in the log file, error messages are as below
    ===========================
    3 ETP399 "SHPOSITION", DD30L."AUTOSUGGEST" AS "AUTOSUGGEST" FROM "DD31S"
    3 ETP399 INNER JOIN "DD30L" ON "SHLPNAME" = "SUBSHLP" WHERE "AS4LOCAL" =
    3 ETP399 'A' AND "AS4LOCAL" = 'A' AND "HIDEFLAG" = ' ' AND "AUTOSUGGEST" = 'X'
    3 ETP399 
    2WETP000 06:42:38: Retcode 1: error in DDL statement for "V_DSH_ASSIGNED                " - repeat
    2EETP345 06:42:50: Retcode 1: SQL-error "-203-SQL0203N  A reference to column "SHLPNAME" is ambiguo
    2EETP345 us.  SQLSTATE=42702" in DDL statement for "V_DSH_ASSIGNED                "
    2 ETP399  --------------- DB-ROLLBACK() ---------------
    2EETP334 06:42:50: error in DDL, nametab for "V_DSH_ASSIGNED" not activated
    3 ETP379X06:42:50: activating Nametab "V_DSH_TF_DETAIL":
    3 ETP355Xstatements:
    3 ETP399 CREATE VIEW "V_DSH_TF_DETAIL" AS SELECT DD02L."TABNAME" AS
    3 ETP399 "TABNAME", DD03L."FIELDNAME" AS "FIELDNAME", DD02L."TABCLASS" AS
    3 ETP399 "TABCLASS", DD03L."SHLPORIGIN" AS "SHLPORIGIN" FROM "DD02L" INNER
    3 ETP399 JOIN "DD03L" ON "TABNAME" = "TABNAME" WHERE "AS4LOCAL" = 'A' AND
    3 ETP399 "AS4LOCAL" = 'A'
    3 ETP399 
    2WETP000 06:42:50: Retcode 1: error in DDL statement for "V_DSH_TF_DETAIL               " - repeat
    2EETP345 06:43:02: Retcode 1: SQL-error "-203-SQL0203N  A reference to column "TABNAME" is ambiguou
    2EETP345 s.  SQLSTATE=42702" in DDL statement for "V_DSH_TF_DETAIL               "
    2 ETP399  --------------- DB-ROLLBACK() ---------------
    2EETP334 06:43:02: error in DDL, nametab for "V_DSH_TF_DETAIL" not activated
    2 ETP301 ----------------------------------------------------------------------
    3 ETP361 "0" Shadow-Nametabs activated, DDL executed
    2 ETP362 "2" Shadow-Nametab activations failed
    2 ETP360 Begin: Act. of Shadow-Nametabs with DDL ("2014/03/19 06:42:38")
    2 ETP363 End  : Act. of Shadow-Nametabs with DDL ("2014/03/19 06:43:02")
    2 ETP301 ----------------------------------------------------------------------
    2 ETP301 ----------------------------------------------------------------------
    2 ETP364 Begin: Act. of Shadow-Nametabs ("2014/03/19 06:43:02")
    2 ETP301 ----------------------------------------------------------------------
    2 ETP301 ----------------------------------------------------------------------
    2 ETP338XTouch Load of nametabs
    ===========================
    I have checked another system which is also ehp7 based on NW740 0005, the view "V_DSH_TF_DETAIL" totally doesn't exist, but that is oracle database, here in my case is DB2 database, I have searched for SAP OSS but seems no sap notes for it.
    Do you have any idea how to solve this problem? Big thanks!
    Best regards,
    Fresh man

    Hi Ashutosh,
    Many thanks for your reply, yes this definitely solve my problem.
    But I feel quite confused what's the real reason.
    Several weeks ago, I update a system (EHP7+Oracle) from 74002 to 74005, with SUM, no such problem, however this time, its EHP7+DB2 10.5, from 74002 to 74004, with SPAM, met this kind of problem...
    The support packages are totally the same...
    is it because I should upgrade from 02 to 05 directly? 04 has problem?
    or I should update with SUM instead of SPAM?
    or it is because of DB2??
    or I should involve other packages like something like ST into the update queue?
    Best regards,
    Fresh

Maybe you are looking for