• Data Warehouse Service

dws
  1. Help Center
  2. Data Warehouse Service
  3. Developer Guide
  4. Stored Procedures
  5. Dynamic Statements
  6. Executing Dynamic Non-query Statements

Executing Dynamic Non-query Statements

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;