Hi,
How StoredProcedure class work in SQL SERVER?
I have error, running MS SQL Procedure from JAVA:
"Procedure or Function 'NextVal' expects parameter '@sequenceName', which was not supplied."
I have this link:
http://msdn.microsoft.com/en-us/library/ms378108.aspx
This code, What I'm tring to do is to run in JAVA the same cod for Oracle and for MS SQL, in Oracle it's working good.
In Oracle I need thid NEXT VAL for the index to the INSERT statment. should provide you an output parameter containing the next number.
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.object.StoredProcedure;
public class GetNextValProcedure extends StoredProcedure {
private static final String PROC_NAME_SQL = "dbo.NextVal";
public GetNextValProcedure(DataSource ds) {
setDataSource(ds);
setFunction(true);
setSql(PROC_NAME_SQL);
declareParameter(new SqlOutParameter("val", Types.BIGINT));
compile();
}
public long getNextSeq()
{
Map returnedVals=execute(new HashMap());
return (Long)returnedVals.get("val");
}
}
And the procedure in MS SQL:
Create function dbo.CurrVal (@sequenceName varchar(40))
returns int
as
begin
return (IDENT_CURRENT(@sequenceName))
end
In Oracle( in this case it's working good!):
function get_val return number is
result number;
begin
SELECT EGLUE_SEQUENCE.nextval INTO result FROM DUAL;
return(result);
end;
Edited by: yael800 on Jun 15, 2008 3:13 AM