Re-compile a package in a stored procedure

Hi all
We are using Oracle 10 g. I coded a stored procedure that does a lot of things which is re - create a materialized using the dynamic SQL view. However, when this materialized view is created, a package that this stored procedure must, becomes invalid. What is the syntax to recompile the package using the dynamic SQL? I tried something like script below, but I'm getting ' * ORA-24344: success with compilation error * "error message. I would like to re - build the package until it is used in this stored procedure.

DECLARE
      v_sql         VARCHAR2 (1000);
      object_name   VARCHAR2 (50) := 'TEST.PS2_FNS366';
BEGIN
       dbms_output.put_line('This is a test.');
       v_sql := 'Alter package ' || object_name || ' compile  package';
       dbms_output.put_line (v_sql);
       EXECUTE IMMEDIATE v_sql;
     
       v_sql := 'Alter package ' || object_name || ' compile  body';
       dbms_output.put_line (v_sql);
       EXECUTE IMMEDIATE v_sql;      
              
END;
Thank you


Seyed

Normally, this means that STUDENT. V_BEN_REG_CASE_NUMBER references objects (tables and views) that has received the STUDENT SELECT on, but not with the WITH GRANT option. If this is the case, STUDENT may not grant other users access to this data.

If STUDENT. V_BEN_REG_CASE_NUMBER refers to tables A, B and C belonged to another user U, U have to

GRANT SELECT ON u.a TO student WITH GRANT OPTION;
GRANT SELECT ON u.b TO student WITH GRANT OPTION;
GRANT SELECT ON u.c TO student WITH GRANT OPTION;

If the STUDENT has these privileges, it will be able to grant access to his point of view V_BEN_REG_CASE_NUMBER other users.

Justin

Tags: Database

