Monday, March 19, 2012

How to use parameter with LIKE?

Hello.
I have a query that ends like this:

WHERE ID LIKE '12345%'

I want to replace the '12345' with a parameter name p_id.
If I'm useing only p_id without the % it ok but if I'm useing the % after the parameter I'm getting an error.

I'm working ORACLE database.

Any ideas?

Thanks in advance,
Roy.

try this

WHERE ID LIKE :your_parameter + "%"

|||

Or, if using native Oracle vs. OLE/DB:

Where ID Like :your_parameter || '%'

Hope this helps,

Don Shelman

No comments:

Post a Comment