Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Can't get HAVING to work with a parameter
Sun, Jan 8 2006 3:30 PMPermanent Link

Dave M
This below listed query produces the error:  "DBISAM Engine Error #11949 SQL parsing error
- Invalid expression ? found in SELECT SQL Statment at line 4, column 58." The DBISAMQuery
does have the params correctly set to ftInteger with a value of 2002. It does work with a
2002 hardcoded instead of :StartYear.  I am using DBISAM 4.22, Build3 and Delphi 2006.
The above error happens at design time.  At run time there is a parameter not found error.

What's wrong?


Query:
-------------------------------------------------------------
SELECT cusnum, MIN(jobdate) AS firstjob
FROM job
GROUP BY cusnum
HAVING (CAST(EXTRACT(YEAR FROM firstjob) AS INTEGER) >= :StartYear)
ORDER BY cusnum
Sun, Jan 8 2006 9:42 PMPermanent Link

Dave M
Ok, the previous post was a bad example. Consider the simpler query below. It produces
this error:

"DBISAM Engine Error #11949 SQL parsing error
- Invalid expression ? found in SELECT SQL Statment at line 4, column 22."



------------------------------------------------
SELECT cusnum, SUM(sale) AS sumsale
FROM job
GROUP BY cusnum
HAVING (sum(sale) >= Tonguemt)
ORDER BY cusnum



Mon, Jan 9 2006 1:58 AMPermanent Link

"Clive"
Possibly you can not use a parameter like putting a parameter in the select,
if so then just string replace it with your value before execution.

"Dave M" <mr_mensch2@hotmail.com> wrote in message
news:90BEC232-6FE4-43F1-A455-DDEAA97BD9E9@news.elevatesoft.com...
> This below listed query produces the error:  "DBISAM Engine Error #11949
> SQL parsing error
> - Invalid expression ? found in SELECT SQL Statment at line 4, column 58."
> The DBISAMQuery
> does have the params correctly set to ftInteger with a value of 2002. It
> does work with a
> 2002 hardcoded instead of :StartYear.  I am using DBISAM 4.22, Build3 and
> Delphi 2006.
> The above error happens at design time.  At run time there is a parameter
> not found error.
>
> What's wrong?
>
>
> Query:
> -------------------------------------------------------------
> SELECT cusnum, MIN(jobdate) AS firstjob
> FROM job
> GROUP BY cusnum
> HAVING (CAST(EXTRACT(YEAR FROM firstjob) AS INTEGER) >= :StartYear)
> ORDER BY cusnum
>

Mon, Jan 9 2006 11:30 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Dave,

<< This below listed query produces the error:  "DBISAM Engine Error #11949
SQL parsing error
- Invalid expression ? found in SELECT SQL Statment at line 4, column 58."
The DBISAMQuery
does have the params correctly set to ftInteger with a value of 2002. It
does work with a
2002 hardcoded instead of :StartYear.  I am using DBISAM 4.22, Build3 and
Delphi 2006.
The above error happens at design time.  At run time there is a parameter
not found error. >>

You can't use parameters in the HAVING clause.  Only in the WHERE clause.

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Jan 9 2006 12:16 PMPermanent Link

"Ole Willy Tuv"
Tim,

<< You can't use parameters in the HAVING clause.  Only in the WHERE clause.
>>

Two questions:

1) What's the reason for this limitation ?

2) Will V5 have the same limitation ?

Ole

Mon, Jan 9 2006 4:33 PMPermanent Link

Dave M
"Clive" <dd@dddd.com> wrote:

Possibly you can not use a parameter like putting a parameter in the select,
if so then just string replace it with your value before execution.
---------------------------------------------------------

Good idea.  If I have to, I will.
Tue, Jan 10 2006 7:51 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ole,

<< 1) What's the reason for this limitation ? >>

It's arbitrary - it could be done and there's no technical limitation since
a parameter is simply a constant value.

<< 2) Will V5 have the same limitation ? >>

At least initially.  I'll have to see what kind of time is available to fit
in such a change.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image