Help Center > > Developer Guide> Stored Procedures> Dynamic Statements> Executing Dynamic Non-query Statements

Executing Dynamic Non-query Statements

Updated at: Jul 15, 2020 GMT+08:00

Syntax

Figure 1 shows the syntax diagram.

Figure 1 noselect::=

Figure 2 shows the syntax diagram for using_clause.

Figure 2 using_clause::=

The above syntax diagram is explained as follows:

USING IN bind_argument: specifies where the variable passed to the dynamic SQL value. This parameter is used if dynamic_noselect_string contains a placeholder.

Example

-- Create a table:
CREATE TABLE sections_t1
(
   section       NUMBER(4) ,
   section_name  VARCHAR2(30),
   manager_id    NUMBER(6),
   place_id      NUMBER(4) 
)  
DISTRIBUTE BY hash(manager_id);

-- Declare a variable:
DECLARE 
   section       NUMBER(4) := 280; 
   section_name  VARCHAR2(30) := 'Info support'; 
   manager_id    NUMBER(6) := 103;
   place_id      NUMBER(4) := 1400;
BEGIN 
-- Execute the query:
    EXECUTE IMMEDIATE 'insert into sections_t1 values(:1, :2, :3, :4)' 
       USING section, section_name, manager_id,place_id; 
END; 
/

-- Query data:
SELECT * FROM sections_t1;

-- Delete the table:
DROP TABLE sections_t1;

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel