Hello again. I certainly remove as many macro substitutions as I can in my
code, but when it comes to sql queries they're pretty much a fact of life.
Consider that when you use sqlexec() the entire query must evaluate to a
character expression, so I figure that if the industry as a whole does
this,
VFP should too. I'm sure you've considered generating a single, all
inclusive character string with no &'s and then using execscript() to fire
the entire query. This seems slicker, imo, plus you can log the entire
statement which may help troubleshooting. You'd think that it'd also
execute
faster, but in my experience it most often doesn't. I'd guess that vfp
generates the complete string internally before firing it, so the
execscript() makes it do this twice.
-Lew
"Gene Wirchenko" <genew@[EMAIL PROTECTED]
> wrote in message
news:brorc31mq1n33n3h7gh1qnlqf5cuech7lt@[EMAIL PROTECTED]
> I frequently build expressions for use in xBASE and SQL
> statements. For example:
>
> do case
> case !empty(this.datefrom) and !empty(this.dateto)
> dateexpwo="(trndtlow>=this.datefrom and
> trndthi<=this.dateto)"
> dateexpol=;
> "((trndtlow<this.datefrom and this.datefrom<trndthi) or "+;
> "(trndtlow<this.dateto and this.dateto<trndthi))"
> case !empty(this.datefrom) and empty(this.dateto)
> dateexpwo="(trndtlow>=this.datefrom)"
> dateexpol="(trndtlow<this.datefrom and
> this.datefrom<trndthi)"
> case empty(this.datefrom) and !empty(this.dateto)
> dateexpwo="(trndthi<=this.dateto)"
> dateexpol="(trndtlow<this.dateto and this.dateto<trndthi)"
> case empty(this.datefrom) and empty(this.dateto)
> dateexpwo=".t."
> dateexpol=".f." && Overlap with ends is impossible if no
> ends!
> endcase
>
> . . .
>
> select . . .
> where;
> wostatus="B" and &dateexpwo and . . .
>
> Short of writing four SQL selects for the above case, is there
> any way to get rid of the & use ("&dateexpwo")?
>
> Sincerely,
>
> Gene Wirchenko
>
> Computerese Irregular Verb Conjugation:
> I have preferences.
> You have biases.
> He/She has prejudices.


|