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

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