Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 11 total
Thread Unknown SQL query parameter with version 1.09
Wed, Mar 26 2008 5:41 PMPermanent Link

Richard Harding
Tim,

I have installed v1.09.  I received an error unknown parameter when attempting to open a
query in an application.

Restored v1.08 and it works OK.


------------------
Richard Harding
Windella Computer Knowhow
28 Freeman Drive
Lochinvar NSW 2321
Phone:    61 2 4930 7336
Mobile:    0419 016 032
email:    rharding@wck.com.au
Thu, Mar 27 2008 5:31 AMPermanent Link

Uli Becker
> I have installed v1.09.  I received an error unknown parameter when attempting to open a
> query in an application.

Same problem here with 1.09. A Stored Procedure doesn't find a parameter.

Regards Uli
Thu, Mar 27 2008 8:12 AMPermanent Link

Abdulaziz Jasser
I had the same problem with 1.08.
This may sound silly, but they way I solved the problem was to open the query, delete the last extra spaces and save it again.  I some other
cases I removed the query component and replace it with another one with the same query.
Thu, Mar 27 2008 2:48 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Richard,

<< I have installed v1.09.  I received an error unknown parameter when
attempting to open a query in an application. >>

Could you possibly send me the query and database catalog/tables ?  I can't
replicate such a problem here:

SELECT * FROM customer
WHERE State=:State

works fine, so it must be something different that I'm missing.

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Mar 27 2008 2:49 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< Same problem here with 1.09. A Stored Procedure doesn't find a parameter.
>>

It's a different issue - dynamic parameters are handled in an entirely
different manner from stored procedure parameters.

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Mar 27 2008 3:32 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

Copied from email:

Okay, here's the issue.  1.09 included a change so that the params for
stored procedures and queries are not stored in the DFMs, which is
compatible with the BDE/TTable/TQuery/TStoredProc.  In fact, the way EDB was
doing it before (storing the params) was incorrect.

The reason that your code worked before was because of this storage, when in
fact you should have been including a Prepare call before you assigned the
stored procedure parameters.

The reason for this is simple - TEDBQuery parameters can always be populated
from the SQL itself, and TEDBStoredProc parameters *must* always be
populated from the actual procedure definition in the database.

Tim Young
Elevate Software
www.elevatesoft.com

Fri, Mar 28 2008 2:06 AMPermanent Link

Richard Harding
Hi Tim,

>>The reason for this is simple - TEDBQuery parameters can always be populated
from the SQL itself, and TEDBStoredProc parameters *must* always be
populated from the actual procedure definition in the database.


I do not understand the paragraph above.  I suspect that all my queries and stored
procedures that have parameters no longer work and I do not know what I need to do to fix
them.


I created a BDE application - the first one for sometime - using the table Customers from
the DBDemos database.    Created a query which is listed below that selects the orders.
The parameter is CustNo from the datasource dsCustomer.  The ParamData is being stored in
the DFM file.

 object qySelectOrders: TQuery
   Active = True
   DatabaseName = 'DBDemos'
   DataSource = dsCustomer
   SQL.Strings = (
     'select * from Orders.db'
     '   WHERE CustNo = :CustNo')
   ParamData = <
     item
       DataType = ftFloat
       Name = 'CustNo'
       ParamType = ptInput
     end>
   . . . . . . . . . . . .
   end
 end


--
Richard Harding
Windella Computer Knowhow
28 Freeman Drive
Lochinvar NSW 2321
Phone:   61 2 4930 7336
Mobile:   0419 016 032
email:   rharding@wck.com.au
Fri, Mar 28 2008 3:18 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Richard


I think I get it, but Tim will tell us if I'm wrong - with a TEDBQuery the definition is stored in the .dfm but a stored procedure the definition is stored in the catalog file. The prepare is to fetch the data from there, check it out, generate parameters etc.


Roy Lambert [Team Elevate]
Fri, Mar 28 2008 4:52 AMPermanent Link

Uli Becker
Richard,

nothing happens to your queries, but if you are using stored procedure
with parameters, these procedures have to be prepared before assigning
value to the parameters - that's all.

To simplify this, I use this procedure in the DataModule of my apps:

procedure Tdm.PrepareAllProcedures;
var
  i: integer;
begin
  for i := 0 to componentcount - 1 do
  begin
    if components[i] is TEDBStoredProc then
      if (components[i] as TEDBStoredProc).StoredProcName <> '' then
        (components[i] as TEDBStoredProc).prepare;
  end;
end;

Regards Uli
Fri, Mar 28 2008 3:02 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Richard,

<< I created a BDE application - the first one for sometime - using the
table Customers from the DBDemos database.    Created a query which is
listed below that selects the orders.  The parameter is CustNo from the
datasource dsCustomer.  The ParamData is being stored in the DFM file. >>

Crap, you're correct.  The Params property has a Stored False declaration,
but then they go ahead and store the parameters anyways using the
lower-level property stream readers and writers for the parameters.

I'll put out a new build today that resolves this.

The stored procedure behavior will not change, however, with respect to the
parameters.

--
Tim Young
Elevate Software
www.elevatesoft.com

Page 1 of 2Next Page »
Jump to Page:  1 2
Image