Re: Wildcard and 4gl code
Posted in 2000
--- "Richard E. Hassler" <Hassler.1@osu.edu>
> wrote:
>I'm running Informix SE 7.2 on an HP9000 390R running HP-UX 10.20. The
>4gl code below was written when I was using Informix On-Line 5.0 on an
>HP9000, 832 running HP-UX 9.0. This code worked on the old system but
>not on the new, i.e. the asterisk would serve as a wildcard on the old
>system whereas now it seems to function as an asterisk and none of the
>names are asterisk. Can someone tell me what I have to do to get it to
>work on the new system?
>
> if (tdata[i].last is null) then
> let tdata[i].last = "*"
> end if
> if (tdata[i].first is null) then
> let tdata[i].first = "*"
> end if
>
> select count(*) into total from faculty where
> (tdata[i].last matches f_last) and
> (tdata[i].first matches f_first)
> if (total = 1) then
> select rowid, f_last, f_first
> into rownumber[i], tdata[i].last, tdata[i].first
> from faculty
> where (tdata[i].last matches f_last) and
> (tdata[i].first matches f_first)
> end if
> if (total = 0) then
> call warning(i)
> end if>
Depending on where this falls within your code and what you're trying to accomplish, there are a couple of ways I would handle this.
One is to build a select_statement from a where_clause char(300) based on your if statements.
if (tdata[i].last is not null) then
let where_clause = " where ",
tdata[i].last,
" matches f_last"
end if
if (tdata[i].first is not null) then
if (tdata[i].last is not null) then
let where_clause = where_clause clipped,
" and ",
tdata[i].first,
" matches f_first"
else
let where_clause = " where ",
tdata[i].first,
" matches f_first"
end if
end if
select_statement = "select whatever from wherever",
where_clause clipped
The other way would be to use the same logic and copy your selects (with variations) into nested if statements.
If this seems fuzzy, blame it on typing one-handed while under the influence of pain medication.
carlos
==
Maintainer of the procrastinator's FAQ. Well, maybe tomorrow I will be.
_____________________________________________________________
Want a new web-based email account ? ---> http://www.firstlinux.net