Create a stored procedure in the settings view

I want to be able to create a view with the parameters of a stored procedure.

Oracle 11g.

don't know how to use the variable in immediate execution.

CREATE OR REPLACE

PROCEDURE TEST_GENERIC (TBL IN VARCHAR2, VWNAME IN VARCHAR2)

AS

BEGIN

RUN IMMEDIATELY "CREATE OR REPLACE VIEW VWNAME AS SELECT SYSDATE FROM TBL";

COMMIT;

END;

exec ('BIRD', 'DUAL') TEST_GENERIC

Thanks for any help

Hello

Single quotes enclose a literal string; in other words, the text between the quotes literally means what it says, without reference to any variables.

So, when you say:

RUN IMMEDIATELY "CREATE OR REPLACE VIEW VWNAME AS SELECT SYSDATE FROM TBL";

CREATE the word literally means to CREATE.  You may or may not have also a variable called CREATE, but that is irrelevant.

The word OR means OR literally.  You may or may not have also a variable called operation GOLD, but that is irrelevant.

REPLACE the word literally means REPLACE.  You may or may not have also a variable called to REPLACE, but that is irrelevant.

...

The TBL Word literally means TBL.  You may or may not have also a variable called TBL, but that is irrelevant.

If you want to reference a variable called TBL, then use TBL outside single quotes, like this:

...

sql_text: = "CREATE or REPLACE VIEW VWNAME AS SELECT SYSDATE FROM '

||  TBL;

dbms_output.put_line (sql_text |) "= sql_text before EXECUTE IMMEDIATE');   -For debugging

EXECUTE IMMEDIATE sql_text.

...

On the rare occasions when you use dynamic SQL statements, always put the dynamic SQL statement in a string variable (for example, sql_text, above) so that you can easily display for debugging purposes and to ensure that the command you are viewing is the same exact command that you should run.

I guess the code you posted is a first test version of something that will be much, much different when it is finished.  Creating objects from database (such as views) in PL/SQL is almost always a terrible idea, and it seems that opinion that this code is attempting to produce would be very useful, anyway.

Tags: Database

