Subject Re: [IBO] mystery with ParamByName
Author Helen Borrie
At 01:05 PM 16/11/2004 +0000, you wrote:


>--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@t...> wrote:
> > Inadequate information is that you don't provide the declarations
>for the
> > SPs and you show your dataset SQL as "Select * from..." That isn't
>useful
> > when you want people to help you find a problem with a missing field.
>
>SSP, insert and delete SP's are:
>
>CREATE PROCEDURE TU(TUID DECIMAL (15, 0))
>RETURNS ( SOID DECIMAL (15, 0),NAME VARCHAR (33))
>AS
>BEGIN
> for select
> s."SoID",
> s."Name"
> from TUR t
> join PRO p
> on t."ProID" = p."ProID"
> join AM_KL ak
> on p."AKID" = ak."AKID"
> join KLA k
> on ak."KlaID" = k."KlaID"
> join KL_SO ks
> on k."KlaID" = ks."KlaID"
> join SO s
> on ks."SoID" = s."SoID"
> where t."TuID" = :TuID and not exists ( select 1 from TU_SO
>where "TuID" = :TuID and "SoID" = s."SoID" )
> into :SoID, :Name
> do
> SUSPEND;
>end

OK, there are two problems with this procedure. 1) it needs to have TUID
in its output set.and 2) you have ambiguity in the WHERE clause. Fix this
up so that it is like this:
where t."TuID" = :TuID
and not exists ( select 1 from TU_SO ts
where ts."TuID" = :TuID and ts."SoID" = s."SoID" )


>CREATE PROCEDURE DELTU ( TUID DECIMAL (15, 0), SOID DECIMAL (15, 0))
>AS
>BEGIN
> if ( TuID is null or SoID is null )
> then exit;
>
> delete from TU_SO
> where "TuID" = :TuID and "SoID" = :SoID;
>END
>
>CREATE PROCEDURE INSTU ( TUID DECIMAL (15, 0), SOID DECIMAL (15, 0))
>AS
>BEGIN
> if ( TuID is null or SoID is null )
> then exit;
>
> insert into TU_SO
> (
> "TuID",
> "SoID"
> )
> values
> (
> :TuID,
> :SoID
> );
>END
>
> > Show the SP exactly as it is defined; and show the DeleteSQL
>statement. I
> > suspect that the problem will be found there.
>
>DeleteSQL calling code:
>// TuID is already provided through the MasterParamsLinks

No, it isn't. You can't masterlink on a non-existent output column.

>qry->ParamByName("SoID")->Assign(qry2->FieldByName("SoID"));

No. This is the wrong thing to do when the DeleteSQL is bound to the
dataset. The Params belong to the SELECT query, not to the bound DeleteSQL
statement. The query doesn't have a Params member named "SoID".

I asked you to provide the DeleteSQL statement, but you didn't. With your
Delete SP as written, it should be as follows:

EXECUTE PROCEDURE DELTU ( :TUID, :SOID )

and you do *not* assign the parameter values: IBO does this internally -
they are not available to the application. The important thing is for you
to match the param names in the EXECUTE PROCEDURE statement *exactly* to
the output field names of the SELECT procedure.

Provided you have this (with no mismatches involving quoted field
identifiers), just removing that assignment statement should fix the
problem of the "unkown field name".

Helen