Call data of Variable in a stored procedure for the name of the Partition

Hello

Here is an excerpt of a Proc Srored I wrote.
The objective here is to copy data from a partition of a table.
I have first query the name of the partition of the table ALL_TAB_PARTITIONS and even store in a VARCHAR2 variable named partition_name_low.
I then try to select the data in that partition of the table using the name of the variable.

PROCEDURE purge AS

partition_name_low VARCHAR2 (25);

BEGIN
--+
-Request for the highest value of the timestamp in the 1st partition in the current table.
--+
SELECT NOM_PARTITION
IN partition_name_low
OF ALL_TAB_PARTITIONS
WHERE TABLE_NAME = 'TABLE1' AND PARTITION_POSITION IN
+(+
SELECT MIN (PARTITION_POSITION)
OF ALL_TAB_PARTITIONS
WHERE TABLE_NAME = 'TABLE1 '.
+);+
COMMIT;


COMMIT;
DBMS_OUTPUT. Put_line (partition_name_low: ' * ' |) TO_char (sysdate, ' ' the HH24: MI: SS DD/MM/YYYY) | ("From scrub data *');

--+
-Copy data from a partition 1 to Table Archive
--+

INSERT / * ADD * / IN TABLE1_ARCHIVE +.
SELECT * FROM TABLE1 PARTITION (partition_name_low).


However, I am facing a problem here because now I get an error that "ORA-02149: specified Partition does not exist.
As I understand it, is that the Oracle query contains the literal string "partition_name_low", instead of the data in it.
I tried with
& partition_name_low
AND
: partition_name_low

with no luck.
In the 2nd case, I get the obvious exception 'bad bind' variable

Please can anyone suggest how I can handle this situation where I can use a variable see the partition name in a select query?

Thanks in advance!
Abhishek.

Hello, try:

EXECUTE IMMEDIATE 'INSERT /*+ APPEND */ INTO TABLE1_ARCHIVE SELECT * FROM TABLE1 PARTITION(' || partition_name_low ||')';

Tags: Database

Similar Questions

  • A piece of procedure for the partition!

    Hi gurus,

    We have a PLSQL package that we use to create partitions. Same code works in a database so that not in another. This is only part of the code that compiles all invalid objects in the database. I am not able to understand why it fails in the TEST database and works perfectly in database production. Please help with your comments. Thanks in advance.

    CODE

    -----------------

    CREATE OR REPLACE PACKAGE 'SYSTEM '. "" PTAPI ".

    as

    procedure p (p_text varchar2);

    procedure to recompile;

    end ptapi;

    CREATE OR REPLACE PACKAGE BODY 'SYSTEM '. "" PTAPI ".

    as

    g_part_date_format varchar2 (1000): = 'YYYYMMDD ';

    procedure p (p_text varchar2)

    as

    Start

    dbms_output.put_line (p_text);

    end;

    procedure to recompile

    as

    cursor c_invalid

    is

    Select 'Edit'.

    Decode (o.object_type, 'BODY of PACKAGE', 'PACKAGE', object_type)

    || ' '

    || o.Owner

    || '.'

    || o.object_name

    || "compilation".

    || decode (object_type, 'BODY of PACKAGE', 'BODY', ") statement

    dba_objects o, (SELECT MAX (LEVEL) dlevel, object_id

    OF PUBLIC_DEPENDENCY

    CONNECTION BY object_id = referenced_object_id PRIOR

    GROUP BY object_id

    ) d

    where o.status = 'INVALID'

    and o.object_type in ('PROCEDURE', 'FUNCTION', 'PACKAGE', 'PACKAGE BODY', 'SHOW', 'TRIGGER')

    and d.object_id = o.object_id

    order by d.dlevel desc, o.object_type, o.object_name

    ;

    Start

    for r_invalid in c_invalid

    loop

    p (r_invalid. Statement);

    immediately run r_invalid.statement;

    end loop;

    end;

    end ptapi;

    TEST DB

    -----------

    DB - 10.1.0.5.0

    OS - ahc529 SunOS 5.10 Genric_120011-14 sun4v sparc SUNW. Sun-Fire-T200

    ERRORS

    ---------------

    35 36 37 p (r_invalid.statement);

    38 immediately execute r_invalid.statement;

    39 end of loop;

    end;

    40 41 end ptapi;

    42.

    WARNING: The body of a Package created with compilation errors.

    SQL > show errors

    No errors.

    SQL > 900 fixed lines

    set of 900 pages

    Select * from dba_errors where name = order of 'PTAPI' by ASC of line; SQL > SQL >

    OWNER NAME ON THE SCRIPT LINE POSITION

    ------------------------------ ------------------------------ ------------ ---------- ---------- ----------

    TEXT

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------

    ATTRIBUTE MESSAGE_NUMBER

    --------- --------------

    PTAPI 2 15 1 SYSTEM PACKAGE BODY

    PL/SQL: SQL statement ignored

    ERROR 0

    PACKAGE SYSTEM 1 23 7 PTAPI BODY

    PL/SQL: ORA-00942: table or view does not exist

    ERROR 0

    PACKAGE SYSTEM 4 37 1 PTAPI BODY

    PL/SQL: Statement ignored

    ERROR 0

    SYSTEM PTAPI 3 37 3 PACKAGE BODY

    PLS-00364: 'R_INVALID' use the loop index variable is not valid

    ERROR 364

    SYSTEM PTAPI 6 38 1 PACKAGE BODY

    PL/SQL: Statement ignored

    ERROR 0

    PACKAGE PTAPI 5 38 19 SYSTEM BODY

    PLS-00364: 'R_INVALID' use the loop index variable is not valid

    ERROR 364

    6 selected lines.

    PROD DB

    --------------

    Version of DB - 10.1.0.5.0

    OS - ahc524 SunOS 5.10 Generic_120011-14 sun4u sparc SUNW, Netra-T12

    Running code

    -----------------------

    SQL > CREATE OR REPLACE PACKAGE 'SYSTEM '. "" PTAPI3 ".

    as

    procedure p (p_text varchar2);

    procedure to recompile;

    end ptapi3;

    2 3 4 5 6

    7.

    Package created.

    SQL > CREATE OR REPLACE PACKAGE BODY 'SYSTEM '. "" PTAPI3 ".

    2 as

    g_part_date_format varchar2 (1000): = 'YYYYMMDD ';

    3 4

    procedure 5 p (p_text varchar2)

    as

    6 7 starts

    8 dbms_output.put_line (p_text);

    9 end;

    10

    procedure to recompile

    11 12 as

    Cursor 13-c_invalid

    is

    14 15 select 'Edit'.

    Decode (o.object_type, 'BODY of PACKAGE', 'PACKAGE', object_type)

    16-17. ' '

    18. o.Owner

    19. '.'

    20. o.object_name

    21. "compilation".

    22. decode (object_type, 'BODY of PACKAGE', 'BODY', ") statement

    o, (SELECT MAX (LEVEL) dlevel, object_id from dba_objects 23

    24 FROM PUBLIC_DEPENDENCY

    25 CONNECT BY object_id = referenced_object_id PRIOR

    26 GROUP BY object_id

    (27) d

    28 where o.status = 'INVALID '.

    29 and o.object_type in ('PROCEDURE', 'FUNCTION', 'PACKAGE', 'PACKAGE BODY', 'SHOW', 'TRIGGER')

    30 and d.object_id = o.object_id

    31 order by d.dlevel desc, o.object_type, o.object_name

    ;

    32 33

    start at 34

    35 for r_invalid in c_invalid

    loop

    36 37 p (r_invalid.statement);

    38 immediately execute r_invalid.statement;

    39 end of loop;

    end 40;

    end 41 ptapi3;

    42.

    Package body created.

    Thanks for your reply.

    Actually, we had a problem with a privileged location. the code was written in 9i and db has been improved to 11g.

    We therefore made below the privilege, to the owner of the procedure and it worked like a charm.

    Select any dictionary to the owner;

    Kind regards

    Lancerique.

  • call a stored procedure for each row in the transitional attribute and display the data in the form of af: table. The other rows are based on the entities

    Hi Experts,

    JDeveloper 12.1.3.0.0

    I have a VO based on entity object. With a column of the VO is transient attribute (I created).

    I need to call a stored procedure for each row in the transitional attribute and display the data in the form of af: table. As well as other attributes.

    So can anyone suggest how can I achieve this?

    Thank you

    AR

    I think that you need a stored function (which returns the value) in this case, is not?

    Take a look at:

    https://docs.Oracle.com/CD/B31017_01/Web.1013/b25947/bcadvgen005.htm

    and search for:

    Invoking stored function with only Arguments in

    call your function in the Get attribute and return value accessor...

  • 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;
    
  • 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.

  • Call of postChanges() front of a stored procedure

    I use 11.1.1.2 JDeveloper and ADF with BC. I have the following situation:

    I am updating a record via a modifiable display object. When I click on validate, I also need to call an existing stored procedure on my database to do some updates. The stored procedure queries the table on which my principal object based and did the updates with other tables/records based on this information. Is there a mistake in the stored procedure, then I want to roll back the changes in my app module, so I can't commit changes in module app until I know that the stored procedure was a success. But the stored procedure cannot see my changes from the object until they are committed (or changes).

    I am considering the following:
    (1) make changes to display the object
    (2) call postChanges() on transaction of my app module
    (3) call the procedure stored via the PreparedStatement class
    (4) commit (if errors, rollback)

    This is the preferred method for this situation?

    Thank you
    Brad

    Brad,

    As long as the stored procedure does not commit, there is no autonomous transaction and you can be sure that the postChanges() and commit() will be called in the same request, I think you should be OK.

    Nick

  • 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

  • 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

  • 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.

  • 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;
    
  • Procedure for the number of working days per month when the user enters to and from everyday

    Hi all

    Can provide you a solution to this - procedure for the number of working days per month when the user enters and days.

    Suppose that the user enters November 18, 2014 start date and date as November 23, 2014.

    The output should display

    Count: 4

    November 18, 2014 Mar

    Sea 19 November 2014

    November 20, 2014 game

    Fri November 21, 2014

    It will exclude Saturday and Sunday.

    Hello

    Here is an example of removing dates Saturday and Sunday:

    with days as(
         select (trunc(sysdate, 'YEAR') + level) as col from dual
         connect by level < 365
    )
    select * from days
    where trim(to_char(col, 'DAY', 'NLS_DATE_LANGUAGE=ENGLISH')) not in ('SATURDAY', 'SUNDAY')
          and col between to_date('18.11.2014', 'DD.MM.YYYY') and to_date('30.11.2014', 'DD.MM.YYYY')
    order by col;
    

    Cheerz,

    Stako

  • What is the procedure for the use of two monitors?

    What is the procedure for the use of two monitors?

  • 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

  • Call stored procedure in the URL

    Hi all

    How to call a stored procedure 4 Apex in the URL. The error is less.

    The requested URL/apex/EXAMPLE. TESTPROCEDURE was not found on this server.

    Thank you.

    802263 wrote:
    Hi all

    How to call a stored procedure 4 Apex in the URL. The error is less.

    The requested URL/apex/EXAMPLE. TESTPROCEDURE was not found on this server.

    Thank you.

    Should work on the assumption that:

    1. the scheme of analysis can 'see' the object such as defined by synonyms, etc.
    2. the schema of analysis has execute privs on the object.

  • 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.

Maybe you are looking for

  • Took the money why?

    Why €9:98 comes from my bank account on 08/12/16 by itunes.com? By the way is it because I was on a plane in the air of the United States in Ireland at this same date?

  • Connect 9.2.1 on iPhone ios problems 6

    Links in emails, applications and search engines don't open and the application to freeze on my iPhone with ios 9.2.1 6. Disabling Java and removal of liquidity in Safari does not help.

  • When writing to my administrator password it says has expired, what should I do?

    I have a Hp G60 when I immediately I can't connect to the internet, because his request a password for the connection in the network. But, when I try to log into my password it says timed out.

  • Helps to remove programs

    Good evening! I want to uninstall Visual Studio 2008, and I don't know where to start. However there are a bunch of list in Add or remove programs. But I don't know where to begin the uninstall. List includes .net, mobile, visual studio, etc. etc. an

  • "failed to open session" on Photosmart all-in-one (C309a)

    I had a series of problems with Photosmart C309a my mother. The scanner on the screen was not functional (need to go to the scan on computer software to print). Not a big deal, but I want the device works as it is designed. I have the drivers updated