Its better to use the SET OPTION SQL statement. It allows you to enforce certain program options in the code itself rather than on the compile command which you might forget to do.
c/exec sql c+ set option commit=*none, c+ datfmt=*iso c/end-exec
Sample SQLRPGLE program to Update data in db2 using Update SQL Statements
d $cmp s 2s 0
d $empId s 5s 0
d $empName s 30a
d $empDate s 8s 0
d $empSalary s 11s 2
/free
//Set SQL options
exec sql
SET OPTION
commit=*none,
datfmt=*iso;
//Update one or more records based on where clause
//If there is no where clause then all records will get updates
$cmp = 1;
$empId = 102;
exec sql
Update qgpl/mydata set
d1saly = d1saly + 100
where d1cmp = :$cmp and d1id = :$empId;
if sqlcod <> 0;
dsply sqlcod; //do something
endif;
*inlr = *on;
/end-free
Host Variables
Host variables are always preceded in SQL by a colon. Since your RPGLE program is the "host" of these SQL statements, the term host variable refers to any variable declared in the RPGLE program. We can use these variables when we execute SQL as parameters or as return values.
No comments:
Post a Comment
NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.