Subject | Re: [firebird-support] Problem with parameters of FOR SELECT cycle |
---|---|
Author | Helen Borrie |
Post date | 2008-09-03T08:25:36Z |
At 18:03 3/09/2008, you wrote:
And - even without this logic problem, you must be careful to initialise variables in PSQL code....just as you would in any coding environment....especially around looping structures.
./heLen
>Hi, I have very interesting results of FOR SELECT cycle.Yes, of course. In the first version, you are changing the value of the variable id_zaz as soon as the first match is found for it....so the inner loop has nowhere to go after that because the dependency that was passed from the outer loop is lost.
>
>I'm using FB1.5.5 on WinXP.
>
>I have two tables
>RECORDS - name, id_rec, tridnaz (<- uppercase NAME)
>VAZBY (relations) - id_nad, id_pod, typ_nadr
>table of relations between records id_nad - master, id_pod - slave,
>typ_nadr - type of relation - master/slave(0) or equality(1)
>
>I have procedure that returns record ID by its name, and then all
>related IDs from VAZBY table with typ_nadr = 1
>
>output parameter is ID_ZAZ
>
>for select id_rec from records where tridnaz starting with :text
>into :id_zaz
>do begin
>
> suspend; // return master record
>
> for select cis_pod from vazby where cis_nad = :id_zaz and typ_nadr = 1
> into :id_zaz
> do begin
>
> suspend; // return slave record
>
> end
>end
>
>When I debug this procedure in IBExpert, everything works fine, but
>when I run this procedure - Select * from ... it returns only 2
>records, master and 1st slave.
>
>I have to alter procedure with new variable - id_aux
>
> id_aux = id_zaz;
>
> for select cis_pod from vazby where cis_nad = :id_aux ...
>
>Now it works fine, but is this expected result ??
And - even without this logic problem, you must be careful to initialise variables in PSQL code....just as you would in any coding environment....especially around looping structures.
./heLen