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
-1
votes
2 answers

wrong number or types of arguments in call to Oracle stored procedure

I have created below Oracle parameterized stored procedure where i am trying to grant Truncate table priviledge to another user but getting error as wrong number or types of arguments in call to DO_TRUNCATE. create or replace procedure…
Andrew
  • 3,632
  • 24
  • 64
  • 113
-1
votes
3 answers

DDL execution from inside PL/SQL is failing

I am executing a DDL from inside a stored proc : v_sql_stmt := 'ALTER INDEX PK_TEST REBUILD ONLINE'; EXECUTE IMMEDIATE (v_sql_stmt); All objects - the index, the table (on which the index is built), and the proc (with the above 2 lines) belong to…
Jay
  • 47
  • 11
-1
votes
1 answer

How to write a dynamic SQL query for a select where clause?

If variable1 is null Select *from table Where condition1 And condition 2 And a is not null and b is not null Else Select * from table Where condition 1 And conditon 2 And a is null and b is null How to write this as…
-1
votes
1 answer

Bulk collect limit with execute immediate

For operating on millions of records I want to put a limit of 500 but the following code gives error. Error report: ORA-06550: line 6, column 49: PLS-00103: Encountered the symbol "LIMIT" when expecting one of the following: DECLARE TYPE EMP_T…
PTK
  • 307
  • 4
  • 19
-1
votes
1 answer

Oracle PL/SQL dynamic if statement global vars

I'm having trouble with dynamic sql, Issue is (I think) reading and setting global variable. Here's what I have and any help at all is greatly appreciated. Please let me know if you need table data too although I have included the data in comments. …
oracle_of
  • 23
  • 6
-1
votes
1 answer

ORA-6502 Character string buffer too small error with Execute immediate statement

I get an Oracle error ORA-6502 Character string buffer too small in my code at the statement below EXECUTE IMMEDIATE 'BEGIN :project_id := Activity_API.Get_Project_Id(:activity_seq); END;' USING OUT project_id_,…
user4507518
  • 71
  • 1
  • 7
-2
votes
1 answer

EXECUTE IMMEDIATE in Oracle 12c?

begin execute immediate select ename, empno from emp where ename !='James'; end; / getting ORA-00904: invalid identifier error while executing above code. And is that possible to…
Vijay
  • 21
  • 1
  • 6
-2
votes
1 answer

execute immediate missing right parentheses error

I have code like below in my procedure. When I call the procedure, there is missing right parentheses error. When I test it outside the procedure, with no execute immediate clause, it works fine. Would anyone help me pls to eliminate the…
JanFi86
  • 449
  • 10
  • 29
1 2 3
12
13