UPDJAVA - USING SQLJ TO WRITE JAVA STORED PROCEDURES
package modify_emp;
import sqlj.runtime.*;
import sqlj.runtime.ref.*;
public class update_emp
{
public static int update_emp (String name, int raise, String location)# function with parameter#
{
int newsal = -1;
String newloc = "UNKNOWN";
try {
# sql {UPDATE emp
SET sal = sal + :raise
WHERE ename = :name } ;
#sql {UPDATE emp
SET city = :location
WHERE ename = :name } ;
#sql {SELECT sal INTO :newsal
FROM emp
WHERE ename = :name} ;
#sql {SELECT city INTO :newloc
FROM emp
WHERE ename = :name} ;
}
catch (Java.sql.SQLException e) { }
return newsal;
}
}