Subject Re: variable not updating in SP
Author alex_vnru
--- In ib-support@y..., "csswa" <csswa@y...> wrote:
> Thanks, SET. Looks *very* promising! Can't wait to get home and
try
> it.
>
> Regards,
> Andrew
> -- more slogans than a bag of shaved weasels
>
> --- In ib-support@y..., Svein Erling Tysvær
> <svein.erling.tysvaer@k...> wrote:
> > 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.

Andrew, addition to excellent observation of Svein Elring:
parameters in subselects often don't work in IB/FB, especially when
both main select and subselect have parameters. I can't exactly
specify when it works and when not and avoid such a constructions. To
get names of columns of table's PK I recommend to use more
simply query:

For Select RI.RDB$FIELD_NAME
From RDB$RELATION_CONSTRAINTS RC, RDB$INDEX_SEGMENTS RI
Where RC.RDB$RELATION_NAME=:VAR_TABLENAME
And RC.RDB$CONSTRAINT_TYPE='PRIMARY KEY'
And RI.RDB$INDEX_NAME=RC.RDB$INDEX_NAME
Order By RI.RDB$FIELD_POSITION
Into :VAR_PKNAME

BTW, what version of server do you use? Seems Claudio eleminated
possibility of ambigious queries in FB. Do you use IB or old FB build
or did you discovered query which overcames his efforts?

Best regards, Alexander V.Nevsky.