[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,

        Try with [ ] arount i.e :

 let $whereclause = 'WHERE DEPTID = $entered_dept'

SELECT (lots of fields)
FROM PS_EMPLOYEES
[$whereclause]

Hope it helps,
-Sameer

-----Original Message-----

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