Create a temporary table using EXECUTE IMMEDIATE

Hello

I need to create a report more complex which must have three different queries. I use a determined IF clause that the query that uses the report, according to the parameters.

I want to write the output to a csv file, so I created a PROCEDURE.

The first package of the procedure has the three SQL and the IF clause in order to determine the query that the report uses and stores the query code in a variable (v_sql), which is passed to the PROCEDURE that needs to write to the output of the report.

I tried to create a table with data from the request in order to make a LOOP and exit, something like this:

WRITE_FILE (errBUFF of the PROCEDUREOUT VARCHAR2,
retCODEOUT VARCHAR2,
v_sqlIN VARCHAR2)

IS

ContorNUMBER;

BEGIN

EXECUTE IMMEDIATE v_sql;
SLIDE G
IS
Select * from XXROR_REG_MF_TBL;
--
-initialization
--
retCode: = 0;
errBUFF: = NULL;
Contor: = 0;
--
-cursor
--

FOR X IN G
LOOP
APPS. FND_FILE.
PUT_LINE)
APPS. FND_FILE. OUTPUT,
....)

I should mention that v_sql is something like:

CREATE GLOBAL TEMPORARY TABLE ACEs (SELECT * of the double);

I can't really do that, so I was wondering if you have any suggestions

Thank you

Claudiu

Hello

I don't think you need a table at all. You can set the cursor based on the SQL passed as parameter

https://docs.Oracle.com/database/121/LNPLS/dynamic.htm#LNPLS629

Concerning

Marcus

Tags: Database

