Re: SQL 'Like' operator
From: <Lance.Humpert_at_mail.tju.edu>
Date: 1996/07/30
Message-ID: <177D4D1A2.ASVLH_at_TJUVM.TJU.EDU>#1/1
Date: 1996/07/30
Message-ID: <177D4D1A2.ASVLH_at_TJUVM.TJU.EDU>#1/1
Atul Batra writes:
> Is it possible to use the LIKE operator using a host variable in
> PRO*C ?? I need to search VARCHAR fields with just the first few letters.
> Something like -
>
> SELECT ename
> FROM emp_table
> WHERE ename LIKE :host_variable ;
> /* 'host_variable' contains the string 'stev' and it should pull out
> 'steven'
> */
If the host_variable is defined in your sqlarea and is properly initialized, try using the concatenation operator with the following syntax:
SELECT ename
FROM emp_table
WHERE ename LIKE :host_variable || '%';
To get the like operator to work, you'll need the percent sign on the end, and that's an easy way to do it.
Hope this helps - it works for me...
- Lance