how to return value in anonymous pl sql using eclipselink [message #1057940] |
Thu, 09 May 2013 22:05 |
|
I need guidance on how to retrieve the value of a variable in a plsql anonymous using EclipseLink. Below I leave a sample of my code. I cannot use functions and stored procedures because I dont have rights. So, how to pass an out parameter and get the result value.
DataReadQuery query = new DataReadQuery();
SQLCall sqlCall = new SQLCall();
StringBuilder plsql = new StringBuilder();
plsql.append("DECLARE ");
plsql.append("\n");
plsql.append("out_variable ");
plsql.append("foo.bar");
plsql.append(".");
plsql.append("number_field");
plsql.append("%TYPE;");
plsql.append("\n");
plsql.append("BEGIN ");
plsql.append("\n");
plsql.append("UPDATE ");
plsql.append("number_field");
plsql.append(" SET number_field = (number_field+1)");
plsql.append(" WHERE ");
plsql.append(" key_field = ");
plsql.append(Key);
plsql.append(" ");
plsql.append(" RETURNING ");
plsql.append(" number_field ");
plsql.append(" INTO ");
plsql.append(" out_variable ; ");
plsql.append("\n");
plsql.append("END; \n");
sqlCall.setQueryString(plsql.toString());
sqlCall.setQuery(query);
query.setCall(sqlCall);
Session session =
JpaHelper.getEntityManager(getEntityManager()).getActiveSession();
Object queryResult = session.executeQuery(query);
|
|
|
|
Powered by
FUDForum. Page generated in 0.04367 seconds