Subject Re: variable not updating in SP
Author csswa
Thanks, SET. Your code solved the problem.

At first I tried qualifying the tablenames/fields in the existing
faulty code but that made no difference. There is something about
that subselect that IB doesn't like.

Regards,
Andrew Ferguson
-- Way thicker than water.


--- In ib-support@y..., Svein Erling Tysvær
<svein.erling.tysvaer@k...> wrote:
> Andrew,
>
> > SELECT RDB$FIELD_NAME
> > FROM RDB$INDEX_SEGMENTS
> > WHERE RDB$INDEX_NAME =
> > (
> > SELECT RDB$INDEX_NAME
> > FROM RDB$INDICES
> > WHERE (RDB$INDEX_NAME STARTING WITH 'RDB$PRIMARY')
> > AND (RDB$RELATION_NAME = :VAR_TABLENAME)
> > )
> > INTO :VAR_PKNAME;
>
> My guess is that this for some reason is considered ambiguous. Maybe
> rdb$index_name in the where-clause of the subselect is considered
to belong
> to rdb$index_segments and not rdb$indices.
>
> I would recommend changing to
> SELECT RDB$FIELD_NAME
> FROM RDB$INDEX_SEGMENTS RS
> WHERE (RS.RDB$INDEX_NAME STARTING WITH 'RDB$PRIMARY')
> AND EXISTS(SELECT 1 FROM RDB$INDEXNAME RI
> WHERE (rI.RDB$INDEX_NAME = RS.RDB$INDEX_NAME)
> AND (RI.RDB$RELATION_NAME = :VAR_TABLENAME)
> )
> INTO :VAR_PKNAME;
>
> but it would be interesting to see if it was enough to qualify your
fields.
>
>
> Set
> -not quite Andrew in signing my messages