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
vote
1 answer

Oracle PL/SQL Procedure Error while checking IF table EXISTS in schema

I am using SQL Developer Tool to create a procedure that checks if table named TRANSPORT_PRODUCT exists, if it does then truncate it, if it does not then create it. Scenario 1: when TRANSPORT_PRODUCT does not exists in the schema and i compile the…
Kfactor21
  • 412
  • 5
  • 14
1
vote
1 answer

'Execute Immediate' with Into Clause in HANA

I have a requirement where-in I need to read a table (table name provided as input parameter of the SP), store the results in a temp table and then store the count of the read table into a variable. Please advise how can this be achieved. I have…
user3277704
  • 15
  • 1
  • 4
1
vote
2 answers

'insert into' in 'execute immediate' clause

Can you check this and tell me why I've got an error, please? How should it look? I have no idea what's wrong here. I need to create a table in a function, and in the same function insert data into this table: create or replace function new_tab (…
bozo_950
  • 23
  • 2
  • 4
1
vote
2 answers

Understanding JavaScript this with private function and self executing function

I was reading Angus Croll understanding JS this blog and found this var a = { b: function() { var c = function() { return this; }; return c(); } }; a.b();//window To me it looks like, at the time of invoking c, c was inside…
Jhankar Mahbub
  • 9,746
  • 10
  • 49
  • 52
1
vote
2 answers

EXECUTE IMMEDIATE with c# String via OracleParameter, quote scaping

I'm currently working on an assignment. I need to be able to execute a SQL statement via an stored procedure in Oracle. I can do it within SQLDeveloper, using something like: declare n varchar2(100); begin n := 'insert into REGION(ID_REGION,…
dhcarmona
  • 402
  • 2
  • 10
  • 29
1
vote
2 answers

Creating a table with a default value in execute immediate statement

I know it isn't recommended to create a table using an execute immediate command but I need to create a table which prompts the user for 2 pieces of information before acting. Currently I have: DECLARE TEST_NAME VARCHAR2(200); TEST_VERSION…
1
vote
1 answer

Oracle Package inside a CLOB with length > 32767 characters. How to "execute immediate" it?

Please suppose that I have a package creation script stored inside a table ALPHA, in a column BETA of type CLOB. The CLOB length is > 32767 characters. Using PL/SQL code, I would like to "execute immediate" the package creation script. I could I…
UltraCommit
  • 2,236
  • 7
  • 43
  • 61
1
vote
4 answers

How do I debug Oracle dynamic sql in sqlplus?

I have a PL/SQL statement that uses EXECUTE IMMEDIATE to execute a query. However, I'm having difficulty figuring out how to even get the text of the query that's being executed. I can't use dbms_output as the query is greater than 255 characters.…
Jason Baker
  • 192,085
  • 135
  • 376
  • 510
1
vote
1 answer

Parameters on Execute Immediate Sentence (Inside a procedure)

I'm triyin to create a ORACLE USER from my User table inside a procedure. The problem is that I don't know how to call a specific column. I've tried with Camp.user.username and that stuff. create or replace PROCEDURE PR_USERPASS AS BEGIN UPDATE…
Sergiodiaz53
  • 1,268
  • 2
  • 14
  • 23
1
vote
1 answer

DB2 Dynamic query execution which returns row count

Here i am trying to run a dynamic query in DB2 which returns row count in a variable. Could anyone help me out how to store the result of a dynamic query into a variable so that I could use it further? Below are code snippet:-- CREATE PROCEDURE…
1
vote
1 answer

Create an object instance in PL/SQL using execute immediate and optional arguments

I have an object defined like this: create or replace type MYOBJ as object ( field1 varchar2(100); field2 varchar2(100); field3 varchar2(100); ); and a function like this (I know I can use a constructor, whatever): create or replace…
molok
  • 1,491
  • 1
  • 14
  • 19
0
votes
1 answer

Using BLOB type in dynamic SQL in Oracle

Iam trying to create a string for using in execute_immediate statement for inserting into a table. One of the columns used is a BLOB type. Iam using the '||' operator to append columns and build the sql. BLOB type doest seem to work with '||'. See…
0
votes
1 answer

Execute Immediate with multiple SQL Statements

Here is my PL/SQL. execute immediate ' create table Alex_Test2(col1 varchar2(100)); / drop table Alex_Test2; / '; In the dynamic SQL, a table is created and then dropped immediately. The funny thing is that the table is successfully created and…
Alex Yeung
  • 2,495
  • 7
  • 31
  • 48
0
votes
2 answers

How to loop through rows to create new dates in Google Bigquery

I'm trying to duplicates a row while changing the end date based on the difference between the current start and end date. The end date also has to be the last day of the month For example Data I have Data I need to end up with This is what i've…
0
votes
0 answers

passing dynamic parameters from table to execute immediate

I am defining different plsql expressions in table level for different types of validations, each validation has different functions with different parameters to evaluate condition. I am able to run one function with fixed parameters in one block ,…
Adeel Aslam
  • 1,285
  • 10
  • 36
  • 69