Icon View Thread

The following is the text of the current message along with any replies.
Messages 21 to 25 of 25 total
Thread A 'How To' question
Thu, Mar 16 2006 12:35 PMPermanent Link

Connie McBride

>The only way to do so is the way that Chris indicated with the IS NULL
>check.  However, you *must* make sure that you add the proper parameters to
>the TDBISAMQuery component since you're using ParamCheck=False.  Frankly, I
>would set ParamCheck:=True and save yourself the trouble of having to
>manually add the parameters.

Can't.  I have one query component, that I am reusing.  The query is coming from a table, and is defined by the user.  (actually a tech).
Because it has parameters that the user is prompted for, the parameters change, depending on the query.  The query component blows up
with 'parameter type undefined', or some such.

To deal with this, I have to turn on the parameter check, to get the list of parameters that get further defined by the advanced user (not
everyone gets access to this function), and the tech defines the type of the parameter (date, string, etc).
I then turn off the parameter check, and do a replace strings on the sql statement (in effect, removing the parameters), then use that for
my sql.

But again, there will be times when the parameter is not filled. (i.e, a customer report where the user wants all customers, but can also be
run for a single customer).

I am trying to figure out how to make it work when the parameters are not filled in  - so if a customer name is entered, the result is just that
one customer (which is why the 'like' function won't work), or, if no customer name is entered, the results are all customers.




Thu, Mar 16 2006 3:18 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Connie,

<< To deal with this, I have to turn on the parameter check, to get the list
of parameters that get further defined by the advanced user (not
everyone gets access to this function), and the tech defines the type of
the parameter (date, string, etc). I then turn off the parameter check, and
do a replace strings on the sql statement (in effect, removing the
parameters), then use that for my sql. >>

Ahhh, that is the information I was looking for.  To do what you want,
you'll have to do what Chris suggested and add a NULL check against the
parameter.  You'll also have to modify your "replace strings" code to
accomodate NULL parameters.

--
Tim Young
Elevate Software
www.elevatesoft.com


Fri, Mar 17 2006 8:20 PMPermanent Link

Connie McBride
"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote:

Ahhh, that is the information I was looking for.  To do what you want,
you'll have to do what Chris suggested and add a NULL check against the
parameter.  You'll also have to modify your "replace strings" code to
accomodate NULL parameters.

Okay, I have removed the replace strings, and am now adding things like (Tonguerameter is null or Field = Tonguerameter) to the SQL statements.
I am still experiencing 2 problems.

1) When I run the report that attached to the query, I am setting ParamCheck = true. (otherwise, I get 'parameter unknown').
2) When I am designing my report, I am also setting ParamCheck = true when I run a test function to view the results.
3) I have this code attached to a button click so I can test the query without testing the parameters :
  dmReports.qryReport.Close;
  dmReports.qryReport.SQL.Clear;
  dmReports.qryReport.ParamCheck := false;
  dmReports.qryReport.SQL.Assign(dmMain.tblDocsSTOREDSQL);
  dmReports.qryReport.FieldDefs.Clear;
  dmReports.qryReport.Open;
  dmReports.qryReport.FieldDefs.Update;


4) Sometimes (not always) after going through 1 and 2, get a message about an unknown parameter type.

5) I have in my code this logic to deal with boolean fields:
        wString := pResult[x];
        ParsePResults(wString, pName, pValue, pType);
        if uppercase(pType) = 'BOOLEAN' then
        begin
           if pValue = 'All' then
              aQuery.ParamByName(pName).AsString := ''  //because it blows up with 'parameter is of an unknown type' if I don't set it to
something, and .AsBoolean = '' doesn't work either.
           else
           if uppercase(pValue) = 'FALSE' then
              aQuery.ParamByName(pName).AsBoolean := false
           else
              aQuery.ParamByName(pName).AsBoolean := true;
        end
When I open it with the 'ALL' selected, I get an SQL Parsing error - expected NULL, boolean, smallint (etc), but instead found ? in select
statement.
Mon, Mar 20 2006 12:28 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Connie,

<< 4) Sometimes (not always) after going through 1 and 2, get a message
about an unknown parameter type. >>

You must be missing the assignment of the data type for a parameter
somewhere.  That is the reason for that error.

<< 5) I have in my code this logic to deal with boolean fields: >>

Use this instead:

        wString := pResult[x];
        ParsePResults(wString, pName, pValue, pType);
        if uppercase(pType) = 'BOOLEAN' then
        begin
           if pValue = 'All' then
              begin
              aQuery.ParamByName(pName).DataType:=ftBoolean;
              aQuery.ParamByName(pName).Clear;
              end
           else
           if uppercase(pValue) = 'FALSE' then
              aQuery.ParamByName(pName).AsBoolean := false
           else
              aQuery.ParamByName(pName).AsBoolean := true;
        end

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Mar 20 2006 6:48 PMPermanent Link

Connie McBride
"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote:

Connie,

<< 4) Sometimes (not always) after going through 1 and 2, get a message
about an unknown parameter type. >>

You must be missing the assignment of the data type for a parameter
somewhere.  That is the reason for that error.

That's why I have 'ParamCheck = false' in that section of code.

<< 5) I have in my code this logic to deal with boolean fields: >>

Use this instead:

        wString := pResult[x];
        ParsePResults(wString, pName, pValue, pType);
        if uppercase(pType) = 'BOOLEAN' then
        begin
           if pValue = 'All' then
              begin
              aQuery.ParamByName(pName).DataType:=ftBoolean;
              aQuery.ParamByName(pName).Clear;


Thanks.
I should probably do that for all the blank parameters, huh?
« Previous PagePage 3 of 3
Jump to Page:  1 2 3
Image