Similar Questions

  • Export list of all the stored procedures in the database settings.

    Hello

    How to export the settings all stored procedures in the database list(IN / OUT).

    Thank you

    Published by: Shema on August 8, 2012 06:28
    select * from ALL_ARGUMENTS;
    
  • Error on the definition of the stored procedure in the simultaneous program

    Hello

    I created a stored procedure and wanted it attached to the concurrent program. The purpose of this stored procedure when you run it in simultaneous program, the system retrieves the data from the csv file downloaded from the server, then it will insert in the tables of SO / the Interface API. Below, the error occurred.


    * Starts * 18 April 2012 18:18:42
    Error ORACLE 6550 in FDPSTP

    Cause: FDPSTP failed due to the ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in the call to 'SPKO1 '.
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

    Steps I did to set the stored proc
    < < simultaneous executable program > >

    Executable: RDRAGON_SO_IMPORT
    Short name: RDRAGON_SO_IMPORT
    Application: Order management
    Method of execution: PL/SQL, stored procedure
    Run file name: SPKO1

    < < concurrent program - set > >

    Program: RDRAGON SO IMPORT
    Short name: RDRAGON_SO_IMPORT
    Application: Order management
    Name of executable: RDRAGON_SO_IMPORT
    Method: PL/SQL, stored procedure

    Format: text
    No set

    -Here are my stored procedure-


    CREATE OR REPLACE PROCEDURE APPS. SPKO1 IS
    FH UTL_FILE. TYPE_DE_FICHIER;
    v_line VARCHAR2 (32767).
    v_source_id NUMBER (10);
    v_created_by NUMBER (10);
    v_creation_date DATE;

    v_org_id NUMBER (10);
    v_orig_sys_docref VARCHAR2 (50);
    V_Customer VARCHAR2 (360);
    v_customer_prev VARCHAR2 (360);
    v_sold_to_org NUMBER (10);

    v_orig_line_ref NUMBER (10);
    v_item_code VARCHAR2 (2000);
    v_ordered_qty NUMBER (10);
    v_selling_price NUMBER (10);
    v_count NUMBER (10);
    v_stat NUMBER;


    /******************************************************************************
    NAME: SPKO
    PURPOSE:

    REVISIONS:
    Worm Date Description of the author
    --------- ---------- --------------- ------------------------------------
    1.0 16/04/2012 administrator 1. Created this procedure.

    NOTES:

    Keywords to replace automatically available Auto:
    Object name: SPKO
    SYSDATE: 16/04/2012
    Date and time: 16/04/2012, 17:55:42 and 16/04/2012 17:55:42
    Username: admin (set in Options of TOAD, editor of the procedure)
    Name of the table: (defined in the dialog box "New PL/SQL object")

    ******************************************************************************/
    BEGIN
    v_source_id: = 6;
    v_created_by: = - 1;
    v_org_id: = 204;
    v_customer_prev: = null;
    v_orig_line_ref: = 0;
    v_stat: = 0;

    SELECT header_id in (DE) v_orig_sys_docref
    Select header_id
    of OE_ORDER_HEADERS_ALL
    creation_date desc order
    ) WHERE ROWNUM = 1;


    FH: = UTL_FILE. FOPEN ('XXANDDIR2', 'myfile1.csv', 'R', 32767);
    < < file_read_lines > >
    LOOP
    BEGIN
    UTL_FILE. GET_LINE (fh, v_line);

    V_Customer: = LTRIM (RTRIM (REGEXP_SUBSTR (v_line, "[^,] +' 1, 1") ',' "') ','" ');
    v_creation_date: = LTRIM (RTRIM (REGEXP_SUBSTR (v_line, "[^,] +' 1, 2") ',' "') ','" ');
    v_item_code: = LTRIM (RTRIM (REGEXP_SUBSTR (v_line, "[^,] +' 1, 3") ',' "') ','" ');
    v_ordered_qty: = LTRIM (RTRIM (REGEXP_SUBSTR (v_line, "[^,] +' 1, 4") ',' "') ','" ');
    v_selling_price: = LTRIM (RTRIM (REGEXP_SUBSTR (v_line, "[^,] +' 1, 5") ',' "') ','" ');
    v_orig_line_ref: = (v_orig_line_ref + 1);

    If v_stat = 0 then
    v_orig_sys_docref: = (v_orig_sys_docref + 1);
    end if;

    SELECT hca.cust_account_id from v_sold_to_org
    OF hz_cust_accounts AOB.
    HP hz_parties
    WHERE hca.party_id = hp.party_id
    AND hca.request_id is null
    AND hp.party_name = v_customer;

    If v_stat = 0 then
    INSERT INTO OE_HEADERS_IFACE_ALL)
    order_source_id,
    orig_sys_document_ref,
    org_id,
    CREATION_DATE,
    created_by,
    last_update_date,
    last_updated_by,
    operation_code,
    sold_to_org_id,
    booked_flag)
    VALUES)
    v_source_id,
    ('TEST' | v_orig_sys_docref).
    v_org_id,
    v_creation_date,
    v_created_by,
    v_creation_date,
    v_created_by,
    "INSERT."
    v_sold_to_org,
    'Y') ;
    commit;
    end if;

    INSERT INTO OE_LINES_IFACE_ALL)
    order_source_id,
    orig_sys_document_ref,
    orig_sys_line_ref,
    inventory_item,
    org_id,
    ordered_quantity,
    unit_selling_price,
    unit_list_price,
    CREATION_DATE,
    created_by,
    last_update_date,
    last_updated_by,
    operation_code)
    VALUES)
    v_source_id,
    ('TEST' | v_orig_sys_docref).
    v_orig_line_ref,
    v_item_code,
    v_org_id,
    v_ordered_qty,
    v_selling_price,
    v_selling_price,
    v_creation_date,
    v_created_by,
    v_creation_date,
    v_created_by,
    "INSERT");
    commit;

    v_customer_prev: = v_customer;
    If v_customer_prev = v_customer then
    v_stat: = 1;
    on the other
    v_stat: = 0;
    end if;
    -DBMS_OUTPUT. Put_line ('Col1: ' | v_source_id |', Col2: ' | v_creation_date |', Col3: ' | v_created_by |', Col4: ' | v_updated_date |', Col5: ' | v_updated_by);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    OUTPUT file_read_lines;
    END;
    END LOOP;
    SELECT count (*) in the OE_HEADERS_IFACE_ALL v_count;
    DBMS_OUTPUT. Put_line (' record Total inserted successfully: ' | v_count);
    UTL_FILE. FCLOSE (FH);

    END SPKO1;
    /


    But when I run the stored procedure using TOAD his work.

    Help, please. This is my first time to attach the stored procedure in the concurrent program.

    Thank you very much.

    Kind regards
    Diane

    Published by: peopsquik08 on April 18, 2012 03:58

    as clive_t solier
    >
    You must explicitly reference the settings out
    >

    Try

    DECLARE
    VFILE VARCHAR2(32767);
    V_SOURCE_ID NUMBER;
    --
    ERRBUF VARCHAR2(200);
    RETCODE NUMBER;
    
    BEGIN
    VFILE := 'myfile1.csv';
    V_SOURCE_ID := 6;
    
    --APPS.OMORDERLOADER.SPKO1 ( VFILE, V_SOURCE_ID );
    --COMMIT;
    
    APPS.OMORDERLOADER.SPKO1(
        ERRBUF => ERRBUF,
        RETCODE => RETCODE,
        VFILE => VFILE,
        V_SOURCE_ID => V_SOURCE_ID
      );
    END;
    

    but the code above to test your proc

    to run concurrent SQL, you can use fnd_submit.submit_program

  • Can not see all the stored procedures in the Entity Data Model Wizard

    I hope it is a simple oversight on my part I try to use the new beta version of odp.net with entity framework support. I can open the Entity Data Model Wizard, give him my information database, and I can choose various tables to use successfully. But in the list where I select the tables, views and stored procedures, the wizard does not see my stored procs or my point of view.

    Does anyone know why he would see the tables but not views or stored procedures? My procs can be found under "packages" If that makes a difference. I tried to create a fictional stored procedure at the level above the title of 'procedures', but it is unclear whether.

    Is it possible for me to debug this from here? The log files, I could watch that would help me?

    Thank you
    Jim

    I belive your Oracle database 10 g such as 9iR2 predates.
    ODP/EF Beta does not list the stored procedures or functions when connect you to a database Oracle 10 g before.

    Readme.txt:
    4. the procedures are not compatible with the DB 9.2.
    Thus, there is no stored procedure listed by the EDM Wizard for 9.2 DBs.

  • How to create a stored procedure to delete and create table

    Version: Oracle 10g

    I am trying to create a stored procedure that is delete it and create a table based on a select statement. I can create the table, but I can't let it go.

    CREATE or REPLACE procedure EC_LOAD is
    Start
    INSERT INTO Sales_table
    (FSCL_WK,
    DIV,
    ACCT_TYPE)
    Select
    FSCL_WK,
    DIV,
    ACCT_TYPE
    Of
    sales_revenue;
    end ecload;

    I need to drop the Sales_table before inserting the values. How can I do this?

    user610131 wrote:

    I need to drop the Sales_table before inserting the values. How can I do this?

    If you drop off where you insert it :)? Do you mean DELETE or TRUNCATE?

    If table can be truncated (and don't forget TRUNCATE is DDL then he will commit):

    CREATE OR REPLACE procedure EC_LOAD is
    begin
    EXECUTE IMMEDIATE 'TRUNCATE TABLE Sales_table';
    INSERT INTO Sales_table
    (FSCL_WK,
    DIV,
    ACCT_TYPE)
    Select
    FSCL_WK,
    DIV,
    ACCT_TYPE
    from
    sales_revenue;
    end ecload;
    

    Otherwise, use DELETE:

    CREATE OR REPLACE procedure EC_LOAD is
    begin
    DELETE Sales_table;
    INSERT INTO Sales_table
    (FSCL_WK,
    DIV,
    ACCT_TYPE)
    Select
    FSCL_WK,
    DIV,
    ACCT_TYPE
    from
    sales_revenue;
    end ecload;
    

    SY.

  • Call stored procedures in the object module and application of entity

    Hello

    I've implemented a helper methods that contains the EntiyImpl base class to call stored procedures.

    Now, I need to call procedures stored from the module of the application.

    Apart from the creation of a module base class asks and the programme of assistance of duplication of code in the method is possible
    to share methods of assistance for calling stored procedures between the entity impl and application module impl?


    Concerning
    Paul

    Support code depends on characteristics of an object instance given entity beyond its database transaction?

    If so, I'm not sure I see how it could be used with a class of application module.

    Otherwise, here's what you do:

    Step 1:

    Set up the database transaction - you can even choose to. So instead of

    {myHelperMethod (Object someParam) protected
    DBTransaction trans = getDBTransaction();
    ...
    }

    This is for change

    protected myHelperMethod (DBTransaction trans, someParam Object) {}
    ...
    }

    Step 2: make the method public and static - once you set DBTransaction, you should be able to do.

    public static myHelperMethod (DBTransaction trans, someParam Object) {}
    ...
    }

    Step 3: Remove your EntityImpl base class method in a utility class:

    Public MustInherit class PlSqlUtils {}
    private PlSqlUtils() {}

    public static myHelperMethod (DBTransaction trans, someParam Object) {}
    ...
    }
    }

    When you call the method of application module, object entity or class of same view object, call

    PlSqlUtils.myHelperMethod (getDBTransaction (), paramValue);

    Unlike Transaction.executeCommand (), allows you to provide features like the setting procedure of parameter values, recovery of the values of the parameters, etc.

    Hope this helps,
    Avrom

  • How to use &amp; APP_ID. stored procedure to the inside.

    Hello, I created a stored procedure. I'm calling it my code in process. I want to use so many variables like page & APP_ID. I don't want to pass as an argument. Is it possible to use these variables without passing on the inside. ? (& page_id. and also an application of variable level)

    Any help is appreciated.

    Thank you.

    Dark Lord

    You can use the function 'v' to reference the APEX elements in pl/sql. Then APP_ID is done refers to

    v ('APP_ID')

    CITY

  • Error in retrieving the stored procedure of the DB JDev adapter

    Hello
    I am facing a problem when configuring Jdeveloper stored procedures using the DB adapter. I use in my Sql Server 2005 database, version Jdeveloper 10.1.3.3 Version 10.1.3.1.Bpel. Connection to the database SQL Server 2005 is good, but it only displays the views and tables. I get the following error message when I try to add the sql stored procedure call
    "An error occurred while getting the database schemas. Make sure the database connection is valid and is supported"

    Can someone help me please.

    Thank you
    Phani

    Published by: Brad on October 28, 2008 11:30

    Post your email and I'll send you a complete tutorial of SQL Server.

  • The call PLSQL stored procedure from the HTML form Submit button

    Hello

    I'm having a little difficulty with the appellant a stored procedure using a html form button. Here is the code I have right now...
    HTP.PRINT('<form action=ZWGKERCF.P_confdelete>');
    HTP.PRINT('<input type=''submit'' value='' Yes '' onClick=''document.getElementById("mypopup").style.display="none"''>');
    HTP.PRINT('</form></div>');
    Here's the question - I need to find a way to pass variables to this stored procedure, so he knows what data to operate on. This stored procedure removes the data in a specific database record and I have to pass three variables to this procedure to run.

    Allows to call class_number, term, conf will impact these three variables and the data will be deleted and the person will see a confirmation screen once the deletion request completed.

    So ideally I would want: ZWGKERCF. P_confdelete (class_number, term, conf), then the stored procedure would deal with the rest!

    Seems simple enough, but I don't know how to make this happen... My thoughts were:

    Transmit data to this (the three areas that I need) html form in hidden variables. Then somehow pass them using the POST method to the procedure and read using GET?

    Can someone clarify what the best way to do it? I feel that its little something miss me you - but I would really like an idea expertise :-)

    Thank you very much in advance!

    -Jeff

    >
    ...

    I would like to assign a variable, the duration, the conf crn all variables in this procedure and then act on them accordingly.

    But you already have it in a variable. If you want you can assign the value again to another variable.

    example of

    PROCEDURE P_confdelete(CRN NUMBER,TERM NUMBER, CONF VARCHAR2)
       IS
          v_crn number(38);
          v_term number(38);
          v_conf varchar2(1000);
    
      BEGIN
           HTP.PRINT('test1 '||crn||'/'||term||'/'||conf); 
    
          v_crn := crn;
          v_term := term;
          v_conf := conf;
    
          HTP.PRINT('test2 '||v_crn||'/'||v_term||'/'||v_conf); 
    
    END P_confdelete;
    
  • Failed to create the stored procedure with the object as a parameter

    Hello

    No idea how to create procedures to the current data stored in SQLFire, try to run the command prompt "sqlf" per call "create_proc.sql" as give below error below

    C:\SQLFire10Beta>sqlf
    sqlf version 10.4
    sqlf> connect client 'localhost:1527';
    sqlf> run 'create_proc.sql';
    sqlf> CREATE PROCEDURE INSURANCE.SEARCHCUSTOMER (IN CUST OBJECT) DYNAMIC RESULT SETS 1 LANGUAGE JAVA PARAMETER STYLE JAVA READS SQ
    L DATA EXTERNAL NAME com.xxx.xxx.sqlfire.dao.CustomerSearchProcedure.searchCustomer;
    ERROR 42X01: Syntax error: Encountered "" at line 1, column 47.
    Caused by: SqlException: Syntax error: Encountered "" at line 1, column 47.
            at com.vmware.sqlfire.internal.client.am.Statement.completeSqlca(Statement.java:1838)
    sqlf> sqlf> 


    and I created a class Java as described below:

    public class CustomerSearchProcedure {
     
     public static void searchCustomer (BaseDTO[] customers, ResultSet[] outResults,
       ProcedureExecutionContext context) throws SQLException {
      BaseDTO searchCriteria = customers[0];
      StringBuilder sql = new StringBuilder();
      sql.append("SELECT * FROM INSURANCE.CUSTOMERS WHERE CUST_NAME LIKE '"+searchCriteria.getCustName().trim() + "%'");
      
      Connection cxn = context.getConnection();
      Statement stmt = cxn.createStatement();
      ResultSet rs = stmt.executeQuery(sql.toString());
      outResults[0] = rs;
     } //END OF METHOD
    }


    This procedure is called class using the class StoredProcedure Spring DAO

    You can let me know why am not able to create the procedure?

    FYI, pots can also can be dynamically installed in the system by using the SYS. Table client-side JARS to transport the jar bytes rather than by requiring that the pot be accessible side Server (http://pubs.vmware.com/vfabric5/index.jsp?topic=/com.vmware.vfabric.sqlfire.1.0/deploy_guide/Topics/sysjars_install.html)

  • Create a stored procedure to convert a temporary table to the current table

    I have a table in oracle, named motor_assist2 with columns:
    NAME
    ADDRESS
    PHONE
    CITY
    STATE
    ZIP
    FRIENDSHIP
    SERVICE
    WAIT_TIME
    CONT_SERVICE
    COMMENTS
    DATETIME
    TECHNICIAN1_RADIO
    TECHNICIAN1_NAME
    LOCATION
    COUNTY_NAME
    COUNTY_ABBR
    MAV_TROOP
    TECHNICIAN2_RADIO
    TECHNICIAN2_NAME
    ID
    BEG_DATE
    END_DATE
    MONTH
    YEAR

    I have an another table (motor_assist9) in excel with similar columns I want to insert this data into my table (motor_assist2) current using a procedure but do not know how to do it. Can someone help me? Thank you

    Deanna

    If the number of columns and the order of the columns match on both tables, you can use:

    insert into motor_assist2 select * from motor_assist9;
    

    If this isn't the case, you will need to specify which columns of the source and/or destination:

    insert into motor_assist2 (destination, column, list)
           select source, column, list from motor_assist9;
    

    To make a wrap just stored as appropriate procedure insert the statement with the following code:

    create or replace procedure procedure_name as
    begin
      
    end;
    /
    
  • Create the stored procedure with the table from another throw diagram PLS-00201

    Oracle 10g. I'm new on procedures, so maybe I'm missing something obvious.

    The ABC schema owner has table T2001_WRITEOFF. The SYSDBAs given SIUD Some_Update_Role and granted this role to developer user IJK. IJK user then created a private synonym T2001_WRITEOFF for ABC. T2001_WRITEOFF. It worked with the usual SQL DML commands.

    When I try to create a simple procedure, it throws PLS-00201 identifier "T2001_WRITEOFF" must be declared and the points of the 2nd line.

    create or replace procedure woof1(
      fooname
    in T2001_WRITEOFF.territory%TYPE,  <=== error points here
      bardesc
    IN T2001_WRITEOFF.ind_batch_submit%TYPE) IS
    BEGIN
      
    INSERT into T2001_WRITEOFF
      
    VALUES ( fooname, bardesc);
    END woof1;
    /


    What I am doing wrong?


    Thank you

    JimR


    Grant the necessary rights directly to the user (not through a role):

    http://asktom.Oracle.com/pls/asktom/asktom.download_file?p_file=6551289900368934430

  • block of data based on a stored procedure with the input arguments

    Hello

    I am able to create a block of data based on the stored procedure.
    but I want that procedure to take both of the input arguments and I am facing issue while setting the value for this input arguments from another block element.
    Please someone help, how to set the value of the input of another block-element of control argument? (Note: data block is based on the stored procedure)

    Thanks in advance,
    Jean François Anandan

    I have an example that really works

    in the ownership of block

    arguments of data source query that you have two sections

    names one argument he write the name of the argument on the right, type the setting, fashion and value: block1.name and then pass the value to the procedure

  • Using a stored procedure with the DBUM connector

    Hello, I am a new to the Oracle Identity Manager. The system that I am running on is Windows Server 2008. I recently installed the version 11.1.1.3.0 from the Identity and Access Management suite, as well as the appropriate components. I use a database of 11 g R2 as my deposit. I installed the DBUM connector and have successfully provided a user to my database (which is also an Oracle database).

    However, I have an instance where I need to provide not only a database user account, but also this user and password (after the execution of some arbitrary for her, as features by adding a 1 or chop) at a table in the same database.

    Could someone give me please a detailed description of what I need to do to achieve and possibly point me in the direction of certain documents? I greatly appreciate it.

    You can write your own custom code to execute a stored procedure. Here is the documentation for it: http://download.oracle.com/javase/tutorial/jdbc/basics/storedprocedures.html

    Create your code and deploy your jar file in the folder xellerate/JavaTasks. Create an adapter to use the code. Then on your commissioning process definition, create a new task and plug in the adapter. Finally, start the task of the user to create the task.

    -Kevin

  • Create a stored procedure

    This procedure works fine, but I want to make a stored procedure to schedule it to run over time. I'd appreciate any help?

    SET SERVEROUTPUT SIZE 1000000
    declare
    cursor obj_cursor (objname Varchar2) is
    Select object_name, object_type, owner
    from dba_objects
    where owner = 'ITA '.
    and object_type IN ('TABLE', 'SEE')
    and object_name like '% JOB_;

    cursor c_job_status is
    SELECT ownerid jobid, starttime, endtime
    OF ita.tpis32_job_status
    WHERE starttime < sysdate - 800
    AND num_lines > 10000000;
    WK_SQL VARCHAR2 (500);
    WK_JOBSTR VARCHAR2 (500);
    BEGIN
    for c_job loop c_job_status
    wk_jobstr: = 'JOB_ | c_job. JobID | '%';
    for wk_rec loop obj_cursor (wk_jobstr)
    If wk_rec.object_type = "TABLE" then
    wk_sql: = 'drop table' |' ITA.' | wk_rec.object_name | ';';
    dbms_output.put_line (wk_sql);
    end if;
    If wk_rec.object_type = "DISPLAY" then
    wk_sql: = 'drop view ' | wk_rec.object_name | ';';
    dbms_output.put_line (wk_sql);
    -Wk_sql EXECUTE IMMEDIATE.
    end if;
    end loop;
    end loop;
    end;
    I tried this, but it did work ' t:
    create or replace procedure delete_table is
    SET SERVEROUTPUT SIZE 1000000
    declare
    cursor obj_cursor (objname Varchar2) is
    Select object_name, object_type, owner
    from dba_objects
    where owner = 'ITA '.
    and object_type IN ('TABLE', 'SEE')
    and object_name like '% JOB_;

    cursor c_job_status is
    SELECT ownerid jobid, starttime, endtime
    OF ita.tpis32_job_status
    WHERE starttime < sysdate - 800
    AND num_lines > 10000000;
    WK_SQL VARCHAR2 (500);
    WK_JOBSTR VARCHAR2 (500);
    BEGIN
    for c_job loop c_job_status
    wk_jobstr: = 'JOB_ | c_job. JobID | '%';
    for wk_rec loop obj_cursor (wk_jobstr)
    If wk_rec.object_type = "TABLE" then
    wk_sql: = 'drop table' |' ITA.' | wk_rec.object_name | ';';
    dbms_output.put_line (wk_sql);
    end if;
    If wk_rec.object_type = "DISPLAY" then
    wk_sql: = 'drop view ' | wk_rec.object_name | ';';
    dbms_output.put_line (wk_sql);
    -Wk_sql EXECUTE IMMEDIATE.
    end if;
    end loop;
    end loop;
    end delete_table;
    create or replace procedure delete_table is
    cursor obj_cursor(objname Varchar2) is
    select object_name, object_type, owner
    from dba_objects
    where owner = 'ITA'
    and object_type IN ('TABLE', 'VIEW')
    and object_name like 'JOB_%';
    
    cursor c_job_status is
    SELECT jobid, ownerid, starttime, endtime
    FROM ita.tpis32_job_status
    WHERE starttime < sysdate - 800
    AND num_lines > 10000000;
    WK_SQL VARCHAR2(500);
    WK_JOBSTR VARCHAR2(500);
    BEGIN
    for c_job in c_job_status loop
    wk_jobstr := 'JOB_' ||c_job.jobid||'%';
    for wk_rec in obj_cursor(wk_jobstr) loop
    if wk_rec.object_type = 'TABLE' then
    wk_sql := 'drop table ' ||'ita.'|| wk_rec.object_name || ';';
    dbms_output.put_line(wk_sql);
    end if;
    if wk_rec.object_type = 'VIEW' then
    wk_sql := 'drop view ' || wk_rec.object_name || ';';
    dbms_output.put_line(wk_sql);
    --EXECUTE IMMEDIATE wk_sql;
    end if;
    end loop;
    end loop;
    end delete_table;
    

Maybe you are looking for