Run immediately in Oracle 10 g

Hi, I have a small doubt regarding run immediately.

According to my knowledge that we use run immediately to the writing of DDL(create,truncate,...) instructions to be executed in the procedure or function.

But I saw in my organization, some of the senior people (already left organization) used to write the inserts, updates, deletes in will also run immediate even there is not much involved dynamic logic.

But as per my knowledge run immediately can be misused by most pirates with SQL injection, I suppose!

Is there some reason they use run immediately instead of writing code directly? Or is there an advantage in writing like this. ???

Delivery immediate to create tables and another using DDL is fundamentally undesirable and should be avoided at all costs.
Using run immediately you seem to exhibit, avoid too. Seniors were apparently not aware of the purpose of PL/SQL and the inconvenience of immediate execution.
If I could vote to remove execute immediate PL/SQL, I would immediately in favour, especially in the packages, procedures and functions, as they are saved, which means pre-built.

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

Tags: Database

Similar Questions

  • Using run immediately in Oracle PLSQL

    Hello

    Please tell me what's the use of using the EXECUTE IMMEDIATE statement?
    According to the docs, it is said that:

    The EXECUTE IMMEDIATE statement prepares (analysis) and immediately executes a dynamic SQL statement.

    The EXECUTE IMMEDIATE statement analyzes the SQL string command and executes the statement.

    An example of EXECUTE IMMEDIATE in a block:


    DECLARE
    sql_stmt VARCHAR2 (200);

    BEGIN
    EXECUTE IMMEDIATE 'CREATE TABLE (NUMBER, amt id NUMBER) Bonus';
    sql_stmt: = "INSERT INTO dept VALUES (: 1,: 2: 3)"; "

    Here, I have a question, what is the purpose to use EXECUTE IMMEDIATE, I mean if I do not use EXECUTE IMMEDIATE will that my statement will not be created?

    For example: him below will also work where I use not any what EXECUTE IMMEDIATE to process a statement,


    DECLARE
    sql_stmt VARCHAR2 (200);

    BEGIN
    ' *' Bonus (id NUMBER, amt NUMBER) CREATE TABLE '; *
    sql_stmt: = "INSERT INTO dept VALUES (: 1,: 2: 3)"; "


    explain please, thank you.

    user10503747 wrote:

    I don't know for what reason the bonus of the table is not being created

    Of course not. You have coded the exception handler for delete all exceptions... and pretend that there is no error.

    Then... According to the logic of this code, there is no error and the table has been created very well.

  • Oracle 11G copy a table to help to run immediately

    I want to copy the contents of a table in another aid to run immediately.

    It keeps fails with the following error

    ORA-00903: invalid table name
    ORA-06512: at "TABLE_COPY", line 6
    ORA-06512: at line 8 level



    create or replace
    procedure TABLE_COPY)
    Table1 varchar2,
    Varchar2 TABLE2)
    is
    Start
    run immediately 'insert'. TABLE2. "(select * from ' |) TABLE1 |') ' ;
    end;

    Published by: user9213000 on January 24, 2013 07:38

    user9213000 wrote:
    I want to copy the contents of a table in another aid to run immediately.

    It keeps fails with the following error

    ORA-00903: invalid table name
    ORA-06512: at "TABLE_COPY", line 6
    ORA-06512: at line 8 level

    create or replace
    procedure TABLE_COPY)
    Table1 varchar2,
    Varchar2 TABLE2)
    is
    Start
    run immediately 'insert'. TABLE2. "(select * from ' |) TABLE1 |') ' ;
    end;

    Published by: user9213000 on January 24, 2013 07:38

    Standard when boards (ab) use of EXECUTE IMMEDIATE is to compose the SQL statement in a single VARCHAR2 variable
    Then print the variable before passing to EXECUTE IMMEDIATE.
    COPY the statement & PASTE in sqlplus to validate its correctness.

  • ONE ERROR: run immediately (p_sql) return to p_id;

    Has written a simple procedure:

    procedure p_test)
    P_ID number,
    p_sql in varchar2
    *)*
    is
    Start
    run immediately (p_sql) return to p_id;
    end;

    Now, test it:

    declare
    P_ID number;
    p_sql varchar2 (2000): = ' insert into test1 (pk, str) values (1, "aaa")';
    Start
    pkg_utility.sp_save_without_blob (p_id, p_sql);
    dbms_output.put_line ('p_id' | p_id);
    end;


    The problem:
    Without the 'back in p_id' statement, the sql code can be run successfully. But with the "p_id return', an error occurred:

    ORA-20999: unexpected error when insert into test1 (pk, str) values (1, 'aaa')
    ORA-01006: there is no bind variable


    What I've done wrong? and how do I solve the problem?


    Thank you for helping.

    You're not saying 'what' you try to return.

    See the examples in the doc of PL/SQL
    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/Collections.htm#BABHDGIG
    >
    Example 5-52, using the RETURN IN the Clause with a Record

    DECLARE
    RECORD IS of TYPE EmpRec (last_name, employees.last_name%TYPE,
    salary employees.salary%TYPE);
    method EmpRec;
    emp_id NUMBER: = 100;
    BEGIN
    UPDATE employees SET salary = salary * 1.1
    WHERE employee_id = emp_id
    RETURN last_name, salary INTO method;
    DBMS_OUTPUT. PUT_LINE
    ("Just give a stimulus to ' | emp_info.last_name |)
    ', which now makes | emp_info.salary);
    ROLLBACK;
    END;
    /

  • ORA-01031: insufficient privileges on run immediately 'create a table... '. »

    Hello. I created a stored procedure that starts an immediate execution "create table..." Responses to Oracle with the message ' ORA-01031: insufficient privileges.

    I solved the problem adding 'authid current_user is' in the procedure declaration.

    Unfortunately, if I try to plan his by DBMS_JOB, responses to oracle with the same error again.

    Why? And how can I avoid it?

    Thank you very much in advance

    Published by: user4501018 on 6-mag-2010 4.00

    user4501018 wrote:

    Unfortunately, if I try to plan his by DBMS_JOB, responses to oracle with the same error again.

    Add:

    run immediately "role play all THE ';"

    before immediate 'create table..."

    SY.

  • How can I create VI with inputs that run immediately when the update?

    I'm using LabView for controlling stepper motors. I would create a VI with a front panel that has 4 arrows, 2 per engine. My goal is to be able to run the VI and then press a button to move the engine.

    I created separate VI for each funcition of engines - one vi to set current operations, to determine the current travel, another to move up by a certain amount and so on. Work of these vi and I can move and adjust engines, but only by running separate VI.

    How can I combine them into a single VI and make them run to the pressure of a button or the change of a property? An example would be to establish a new current holding company and place the operation current vi run immediately and send the order to the engine. Then continue to press the arrow keys without having to hit 'run' on an another vi.

    Thank you very much


  • What is the purpose of USE in "run immediately".

    Hi all

    I just want to understand what is the purpose of USING in "EXECUTE IMMEDIATE".

    Say for example, the procedure below, what is the difference? Both will end up in the same result.

    DECLARE

    FIXED_STAT VARCHAR2 (4000);

    VAL_STAT VARCHAR2 (4): = "ijkl";

    BEGIN

    EXECUTE IMMEDIATE ' INSERT INTO abcd (efgh) VALUES (: text_string)' USING "ijkl";

    FIXED_STAT: = "INSERT INTO abcd (efgh) VALUES ('|)" VAL_STAT |') ' ;

    IMMEDIATELY RUN FIXED_STAT;

    END;

    /

    Two major assets to HELP to run immediately, i.e. using parameters

    (1) SQL statement should not hard analysed by the database every time [performance gain].

    (2) more important, to avoid the "SQL injection" and ensure that the variable data will be properly includes as part of the statement

  • run immediately fails with the error

    The following code generates the error and I can not understand what the problem is:

    SET SERVEROUTPUT ON;

    declare

    Val number (21);

    s_sql varchar2 (2000);

    Start

    s_sql: = q '{select last_number in the Vale of all_sequences where sequence_owner = 'SST' and sequence_name = "ADDRESS_SEQ"}';

    Dbms_output.put_line ('sql 1 ' | s_sql);

    run immediately s_sql;

    end;


    Error report:

    ORA-00905: lack of keyword

    ORA-06512: at line 7

    00905 00000 - 'lack the key word'

    * Cause:

    * Action:

    select last_number SQL 1 in val all_sequences where sequence_owner = 'SST' and sequence_name = "ADDRESS_SEQ."

    The error is strange since

    Select last_number in the all_sequences where sequence_owner = 'SST' and sequence_name = "ADDRESS_SEQ."

    is a valid instruction

    Although I see no need for SQL dynamic in this case, in general, you must provide the vatiable to receive the value of the select statement outside the immediate execution.  More like:

    s_sql: = q '{select last_number in the all_sequences where sequence_owner = 'SST' and sequence_name = "ADDRESS_SEQ"}';

    execute immediate s_sql in val

    John

  • procedure call to run immediately

    Hi Please help me call the procedure to run immediately.

    I am trying to execute the procedure for several tables.

    the same procedure on the SQL prompt works very well as shown below.

    EXECUTE PROC1 ('BC_COALMINE');

    Start

    for rec in (select table_name

    from all_tables

    where table_name like '% BC_.

    )

    loop

    run immediately 'execute proc1 (rec.table_name);

    end loop;

    end;

    I get an error invalid SQL ORA-900.

    concerning

    EXECUTE is a SQL Plus command. In PL/SQL, you can simply call the procedure. And you need not EXECUTE IMMEDIATE. You can make a static call to the procedure. Like this.

    Start

    for rec in (select table_name

    from all_tables

    where table_name like '% BC_.

    )

    loop

    PROC1 (Rec.table_name);

    end loop;

    end;

  • How to replace run immediately in 11g?

    Hi, package and I need not not to use run immediately. There are a few plsql dynamic generation and sql stored in global lists. Any other possibility to execute without run immediately? TNX for help.

    Edited by: 982676 2013-01-18 01:11

    Dynamic code is dynamic. It must be run dynamically. And THIS should be the concern and not what dynamic execution interface is used.

    Regarding the interfaces to execute dynamic PL/SQL code:
    -immediate execution
    -ref Cursor
    -DBMS_SQL

  • How to pass a sequence of 'help' to run immediately

    How can I place a sequence.nxlval as a parameter using, here is my code looks like

    sql_string is-> insert into some_tab (col1, col2,...) (select col1: passed_seq,...) where the... (I want to insert values in sequence for col2)


    and I call it like


    passed_seq: = "seq_". some_dynamic_num |'. nextval' (in my PB will be sequences with the string formed as seq_10.nextval)

    EXECUTE IMMEDIATE sql_string using passes_seq;

    If I do like this I get

    Error: - 1722:ORA - 01722: invalid number seq_10.nextval

    Published by: DIVI on 8 January 2013 07:40

    >
    So is there another way to solve my problem, where queries are already formed and stored in a table in the form of data in the column, and I need to run those from different sequences in different scenarios.
    >
    Yes - you change applications to use a placeholder for the sequence you need (e.g. [SEQ_GOES_HERE]) when you need to run it you create a PL/SQL block into a VARCHAR2 variable, then use run immediately on the variable.

    If your stored query would look like this

    sql_string is -> insert into some_tab (col1,col2, ....) (select col1,[SEQ_GOES_HERE],......) where .... 
    

    Load the good seq.nextval in a variable, and then replace "[SEQ_GOES_HERE]" in the query with this value.

  • How to set schema running information in Oracle forms

    Hello

    Please tell me, how to set schema running information in Oracle forms.

    Thank you and best regards,
    Sanjeev.

    What exactly do you want? Your question is not very clear.

    Craig...

  • Scheduled task (dba_job) running immediately after starting

    Hello


    Clone of post a scheduled task (dba_job) runs immediately after startup. This task must be performed only in Production - not in the test environment.


    I know that we can stop the task to run using exec dbms_job.broken (42, TRUE), but to do this, I have to start the database.

    The job runs as soon as I start the database. This creates problems.


    Could someone help to prevent the execution of this work.


    Thank you
    Prasad Arava

    JOB_QUEUE_PROCESSES = 0

  • using where clause with value to hardcode in run immediately

    Dear Experts, I use below in the stored procedure make exception.

    RUN IMMEDIATELY "REMOVE CC. TB WHERE COL ='HG ";

    When the collar is varchar2 (30) DC. TB

    Please guide how to use above the statement in the stored procedure


    Thank you

    DBA wrote:
    Dear Experts, I use below in the stored procedure make exception.

    RUN IMMEDIATELY "REMOVE CC. TB WHERE COL ='HG ";

    When the collar is varchar2 (30) DC. TB

    Please guide how to use above the statement in the stored procedure

    Thank you

    Why you use dynamic SQL? DELETE statement is a DML statement and its valid inside a PL/SQL block.

    So, you can remove the immediate execution and write your DELETE statement directly.

    begin
      delete from cc.tb where col = 'HG';
    end;
    
  • Run immediately - please help

    Hello

    I have a requirement where I have to choose the number of records in each table (which meets specific criteria) in a variable and print it.
    I wrote the following piece of code which results in an error.

    Code:
    declare
    row_cnt number;
    v_query varchar2 (200);
    Start
    for x in (select table_name
    from all_tables
    where owner = ' EDI$ ".
    table_name order)
    loop
    v_query: = ' select count (*) in: Y of ' | x.table_name;
    dbms_output.put_line (x.table_name);
    dbms_output.put_line (v_query);
    execute immediate v_query using row_cnt;
    end loop;
    end;
    /


    Output:
    EDI_UFE
    Select count (*) in: Y de EDI_UFE
    ERROR on line 13:
    ORA-06550: line 13, column 14:
    PLS-00103: encountered the symbol "SELECT" at the expected in the following way:
    (- + new case mod not null < an ID >)


    Let me know if the code has a any error.

    Thanks in advance.

    declare
    row_cnt number;
    v_query varchar2 (200);
    Start
    for x in (select table_name
    from all_tables
    where owner = ' EDI$ ".
    table_name order)
    loop
    v_query: = ' select count (*) from ' | x.table_name;
    dbms_output.put_line (x.table_name);
    dbms_output.put_line (v_query);
    run immediately v_query in row_cnt;
    end loop;
    end;
    /

    Edited by: lifexisxnotxsoxbeautiful Vithalani March 4, 2011 04:36

Maybe you are looking for

  • Firefox with black and white stripes

    I have problems with Mozilla Firefox 12 and Windows 7 in a laptop special. The problem is that the Firefox window with a pattern of black and white stripes. When I disable all addons (using the option in the Help menu) it works fine, but then I try t

  • Why can I not hear a voice on my laptop?

    I hear no song when I use my laptop. It runs Windows XP.All of a sudden my sound is really messed up, I get this weird feedback who resembles outsiders trying to communicate to me.If I go on YouTube to listen to the music, the instruments are watered

  • How can I disable sapi 6 and use sapi 5 in windows vista and windows 7

    any body know how to disable the sapi 6 under vista so I can install sapi 5because sapi 6 runs outside the visual studio programming environment and cannot be completely disabled in visual studio for tts activating tts recognition is still ongoing an

  • BIOS HP Compaq Elite (i5-2400 CPU) 8280 cannot set the VT option

    BIOS HP Compaq Elite (i5-2400 CPU) 8280 cannot set the VT option

  • Router w / Tunnel dynamic L2L and Clients VPN

    I have a 7200 router currently configured w / vpn clients. I'm looking to add a tunnel dynamic l2l. When I do, I am more able to connect using the vpn client. I following the configuration the following URL. http://Cisco.com/en/us/Tech/tk583/TK372/te