Similar Questions

  • What is the syntax for creating a global temporary table using a select query

    HII
    I create a global temporary table using a select query... How to speak of "on commit preserve rows ' who?


    create a table temporary global t1 select * from trn_ordbase on the lines of commit preserve;

    but this is an invalid syntax, then how to talk on commit preserve rows in this? If I don't mention, by default its recital on the validation of deleted rows.

    Please help me on this problem.
    create global temporary table t1 on commit preserve rows
      2  as select * from dual;
    
    Table created.
    
    TUBBY_TUBBZ?
    
  • Create a temporary table and insert using a select statement

    Hello

    I tried to create a temporary table and insert it by using the value in a select statement. Please see below the code

    ---
    CREATE a TEMPORARY TABLE GLOBAL Temp_Test
    (
    DATE OF DAY_FUTURE
    )
    AS
    SELECT TO_DATE (SYSDATE + ROWNUM, 'DD-MON-YY')
    DUAL CONNECT BY ROWNUM FROM < = 14)
    ---

    As soon as I run the script, the error message indicates the following:
    --

    Error from the 1 in the command line:
    CREATE a TEMPORARY TABLE GLOBAL Temp_Test
    (
    DATE OF DAY_FUTURE
    )
    ONLY select TO_DATE (sysdate + rownum, 'DD-MON-YY')
    Double connect rownum < = 14)

    Error in the command line: 2 column: 1
    Error report:
    SQL error: ORA-01773: cannot specify the types of data in this TABLE to CREATE column
    01773 00000 - 'cannot specify the types of column data in this TABLE to CREATE"
    * Cause:
    * Action:
    --


    What seems the problem? I already have the data type such as TO_DATE on my select statement.

    Any help would be appreciated

    Thank you
    SQL> CREATE GLOBAL TEMPORARY TABLE Temp_Test
      2  (
      3  DAY_FUTURE
      4  ) on commit preserve rows
      5  AS
      6  SELECT TO_DATE(SYSDATE+ROWNUM, 'DD-MON-YY')
      7  FROM DUAL CONNECT BY ROWNUM <= 14
      8  /
    
    Table created.
    
    SQL> select count(*)
      2    from temp_test
      3  /
    
      COUNT(*)
    ----------
            14
    
  • How to create a temporary table in a procedure.

    How to create a temporary table in a procedure.

    Hello

    user9093700 wrote:
    How to create a temporary table in a procedure.

    Why create a temporary table in a procedure?

    Oracle has soemthing called a global temporary Table , where the table is in fact permanent, but data is automatically deleted at the end of the session (or the transaction, depending on how the table was created). What did you talk about? Why do you want to create one in a procedure?

    Temporary tables, in the sense of the tables that are created on the fly and fell just as they are used, are almost never a good way to do anything in Oracle. Explain what you want to do, and someone will help you find a good way to do it.

    If you need really to create a table (or any other kind of DDL) in a procedure, use EXECUTE IMMEDIATE.

  • Create a temporary table as select fails... Why?

    Hello, I have this simple stored procedure

    PROCEDURE prueba_cursor is
    BEGIN

    CREATE TEMPORARY TABLE global emp_tab ON COMMIT PRESERVE ROWS AS
    SELECT T.STATUS_CD IN THE T_CRES_FILES T;


    END prueba_cursor;

    I get the following error

    "PLS-00103: encountered the symbol"CREATE"when waiting for one of the following values:

    (begin case declare exit for goto if loop mod null pragma
    raise return select update while < ID >


    "

    What's not here?
    Thank you

    Xavi says:
    Hello, I have this simple stored procedure

    PROCEDURE prueba_cursor is
    BEGIN

    CREATE TEMPORARY TABLE global emp_tab ON COMMIT PRESERVE ROWS AS
    SELECT T.STATUS_CD IN THE T_CRES_FILES T;

    END prueba_cursor;

    I get the following error

    "PLS-00103: encountered the symbol"CREATE"when waiting for one of the following values:

    (begin case declare exit for goto if loop mod null pragma
    lift the back updated select everything with

    "

    What's not here?
    Thank you

    You can't put DDL statements directly into the PL/SQL like this. Why you wrap upward in a PL/SQL procedure anyway?

    Why not:

    CREATE GLOBAL TEMPORARY TABLE  emp_tab ON COMMIT PRESERVE ROWS AS
          SELECT T.STATUS_CD FROM T_CRES_FILES T;
    

    directly as SQL?

  • How to create and insert data with Execute Immediate?

    Hi guys

    Am stuck on a procedure of formatting in a package... script works okay however integrating a module turns out to be difficult!

    Am not used to oracle... I have the script runs, but not in the package... Well not all that... Drop Table worked

    CREATE or REPLACE PACKAGE BODY is

    PROCEDURE DropTable1 IS

    BEGIN

    run immediately ("DROP TABLE mytable1");

    END;

    PROCEDURE PopulateTable1 IS

    BEGIN

    immediately execute ('CREATE TABLE mytable1 )

    AS LONG AS)

    Select

    substr (T1.genarea, 3, 3) as M_Class,

    substr (T1.genarea, 6, 30) as M_Description,

    substr (T1.genarea, 36, 3) as M_Class,

    substr (T1.genarea, 39, 30) as M_Description,

    substr (T1. ItemItem, 1, 3) as product_code,.

    T3. CHANNEL_NUM as SALES_CHANNEL,

    to_date(''t2.time_id'',''dd-mon-yyyy'') as mis_date,

    Sum (T2.ap_cw_cfi_irp + T2.ap_cw_issues_irp) as ap_gross,

    sum (t2. Ap_Cw_Cfi_Irp + t2. Ap_Revivals_Irp) as ap_net,

    Sum (T2.sp_inc_irp + T2.sp_issues_irp) as sp_gross,

    Sum (T2.sp_dec_irp + T2.sp_fs_irp) as sp_net

    Of

    d_pr t1, t2 age_map t3 law

    where

    T1.pfx = "WE"and t1.coy ="1" and t1.tabl = "T81" and substr (t1.itemitem, 1, 3) = t2.product_id and t3. AGE_NUM = t2.age_id

    Group

    substr (T1.genarea, 3, 3),

    substr (T1.genarea, 6, 30),

    substr (T1.genarea, 36, 3),

    substr (T1.genarea, 39, 30),

    substr (T1. ItemItem, 1, 3).

    T3. CHANNEL_NUM,

    to_date(''t2.time_id'',''dd-mon-yyyy'')

    )');

    COMMIT;

    END PopulateTable1;

    END test;

    /

    Thank you

    Hello

    a few notes.

    1. to_date(t2.time_id,'dd-mon-yyyy')

    New York T2.Time_ID Cis the varchar2 data type that contains values to JJ-me-YYYY format?

    And if, in which language is used for the names of the months? Conversions are point impossible to solve in reasonable time limits without logging of dml errors and unique failure on charges of staging nightly!


    2 single quote escaping "alternative in string literals.

    You can use Q or q to escape single quotes in strings.

    http://docs.Oracle.com/database/121/SQLRF/sql_elements003.htm#SQLRF00218

    3. validation

    Not required because the DDL commands commit implied.

    In general I recommend you write commit clauses only in calling script rather than in the code unless it connects with an autonomous transaction.

    You end up with a lot of validation of code here and there and you don't know where it is and where it isn't. That is, your process may have more than one appeal process and commit the middle of the process, it is not atomic processes.

    Here's the demo although I recommend also using the static table and truncate to efficiency. ETG is good choice for the purpose of maintenance table.

    create or replace
    package testing is
      procedure staging_one;
    end;
    /
    create or replace
    package body testing is
      --
      procedure staging_one is
        --
        procedure drop_staging_one is
          table_does_not_exist exception;
          pragma exception_init(table_does_not_exist, -00942);
        begin
          execute immediate q'{
            drop table staging_one purge
          }';
        exception when table_does_not_exist then
          return; -- fine
        end;
        --
        procedure create_staging_one is
        begin
          execute immediate q'{
    
            -- remove >>>
            create table staging_one nologging
            as
            select * from dual
            -- <<< remove
    
            /* uncomment >>>
            create table staging_one nologging
            as
            select
              substr(t1.genarea,3,3)                    as m_class,
              substr(t1.genarea,6,30)                   as m_description,
              substr(t1.genarea,36,3)                   as m_class,
              substr(t1.genarea,39,30)                  as m_description,
              substr(t1.itemitem,1,3)                   as product_code,
              t3.channel_num                            as sales_channel,
              to_date(t2.time_id,'dd-mon-yyyy')         as mis_date,
              sum(t2.ap_cw_cfi_irp+t2.ap_cw_issues_irp) as ap_gross,
              sum(t2.ap_cw_cfi_irp+t2.ap_revivals_irp)  as ap_net,
              sum(t2.sp_inc_irp   +t2.sp_issues_irp)    as sp_gross,
              sum(t2.sp_dec_irp   +t2.sp_fs_irp)        as sp_net
            from
              d_pr t1,
              act t2,
              age_map t3
            where
              t1.pfx                      = 'IT'
              and t1.coy                  = '1'
              and t1.tabl                 = 'T81'
              and substr(t1.itemitem,1,3) = t2.product_id
              and t3.age_num              = t2.age_id
            group by
              substr(t1.genarea,3,3),
              substr(t1.genarea,6,30),
              substr(t1.genarea,36,3),
              substr(t1.genarea,39,30),
              substr(t1.itemitem,1,3),
              t3.channel_num,
              to_date(t2.time_id,'dd-mon-yyyy')
            <<< uncomment */
          }';
          --
        end;
      -- main
      begin
        drop_staging_one;
        create_staging_one;
      end;
    end;
    /
    
    set serveroutput on
    
    exec testing.staging_one;
    
    select * from staging_one
    ;
    commit
    ;
    
    PACKAGE TESTING compiled
    PACKAGE BODY TESTING compiled
    anonymous block completed
    DUMMY
    -----
    X 
    
    committed.
    
  • "missing the SELECT keyword" error during an insert into the temporary table using the blob value

    I'm trying to insert into an oracle temp table using select that retrieves data from a blob field but I get the error: "lack the SELECT keyword.

    How we store temporary in oracle result when we make this type of operation (extraction of data in fields and try to load them into a separate table on the fly.?)

    with cte as)

    Select user_id, utl_raw.cast_to_varchar2 (dbms_lob.substr (PREFERENCES)) as USER my_blob

    )

    create table new_table as

    SELECT user_id,EXTRACTvalue(xmltype(e.my_blob),'/preferences/locale') regional settings

    E ETC

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

    BLOB data - value - which is

    <? XML version = "1.0" encoding = "ISO-8859-1" ?>

    - < Preferences >

    < time zone > America/New_York < / > zone

    < displayscheduleinusertimezone > Y < / displayscheduleinusertimezone >

    < local > Spanish < /locale >

    < DateFormat > JJ/mm/aaaa < / DateFormat >

    < timeFormat > hh: mm aaa < / timeFormat >

    < longformat > Long_01 < / longformat >

    < doubleformat > Double_01 < / doubleformat >

    < percentformat > Percentage_01 < / percentformat >

    < currencyformat > Currency_01 < / currencyformat >

    < / Preferences >

    A WITH clause that must immediately precede the SELECT keyword:

    SQL > create table t:

    2 with the o as (select double dummy)

    3 select * West longitude;

    Table created.

  • steps to create the new table using existing metadata

    Hi all


    That's what I want to achieve,

    I want to create a procedure that will take an input parameter as a table name lets say 'EMP ',.
    This procedure checks if this table exists or not?
    If they don't exist
    It will create a new table with the name _dummy join the existing table name (ex: new table will be EMP_DUMMY).
    and new table should have the same structure of the table, indexes, and constraints on the EMP table.


    NB: It should not be created using select as create table EMP_DUMMY select * from EMP where = condition false;



    Can someone help me please how to achieve this?

    Please, don't post duplicate discussions.

    Check your thread previous stored procedure to create a new table with the existing table structure to further discussions

  • temporary tables using interfaces in this

    What is the purpose of the temporary tables in all by performing interfaces
    someone explain to me the treatment

    Transformation of a CI mess up sliders SQL, that I recently discovered. A temporary table or a set of rows to retrieve the values you are looping on (if of course) can help solve this problem.

    If you mean App Engine treatment in general (as in the post above), it is especially to avoid a loop by line and the same action above and all over again, or to avoid having to put many large tables in 1 query (you can update some fields in various stages), for example support I want to update an amount for each person , then I could have one

    In most cases less capable version:
    -----------------------------------------------------
    DoSelect:
    %Select(EmplId)
    SELECT COST FROM your query
    Followed by:
    INSERT INTO My_Result
    SELECT * FROM my_table
    Where emplid = %Bind(Emplid)

    In most cases better:
    ------------------------------
    Step SQL:
    Insert into %Table(My_ExmplTMP) (EMPLID) SELECT EMPLID FROM your query
    Followed by:
    INSERT INTO My_Result
    SELECT * FROM Tbl my_table, Tmp %Table(My_ExmplTMP)
    Where Tbl.emplid = TMP. EmplId

  • Create a temporary table of XmlType

    I am interested in other ways to achieve this.
    The solution below works when each statement is executed seperatly(Toad f5), but not at once (Toad F9)

    To run this from Java code, it is best to have it in a single queery/statement

    any ideas of ways to do this is very welcome.

    CREATE TABLE CONTROL_SETTINGS
    (
    CONTROL_SETTINGS_ID NUMBER (10) NOT NULL,
    SYS SETTINGS_XML. XMLTYPE,
    SETTINGS_NAME VARCHAR2 (128 CHAR) NOT NULL
    )

    CREATE TABLE COMPANY
    (
    COMPANY_ID int,
    company_name varchar (255)
    )

    INSERT INTO THE VALUES OF THE COMPANY (3456, '3456')

    SELECT * FROM COMPANY
    where company.company_name = '3456'

    INSERT INTO CONTROL_SETTINGS VALUES (5, XMLType ("< parameters >
    < order >
    < > 234 order_id < / order_id >
    < company > 3456 < / company >
    < / order >
    < order >
    < > 4563 order_id < / order_id >
    < company > 5674 < / company >
    < / order >
    ((< / Parameter > '), 'ORDER');


    create table
    map_order
    as
    (SELECT p.settings_name,
    extractValue (value (order_seq), "/ order/order_id") as order_id,.
    extractValue (value (order_seq), "/ order/company") as a business
    CONTROL_SETTINGS p,
    Table (XMLSequence (p.settings_xml.extract('/settings/order'))) order_seq
    WHERE p.settings_name like 'COMMAND');


    SELECT * from map_order
    LEFT JOIN map_order.company = company.company_name IT company;

    DROP TABLE map_order;

    There isn't a single if statement.

    The only thing you can do is to wrap in an anonymous block, but then all your DDL and DML that use the new table will have to be converted to dynamic SQL.

    What you do is a very bad idea.

  • Is there a way to create a temporary table whenever someone knocks a procedure?

    I'm creating a procedure in Oracle 10 g to retrieve data in Oracle in a cognos report. The problem with the creation of a permanent table, is that several people will run this report at the same time, which means that the procedure will take place whenever someone runs this report. The permanent table will be give up the old data or the data will mingle which means that the reports of the various peoples will not correct. I tried to put a lock on the tables that would release the lock once one person made run their report, but that did not work. I suggested that we put the data directly in the slider, but what happens when executing this procedure by several people at the same time?
    Any assistance in finding ways to solve this problem would be greatly appreciated.

    user10426897 wrote:
    According to our team cognos cognos 7 has been set up to be able to do that, but cognos 8 is not.

    Your Cognos team must then do some reading. Cognos 8 is quite able to query the tables directly, our Cognos team that regularly.

    John

  • Creating an external Table using Xml Dataset - how to include null values?

    The script below works fine, but I'm fails as soon as the xml file does not contain a column for a line, or has the value as "< ACTUAL_FLAG / >.

    Is there way I can show the missing values as null?

    With the help of "missing field is null values" does not work for me.

    Any help would be appreciated.


    < < < < < < < < < <
    / * Formatting on the 2010-05-24 14:53:01 (v5.136.908.31019 PS5) * /.
    DROP TABLE ENE_GL_SAP_TEMP;

    CREATE TABLE ENE_GL_SAP_TEMP
    (
    status VARCHAR2 (50).
    number of ledger_id (15),
    set_of_books_id NUMBER (15),
    accounting_date DATE,
    CURRENCY_CODE VARCHAR2 (15).
    Date_Created DATE,
    created_by NUMBER (15),
    actual_flag VARCHAR2 (1).
    user_je_category_name VARCHAR2 (25).
    user_je_source_name VARCHAR2 (25).
    Segment1 VARCHAR2 (25).
    Segment2 VARCHAR2 (25).
    segment3 VARCHAR2 (25).
    segment4 VARCHAR2 (25).
    segment5 VARCHAR2 (25).
    segment6 VARCHAR2 (25).
    segment7 VARCHAR2 (25).
    entered_dr NUMBER,
    entered_cr NUMBER,
    accounted_dr NUMBER,
    accounted_cr NUMBER,
    Reference1 VARCHAR2 (100)
    )
    EXTERNAL ORGANIZATION
    (
    TYPE ORACLE_LOADER
    THE DEFAULT DIRECTORY ENE_SOLAR_FTP_IN_DIR
    ACCESS SETTINGS
    (
    records delimited by ' < / GL_REC >.
    BadFile "temp.bad."
    logfile "temp.log.
    fields)

    filler TANK (2000) TERMINATED BY "< GL_REC >,"
    status (50) tank surrounded by '<>STATUS' and ' < / STATUS >. "
    ledger_id char (15), framed by '< LEDGER_ID >' and ' < / LEDGER_ID >, "
    set_of_books_id char (15), framed by '< SET_OF_BOOKS_ID >' and ' < / SET_OF_BOOKS_ID >, "
    accounting_date char (11), framed by '< ACCOUNTING_DATE >' and ' < / ACCOUNTING_DATE >, "
    Char (15) currency_code framed by '< CURRENCY_CODE >' and ' < / CURRENCY_CODE >. "
    tank (11) Date_Created framed by '< DATE_CREATED >' and ' < / DATE_CREATED > "date_format DATE mask MON/dd/yyyy". "
    created_by char (12), framed by '< CREATED_BY >' and ' < / CREATED_BY >. "
    actual_flag char (1) surrounded by '< ACTUAL_FLAG >' and ' < / ACTUAL_FLAG >, "
    user_je_category_name tank (25), framed by '< USER_JE_CATEGORY_NAME >' and ' < / USER_JE_CATEGORY_NAME >, "
    user_je_source_name tank (25), framed by '< USER_JE_SOURCE_NAME >' and ' < / USER_JE_SOURCE_NAME >, "
    tank (25) Segment1 framed by '< SEGMENT1 >' and ' < / SEGMENT1 >. "
    tank (25) Segment2 framed by '< SEGMENT2 >' and ' < / SEGMENT2 >. "
    tank (25) segment3 framed by '< SEGMENT3 >' and ' < / SEGMENT3 >. "
    segment4 tank (25), framed by '< SEGMENT4 >' and ' < / SEGMENT4 >, "
    tank (25) segment5 framed by '< SEGMENT5 >' and ' < / SEGMENT5 >, "
    segment6 tank (25), framed by '< SEGMENT6 >' and ' < / SEGMENT6 >, "
    segment7 tank (25), framed by '< SEGMENT7 >' and ' < / SEGMENT7 >. "
    entered_dr char (15), framed by '< ENTERED_DR >' and ' < / ENTERED_DR >, "
    entered_cr char (15), framed by '< ENTERED_CR >' and ' < / ENTERED_CR >, "
    accounted_dr char (15), framed by '< ACCOUNTED_DR >' and ' < / ACCOUNTED_DR >, "
    accounted_cr char (15), framed by '< ACCOUNTED_CR >' and ' < / ACCOUNTED_CR >, "
    tank (100) of reference1 framed by '< REFERENCE1 >' and ' < / REFERENCE1 >.



    )
    )
    LOCATION ("books2.xml")
    )
    PARALLEL
    REJECT LIMIT UNLIMITED;


    Select * from ENE_GL_SAP_TEMP;

    > > > > > > > > > > > > > > > > > >

    Hello

    It's funny, I never thought of parsing an XML through SQL * Loader before.

    Are you aware of the XML DB features? They are intended only for what you are doing here.

    Also, please look at function XMLTable. It allows you to directly map your XML file in columns and relational rows.

    For example, by giving an example of file "book.xml" like this:

    
    
     
      1
      2
      ABC
      DEF
     
     
      1
      3
      XYZ
      TTT
     
    
    

    Then, just do:

    SELECT *
    FROM XMLTable(
     '/GL_RECS/GL_REC'
     passing xmltype( bfilename('XML_DIR','book.xml'), nls_charset_id('CHAR_CS') )
     columns
      status varchar2(50) path 'STATUS',
      ledger_id varchar2(15) path 'LEDGER_ID',
      segment1 varchar2(25) path 'SEGMENT1',
      segment2 varchar2(25) path 'SEGMENT2'
    );
    
  • MySQL temporary tables or call Stored procedures in CS4

    I need to filter the results by username before making a LEFT JOIN and including lines or IS NULL. The SQL works from the mysqli client, either by creating a temporary table using the "create a temporary table temp_appts select * from...» "Or by creating a stored procedure that contains the statement even 'create temporary table' and then running my LEFT JOIN statement against the temporary table.

    I've tried both in CS4, it accepts the code 'code' without errors but the page loads in a browser as a white or a 500 error in Internet Explorer. From my experience, this is caused by the exit before arriving to the html header.

    Is it possible to do either in CS4?  Here is the code I use.

    $varU_temp_appts = "-1";
    If (isset (<? php $_SESSION ['MM_Username'])) {}
    $varU_temp_appts = $_SESSION ['MM_Username"];
    }

    @mysql_select_db ($database_ess, $ess);
    $query_temp_appts = sprintf ("' CREATE TEMPORARY TABLE SELECT temp_appts * of appts WHERE username = %s", /GetSQLValueString($varU_temp_appts,"text") ");
    $temp_appts = mysql_query ($query_temp_appts, $ess) or die (mysql_error ());
    $row_temp_appts = mysql_fetch_assoc ($temp_appts);
    $totalRows_temp_appts = mysql_num_rows ($temp_appts);


    @mysql_select_db ($database_ess, $ess);
    $query_todays_appts = "SELECT * from appt_tm LEFT JOIN (temp_appts) ON appt_tm.appt_time = temp_appts.appt_hr WHERE (appt_date = CURDATE () OR appt_date IS NULL)";
    $todays_appts = mysql_query ($query_todays_appts, $ess) or die (mysql_error ());
    $row_todays_appts = mysql_fetch_assoc ($todays_appts);
    $totalRows_todays_appts = mysql_num_rows ($todays_appts);

    Any help is appreciated!

    Why not just use a derived table, rather than creating a temporary table?

  • Creating external Tables using the EXECUTE IMMEDIATE in PL/SQL

    Hi guys,.

    I am trying to create an external Table using the EXECUTE IMMEDIATE in a procedure and I managed to compile and no errors were generated. But when I try to run it from sql using the exec command I get the following error:

    ------------------------------------------------------------------------
    ERROR on line 5:
    ORA-00911: invalid character
    ORA-06512: at "GEO. TEST_DDL', line 4
    ORA-06512: at line 5

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

    I tried to check the whole statement to create the external table, but I can't find where is the error. Surprisingly, if I simply run the command table create external on sqlplus it works, but not a procedure.

    If anyone can help with ideas or experience?

    Geoffrey Kossami

    The error means that there is an identifier somewhere that starts with a nonalphanumeric. This is a typical mistake of editing. A procedure compiles correctly is not of course because the underlying dynamic sql running is OK. Which of course only be resolved when you try to run it.

    There is certainly a problem with the text you provide to be run as a piece of dynamic sql code. You should try to watch it with dbms_output and run this code in sqlplus. But your problem is with the code you run as dynamic PL/SQL, it is not itself compilable.

    Jack

  • Execute Immediate - Drop table

    Hello

    I have a piece of code that accepts name of table as a parameter entry and the fall of the table using dynamic SQL. The code follows below:

    create or replace procedure drop_table (in_table_name in varchar2)
    as
    sql_stmt varchar2 (25);
    Start
    dbms_output.put_line (' name of the Table that had to be abandoned is: ' | in_table_name);
    sql_stmt: = 'drop table ' | in_table_name;
    execute_immediate sql_stmt;
    end;
    /

    When I'm trying to compile this procedure, I get compilation errors.
    We can use execute immediate to remove the tables inside PL/SQL code.

    Kindly help.

    Thanks in advance
    Rambeau

    You get an error because of the "_" between run and immediate.

    Try:

    create or replace procedure drop_table(in_table_name in varchar2)
    as
    sql_stmt varchar2(25);
    begin
    dbms_output.put_line('Table name that has to be dropped is: '|| in_table_name);
    sql_stmt := 'drop table ' || in_table_name;
    execute immediate sql_stmt;
    end;
    /
    

Maybe you are looking for