re-enter of construct causes truncation of data?
Posted in 1994
Topics: Installation, Setup & Upgrades, Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
I am having problems re-entering a construct statement and displaying
the data from a previous construct. When fixing a bug caused by an
ON KEY statement and re-entering the construct to redisplay the data,
the data will be truncated to the size of the field on the form
I already have requested for informix to fix this in a future upgrade.
When do display to a field in a before construct the display will not
put the data into the overflow buffer that is there when in the
construct statement the first time.
sequence of events
enter ">AA" in field_a which will expand into the overflow field at
the bottom of the screen.
go to field_b
enter ON KEY (whatever) to enter the on key function which is input array
and select some data that is returned. say "AB"
then the statements in ON KEY exit from construct and stay in while
statement.
After the BEFORE CONSTRUCT statement the following values are in the fields
field_a [>A]
field_a [AB]
if do get_fldbuf on field_a returns ">A" instead of ">AA"
Question:
Is there any way to get ">AA" in field_a besides resizing all of my
fields to the maximum that I think my users will enter which would
be the 78char max of the overflow line for a construct?
Please contact me directly if any one can help me with this.
Using the following form.
------------------cut here ------------------- cut here -------------------
database test
screen size 24 by 80
{
field_a [ ]
field_b [ ]
field_c [ ]
}
end
tables
test
attributes
a1 = field_a LIKE test.a;
b1 = field_b LIKE test.b;
c1 = field_c LIKE test.c;
end
------------------cut here ------------------- cut here -------------------
using the following table
------------------cut here ------------------- cut here -------------------
create table test
(
a CHAR(2),
b CHAR(2),
c CHAR(2)
);------------------cut here ------------------- cut here -------------------
BUG FIX recomendation.
a construct
According to Karl Schimmel:
}
} Bug: 14985 WITHIN CONSTRUCT ON KEY TO A INPUT ARRAY DOES NOT WORK IN R4GL
} Prob: 14561
}
} Category: 4GL
} Type: SW
}
} Description:
}
} Within a constructed query if an on key is used to do a lookup
} of data using a input array, then the data is not used in the
} query. If the same thing is done with a DISPLAY ARRAY the value
} past back is used in the query construction. For R4GL this is
} true and when I started this problem entry it also failed on
} C4GL but no longer.
}
} Workaround:
}
} Put the CONSTRUCT into a loop that exits and reenters whenever an
} ON KEY is used
}
} See /pts/bugs/bug.14985/loop.ex for sample code.
}
} ------------------cut here ------------------- cut here -------------------
} # Workaround for bug 14985, value gotten from ON KEY clause is not
} # display or used in a CONSTRUCT statement.
} # The trick is similar to the INPUT ARRAY looping trick to go to a
} # prior row; but the while CONSTRUCT in a loop and keep flags to track
} # where we're going
}
} # need a record to track the values in each field of the CONSTRUCT.
} # These don't match the table datatype, but are CHARs.
} DEFINE l_const RECORD
} a CHAR(80),
} b CHAR(80),
} c CHAR(80)
} END RECORD
} DEFINE disptxt CHAR(80) # display text from the pick function(s)
} DEFINE lloop SMALLINT # looping flag
} DEFINE nfield CHAR(18) # file we were in
}
} ...
}
} # set up any defaults here
}
} LET lloop = TRUE
} LET nfield = NULL
} WHILE lloop
} LET lloop = FALSE
} CONSTRUCT wclause ON table.a, table.b, table.c FROM s_table.*
} BEFORE CONSTRUCT
} # display any default or already-entered values
} IF LENGTH(l_const.a) > 0 THEN
} DISPLAY l_const.a TO s_table.a
} END IF
} IF LENGTH(l_const.b) > 0 THEN
} DISPLAY l_const.b TO s_table.b
} END IF
} IF LENGTH(l_const.c) > 0 THEN
} DISPLAY l_const.c TO s_table.c
} END IF
} # for looping, go to field where we just left
} IF LENGTH(nfield) > 0 THEN
} CASE
} WHEN nfield = "a"
} NEXT FIELD a
} WHEN nfield = "b"
} NEXT FIELD b
} WHEN nfield = "c"
} NEXT FIELD c
} END CASE
} END IF
} # keep track of which field we're in
} BEFORE FIELD a
} LET nfield = "a"
} # keep track of values as they are entered
} AFTER FIELD a
} CALL get_fldbuf(s_table.a) RETURNING l_const.a
} BEFORE FIELD b
} LET nfield = "b"
} AFTER FIELD b
} CALL get_fldbuf(s_table.b) RETURNING l_const.b
} BEFORE FIELD c
} LET nfield = "c"
} AFTER FIELD c
} CALL get_fldbuf(s_table.c) RETURNING l_const.c
} ON KEY (whatever)
} # provide the picker based on field
} CASE
} WHEN INFIELD(a)
} LET disptxt = pick_function()
} IF LENGTH(disptxt) > 0 THEN
} LET l_const.a = disptxt CLIPPED
} END IF
} # here's the wokaround trick. If we just display
} # l_const.a and do a next field a or something,
} # the bug prevents its display. So set the loop flag
} # and exit
} IF LENGTH(l_const.a) > 0 THEN
} LET lloop = TRUE
} EXIT CONSTRUCT
} END IF
} WHEN INFIELD(b)
} LET disptxt = pick_function()
} IF LENGTH(disptxt) > 0 THEN
} LET l_const.b = disptxt CLIPPED
} END IF
} IF LENGTH(l_const.b) > 0 THEN
} LET lloop = TRUE
} EXIT CONSTRUCT
} END IF
} OTHERWISE
} ERROR "No picker for c"
} END CASE
} END CONSTRUCT
} END WHILE # lloop
}
}
}
}
}
} ---------------------cut here ----------------- cut here -----------------
}
--
Brian Ray Jones Internet:brian@gteens.com (IP 198.67.7.4)
GTE Educational Network Services, Inc.
Voice: 1-800-927-3000 Ext. 8510