Description:
Execute a SPL script via esProc JDBC.
Syntax:
call path/spl(…)
Note:
The function executes a SPL script via esProc JDBC.
Parameter path is path of the spl script file. First search local paths for the spl file; and then the server (configure the list of servers in raqsoftConfig.xml) if the script file cannot be found.
This is similar to calling a stored procedure in the normal database driver. During execution, use con.prepareCall() to call the SPL statement, where parameters can be directly written or set with st.setObject(). Once the Statement is generated, use st.execute() to execute it and return the result set as a sequence.
In call path/spl(…), “(…)” can be omitted. By default, parameter values are passed in according to the order of parameters defined in the script.
Parameter:
path |
The relative search path or absolute search path of a file. The default setting is the relative search path when this parameter isn’t specified. |
spl |
A script file of .splx/.spl/.dfx format, whose extension is determined according to the order of .splx/.spl/.dfx. |
… |
Parameter values passed to the spl script file; they are assigned to the parameters in order without considering the parameter names. Use comma to separate the multiple parameters. |
Example:
Below are the contents of the cellset file test.splx, in which StuId and Class are the cellset parameters.
|
A |
1 |
=connect("demo") |
2 |
=A1.query("select * from SCORES where STUDENTID=? and CLASS=?",StuId,Class) |
3 |
=A2.sum(SCORE) |
4 |
>A1.close() |
5 |
return A3 |
Test code is as follows:
public void testDataServer() {
Connection con = null;
java.sql.PreparedStatement st;
try{
Class.forName("com.esproc.jdbc.InternalDriver");
con= DriverManager.getConnection("jdbc:esproc:local://");
// Call the stored procedure in which test is the name of the splx file
st =con.prepareCall("call test(?,?)");
// Set the first parameter
st.setObject(1,"4");
// Set the second parameter
st.setObject(2,"Class one");
// Execute stored procedure
st.execute();
// Get result set
ResultSet set = st.getResultSet();
// Print results
printRs(set);
// The following statement gets same result as the above-mentioned calling method has
st =con.prepareCall("call test(4,\"Class one\")");
st.execute();
set = st.getResultSet();
printRs(set);
}
catch(Exception e){
System.out.println(e);
}
finally{
// Close the connection
if (con!=null) {
try {
con.close();
}
catch(Exception e) {
System.out.println(e);
}
}
}
}