Sample EXEC SQL control statements
Use the sample control statements as models for developing your own EXEC SQL control statements.
Example 1: Creating a table
The following control statement specifies that DB2® is to create table MYEMP with the same rows and columns as sample table EMP.

EXEC SQL
CREATE TABLE MYEMP LIKE DSN8A10.EMP CCSID EBCDIC
ENDEXEC

This type of statement can be used to create a mapping table.
Example 2: Inserting rows into a table
The following control statement specifies that DB2 is to insert all rows from sample table EMP into table MYEMP.

EXEC SQL
INSERT INTO MYEMP SELECT * FROM DSN8A10.EMP
ENDEXEC

Example 3: Declaring a cursor
The following control statement declares C1 as the cursor for a query that is to return all rows from table DSN8810.EMP.

EXEC SQL
DECLARE C1 CURSOR FOR SELECT * FROM DSN8A10.EMP
ENDEXEC

You can use a declared cursor with the DB2 cross-loader function to load data from a local server or from any DRDA-compliant remote server as part of the DB2 cross-loader function.