Use of Like with a Parameter

  • James L. Falk

    James L. Falk - 2011-05-11

    When I use a Parameter of CustName, in combination with the following SQL  code, I don't get any results on my OpenReport.
    "WHERE CUST_NAME like '%$P{CustName}%' "

    Whereas if I use a "Hard-Code", it returns the desired results on the  report.  I've tried various versions of the code segment '%$P{CustName}%'
    using & not using the " ' ", or adding the ' to the code like:
    '%'+$P{CustName}+'%', all without any success.
    Searches on the internet and this site haven't resulted in any additional  information on recommended methodology

  • James L. Falk

    James L. Falk - 2011-05-12

    I've resolve the issue as follows:
    1. Declare a Variable @Cust_name  varchar(20)
    2. Set @Cust_Name = $P{Param_Entry}
    3. Incorporated the Variable name in the criteria:  where c.cust_name like '%'+@Cust_name+"%'

    4. Success! 
    Hope this helps others with a similar issue in the future.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks