Questions tagged [execute-immediate]

An Oracle statement to execute a dynamic query or anonymous PL/SQL block.

The EXECUTE IMMEDIATE statement can be used within PL/SQL to build and run dynamically generated SQL.

Dynamically generated SQL can be vulnerable to SQL Injection. To guard against this bind variables and the system package dbms_assert should be used.

Questions tagged should normally also be tagged and / or .

Further Reading

188 questions
0
votes
1 answer

execute immediate with string in sql statement in teradata

I've met the problem when using execute immediate in Teradata. SET str_sql = 'UPDATE TABLE SET COLA = 0'; EXECUTE IMMEDIATE str_sql; The above code works fine. SET str_sql = 'UPDATE TABLE SET COLA = 0, …
Frank Liu
  • 553
  • 1
  • 5
  • 6
0
votes
1 answer

TABLE function with Dynamic SQL?

Is it possible to use TABLE function in Dynamic SQL? I get Invalid identifier error when I use table function with Table of Records as Input in EXECUTE IMMEDIATE. I can't get the following SQLs to work. EXECUTE IMMEDIATE 'SELECT COUNT(1) from…
0
votes
1 answer

Issue with dynamic execute immediate query

I have a code in my procedure that looks like this. But when i execute this code, i get the error as mentioned below. The Error report that i got is: Error report - ORA-06553: PLS-306: wrong number or types of arguments in call to 'OGC_Y' ORA-06512:…
prince
  • 854
  • 2
  • 9
  • 36
0
votes
1 answer

Table or view doesnot exist

Hi given below is my code. I need to create a view and get data in another cursor using data in the view. But when i execute my code , i am getting the error "ORA-06550: line 56, column 37: PL/SQL: ORA-00942: table or view does not exist ORA-06550:…
prince
  • 854
  • 2
  • 9
  • 36
0
votes
2 answers

populate placeholders for a column with values dynamically

I have the following table structure that holds error codes and related error messages: ERR_CODE ERR_MESSAGE CN001 Invalid Username :USERNM CN002 Invalid Password :PWD In my PLSQL code, i would like to dynamically substitute the…
Mohd Asim
  • 45
  • 1
  • 10
0
votes
1 answer

UPDATE statements in oracle pl/sql loop with tablenames as parameters

I have a requirement where I need to run set of UPDATE statements in a for loop. In the cursor there is a column called PROPERTY_ID which is a number and there are many tables that have this number appended. For ex: SELECT * FROM…
0
votes
1 answer

Execution of variable throwing error

I am creating a plslq program. In that the query needs to be generated dynamically according to the table names specified. I am able to generate the query in a variable. My question is how to execute the query in the variable using plsql. Execute /…
Rohith Gopi
  • 536
  • 1
  • 5
  • 22
0
votes
2 answers

Insert SQL Command with dynamic Username and rowtypes

I'd like to generate a dynamic Insert statement with different Username and data from a rowtype My snippet create or replace procedure test() is TYPE cv_typ is REF CURSOR; cv cv_typ; stmt varchar(2000); zieldb varchar(20); vKunden…
0
votes
2 answers

Execute immediate ... Catching record specific exception

I am insertin some values in Table2 from Table1. There could be chances that there are Primary Key collision. I am using EXECUTE IMMEDIATE to insert value from Table1 to Table2. The records could be in million and there is only 1 commit i.e., …
Em Ae
  • 8,167
  • 27
  • 95
  • 162
0
votes
3 answers

Execute Immediate : Encountered the symbol

i am currently getting this error ORA-06550 PLS-00103 Encountered the symbol "VERSION"... Can any one help me rectify this problem? Much appreciated! declare sql_stmnt VARCHAR(200); lsparameter varchar(50); lsparameterdata varchar(20); begin …
J2H656
  • 101
  • 1
  • 16
0
votes
1 answer

how to use OUT mode in dynamic sql

This is what, I'm trying 1 declare 2 stmt VARCHAR2(200):='&query'; 3 emprec emp%ROWTYPE; 4 BEGIN 5 EXECUTE IMMEDIATE stmt USING out emprec,in &id; 6 DBMS_OUTPUT.PUT_LINE('Emp: '||emprec.ename); 7* END; SQL> / Enter value for…
Ravi
  • 30,829
  • 42
  • 119
  • 173
0
votes
1 answer

Missing right parenthesis and column being added already exists in table error shown in my code

I am trying to run this code declare temp_atr_val varchar2(400); temp_val varchar2 (400); temp_sum_percent decimal (10,3); temp_variable number (10,3); column_count number ; val_count number; sales_store number; begin select count(distinct…
0
votes
2 answers

Why isn't my COLUMN NEW_VALUE getting set by my SELECT statement?

I have the following SQL*Plus code: COLUMN x NEW_VALUE x2 BEGIN -- ... EXECUTE IMMEDIATE 'SELECT ''a'' x FROM dual'; EXECUTE IMMEDIATE 'SELECT colname x FROM some_table WHERE (some_condition)'; -- ... END; at this point, &x2 is still…
Thought
  • 700
  • 2
  • 9
  • 21
0
votes
1 answer

Run sql stored as value in a table in oracle and return recordset in SSRS report

I've a query that creates a SQL Statement as a field. I want to execute this statement and return the recordset in SSRS report. select 'select '||FILE_ID||' FILE_ID,'|| ltrim(sys_connect_by_path('REC_FLD_'||FIELD_NUMBER||'…
CeeVei
  • 95
  • 2
  • 13
-1
votes
2 answers

Can we use collection variable as a table in execute immediate?

Declare Type t_approved_node is record( node_rowid Hr node_rowid%type, Node_+type hr.node_type%type); Type t_val is table of t_approved_node Index by pls_integer; V_node t_val; V_tab varchar2(20); V_col varchar2(400); V_nrf_flg…
1 2 3
12
13