Try OpenEdge Now
skip to main content
SQL Development
Stored Procedures and Triggers : Writing stored procedures : Using the OpenEdge SQL Java classes : Immediate execution
 
Immediate execution
Use immediate execution when a procedure must execute an SQL statement only once.
This stored procedure in this sample script inserts a row in a table. The constructor for SQLIStatement takes the SQL INSERT statement as its only argument. In the following example, the statement includes five parameter markers.
CREATE PROCEDURE insert_team(
IN empnum INTEGER not null,
IN FirstName VARCHAR(30) not null,
IN LastName VARCHAR(50) not null,
IN State VARCHAR(50) not null,
IN Sport CHAR(20)
)
BEGIN
SQLIStatement insert_team = new SQLIStatement (
"INSERT INTO team (empnum, FirstName, LastName, State, Sport)
VALUES ( ?,?,?,?,? ) ");
insert_team.setParam (1, empnum);
insert_team.setParam (2, FirstName);
insert_team.setParam (3, LastName);
insert_team.setParam (4, State);
insert_team.setParam (5, Sport) ;
insert_team.execute ();
END
COMMIT WORK ;