Subject | Re: DSQL execute procedure |
---|---|
Author | edcurren |
Post date | 2005-10-27T00:21:14Z |
WOW! Thanks so much Helen. That is exactly what I needed :).
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
>preclude
> At 08:22 PM 26/10/2005 +0000, you wrote:
> >Hello all,
> >I'm having a great deal of difficulty executing a stored procedure
> >from DSQL. When I execute it I get a message saying:
> >
> >"Unsuccessful execution caused by system error that does not
> >successful execution of subsequent statementsselectable
> >message length error (encountered 0, expected 104)"
>
> Primarily, it just means you used EXECUTE PROCEDURE to call a
> SP. Call your SP using SELECT (see below) and make sure your apphas a
> structure into which to fetch multiple output rows one at a time.INTO :UserId, :TablePassword;
>
>
> >The stored procedure code is
> >
> >CREATE PROCEDURE LOGINUSER
> > (
> > USERNAME VARCHAR (50) CHARACTER SET NONE,
> > USERPASSWORD VARCHAR (50) CHARACTER SET NONE
> > )
> > RETURNS
> > (
> > RIGHTNAME VARCHAR (100) CHARACTER SET NONE
> > )
> > AS
> >
> > DECLARE VARIABLE UserId CHAR(37);
> > DECLARE VARIABLE GroupId CHAR(37);
> > DECLARE VARIABLE RightsId CHAR(37);
> > DECLARE VARIABLE TablePassword VARCHAR(50);
> >
> > BEGIN
> > SELECT UserId, UserPassword FROM Users
> > WHERE UserName=:UserName
> >UserId=:UserId
> > IF( :UserId IS NULL ) THEN
> > EXCEPTION EXC_NO_SUCH_USER;
> >
> > IF( :TablePassword != :UserPassword ) THEN
> > EXCEPTION EXC_INCORRECT_PASSWORD;
> >
> > FOR SELECT GroupId FROM GroupUsers WHERE
> >INTO :GroupId DOOLE2T
> > BEGIN
> > FOR SELECT RightsId FROM AccessControl
> > WHERE UserId=:GroupId INTO :RightsId DO
> > BEGIN
> > SELECT RightName FROM Rights
> > WHERE RightId=:RightsId INTO :RightName;
> > SUSPEND;
> > END
> > END
> > FOR SELECT RightsId FROM AccessControl
> > WHERE UserId=:UserId INTO :RightsId DO
> > BEGIN
> > SELECT RightName FROM Rights
> > WHERE RightId=:RightsId INTO :RightName;
> > SUSPEND;
> > END
> > END
> >
> >I am setting up the SQL statement in my code like this:
> >"sprintf(sqlQuery, "EXECUTE PROCEDURE LoginUser('%s', '%s')",
> >(UserName), OLE2T(Password));"selectable
>
> A parameterised statement looks like this:
>
> EXECUTE PROCEDURE LoginUser(?, ?)
>
> or, in this case, because it's not an executable procedure but a
> one:knows
>
> SELECT RightName from LoginUser(?, ?)
>
> The database engine knows about SQL statement syntax and the API
> about its request structure; but neither knows about yourapplication
> code's native conventions for passing values.order) to
>
> In your code, either pass the two parameter values (in the right
> the place holders by filling the XSQLVAR structures that you havestatement
> previously prepared; or (less desirable), construct the complete
> in the client code as a string, using concatenation or whatever ittakes to
> compose a string that is only a valid SQL statement.a .NET
>
> If you are using a data access abstraction layer like IBPP, ODBC,
> provider, etc., each will have its own way of surfacing the APIfunction
> structures to encapsulate the whole thing. You can consult therelevant
> list for help with your particular choice of layer.the IB6
>
> If you are bravely doing this with the raw API, then you will need
> API Guide - Google for "ApiGuide.pdf", it's in lots ofrepositories; and
> you will find some examples in Firebird's examples subdirectory.
>
> ./heLen
>