cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Сурнин Евгений <surni...@gmail.com>
Subject Re: Stored Procedure&Function(Oracle parse results, SQL server - TVF)
Date Tue, 07 Aug 2012 08:46:59 GMT
I try execute procedures&functions dynamically as:
Procedure proc = new Procedure(procedureName);

So if i want exec function, i add some code (parameter for returning value):
proc.setReturningValue(true); //  i think it means that i execute function
ProcedureParameter returnValueParameter = new
ProcedureParameter("RETURN_VALUE",
TypesMapping.getSqlTypeByName(returnType),
ProcedureParameter.OUT_PARAMETER);
proc.addCallParameter(returnValueParameter);

For Oracle tests I dynamically set type so:
returnValueParameter.setType(OracleTypes.CURSOR);

But which type I must set for SQL Server I'm not understand.

> 2)
> > How to execute this function? Or I have to execute it like this: select *
> > from test('some') via performQuery method?
>
> If you have this option, I would certainly do the later. Or even better:
>
> Class queryType = .. ; // init this dynamically
> SelectQuery query = new SelectQuery(queryType); // very ORM code
>
> Which is good ORM code.... Other than that... I know the following works on SQLServer.
>
> CREATE PROCEDURE cayenne_tst_select_proc @aName VARCHAR(255), @paintingPrice INT AS
> BEGIN
> 	SELECT DISTINCT A.ARTIST_ID, A.ARTIST_NAME, A.DATE_OF_BIRTH
> 	FROM ARTIST A, PAINTING P
> 	WHERE A.ARTIST_ID = P.ARTIST_ID AND
> 	A.ARTIST_NAME = @aName
> 	ORDER BY A.ARTIST_ID
> END
>
> Haven't tried functions with it though. Have you checked 'Return Value' checkbox when
mapping
> the procedure and created a parameter for the return value?
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message