Sunday, March 11, 2012

Date from Oracle

I am trying to show data from Oracle database. This data has a date field.
Here is an SQL statement I am using:
select job_work_date, work_asgn_id, work_terminal, work_craft from
assignment_history
where trunc(job_work_date) >= to_date(@.From, 'MM/DD/YYYY')
It says named parameters cannot be used. Used unnamed parameters. What do I
do?
ThanksOn Dec 6, 3:14 pm, "Mark Goldin" <mgol...@.ufandd.com> wrote:
> I am trying to show data from Oracle database. This data has a date field.
> Here is an SQL statement I am using:
> select job_work_date, work_asgn_id, work_terminal, work_craft from
> assignment_history
> where trunc(job_work_date) >= to_date(@.From, 'MM/DD/YYYY')
> It says named parameters cannot be used. Used unnamed parameters. What do I
> do?
> Thanks
Here's the trick:
1. If you can't use a Named Parameter, it means that the query is
expecting a parameter designator of "?". Your query would then be
TO_DATE( ?, 'MM/DD/YYYY' )
2. Make this change, then click on the DataSet Properties button at
the top [...]. Go to the Parameters tab. This list is now the
parameters that line up with the parameters used in the query, and
they *don't* have to be the same Report Parameters that you are
passing back into your report. Not that there are Expression options
all here.
3. Note that the Parameter Name is "?" and the expression is now
=Parameters!Parameter1.Value . What RS just did was create a new
parameter for you... how nice. What you really want is to change the
expression here to use the Named Parameter that you are using to drive
the report. But, since TO_DATE() expects a string, and your From
Parameter is probably a DateTime (so you can use the Calendar), you
want to convert the types with the Format command; that ,and Oracle is
really picky about formatting. Change the expression for ? to
= Format( Parameters!From.Value, "MM/dd/yyyy" )
4. Close out, go to Report Parameters, and delete the Parameter1
-- Scott|||It might have to do with use of the @. sign. I know that Oracle doesn't need
that for parameters, unlike MSSQL. You could try without the @., but I'm not
sure SSRS will like that.
Alain Quesnel
alainsansspam@.logiquel.com
www.logiquel.com
"Mark Goldin" <mgoldin@.ufandd.com> wrote in message
news:%2351ivSEOIHA.2140@.TK2MSFTNGP03.phx.gbl...
>I am trying to show data from Oracle database. This data has a date field.
>Here is an SQL statement I am using:
> select job_work_date, work_asgn_id, work_terminal, work_craft from
> assignment_history
> where trunc(job_work_date) >= to_date(@.From, 'MM/DD/YYYY')
> It says named parameters cannot be used. Used unnamed parameters. What do
> I do?
> Thanks
>

No comments:

Post a Comment