Similar Questions

  • Call a package within a stored procedure

    Hi people,

    I created a package that works very well (well compiled).

    Now, if I run my package via a command in the oracle command line:

    run package_name.procedure_of_package ("arguments");

    in this way, it works perfectly.

    Inside of another procedure (procedure2) I do the same thing,

    but it gives the error:
    There is no function with the name of procedure_of_package in this scope.

    I implemented on the owner of shema and I'm also running on the owner of the schema.

    Thank you very much

    Pipoca

    Hello

    What do you do?...

    If you want to call the "procedure1' according to the number of records in the table 'table_a', then you can do:

    CREATE OR REPLACE PROCEDURE procedure2 AS
       v_teste  number;
    BEGIN
       SELECT count(*)
       INTO   v_teste
       FROM   table_a;
    
       IF v_teste = 0 THEN
          package1.procedure1('AAA', 'BBB');
       ELSE
          package1.procedure1('111', '222');
       END IF;
    END;
    
  • Creating views, dynamic SQL within stored procedure

    I'm having a problem with the creation of dynamic views of in a stored procedure. The following declare block works fine:

    DECLARE
    parameter i_nom_table varchar2 (200): = 'abc ';
    xyz cursor script, SELECT step
    STARTING from scripts
    WHERE table_name = i_nom_table parameter
    ORDER BY step CAD;
    l_sql scripts.script%TYPE;
    l_step scripts.step%TYPE;
    l_error VARCHAR2 (200);
    l_code VARCHAR2 (200);
    Start
    XYZ OPEN;
    LOOP
    XYZ-FETCH INTO l_step, l_sql;
    OUTPUT WHEN xyz % NOTFOUND;
    immediately run l_sql;
    insert into ingest_log values (null, sysdate, i_nom_table, l_step, l_sql, 'Success' parameter);
    END LOOP;
    CLOSE XYZ;
    insert into ingest_log values (null, sysdate, parameter i_nom_table, 0, "Accomplished all the steps.", "Success");
    EXCEPTION WHEN OTHERS THEN
    l_error: = substr (SQLERRM, 1, 200);
    l_code: = SQLCODE;
    insert into ingest_log values (null, sysdate, parameter i_nom_table, l_step, l_sql, l_code |) ' - ERROR - ' | l_error);
    END;

    However, if I create a procedure with this block and try to run it I get an insufficient privileges error. Do not know why. All tables, views, procedures are under the same user, and the user that I'm connected as the runtime of the declare block. The user has the following privileges:

    Connect, resource, xdbadmin, s/n

    Any reason you can think of for this? Script values are generally "CREATE OR REPLACE VIEW As.... » ;

    Permissions in Oracle to do indirectly through roles are not available when compiling packages, functions, and stored procedures. Direct subsidies are required during the creation of these objects in the database.

    http://articles.TechRepublic.com.com/5100-10878_11-6183799.html

  • Entity Framework stored procedure Mapping - OUT unrecognized parameter

    I use the following software:

    • ODP.NET 12 c Release 3
    • Entity Framework 6
    • Visual Studio 2013, SP3
    • Oracle 11g Server

      I created a package containing a stored procedure to update a row in a table.  The procedure is an OUT parameter (named ROWS_AFFECTED) which returns the number of rows affected.

      CREATE OR REPLACE PACKAGE BODY TST. Customer_Procs
      AS
      PROCEDURE Update_Customer
      (
      CUST_ID IN NUMBER,
      WHAT IN VARCHAR2,
      L_NAME IN VARCHAR2,
      EMAIL IN VARCHAR2,
      LAST_UPDATE TIMESTAMP IN
      ROWS_AFFECTED NUMBER
      )
      AS
      BEGIN
      UPDATE
      TST. CUSTOMER
      SET
      NAME = WHAT,.
      LAST_NAME = L_NAME,
      EMAIL_ADDR = EMAIL,
      LAST_UPDT_TIME = CURRENT_TIMESTAMP
      WHERE
      CUSTOMER_ID = CUST_ID
      AND LAST_UPDT_TIME = LAST_UPDATE;

      ROWS_AFFECTED: = NUMBER OF ROWS SQL %;

      END Update_Customer;


      I executed successfully the stored procedure in SQL * more.  The ROWS_AFFECTED OUT parameter is filled with the good

      value.

      I imported the stored procedure in my Entity Framework model using the function successfully import.

      I then traced the parameters of the stored procedure to my entity properties. The ROWS_AFFECTED parameter is shown in the stored procedure mappings, but the "rows affected parameter" check box is cleared.

      Attempt to run my results in the following exception being throw:
      "CustomerModel.msl (22,12): error 2047: a mapping liaison function specifies a function.

      CustomerModel.Store.CUSTOMER_PROCS_UPDATE_CUSTOMER with a parameter not supported: ROWS_AFFECTED. Output parameters cannot

      be mapped through the RowsAffectedParameter property. Use the result links to return values from a function call.

      I am trying to determine what I need to do in order to have the Entity Framework to recognize the ROWS_AFFECTED OUT parameter in the

      stored procedure chart for concurrency control.

      I found a solution: try to declare ROWS_AFFECTED such as 'PLS_INTEGER' instead of 'NUMBER '.  This solved it for me.

    • Cannot create the web service stored procedure.

      I can create more web services is by right clicking on the package of the stored procedure in the db connection. This good worked before and I cannot explain why I can't see this option. Grateteful for tips on why it has stopped working.

      '2009' is what Oracle said.

      John

    • Should I compile the whole package in order to compile in a function, or a procedure inside?

      Should I compile the whole package in order to compile in a function, or a procedure inside?

      Thank you

      Yes.

    • ODP 12 c version 3 with EF 6.1.1 I can't add Stored Procedure of a package to my model

      I use the ODP 12 c Release 3 (12.1.0.2.1), with Entity Framework 6.1.1 with the first database in MS Visual Studio 2013 update 4

      I have a MVC 5 (.Net Framework 4.5.2) project that connects to Oracle 11 G R2 Database server, an existing database (Tables, views and a pack of Stored procedures)

      I can add tables and use them successfully in my model
      I can add a simple stored procedure

      Here's the problem:
      I have my .edmx file right click and click on "update model from database...". «, on the 'Add' tab, I chose «Stored procedures and functions»
      I can see the list of procedures stored in the package (format packageName.usp) and check the box for the stored procedure of my package, then click 'Finish' to start the update process.

      No stored procedures have been added to my Model.Store


      The only possible exit I get the 'entity data model' is:
      Generated template file: Model1.edmx.
      Loading metadata from the database took 00:00:00.5803351.
      The model generation took 00:00:00.3761861.

      How to add a stored procedure from a package with the Entity Framework 6.1.1?

      I found the answer.

      When in the edmx model and you right click "Update Model database.

      Uncheck "Import selected stored procedures and functions in the entity model", select the package and update procedures. (It works)

      Then in "Model Explorer" under "Model. Store\ stored procedures/functions" you will see your procedures in the package (finally). Then their card in "Function Imports".

      I don't understand why unchecking import stored procedures works, but it does.

      I also found easier to simply call the procedure directly and not using Entity Framework, as all my procedures are: insertion, update and deletions and not all parameters mapped on the model for the view.

    • Cursor to another stored procedure return package

      Hello
      I am new to Oracle, and I have the following problem:

      I have a slider in a package that is defined like this:
      create or replace
      PACKAGE 'TestPACKAGE' AS
      DOWNLOAD_CURSOR cursor's select A.* from A Table1, Table2 B
      END TestPACKAGE;
      In reality, there is more than one package with different cursors. I want to use this DOWNLOAD_CURSOR in a stored procedure, function, or another package, to return to the client in a ref cursor
      Something like this:
      create or replace
      procedure aa_test (retCURSOR to sys_refcursor) is
      Start
      retCURSOR: = TestPACKAGE.DOWNLOAD_CURSOR;
      end;
      or replace this procedure with another method to return data and use in a .NET application.

      961449 wrote:
      There are so any solution to access TestPACKAGE. DOWNLOAD_CURSOR to .NET web application. I found how to access a stored procedure that returns a ref cursor
      And the package cannot be change, add a stored procedure that returns a ref cursor

      In this case, it is not possible. Your .NET code cannot directly access the static cursor declaration, because at this point it's just a statement, not an open cursor.
      Cursors declared that are opened using the PL/SQL code, using the OPEN cursor_name statement or variable IN the syntax of other cases.
      .NET and other external applications require a ref Cursor, so the only way you can get this query in a Ref cursor is to open the ref cursor in the query itself.

    • Execution of a stored procedure in a Package in an Oracle schema?

      I found solutions to guidance how to run stored procedures to an Oracle DB, for example http://blogs.oracle.com/adf/entry/call_db_stored_procedure_using.

      However, I have a database where procedures are in the packages and I want to know if there a way, that they can be run using enterprise Java Bean.


      See you soon.

      Published by: 893478 on October 27, 2011 05:46

      Calling stored procedures has nothing to do with the Enterprise Javabeans directly. What you want to do, is to use JDBC to create a callable statement and follow these steps:

           Connection conn = ...; // fetch from a datasource for example
           CallableStatement ps = conn.prepareCall("call PACKAGENAME.PROCEDURENAME(?,?,?)");
      
            ps.setString(1, "InputParam1");
            ps.setString(2, "InputParam2");
            ps.registerOutParameter(3, java.sql.Types.VARCHAR);
      
            ps.execute();
            String res = ps.getString(3);
      

      This example accepts two input parameters and an output parameter. Adapt to your own needs. And don't forget to add exceptions and a finally clause in which you close the statement and connection.

    • Compilation of a stored procedure that is frequently consulted

      RDBMS version: 10.2.0.4.0 in a 2 RAC node

      Our Production database is 24 x 7. Our development team has made a change in the code of the procedure frequently consulted.
      At some point this stored proc is accessible by at least 5 sessions.
      I was asked to compile this procedure with the new changes.
      Since this is a frequently viewed, I think that the only option I have left to compile this proc is stopped by the DB and launch it using
      STARTUP RESTRICT
      and then compile it. But, this procedure is actually headed by a DBMS_JOB, so even if I stop, when I restart, the work will resume i.e. that execution of the stored procedure. Right?

      I can't knock local listeners because they are listening to an another DB in the cluster.

      Is there another better way?

      ALTER system set job_queue_processes = 0 will stop the ease of use.

      You might also consider to define windows service and stop the practical execution of cowboy.

      ------------
      Sybrand Bakker
      Senior Oracle DBA

    • Problem: Not sufficient privileges execution of stored procedure in a package

      I am using Visual Studio 2008 Team Suite, ODT with ODAC 111.07.20 and I am trying to run a procedure stored within a packet, it displays the following error message:

      Oracle.DataAccess.Client.OracleException: ORA-01031: insufficient privileges
      ORA-06512: at & quot; KIKO. PACK_SP & quot; line 205
      ORA-06512: at line 1
      at Oracle.DataAccess.Client.OracleException.HandleErrorHelper (Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx * pOpoSqlValCtx, ByVal src, String, Boolean Bcheck procedure)
      at Oracle.DataAccess.Client.OracleException.HandleError (Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx * pOpoSqlValCtx, ByVal src, Boolean Bcheck)
      at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery)
      at SqlOracleWebService.OracleReplicationTool.GetData (String strNameServer, String strNameDatabase, String strNameTable, String strNameStoreProcedure, String strUserId, String strPassword, intSince, intUntil, Int32 intPort, string strID Int64 Int64) in C:\Documents and Settings\kiko\Desktop\kiko\SQL-ORACLE\SqlOracleWebService\SqlOracleWebService\Oracle\OracleReplicationTool.vb:line 1171
      at SqlOracleWebService.OracleReplicationTool.SmallDataInit (String strNameServerSource, String strNameDatabaseSource, String strNameServerDestiny, String strNameDatabaseDestiny, String strNameTable, String strUserIdSource, String strPasswordSource, String strUserIdDestiny, String strPasswordDestiny, Int32 intPortSource, Int32 intPortDestiny) in C:\Documents and Settings\kiko\Desktop\kiko\SQL-ORACLE\SqlOracleWebService\SqlOracleWebService\Oracle\OracleReplicationTool.vb:line 614
      at SqlOracleWebService.OracleReplicationTool.ReplicationDataInit (Boolean boolBothDirections, String strNameServerSource, String strNameDatabaseSource, String strNameServerDestiny, String strNameDatabaseDestiny, String strNameTable, String strUserIdSource, String strPasswordSource, String strUserIdDestiny, String strPasswordDestiny, Int32 intPortSource, Int32 intPortDestiny) in C:\Documents and Settings\kiko\Desktop\kiko\SQL-ORACLE\SqlOracleWebService\SqlOracleWebService\Oracle\OracleReplicationTool.vb:line 28
      at SqlOracleWebService.Service1.Oracle_ReplicationDataInit (Boolean boolBothDirections, String strNameServerSource, String strNameDatabaseSource, String strNameServerDestiny, String strNameDatabaseDestiny, String strNameTable, String strUserIdSource, String strPasswordSource, String strUserIdDestiny, String strPasswordDestiny, Int32 intPortSource, Int32 intPortDestiny) in C:\Documents and Settings\kiko\Desktop\kiko\SQL-ORACLE\SqlOracleWebService\SqlOracleWebService\Service1.asmx.vb:line 20

      I have change the execute privileges and granted to the user KIKO execute the PACK_SP package, but it does not work. Could you help me?

      Thanks in advance.

      Published by: user9112176 on February 8, 2010 10:27

      This behavior is probably not related to the ODP and will happen when you run the same procedure as the same user of SQLPlus directly for example, so the PLSQL forum is probably a more appropriate place for assistance.

      What is 'KIKO. PACK_SP', line 205? Roles are disabled inside stored procedures, so you must have the permissions that are granted directly.

      It will be useful,
      Greg

    • How to query the DDL lock functions or stored procedures and packages?

      Hello!

      The subject says it all: how to display existing DDL locks on the functions or stored procedures and packages?

      While running a procedure, it cannot be deleted or replaced, so there must be a DDL lock on it. The information does not seem to be in V$ LOCK or V$ LOCKED_OBJECTS.

      Thank you!
      Marcus

      Published by: David on November 21, 2009 15:43

      Hello

      You have the DBA_DDL_LOCKS view.

      Best regards
      Jean Valentine

    • compilation of stored procedure

      The procedure can be stored below.

      I need to declare varchar2 with a number such as varchar2 (30)
      How can I do and how to compile the stored procedure to display the output.

      number variable t1
      date variable t2

      test exec ('345', 'test', 'ECE','' 2008-09-10: t1: t2);

      I am facing problems




      Create or REPLACE procedure (eno vARCHAR2
      ename VARCHAR2
      dept VARCHAR2
      Join_date DATE
      sno ON NUMBER
      End_date DATE
      )
      IS

      BEGIN

      SELECT SNO, end_date IN sno, end_date of EMPLOYEE

      WHERE EMPLOYEE_NO = eno;



      EXCEPTION

      WHEN NO_DATA_FOUND THEN
      SNO: = NULL;
      End_date: = NULL;

      WHILE OTHERS THEN
      SNO: = NULL;
      End_date: = NULL;

      END;
      /

      Your case,

      satyaki>
      satyaki>ed
      Wrote file afiedt.buf
      
        1  cREATE OR REPLACE PROCEDURE Sample (carrier_code vARCHAR2
        2  ,vessel_name VARCHAR2
        3  ,voyage_no  VARCHAR2
        4  ,port_code  VARCHAR2
        5  ,eta_date   DATE
        6  ,tmp_rotation OUT NUMBER
        7  ,tmp_eta_date OUT DATE
        8  )
        9  IS
       10  BEGIN
       11  SELECT ROTN,ETA_DATE INTO
       12  tmp_rotation,tmp_eta_date
       13  FROM Sample1
       14  WHERE LINE_CODE = carrier_code
       15  AND VESS_NAME = vessel_name
       16  AND VOYAGE_NO = voyage_no
       17  AND PORT_CODE = port_code
       18  AND SAIL_DATE IS NULL
       19  AND VOYAGE_TYPE = 0;
       20  EXCEPTION
       21  WHEN NO_DATA_FOUND THEN
       22  tmp_rotation := NULL;
       23  tmp_eta_date := NULL;
       24  WHEN OTHERS THEN
       25  tmp_rotation := NULL;
       26  tmp_eta_date := NULL;
       27* END;
       28  /
      
      Procedure created.
      
      Elapsed: 00:00:02.33
      satyaki>
      satyaki>
      
      satyaki>
      satyaki>declare
        2  t1 number(10);
        3  t2 date;
        4  begin
        5  Sample('MSK','DUBAI','5645','J',null,t1,t2);
        6  dbms_output.put_line('SNO: '||t1||' - '||' END_DATE: '||t2);
        7  exception
        8  when others then
        9  dbms_output.put_line(sqlerrm);
       10  end;
       11  /
      SNO:  -  END_DATE:
      
      PL/SQL procedure successfully completed.
      
      Elapsed: 00:00:01.04
      satyaki>
      satyaki>
      satyaki>
      satyaki>SELECT ROTN,ETA_DATE
        2  FROM Sample1
        3  WHERE LINE_CODE = 'MSK'
        4  AND VESS_NAME = 'DUBAI'
        5  AND VOYAGE_NO = '5645'
        6  AND PORT_CODE = 'J'
        7  AND SAIL_DATE IS NULL
        8  AND VOYAGE_TYPE = 0;
      
            ROTN ETA_DATE
      ---------- ---------
          623930 23-APR-08
      
      Elapsed: 00:00:00.16
      satyaki>
      

      And now to change your query to->

      satyaki>
      satyaki>cREATE OR REPLACE PROCEDURE Sample (carrier_code vARCHAR2
        2  ,vessel_name VARCHAR2
        3  ,voyage_no  VARCHAR2
        4  ,port_code  VARCHAR2
        5  ,eta_date   DATE
        6  ,tmp_rotation OUT NUMBER
        7  ,tmp_eta_date OUT DATE
        8  )
        9  IS
       10
       11  cursor c1
       12  is
       13    SELECT ROTN,ETA_DATE
       14    FROM Sample1
       15    WHERE LINE_CODE = carrier_code
       16    AND VESS_NAME = vessel_name
       17    AND VOYAGE_NO = voyage_no
       18    AND PORT_CODE = port_code
       19    AND SAIL_DATE IS NULL
       20    AND VOYAGE_TYPE = 0;
       21
       22    r1 c1%rowtype;
       23
       24  BEGIN
       25
       26  for r1 in c1
       27  loop
       28    tmp_rotation := r1.ROTN;
       29    tmp_eta_date := r1.ETA_DATE;
       30  end loop;
       31
       32  EXCEPTION
       33  WHEN NO_DATA_FOUND THEN
       34  tmp_rotation := NULL;
       35  tmp_eta_date := NULL;
       36  WHEN OTHERS THEN
       37  tmp_rotation := NULL;
       38  tmp_eta_date := NULL;
       39  dbms_output.put_line(sqlerrm);
       40  END;
       41  /
      
      Procedure created.
      
      Elapsed: 00:00:01.96
      satyaki>
      satyaki>
      satyaki>declare
        2  t1 number(10);
        3  t2 date;
        4  begin
        5  Sample('MSK','DUBAI','5645','J',null,t1,t2);
        6  dbms_output.put_line('SNO: '||t1||' - '||' END_DATE: '||t2);
        7  exception
        8  when others then
        9  dbms_output.put_line(sqlerrm);
       10  end;
       11  /
      SNO: 623930 -  END_DATE: 23-APR-08
      
      PL/SQL procedure successfully completed.
      
      Elapsed: 00:00:00.17
      satyaki>
      satyaki>
      satyaki>SELECT ROTN,ETA_DATE
        2  FROM Sample1
        3  WHERE LINE_CODE = 'MSK'
        4  AND VESS_NAME = 'DUBAI'
        5  AND VOYAGE_NO = '5645'
        6  AND PORT_CODE = 'J'
        7  AND SAIL_DATE IS NULL
        8  AND VOYAGE_TYPE = 0;
      
            ROTN ETA_DATE
      ---------- ---------
          623930 23-APR-08
      
      Elapsed: 00:00:00.06
      satyaki>
      

      Hope this will help.

      Kind regards.

      LOULOU.

    • stored procedures, newbie question

      I am at the point with my Web site where I need to think about the optimization of the query and have started looking at stored procedures for the first time.

      1. am I right in thinking the benefit of the execution of stored procedures is that it is a pre-compiled query?

      2. I'm trying to use the query cache as my 'normal' queries go, but is it possible to cache the results of a stored procedure?

      In practice, using 1 & 2 would provide a significant increase in performance.

      Personally, I use it only for large heavy updates or deletions. For example, I have an Oracle package with a bunch of procedures that run when a person completes an order - this process involves many tables, deletions, updates and a relatively simple logic. I think that the ideal candidate for a stored procedure.

      I use CF as an alternative if, for example, I have to repeat a load of complex business logic in a stored procedure that I have already written in a CFC.

      Keep in mind the benefits of a stored procedure - basically precompiled code. Don't forget that if you are using well trained cfqueries with cfqueryparams, execution plan gets compiled to the top in the first round * anyway *, so if you call a stored procedure or run your query really there is no difference.

      And Yes - do not underestimate the additional time it takes for a developer to do everything in the stored procedures rather than ColdFusion, they don't call it rapid development of applications for anything

      Don't forget as well as someone can write a stored procedure to poorly coded as well as they can write a wrong encoded query. At least if the developer has its application in front of him, he can see instantly what he needs of the index and locate errors, you could go years before realizing a person made a mistake inside a stored procedure, as no one can see the code.

      Regarding security Yes - if you really want to limit security then sprocs will do that for you. However in most of the applications I've seen the right developer has the possibility to write a query, as they see fit.

      Once I use stored procedures while I think of it - if you have more than one application that needs to do the same thing: this should * definitely * be a stored procedure.

      Basically, the same rules apply to them as any other aspect of programming; security of the duplication of code, efficiency, ease of maintenance - it's all a matter of their maximum weight and decide what is best.

    • Using the stored procedure: Source does not have a target executable

      I'm a guy from MS - SQL, so I'm fairly familiar with T - SQL syntax, but feels a heck of a time trying to take the code I wrote for SQL and turn this works with Oracle.

      in any case, I'm using Oracle SQL Developer, and I have a stored procedure that calls the Alter Table statement and adds a column. Just trying to get this one to work before moving on to the other that I have. I get the message that source does not have a target executable when I try to run this command.

      create or replace PROCEDURE rta_conv_addcolumn (rtatablename1 in varchar (20),)
      rtatablename2 in varchar (20),
      rtacolumnname in varchar (256),
      rtacolumninfo in varchar (256))
      AS
      DECLARE rtasql VARCHAR (4000);
      BEGIN
      IF EXISTS (SELECT * from user_tables WHERE table_name = rtatablename1)
      AND NOT EXISTS (SELECT * from user_tab_columns WHERE column_name = rtacolumnname)
      AND table_name = rtatablename1)
      AND NOT EXISTS (SELECT * from user_tab_columns WHERE column_name = rtacolumnname)
      AND table_name = rtatablename2)
      Then rtasql: = ' ALTER TABLE ["+ rtatablename2 +"] ADD "+ rtacolumnname +" "+ rtacolumninfo;
      Run (rtasql);
      END rta_conv_addcolumn;

      If I try to compile I get the following messages, which make no sense, since the syntax I use to declare the input variables seems to be good.

      Error (1.54): PLS-00103: encountered the symbol "(" quand attend une deles de valeurs suivantes:: =.), @ default % of the characters of the symbol ': = ' has been replaced by "(" pour continuer.)
      Error (2.29): PLS-00103: encountered the symbol "(" quand attend une deles de valeurs suivantes:: =.), @ default % of the characters of the symbol ': = ' has been replaced by "(" pour continuer.)
      Error (3.29): PLS-00103: encountered the symbol "(" quand attend une deles de valeurs suivantes:: =.), @ default % of the characters of the symbol ': = ' has been replaced by "(" pour continuer.)
      Error (4.29): PLS-00103: encountered the symbol "(" quand attend une deles de valeurs suivantes:: =.), @ default % of the characters of the symbol ': = ' has been replaced by "(" pour continuer.)
      Error (6.1): PLS-00103: encountered the symbol "DECLARE" when expecting one of the following: begin function package pragma procedure < an ID > subtype type use < a between double quote delimited identifiers of > form current cursor external language the symbol 'start' is substituted for 'SAID' continue.
      Error (15.5): PLS-00103: encountered the symbol "RTA_CONV_ADDCOLUMN" when expects it one of the following values: If

      Adds the column to the table specified in rtatablename1, if there is neither rtatablename1 nor rtatablename2.

      NOT TESTED

      create or replace PROCEDURE rta_conv_addcolumn(rtatablename1 in varchar,
      rtatablename2 in varchar,
      rtacolumnname in varchar,
      rtacolumninfo in varchar)
      AS
      rtasql VARCHAR(4000);
      count1 number;
      count2 number;
      count3 number;
      BEGIN
        SELECT count(*) into count1 FROM user_tables WHERE table_name = rtatablename1;
        SELECT count(*) into count2 FROM user_tab_columns WHERE column_name = rtacolumnname AND table_name = rtatablename1;
        SELECT count(*) into count3 FROM user_tab_columns WHERE column_name = rtacolumnname AND table_name = rtatablename2;
        IF count1>0 AND count2 = 0 AND count3=0 Then
          rtasql:= 'ALTER TABLE '|| rtatablename1 ||'ADD ' || rtacolumnname || ' ' || rtacolumninfo;
          Execute immediate rtasql;
        END IF;
      END rta_conv_addcolumn;
      /
      

      Max

      Published by: Massimo Ruocchio, December 12, 2009 02:15
      Missing AND

    Maybe you are looking for