Run query: ORA-00936: missing expression

I am using run query for select
“Select a.* From bajaj_ar_head a, bajaj_plan_master b, bajaj_policy_type c, bajaj_main_type d
WHERE
A.PLAN_NO=B.PLAN_NO and B.PL_TYPE_CD=c.pt_code
and C.MAIN_PT_CODE=D.PT_CODE and d.PT_DESC=‘MOTOR’
and (a.sys_ar_dt>=@FromDate and a.sys_ar_dt<=ToDate)
and (a.status_cd<>‘B’ or a.status_cd is null)
And a.status_cd<>‘A’”

where I’m passing values for date using parameters giving me an error as missing expression but while executing same query like

Select a.* From bajaj_ar_head a, bajaj_plan_master b, bajaj_policy_type c, bajaj_main_type d
WHERE
A.PLAN_NO=B.PLAN_NO and B.PL_TYPE_CD=c.pt_code
and C.MAIN_PT_CODE=D.PT_CODE and d.PT_DESC=‘MOTOR’
and (a.sys_ar_dt>=‘01-APR-2022’ and a.sys_ar_dt<=‘30-APR-2022’)
and (a.status_cd<>‘B’ or a.status_cd is null)
And a.status_cd<>‘A’
it works
So how to resolve this issue any help

@sushantchanakhekar2299 Use Single Quote for date field like ‘+@Fromdate+’

1 Like

Hello @sushantchanakhekar2299

Plz refer the below post.

Hi Thanks for help
But By using this I am getting error as Run query: ORA-01858: a non-numeric character was found where a numeric was expected.

what is the DataType of sys_ar_dt?
if it is Date ensure you are passing the parameter of the type Date, and before passing it convert to the standard type for which your query is successfully debugging and then pass it as an argument.
If it is varchar then use single quote.

Convert your date variable to required format like dd-MMM-yyyy and then pass it.

@Divyashreem the datatype is Date and when we are convert string to date using CDate() the output is with timestamp and when we convert that to required format then it is change to string. So how can I change required format so that it is not change to string and still remain as Date.
Also How can I pass Date type variable into sql query for oracle.

@Mohan1 By passing variable as dd-MMM-yyyy getting error as a non-numeric character was found where a numeric was expected.

@sushantchanakhekar2299 dd-MMM-yyyy is this the date format stored in db? Can you please share the database row screenshot and uipath workflow screenshot?

@Mohan1

@Mohan1

trye to convert with this
TO_DATE(‘“+convert.ToDateTime(YourVariable).ToString(“dd-MM-yyyy”)+”’,‘dd-MMM-yy’)

and pass it without single quote

What ia To_Date and this expression is used in sql query? is this right

@Divyashreem What is To_Date and The expression is used in sql query? or at parameter window and what is Datatype of parameter should pass string or DateTime

Data type of the parameter must be same as the column datatype