Subject | Re: Stored procedures: Order of named parameters important - why? |
---|---|
Author | davidalbiston |
Post date | 2005-08-30T10:20:53Z |
Hi Stefan
You must understand that the parameter names are not sent to Firebird.
Only the values are sent so they must be in the same order as the SP
declaration.
I don't know which tool your are using. With IBX, you can use
ParamByName('REPERTOIREMOVEGUID').AsString := ...
If your tool has a similar syntax then you could assign the parameters
in any order. If not, you will have to be careful to add the
parameters in the correct order.
Dave
--- In firebird-support@yahoogroups.com, "Stefan Renzewitz"
<Stefan.Renzewitz@a...> wrote:
You must understand that the parameter names are not sent to Firebird.
Only the values are sent so they must be in the same order as the SP
declaration.
I don't know which tool your are using. With IBX, you can use
ParamByName('REPERTOIREMOVEGUID').AsString := ...
If your tool has a similar syntax then you could assign the parameters
in any order. If not, you will have to be careful to add the
parameters in the correct order.
Dave
--- In firebird-support@yahoogroups.com, "Stefan Renzewitz"
<Stefan.Renzewitz@a...> wrote:
> It seems like the order of the parameter is important even if I use
> named parameters like this:
>
> _cmdMove = DatabaseHelper.GetCommand("ADDREPERTOIREMOVE");
> _cmdMove.CommandType = CommandType.StoredProcedure;
> _cmdMove.Parameters.Add("@REPERTOIREMOVEGUID", FbDbType.Guid);
> _cmdMove.Parameters.Add("@REPERTOIREPOSITIONBEFOREGUID", FbDbType.
> Guid);
>
> ...
>
> My stored procedure:
>
> CREATE PROCEDURE ADDREPERTOIREMOVE (
> REPERTOIREMOVEGUID CHAR(16) CHARACTER SET OCTETS,
> REPERTOIREPOSITIONBEFOREGUID CHAR(16) CHARACTER SET OCTETS,
> REPERTOIREPOSITIONAFTERGUID CHAR(16) CHARACTER SET OCTETS,
> REPERTOIREGUID CHAR(16) CHARACTER SET OCTETS,
>
> ....
>
> This surprised me. I would expect that I could add these parameters in
> any order as I'm using variable names, but when I change the order of
> adding the parameters the first parameter is always matched to
> REPERTOIREMOVEGUID, the 2nd to REPERTOIREPOSITIONBEFOREGUID etc. no
> matter what the name of the parameter is.
>
> So basically the names have no real impact except that they give me
> some kind of oriantation and of course if I change the values for
> executing the same procedure more than one time I can easier match the
> values to the parameters.
>
> Anyway, I think this is an easy way to go wrong and I wonder if a
> future Firebird version is going to change this?
>
> Beside that I'm deeply impressed by Firebird. I have spent quite some
> time with it now and I can't believe how professional this database is
> in all meanings and yet for free.
>
> Stefan