User456789
User456789

Reputation: 397

Oracle parameters in c# inline query with wildcard

I am having trouble using parameters for my in line oraclae query in c#. Why does the parameter not work within the wildcard?

This line returns no results:

Select id, name from Users where UPPER(name) like '%:name%'
command.Parameters.Add("name", OracleDbType.Varchar2, name.ToUpper(), ParameterDirection.Input);

But this returns:

Select id, name from Users where UPPER(name) like '%" + name.ToUpper() +"%'

Upvotes: 0

Views: 1004

Answers (1)

kevinskio
kevinskio

Reputation: 4551

Did you mean this?

Select id, name 
from Users 
where UPPER(name) like '%' ||:name.ToUpper()||'%'

This concatenates your C# variable and the Oracle wildcard characters.

Upvotes: 1

Related Questions