[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Question on a dynamic where statement



HI Doris

        You should do that way

let $whereclause = 'WHERE DEPTID = ' || $entered_dept

select (lots of fields)
from ps_employees
[$whereclause]

        Try this

Merci

Ngo Baochau
baochaun@mail.transcontinental.ca
tel: 335 - 1466/4943
http:\\www.transcontinental.ca

-----Original Message-----
From:   Doris K. Brinson [SMTP:DBrinson@COMMHOSPINDY.ORG]
Sent:   Tuesday, October 06, 1998 3:00 PM
To:     Multiple recipients of list SQR-USERS
Subject:        Question on a dynamic where statement

Is there a way using SQR to use a variable as the where statement in a
select command.  I am trying to write a label program that will allow the
user to enter either an emplid, department or location. Depending on what
the user entered, I want to select the appropriate data. I can easily set a
variable to say
  let $whereclause = 'WHERE DEPTID = $entered_dept'

SELECT (lots of fields)
FROM PS_EMPLOYEES
$whereclause

But where I run the above type code, I get an SQL error.  I know the easy
way would be to write different selects for each of the allowed criteria,
but I think there has to be a better way.

Doris

Unrecognized Data: application/ms-tnef