Re: 4gl SELECT Statement Woes
Posted in 1996
Another solution which has the benefit of preparing the
select statement only once (a benefit if this section of code
is executed more than once) would be to create a
temp table (lets call it cStuff) to store the individual
values of the user input, then prepare
a statement like so:
let sel_str=
"select count(*) ",
"from customers ",
"where cust_no in (select fld1 from cStuff)"
prepare cnt_id from sel_str
declare cnt_cur cursor for cnt_id
Now comes the disadvantage: you have to delete from the temp table, then
insert the individual
values of the user input in the temp table (you'll have to either
change the input routine or write a routine to parse the current input).
but the select routine becomes:
open cnt_cur
fetch cnt_cur into nCount
close cnt_cur
then again, maybe this is unneccessarily complicated. Do whatever
you think is best.
Edwin Babadaglian wrote:
>
> John Cokos wrote:
> >
> > Help....
> >
> > Why doesnt this work:
> >
> > INPUT BY NAME cStuff
> > { User will type in the following: 500,400,300 }
> >
> > SELECT count(*) INTO nCount FROM customers
> > WHERE cust_no IN(cStuff)> >
> > IF nCount > 0 THEN
> > ERROR "Duplicate Customer Number Found!"
> > END IF
> >
> > If I (in the 4gl code) hard code 500,400,300 into the SELECT,
> > the program works fine. Why won't it accept the variable, and
> > is there a work-around to this?