🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #1904

Re: Using a parameter multiple times

#1904
From: Arnie Mauer
Date: Thu, 15 Jan 2004 19:59
46 lines
2131 bytes
"Freshy" <_REMOVE_THIS_freshy_s@hotmail.com> wrote in message
news:40034ae2$1@newsgroups.borland.com...
> Hello,
>
> I have a query to run against an Access 2000 database for a report where I
> need to use a parameter twice.  For example:
>
> SELECT
>    a.[Name],
>    a.[StartDate],
>    a.[EndDate],
>    a.[Hours],
>    (SELECT SUM([Hours]) FROM [ATable] AS b WHERE b.[StartDate] >= :SDate
AND
> b.[EndDate] <= :EDate) AS Total
> FROM [ATable] AS a
> WHERE a.[StartDate] >= :SDate AND a.[EndDate] <= :EDate ;
>
> I know that ADO has a problem with this, so I tried a couple of
variations:
>
> SELECT
>    a.[Name],
>    a.[StartDate],
>    a.[EndDate],
>    a.[Hours],
>    :SDate AS PSDate,
>    :EDate AS PEDate,
>    (SELECT SUM([Hours]) FROM [ATable] AS b WHERE b.[StartDate] >= PSDate
AND
> b.[EndDate] <= PEDate) AS Total
> FROM [ATable] AS a
> WHERE a.[StartDate] >= PSDate AND a.[EndDate] <= PEDate ;
>
> Unfortunately, this did not work.  Does anyone know of a way around this?
>
> Thanks,
> Ken

Rename your parameters so that they have unique names.  For example, you'll
have to seperately set :SDate1 and :SDate2.

The BDE handled this case but ADO doesn't.

- Arnie
Technical Details
Message-ID: <4006f0cc$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40034ae2$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,1641a77b6273a1af
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2004-01-15 12:10:40 PST
From: "Arnie Mauer" <xxx@nowhere.net>
Newsgroups: borland.public.cppbuilder.database.ado
References: <40034ae2$1@newsgroups.borland.com>
Subject: Re: Using a parameter multiple times
Date: Thu, 15 Jan 2004 14:59:00 -0500
Lines: 48
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 24.151.21.222
Message-ID: <4006f0cc$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1074196684 24.151.21.222 (15 Jan 2004 11:58:04 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail