Search code examples
sqloracle-databasecrystal-reports

Append single quotes at starting and ending of the alphanumeric in Oracle


I have a Crystal Report that has a SQL query, that is passed a alphanumeric number like 9760750B1CC37.

My query is like

Select * from emp where emp_desc = {Parameter}

Now my issue here is emp_desc is a nchar field and when I pass the 9760750B1CC37 without '' query returns no records but I can't pass the value as '9760750B1CC37' from crystal reports.

How can I convert the input 9760750B1CC37 to '9760750B1CC37' in query where clause?

My input is 9760750B1CC37 when it comes to query it should be

Select * from emp where emp_desc = '9760750B1CC37'

Not sure how to do it, either to concatenate the single quotes.


Solution

  • Since your parameter is a string, you need to enclose references to it within the Command inside single quotes.

    so just try instead of {Parameter} => '{Parameter}'

    so your sql will looks like:

    Select * from emp where emp_desc = '{Parameter}'