Re: Error: Parameter #1 has not been set

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Apr 30 2007 - 11:21:01 EDT


Hmm... I wonder if configuring a procedure to return a value (as
opposed to using an OUT parameter) causes the problem. Here is a
procedure from the Cayenne test suite that returns OUT parameter that
works with SQLServer 2005:

1. procedure definition:

CREATE PROCEDURE [dbo].[cayenne_tst_out_proc]..n_param INT,
@out_param INT output AS
BEGIN
        SELECT..ut_param = @in_param * 2
END

2. Cayenne mapping of procedure (note that since procedure parameters
in JDBC are positional, the names I've been using are mapped for Java
convenience and exclude ..):

<procedure name="cayenne_tst_out_proc">
    <procedure-parameter name="in_param" type="INTEGER" direction="in"/>
    <procedure-parameter name="out_param" type="INTEGER"
direction="out"/>
</procedure>

3. Code that calls it:

         ProcedureQuery q = new ProcedureQuery("cayenne_tst_out_proc");
         q.addParameter("in_param", new Integer(20));

         List rows = runProcedureSelect(q);
         Map outParams = (Map) rows.get(0);
         Number price = (Number) outParams.get("out_param");

4. Logs:

INFO [main 04-30 11:08:04] QueryLogger: {call cayenne_tst_out_proc
(?, ?)} [bind: 20, '[OUT]']
INFO [main 04-30 11:08:04] QueryLogger: === returned 1 row. - took 0
ms.

Andrus

On Apr 27, 2007, at 7:42 PM, Alejandro Daniel Toffetti wrote:

> Hi !!
>
> It didn't worked, even when I modified everything (the stored
> procedure,
> the xml datamap and the java code) to call a SP with no parameters,
> it still
> shows me the same error...
>
>
> Hi Daniel,
>
>
> On Apr 26, 2007, at 7:39 PM, Alejandro Daniel Toffetti wrote:
>> q.addParameter("RegionID", 1);
>
> I think you need to use the .. sign in the parameter name
> (..egionID"). To Cayenne "@" has no special meaning in this case, so
> the parameter name is taken literally.
>



This archive was generated by hypermail 2.0.0 : Mon Apr 30 2007 - 11:21:39 EDT