I have a stored procedure that has 5 parameters entered by the users. I am using this stored procedure to run my crystal report. One parameter called 'pCODE' is based on 4 fields in the database. The 4 fields together are 5 characters in length(field1 is 2 characters, and rest 3 are 1 character). I have concatenated the 4 fields so that my selection looks like something like this
The issuse I am having is that if a user enters pAREA parameter or any other parameter and leaves pCODE blank I get data but if they enter a valid pCODE parameter I get no data. A user can enter partial data in pCODE paramter to search for data. Not sure why this is not working. Is this the right way to do it?
Appreciate any help!
Thanks,
-E
Code:
select * from table
where
field1||field2||field3||field4 = pCODE||'%' OR pCODE IS NULL
AND AREA = pAREA OR pAREA IS NULL
and so on
The issuse I am having is that if a user enters pAREA parameter or any other parameter and leaves pCODE blank I get data but if they enter a valid pCODE parameter I get no data. A user can enter partial data in pCODE paramter to search for data. Not sure why this is not working. Is this the right way to do it?
Appreciate any help!
Thanks,
-E